Skip to content

Commit

Permalink
feat: auto import route
Browse files Browse the repository at this point in the history
  • Loading branch information
anncwb committed Oct 16, 2020
1 parent aca07d4 commit 8a1bfdf
Show file tree
Hide file tree
Showing 20 changed files with 530 additions and 341 deletions.
9 changes: 6 additions & 3 deletions .env.development
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,14 @@ VITE_USE_MOCK = true
# public path
VITE_PUBLIC_PATH = /

# Cross-domain proxy, you can configure multiple
VITE_PROXY=[["/api","http://localhost:3000"]]

# Delete console
VITE_DROP_CONSOLE = false

# Basic interface address SPA
VITE_GLOB_API_URL=/api

# Interface prefix
VITE_GLOB_API_URL_PREFIX=

# Cross-domain proxy, you can configure multiple
VITE_PROXY=[["/api","http://localhost:3000"]]
7 changes: 6 additions & 1 deletion .env.production
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,17 @@ VITE_USE_MOCK = true
# public path
VITE_PUBLIC_PATH = ./

# Delete console
VITE_DROP_CONSOLE = true

# Delete console
VITE_BUILD_GZIP = false

# Basic interface address SPA
VITE_GLOB_API_URL=/api

# Interface prefix
VITE_GLOB_API_URL_PREFIX=


# TODO use Cdn
VITE_USE_CDN = true
25 changes: 25 additions & 0 deletions CHANGELOG.zh_CN.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,28 @@
# wip

### ✨ Features

- 打包可以配置输出`gizp`
- 打包可以配置删除`console`
- 路由及菜单不需要在手动引入,改为自动引入

### 🎫 Chores

- 升级 vue 到`3.0.1`
-`vite`版本改为每日构建版本

### 🐛 Bug Fixes

- 修复菜单报错
- 修复表格自适应高度问题
- 修复`window系统`执行 script 报错问题

### ⚡ Performance Improvements

- 删除菜单最小化背景
- 阻止页面刷新重新渲染菜单
- 其他一些细节优化

# 2.0.0-rc.1 (2020-10-14)

### ✨ Features
Expand Down
11 changes: 6 additions & 5 deletions README.en-US.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ The documentation for 2.0 hasn't started yet, it will be provided later.
- [vite-plugin-mock](https://github.com/anncwb/vite-plugin-mock) - Mock plugin base on vite
- [vue-i18n](https://github.com/intlify/vue-i18n-next) - Internationalization
- [lodash-es](https://github.com/lodash/lodash) - JavaScript utility library
- [moment](https://github.com/moment/moment) - Time operation library
- [axios](https://github.com/axios/axios) - Http data interaction
- [TypeScript](https://www.typescriptlang.org/)

Expand Down Expand Up @@ -225,6 +224,7 @@ yarn clean:lib # Delete node_modules, supported window
- [x] Digital animation
- [x] First screen loading waiting animation
- [x] Extract the production environment profile
- [x] Build Gzip

## Developing features

Expand All @@ -234,7 +234,6 @@ yarn clean:lib # Delete node_modules, supported window
- [ ] Global error handling
- [ ] Theme configuration
- [ ] Dark theme
- [ ] Build Gzip
- [ ] Build CDN
- [ ] System performance optimization

Expand All @@ -246,6 +245,8 @@ It is recommended to use the `Chrome` browser for local development. Development

Support modern browsers, Not currently supported ie11,Follow-up consideration support ie11

| [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/edge/edge_48x48.png" alt="IE / Edge" width="24px" height="24px" />](http://godban.github.io/browsers-support-badges/)</br>IE / Edge | [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/firefox/firefox_48x48.png" alt="Firefox" width="24px" height="24px" />](http://godban.github.io/browsers-support-badges/)</br>Firefox | [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/chrome/chrome_48x48.png" alt="Chrome" width="24px" height="24px" />](http://godban.github.io/browsers-support-badges/)</br>Chrome | [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/safari/safari_48x48.png" alt="Safari" width="24px" height="24px" />](http://godban.github.io/browsers-support-badges/)</br>Safari |
| :-: | :-: | :-: | :-: |
| Not currently supported | last 2 versions | last 2 versions | last 2 versions |
| [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/edge/edge_48x48.png" alt=" Edge" width="24px" height="24px" />](http://godban.github.io/browsers-support-badges/)</br>IE | [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/edge/edge_48x48.png" alt=" Edge" width="24px" height="24px" />](http://godban.github.io/browsers-support-badges/)</br>Edge | [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/firefox/firefox_48x48.png" alt="Firefox" width="24px" height="24px" />](http://godban.github.io/browsers-support-badges/)</br>Firefox | [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/chrome/chrome_48x48.png" alt="Chrome" width="24px" height="24px" />](http://godban.github.io/browsers-support-badges/)</br>Chrome | [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/safari/safari_48x48.png" alt="Safari" width="24px" height="24px" />](http://godban.github.io/browsers-support-badges/)</br>Safari |
| :-: | :-: | :-: | :-: | :-: |
| not support | last 2 versions | last 2 versions | last 2 versions | last 2 versions |

More browsers can view [Can I Use Es Module](https://caniuse.com/?search=ES%20Module)
17 changes: 7 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,6 @@

## 介绍

该分支为 2.0 新分支,使用 vue3 进行开发。

1.0 分支请切换到`master`分支。1.0 采用`vue2.6`+`vue-composition-api`+`vue-cli`开发

项目基于`ant-design-vue`,`typescript`,`vue3.0`,`vite`,`tsx`实现的 vue3 风格的后台管理系统,

## gitHub 地址
Expand All @@ -65,7 +61,7 @@

## 文档

2.0 文档还没开始写。后续补上
2.0 文档很快完成,请耐心等待

## 预安装

Expand Down Expand Up @@ -93,7 +89,6 @@
- [vite-plugin-mock](https://github.com/anncwb/vite-plugin-mock) - 基于 vite 的 mock 插件.
- [vue-i18n](https://github.com/intlify/vue-i18n-next) - 国际化
- [lodash-es](https://github.com/lodash/lodash) - JavaScript 实用程序库
- [moment](https://github.com/moment/moment) - 时间操作库
- [axios](https://github.com/axios/axios) - Http 数据交互
- [TypeScript](https://www.typescriptlang.org/)

Expand Down Expand Up @@ -227,6 +222,7 @@ yarn clean:lib # 删除node_modules,兼容window系统
- [x] 数字动画
- [x] 首屏加载等待动画
- [x] 抽取生产环境配置文件
- [x] 打包 Gzip

## 正在开发的功能

Expand All @@ -236,7 +232,6 @@ yarn clean:lib # 删除node_modules,兼容window系统
- [ ] 全局错误处理
- [ ] 主题配置
- [ ] 黑暗主题
- [ ] 打包 Gzip
- [ ] 打包 CDN
- [ ] 系统性能优化

Expand All @@ -248,9 +243,11 @@ yarn clean:lib # 删除node_modules,兼容window系统

支持现代浏览器, IE 暂不支持,后续考虑支持 ie11

| [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/edge/edge_48x48.png" alt="IE / Edge" width="24px" height="24px" />](http://godban.github.io/browsers-support-badges/)</br>IE / Edge | [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/firefox/firefox_48x48.png" alt="Firefox" width="24px" height="24px" />](http://godban.github.io/browsers-support-badges/)</br>Firefox | [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/chrome/chrome_48x48.png" alt="Chrome" width="24px" height="24px" />](http://godban.github.io/browsers-support-badges/)</br>Chrome | [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/safari/safari_48x48.png" alt="Safari" width="24px" height="24px" />](http://godban.github.io/browsers-support-badges/)</br>Safari |
| :-: | :-: | :-: | :-: |
| not support | last 2 versions | last 2 versions | last 2 versions |
| [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/edge/edge_48x48.png" alt=" Edge" width="24px" height="24px" />](http://godban.github.io/browsers-support-badges/)</br>IE | [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/edge/edge_48x48.png" alt=" Edge" width="24px" height="24px" />](http://godban.github.io/browsers-support-badges/)</br>Edge | [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/firefox/firefox_48x48.png" alt="Firefox" width="24px" height="24px" />](http://godban.github.io/browsers-support-badges/)</br>Firefox | [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/chrome/chrome_48x48.png" alt="Chrome" width="24px" height="24px" />](http://godban.github.io/browsers-support-badges/)</br>Chrome | [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/safari/safari_48x48.png" alt="Safari" width="24px" height="24px" />](http://godban.github.io/browsers-support-badges/)</br>Safari |
| :-: | :-: | :-: | :-: | :-: |
| not support | last 2 versions | last 2 versions | last 2 versions | last 2 versions |

更多浏览器可以查看 [Can I Use Es Module](https://caniuse.com/?search=ES%20Module)

## 加入我们

Expand Down
22 changes: 0 additions & 22 deletions build/gzip/index.ts

This file was deleted.

36 changes: 36 additions & 0 deletions build/plugin/gzip/compress.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { gzip } from 'zlib';
import { readFileSync, writeFileSync } from 'fs';
import { GzipPluginOptions } from './types';
import viteConfig from '../../vite.config';
import { readAllFile, getCwdPath, isBuildGzip, isSiteMode } from '../utils';

export function startGzip(
fileContent: string | Buffer,
options: GzipPluginOptions = {}
): Promise<Buffer> {
return new Promise((resolve, reject) => {
gzip(fileContent, options.gzipOptions || {}, (err, result) => {
if (err) {
reject(err);
} else {
resolve(result);
}
});
});
}

// 手动压缩css
export async function startGzipStyle() {
if (isBuildGzip() || isSiteMode()) {
const outDir = viteConfig.outDir || 'dist';
const assets = viteConfig.assetsDir || '_assets';
const allCssFile = readAllFile(getCwdPath(outDir, assets), /\.(css)$/);
for (const path of allCssFile) {
const source = readFileSync(path);
const content = await startGzip(source);
const ds = path.split('/');
const fileName = ds[ds.length - 1];
writeFileSync(getCwdPath(outDir, assets, `${fileName}.gz`), content);
}
}
}
Loading

0 comments on commit 8a1bfdf

Please sign in to comment.