@gx-design-vue/create-gx-cli 0.1.10 → 0.1.11
Sign up to get free protection for your applications and to get access to all the features.
- package/package.json +2 -1
- package/template-gx-design-thin/.editorconfig +19 -0
- package/template-gx-design-thin/.env +4 -0
- package/template-gx-design-thin/.env.development +15 -0
- package/template-gx-design-thin/.env.production +28 -0
- package/template-gx-design-thin/.eslintignore +16 -0
- package/template-gx-design-thin/.prettierignore +9 -0
- package/template-gx-design-thin/LICENSE +21 -0
- package/template-gx-design-thin/README.md +112 -0
- package/template-gx-design-thin/build/constant.ts +1 -0
- package/template-gx-design-thin/build/generate/generateModifyVars.ts +14 -0
- package/template-gx-design-thin/build/rollupOptions/index.ts +22 -0
- package/template-gx-design-thin/build/util/hash.ts +17 -0
- package/template-gx-design-thin/build/util/index.ts +131 -0
- package/template-gx-design-thin/build/vite/cdn.ts +63 -0
- package/template-gx-design-thin/build/vite/optimizer.ts +26 -0
- package/template-gx-design-thin/build/vite/plugin/appConfig.ts +91 -0
- package/template-gx-design-thin/build/vite/plugin/autoImport.ts +26 -0
- package/template-gx-design-thin/build/vite/plugin/compress.ts +31 -0
- package/template-gx-design-thin/build/vite/plugin/html.ts +39 -0
- package/template-gx-design-thin/build/vite/plugin/index.ts +75 -0
- package/template-gx-design-thin/build/vite/plugin/mock.ts +14 -0
- package/template-gx-design-thin/build/vite/plugin/pwa.ts +31 -0
- package/template-gx-design-thin/build/vite/plugin/visualizer.ts +14 -0
- package/template-gx-design-thin/build/vite/plugin/viteMock/client.ts +88 -0
- package/template-gx-design-thin/build/vite/plugin/viteMock/createMockServer.ts +271 -0
- package/template-gx-design-thin/build/vite/plugin/viteMock/index.ts +69 -0
- package/template-gx-design-thin/build/vite/plugin/viteMock/types.ts +48 -0
- package/template-gx-design-thin/build/vite/plugin/viteMock/utils.ts +48 -0
- package/template-gx-design-thin/build/vite/plugin/viteNotice.ts +40 -0
- package/template-gx-design-thin/commitlint.config.cjs +32 -0
- package/template-gx-design-thin/config/default/defaultSettings.ts +78 -0
- package/template-gx-design-thin/config/default/network.ts +10 -0
- package/template-gx-design-thin/config/default/proxy.ts +47 -0
- package/template-gx-design-thin/config/default/theme.ts +3 -0
- package/template-gx-design-thin/config/index.ts +11 -0
- package/template-gx-design-thin/eslint.config.js +51 -0
- package/template-gx-design-thin/index.html +42 -0
- package/template-gx-design-thin/mock/_createProductionServer.ts +19 -0
- package/template-gx-design-thin/mock/_util.ts +33 -0
- package/template-gx-design-thin/mock/config/menu.ts +21 -0
- package/template-gx-design-thin/mock/config/user.ts +123 -0
- package/template-gx-design-thin/mock/datasSource/system/menu.ts +10 -0
- package/template-gx-design-thin/mock/datasSource/user/account.ts +30 -0
- package/template-gx-design-thin/mock/datasSource/user/index.ts +47 -0
- package/template-gx-design-thin/mock/util/crypto.ts +23 -0
- package/template-gx-design-thin/mock/util/table.ts +92 -0
- package/template-gx-design-thin/mock/util/utils.ts +73 -0
- package/template-gx-design-thin/package.json +129 -0
- package/template-gx-design-thin/pnpm-lock.yaml +12575 -0
- package/template-gx-design-thin/prettier.config.cjs +18 -0
- package/template-gx-design-thin/public/resource/css/index.css +119 -0
- package/template-gx-design-thin/public/resource/css/normalize.css +396 -0
- package/template-gx-design-thin/public/resource/img/favicon.ico +0 -0
- package/template-gx-design-thin/public/resource/img/logo.png +0 -0
- package/template-gx-design-thin/public/resource/img/pro_icon.svg +1 -0
- package/template-gx-design-thin/public/resource/img/pwa-192x192.png +0 -0
- package/template-gx-design-thin/public/resource/img/pwa-512x512.png +0 -0
- package/template-gx-design-thin/src/App.vue +42 -0
- package/template-gx-design-thin/src/assets/error_images/403.png +0 -0
- package/template-gx-design-thin/src/assets/error_images/404.png +0 -0
- package/template-gx-design-thin/src/assets/error_images/cloud.png +0 -0
- package/template-gx-design-thin/src/assets/login_images/login_background.svg +1 -0
- package/template-gx-design-thin/src/assets/logo.png +0 -0
- package/template-gx-design-thin/src/assets/menu_font/iconfont.css +94 -0
- package/template-gx-design-thin/src/assets/menu_font/iconfont.eot +0 -0
- package/template-gx-design-thin/src/assets/menu_font/iconfont.js +1 -0
- package/template-gx-design-thin/src/assets/menu_font/iconfont.json +142 -0
- package/template-gx-design-thin/src/assets/menu_font/iconfont.svg +1 -0
- package/template-gx-design-thin/src/assets/menu_font/iconfont.ttf +0 -0
- package/template-gx-design-thin/src/assets/menu_font/iconfont.woff +0 -0
- package/template-gx-design-thin/src/assets/menu_font/iconfont.woff2 +0 -0
- package/template-gx-design-thin/src/assets/menu_font/index.less +94 -0
- package/template-gx-design-thin/src/assets/public_icon/iconfont.css +42 -0
- package/template-gx-design-thin/src/assets/public_icon/iconfont.eot +0 -0
- package/template-gx-design-thin/src/assets/public_icon/iconfont.js +1 -0
- package/template-gx-design-thin/src/assets/public_icon/iconfont.json +51 -0
- package/template-gx-design-thin/src/assets/public_icon/iconfont.svg +1 -0
- package/template-gx-design-thin/src/assets/public_icon/iconfont.ttf +0 -0
- package/template-gx-design-thin/src/assets/public_icon/iconfont.woff +0 -0
- package/template-gx-design-thin/src/assets/public_icon/iconfont.woff2 +0 -0
- package/template-gx-design-thin/src/assets/public_icon/index.less +42 -0
- package/template-gx-design-thin/src/assets/public_images/nodata.svg +1 -0
- package/template-gx-design-thin/src/common/global.ts +4 -0
- package/template-gx-design-thin/src/components/GDesign/Result/index.tsx +144 -0
- package/template-gx-design-thin/src/components/GDesign/Result/style.less +140 -0
- package/template-gx-design-thin/src/components/GDesign/utils/index.ts +7 -0
- package/template-gx-design-thin/src/components/GlobalLayout/Confirm/index.ts +21 -0
- package/template-gx-design-thin/src/components/GlobalLayout/Empty/index.vue +18 -0
- package/template-gx-design-thin/src/components/GlobalLayout/RightContent/index.tsx +126 -0
- package/template-gx-design-thin/src/components/GlobalLayout/RightContent/style.ts +77 -0
- package/template-gx-design-thin/src/components/GlobalLayout/Spin/index.tsx +30 -0
- package/template-gx-design-thin/src/components/PageLoading/index.tsx +51 -0
- package/template-gx-design-thin/src/components/index.ts +6 -0
- package/template-gx-design-thin/src/core/ant-design/index.ts +10 -0
- package/template-gx-design-thin/src/core/gx-admin-design/index.ts +6 -0
- package/template-gx-design-thin/src/core/gx-design/index.ts +6 -0
- package/template-gx-design-thin/src/core/gx-pro-design/index.ts +8 -0
- package/template-gx-design-thin/src/core/index.ts +84 -0
- package/template-gx-design-thin/src/design/ant-design/index.less +4 -0
- package/template-gx-design-thin/src/design/ant-design/layout.less +22 -0
- package/template-gx-design-thin/src/design/ant-design/menu.less +48 -0
- package/template-gx-design-thin/src/design/ant-design/spin.less +23 -0
- package/template-gx-design-thin/src/design/ant-design/tooltip.less +7 -0
- package/template-gx-design-thin/src/design/color.less +1 -0
- package/template-gx-design-thin/src/design/config.less +5 -0
- package/template-gx-design-thin/src/design/imageEditor.less +180 -0
- package/template-gx-design-thin/src/design/index.less +95 -0
- package/template-gx-design-thin/src/design/mixin.less +65 -0
- package/template-gx-design-thin/src/design/normalize.less +391 -0
- package/template-gx-design-thin/src/design/root.less +3 -0
- package/template-gx-design-thin/src/hooks/core/index.ts +3 -0
- package/template-gx-design-thin/src/hooks/core/useRequest/index.ts +118 -0
- package/template-gx-design-thin/src/hooks/event/index.ts +3 -0
- package/template-gx-design-thin/src/hooks/event/useClipboard.ts +15 -0
- package/template-gx-design-thin/src/hooks/web/index.ts +5 -0
- package/template-gx-design-thin/src/hooks/web/useThemeStyle.ts +16 -0
- package/template-gx-design-thin/src/layout/BasicLayout.vue +123 -0
- package/template-gx-design-thin/src/layout/BlankLayout.vue +5 -0
- package/template-gx-design-thin/src/layout/ContentView.vue +50 -0
- package/template-gx-design-thin/src/layout/IframeView.vue +1 -0
- package/template-gx-design-thin/src/layout/UserLayout.vue +7 -0
- package/template-gx-design-thin/src/main.ts +34 -0
- package/template-gx-design-thin/src/plugins/index.ts +2 -0
- package/template-gx-design-thin/src/router/guard/index.ts +83 -0
- package/template-gx-design-thin/src/router/guard/permissions.ts +70 -0
- package/template-gx-design-thin/src/router/guard/stateGuard.ts +10 -0
- package/template-gx-design-thin/src/router/helper/routeHelper.ts +231 -0
- package/template-gx-design-thin/src/router/helper/utils.ts +19 -0
- package/template-gx-design-thin/src/router/index.ts +31 -0
- package/template-gx-design-thin/src/router/routes/index.ts +86 -0
- package/template-gx-design-thin/src/router/routes/modules/dataSource.ts +12 -0
- package/template-gx-design-thin/src/services/common/index.ts +11 -0
- package/template-gx-design-thin/src/services/systemCenter/index.ts +1 -0
- package/template-gx-design-thin/src/services/systemCenter/menu.ts +9 -0
- package/template-gx-design-thin/src/services/userCenter/account.ts +42 -0
- package/template-gx-design-thin/src/services/userCenter/index.ts +28 -0
- package/template-gx-design-thin/src/store/index.ts +32 -0
- package/template-gx-design-thin/src/store/modules/dict.ts +28 -0
- package/template-gx-design-thin/src/store/modules/global.ts +42 -0
- package/template-gx-design-thin/src/store/modules/permission.ts +19 -0
- package/template-gx-design-thin/src/store/modules/routes.ts +113 -0
- package/template-gx-design-thin/src/store/modules/tabsRouter.ts +76 -0
- package/template-gx-design-thin/src/store/modules/user.ts +136 -0
- package/template-gx-design-thin/src/utils/accessToken.ts +80 -0
- package/template-gx-design-thin/src/utils/crypto/base64.ts +101 -0
- package/template-gx-design-thin/src/utils/crypto/index.ts +57 -0
- package/template-gx-design-thin/src/utils/env.ts +50 -0
- package/template-gx-design-thin/src/utils/fetchFile.ts +81 -0
- package/template-gx-design-thin/src/utils/index.ts +123 -0
- package/template-gx-design-thin/src/utils/pageTitle.ts +20 -0
- package/template-gx-design-thin/src/utils/request/XHR.ts +139 -0
- package/template-gx-design-thin/src/utils/request/axiosCancel.ts +69 -0
- package/template-gx-design-thin/src/utils/request/checkStatus.ts +25 -0
- package/template-gx-design-thin/src/utils/request/index.ts +144 -0
- package/template-gx-design-thin/src/utils/request/typings.ts +171 -0
- package/template-gx-design-thin/src/utils/storage.ts +199 -0
- package/template-gx-design-thin/src/utils/uploadFile.ts +27 -0
- package/template-gx-design-thin/src/utils/util.ts +198 -0
- package/template-gx-design-thin/src/utils/validate.ts +216 -0
- package/template-gx-design-thin/src/views/Iframe/index.vue +76 -0
- package/template-gx-design-thin/src/views/Page/one.vue +13 -0
- package/template-gx-design-thin/src/views/Page/two.vue +13 -0
- package/template-gx-design-thin/src/views/exception/403/index.vue +7 -0
- package/template-gx-design-thin/src/views/exception/404/index.vue +9 -0
- package/template-gx-design-thin/src/views/user/login/index.vue +109 -0
- package/template-gx-design-thin/src/views/user/login/style.less +38 -0
- package/template-gx-design-thin/tsconfig.json +46 -0
- package/template-gx-design-thin/types/ant-design-import.d.ts +99 -0
- package/template-gx-design-thin/types/auto-imports.d.ts +81 -0
- package/template-gx-design-thin/types/components.d.ts +24 -0
- package/template-gx-design-thin/types/config.d.ts +44 -0
- package/template-gx-design-thin/types/global.d.ts +97 -0
- package/template-gx-design-thin/types/mock.d.ts +16 -0
- package/template-gx-design-thin/types/module.d.ts +20 -0
- package/template-gx-design-thin/types/response.d.ts +15 -0
- package/template-gx-design-thin/unocss.config.ts +101 -0
- package/template-gx-design-thin/vite.config.ts +120 -0
- package/template-gx-design-thin/yarn.lock +9492 -0
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@gx-design-vue/create-gx-cli",
|
3
|
-
"version": "0.1.
|
3
|
+
"version": "0.1.11",
|
4
4
|
"license": "MIT",
|
5
5
|
"description": "a cli to bootstrap gx project",
|
6
6
|
"main": "src/index.js",
|
@@ -30,6 +30,7 @@
|
|
30
30
|
"files": [
|
31
31
|
"bin/",
|
32
32
|
"src/",
|
33
|
+
"template-gx-design-thin/*",
|
33
34
|
"template-mobile-vant-html/*",
|
34
35
|
"template-mobile-vant-cli/*"
|
35
36
|
]
|
@@ -0,0 +1,19 @@
|
|
1
|
+
root = true
|
2
|
+
|
3
|
+
[*]
|
4
|
+
charset=utf-8
|
5
|
+
end_of_line=lf
|
6
|
+
insert_final_newline=true
|
7
|
+
indent_style=space
|
8
|
+
indent_size=2
|
9
|
+
max_line_length = 100
|
10
|
+
|
11
|
+
[*.{yml,yaml,json}]
|
12
|
+
indent_style = space
|
13
|
+
indent_size = 2
|
14
|
+
|
15
|
+
[*.md]
|
16
|
+
trim_trailing_whitespace = false
|
17
|
+
|
18
|
+
[Makefile]
|
19
|
+
indent_style = tab
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# 项目启动执行环境
|
2
|
+
VITE_NODE_ENV= production
|
3
|
+
|
4
|
+
# 代码运行环境
|
5
|
+
VITE_USE_MODE = production
|
6
|
+
|
7
|
+
# 是否开启mock
|
8
|
+
VITE_USE_MOCK = true
|
9
|
+
|
10
|
+
# 是否删除console
|
11
|
+
VITE_DROP_CONSOLE = false
|
12
|
+
|
13
|
+
# Whether to enable gzip or brotli compression
|
14
|
+
# Optional: gzip | brotli | none
|
15
|
+
# If you need multiple forms, you can use `,` to separate
|
16
|
+
VITE_BUILD_COMPRESS = 'none'
|
17
|
+
|
18
|
+
# 使用压缩时是否删除源文件,默认为false
|
19
|
+
VITE_BUILD_COMPRESS_DELETE_ORIGIN_FILE = false
|
20
|
+
|
21
|
+
# 是否使用pwa
|
22
|
+
VITE_USE_PWA = false
|
23
|
+
|
24
|
+
# 是否为打包后的文件提供传统浏览器兼容性支持
|
25
|
+
VITE_LEGACY = false
|
26
|
+
|
27
|
+
# api前缀
|
28
|
+
VITE_BASE_URL=/mock-server
|
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2021 gx12358
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
@@ -0,0 +1,112 @@
|
|
1
|
+
<div align="center"> <a href="https://github.com/gx12358/vue3-antd-admin"> <img alt="VbenAdmin Logo" width="200" src="https://gx12358.cn/resource/img/favicon.ico"> </a> <br> <br>
|
2
|
+
|
3
|
+
<h1>GX Pro Admin(Ant Design Vue)</h1>
|
4
|
+
</div>
|
5
|
+
|
6
|
+
## 简介
|
7
|
+
|
8
|
+
GX Pro Admin 是一个免费开源的中后台模版。使用了最新的`vue3.0+`,`vite5`,`TypeScript`, `Ant Design Vue4.0+`, `Unocss`等主流技术开发,开箱即用的中后台前端解决方案,也可用于学习参考。
|
9
|
+
如果大家喜欢的话,给个start!
|
10
|
+
|
11
|
+
## 特性
|
12
|
+
|
13
|
+
- **最新技术栈**:使用 Vue3、vite5、ant-design-vue4、unocss 等前端前沿技术开发
|
14
|
+
- **TypeScript**: 应用程序级 JavaScript 的语言
|
15
|
+
- **主题**:可配置定制化的主题
|
16
|
+
- **Mock 数据** 内置 Mock 数据方案
|
17
|
+
- **权限** 内置完善的动态路由权限生成方案
|
18
|
+
- **组件** 二次封装了多个pro企业级的组件
|
19
|
+
|
20
|
+
## 预览
|
21
|
+
|
22
|
+
- [🚀 pro 版演示地址](https://gx12358.cn/)
|
23
|
+
测试账号: admin/gx.design
|
24
|
+
|
25
|
+
- [🚀 系统文档地址](https://gx12358.cn/doc/)
|
26
|
+
- [🚀 pro 组件文档地址](https://gx12358.cn/procomponents/)
|
27
|
+
|
28
|
+
|
29
|
+
## 准备
|
30
|
+
|
31
|
+
- [node](http://nodejs.org/) 和 [git](https://git-scm.com/) -项目开发环境
|
32
|
+
- [Vite](https://vitejs.dev/) - 熟悉 vite 特性
|
33
|
+
- [Vue3](https://v3.vuejs.org/) - 熟悉 Vue 基础语法
|
34
|
+
- [TypeScript](https://www.typescriptlang.org/) - 熟悉`TypeScript`基本语法
|
35
|
+
- [Es6+](http://es6.ruanyifeng.com/) - 熟悉 es6 基本语法
|
36
|
+
- [Vue-Router-Next](https://next.router.vuejs.org/) - 熟悉 vue-router 基本使用
|
37
|
+
- [Ant-Design-Vue](https://next.antdv.com/components/overview-cn/) - ui 基本使用
|
38
|
+
- [Mock.js](https://github.com/nuysoft/Mock) - mockjs 基本语法
|
39
|
+
|
40
|
+
## 安装使用
|
41
|
+
|
42
|
+
- 获取项目代码
|
43
|
+
|
44
|
+
```bash
|
45
|
+
git clone https://gitee.com/gx12358/vite-admin-pro
|
46
|
+
```
|
47
|
+
|
48
|
+
- 安装依赖
|
49
|
+
|
50
|
+
```bash
|
51
|
+
cd gx-admin-pro
|
52
|
+
|
53
|
+
pnpm install
|
54
|
+
|
55
|
+
```
|
56
|
+
|
57
|
+
- 运行
|
58
|
+
|
59
|
+
```bash
|
60
|
+
pnpm run serve
|
61
|
+
```
|
62
|
+
|
63
|
+
- 打包
|
64
|
+
|
65
|
+
```bash
|
66
|
+
pnpm run build
|
67
|
+
```
|
68
|
+
|
69
|
+
## Git 贡献提交规范
|
70
|
+
|
71
|
+
- 参考 [vue](https://github.com/vuejs/vue/blob/dev/.github/COMMIT_CONVENTION.md) 规范
|
72
|
+
- `feat` 增加新功能
|
73
|
+
- `fix` 修复问题/BUG
|
74
|
+
- `style` 代码风格相关无影响运行结果的
|
75
|
+
- `perf` 优化/性能提升
|
76
|
+
- `refactor` 重构
|
77
|
+
- `revert` 撤销修改
|
78
|
+
- `test` 测试相关
|
79
|
+
- `docs` 文档/注释
|
80
|
+
- `chore` 依赖更新/脚手架配置修改等
|
81
|
+
- `workflow` 工作流改进
|
82
|
+
- `ci` 持续集成
|
83
|
+
- `types` 类型定义文件更改
|
84
|
+
- `wip` 开发中
|
85
|
+
|
86
|
+
## 浏览器支持
|
87
|
+
|
88
|
+
本地开发推荐使用`Chrome 80+` 浏览器
|
89
|
+
|
90
|
+
支持现代浏览器, 不支持 IE
|
91
|
+
|
92
|
+
## 相关仓库
|
93
|
+
|
94
|
+
如果这些插件对你有帮助,可以给一个 star 支持下
|
95
|
+
|
96
|
+
- [vite-plugin-html](https://github.com/anncwb/vite-plugin-html) - 用于 html 模版转换及压缩
|
97
|
+
- [vite-plugin-compression](https://github.com/anncwb/vite-plugin-compression) - 用于打包输出.gz|.brotil 文件
|
98
|
+
- [vite-plugin-svg-icons](https://github.com/anncwb/vite-plugin-svg-icons) - 用于快速生成 svg 雪碧图
|
99
|
+
|
100
|
+
## 维护者
|
101
|
+
|
102
|
+
[@gx12358](https://github.com/gx12358/vue3-antd-admin)
|
103
|
+
|
104
|
+
## 交流
|
105
|
+
|
106
|
+
`Vue3-Antd-Admin` 是完全开源免费的项目,在帮助开发者更方便地进行中大型管理系统开发,同时也提供 QQ 交流群使用问题欢迎在群内提问。
|
107
|
+
|
108
|
+
- QQ 群 `871430530`
|
109
|
+
|
110
|
+
## License
|
111
|
+
|
112
|
+
[MIT © gx12358-2021](./LICENSE)
|
@@ -0,0 +1 @@
|
|
1
|
+
export const GLOB_CONFIG_FILE_NAME = '_app.config.js'
|
@@ -0,0 +1,14 @@
|
|
1
|
+
import { resolve } from 'node:path'
|
2
|
+
import { theme } from 'ant-design-vue'
|
3
|
+
|
4
|
+
export function generateModifyVars() {
|
5
|
+
const { defaultAlgorithm, defaultSeed } = theme
|
6
|
+
|
7
|
+
const mapToken = defaultAlgorithm(defaultSeed)
|
8
|
+
const modifyVarsParams = {
|
9
|
+
...mapToken,
|
10
|
+
hack: `true; @import (reference) "${resolve('src/design/config.less')}";`
|
11
|
+
}
|
12
|
+
|
13
|
+
return modifyVarsParams
|
14
|
+
}
|
@@ -0,0 +1,22 @@
|
|
1
|
+
import type { RollupOptions } from 'rollup'
|
2
|
+
import externalGlobals from 'rollup-plugin-external-globals'
|
3
|
+
import { pathResolve } from '../util'
|
4
|
+
import { configManualChunk } from '../vite/optimizer'
|
5
|
+
import { getExternalMap } from '../vite/cdn'
|
6
|
+
|
7
|
+
export default function (useCdn: boolean) {
|
8
|
+
return {
|
9
|
+
input: {
|
10
|
+
index: pathResolve('index.html')
|
11
|
+
},
|
12
|
+
// 静态资源分类打包
|
13
|
+
output: {
|
14
|
+
manualChunks: configManualChunk,
|
15
|
+
chunkFileNames: 'static/js/[name]-[hash].js',
|
16
|
+
entryFileNames: 'static/js/[name]-[hash].js',
|
17
|
+
assetFileNames: 'static/[ext]/[name]-[hash].[ext]'
|
18
|
+
},
|
19
|
+
external: useCdn ? Object.keys(getExternalMap()) : [],
|
20
|
+
plugins: useCdn ? [ externalGlobals(getExternalMap()) ] : []
|
21
|
+
} as RollupOptions
|
22
|
+
}
|
@@ -0,0 +1,17 @@
|
|
1
|
+
import { createHash } from 'node:crypto'
|
2
|
+
|
3
|
+
function createContentHash(content: string, hashLSize = 12) {
|
4
|
+
const hash = createHash('sha256').update(content)
|
5
|
+
return hash.digest('hex').slice(0, hashLSize)
|
6
|
+
}
|
7
|
+
|
8
|
+
function strToHex(str: string) {
|
9
|
+
const result: string[] = []
|
10
|
+
for (let i = 0; i < str.length; ++i) {
|
11
|
+
const hex = str.charCodeAt(i).toString(16)
|
12
|
+
result.push((`000${hex}`).slice(-4))
|
13
|
+
}
|
14
|
+
return result.join('').toUpperCase()
|
15
|
+
}
|
16
|
+
|
17
|
+
export { createContentHash, strToHex }
|
@@ -0,0 +1,131 @@
|
|
1
|
+
import fs from 'node:fs'
|
2
|
+
import path, { resolve } from 'node:path'
|
3
|
+
import dotenv from 'dotenv'
|
4
|
+
|
5
|
+
export const rootPath = process.cwd()
|
6
|
+
|
7
|
+
export function pathResolve(dir: string) {
|
8
|
+
return resolve(process.cwd(), '.', dir)
|
9
|
+
}
|
10
|
+
|
11
|
+
/**
|
12
|
+
* Whether to generate package preview
|
13
|
+
*/
|
14
|
+
export function isReportMode(): boolean {
|
15
|
+
return process.env.REPORT === 'true'
|
16
|
+
}
|
17
|
+
|
18
|
+
// Read all environment variable configuration files to process.env
|
19
|
+
export function wrapperEnv(envConf: Recordable): ViteEnv {
|
20
|
+
const ret: any = {}
|
21
|
+
|
22
|
+
for (const envName of Object.keys(envConf)) {
|
23
|
+
let realName = envConf[envName].replace(/\\n/g, '\n')
|
24
|
+
realName = realName === 'true' ? true : realName === 'false' ? false : realName
|
25
|
+
|
26
|
+
ret[envName] = realName
|
27
|
+
process.env[envName] = realName
|
28
|
+
}
|
29
|
+
return ret
|
30
|
+
}
|
31
|
+
|
32
|
+
/**
|
33
|
+
* 获取当前环境下生效的配置文件名
|
34
|
+
*/
|
35
|
+
function getConfFiles() {
|
36
|
+
const script = process.env.npm_lifecycle_script
|
37
|
+
const reg = new RegExp('--mode ([a-z]+)')
|
38
|
+
const result = reg.exec(script as string) as any
|
39
|
+
if (result) {
|
40
|
+
const mode = result[1] as string
|
41
|
+
return [ '.env', `.env.${mode}` ]
|
42
|
+
}
|
43
|
+
return [ '.env', '.env.production' ]
|
44
|
+
}
|
45
|
+
|
46
|
+
/**
|
47
|
+
* Get the environment variables starting with the specified prefix
|
48
|
+
* @param match prefix
|
49
|
+
* @param confFiles ext
|
50
|
+
*/
|
51
|
+
export function getEnvConfig(confFiles = getConfFiles()): Partial<ViteEnv> {
|
52
|
+
let envConfig: Partial<ViteEnv> = {}
|
53
|
+
confFiles.forEach((item) => {
|
54
|
+
try {
|
55
|
+
const env = dotenv.parse(fs.readFileSync(path.resolve(process.cwd(), item)))
|
56
|
+
envConfig = { ...envConfig, ...env }
|
57
|
+
} catch (e) {
|
58
|
+
console.error(`Error in parsing ${item}`, e)
|
59
|
+
}
|
60
|
+
})
|
61
|
+
return envConfig
|
62
|
+
}
|
63
|
+
|
64
|
+
/**
|
65
|
+
* Get user root directory
|
66
|
+
* @param dir file path
|
67
|
+
*/
|
68
|
+
export function getRootPath(...dir: string[]) {
|
69
|
+
return path.resolve(process.cwd(), ...dir)
|
70
|
+
}
|
71
|
+
|
72
|
+
export function getDefaultPath(supportTs = true) {
|
73
|
+
return path.resolve(process.cwd(), `src/main.${supportTs ? 'ts' : 'js'}`)
|
74
|
+
}
|
75
|
+
|
76
|
+
export function fileExists(f: string) {
|
77
|
+
try {
|
78
|
+
fs.accessSync(f, fs.constants.W_OK)
|
79
|
+
return true
|
80
|
+
} catch (error) {
|
81
|
+
return false
|
82
|
+
}
|
83
|
+
}
|
84
|
+
|
85
|
+
function q(t) {
|
86
|
+
return t.reduce((n, e) => n + e)
|
87
|
+
}
|
88
|
+
|
89
|
+
function Gt(t, n?: number) {
|
90
|
+
if (t === 0)
|
91
|
+
return '0 Bytes'
|
92
|
+
const e = 1024
|
93
|
+
const r = n || 2
|
94
|
+
const o = [ 'Bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB' ]
|
95
|
+
const s = Math.floor(Math.log(t) / Math.log(e))
|
96
|
+
return `${Number.parseFloat((t / e ** s).toFixed(r))} ${o[s]}`
|
97
|
+
}
|
98
|
+
|
99
|
+
const ot = []
|
100
|
+
|
101
|
+
export function getPackageSize({ folder, callBack, format = !0 }) {
|
102
|
+
fs.readdir(folder, (err, files) => {
|
103
|
+
if (err)
|
104
|
+
throw err
|
105
|
+
|
106
|
+
let index = 0
|
107
|
+
const callBacks = () => {
|
108
|
+
if (++index === files.length) {
|
109
|
+
callBack(format ? Gt(q(ot)) : q(ot))
|
110
|
+
}
|
111
|
+
}
|
112
|
+
|
113
|
+
files.forEach((p) => {
|
114
|
+
fs.stat(`${folder}/${p}`, (err, stat) => {
|
115
|
+
if (err)
|
116
|
+
throw err
|
117
|
+
if (stat.isFile()) {
|
118
|
+
ot.push(stat.size)
|
119
|
+
callBacks()
|
120
|
+
} else {
|
121
|
+
getPackageSize({
|
122
|
+
folder: `${folder}/${p}`,
|
123
|
+
callBack: callBacks
|
124
|
+
})
|
125
|
+
}
|
126
|
+
})
|
127
|
+
})
|
128
|
+
|
129
|
+
files.length === 0 && callBack(0)
|
130
|
+
})
|
131
|
+
}
|
@@ -0,0 +1,63 @@
|
|
1
|
+
import fs from 'node:fs'
|
2
|
+
import path from 'node:path'
|
3
|
+
import { defaultSettings } from '../../config'
|
4
|
+
|
5
|
+
const { cdnUrl, cdnModules } = defaultSettings
|
6
|
+
|
7
|
+
function getModuleVersion(name: string): string {
|
8
|
+
const pwd = process.cwd()
|
9
|
+
const pkgFile = path.join(pwd, 'node_modules', name, 'package.json')
|
10
|
+
if (fs.existsSync(pkgFile)) {
|
11
|
+
const pkgJson = JSON.parse(fs.readFileSync(pkgFile, 'utf8'))
|
12
|
+
return pkgJson.version
|
13
|
+
}
|
14
|
+
|
15
|
+
return ''
|
16
|
+
}
|
17
|
+
|
18
|
+
function isFullPath(path: string) {
|
19
|
+
return path.startsWith('http:') || path.startsWith('https:') || path.startsWith('//')
|
20
|
+
}
|
21
|
+
|
22
|
+
function renderUrl(data: CdnModuleList & {
|
23
|
+
version: string
|
24
|
+
}) {
|
25
|
+
const { path } = data
|
26
|
+
if (isFullPath(path))
|
27
|
+
return path
|
28
|
+
return cdnUrl.replace(/\{name\}/g, data.name)
|
29
|
+
.replace(/\{version\}/g, data.version)
|
30
|
+
.replace(/\{path\}/g, path)
|
31
|
+
}
|
32
|
+
|
33
|
+
function getCdnModuleFiles() {
|
34
|
+
return cdnModules.map(m => {
|
35
|
+
const version = getModuleVersion(m.name)
|
36
|
+
if (!version) {
|
37
|
+
throw new Error(`modules: ${m.name} package.json file does not exist`)
|
38
|
+
}
|
39
|
+
|
40
|
+
let css = m.css || []
|
41
|
+
if (!Array.isArray(css) && css) {
|
42
|
+
css = [ css ]
|
43
|
+
}
|
44
|
+
|
45
|
+
return {
|
46
|
+
js: renderUrl({
|
47
|
+
...m,
|
48
|
+
version
|
49
|
+
}),
|
50
|
+
css
|
51
|
+
}
|
52
|
+
})
|
53
|
+
}
|
54
|
+
|
55
|
+
export function getExternalMap() {
|
56
|
+
const externalMap = {}
|
57
|
+
cdnModules.forEach((v) => {
|
58
|
+
externalMap[v.name] = v.globalName
|
59
|
+
})
|
60
|
+
return externalMap
|
61
|
+
}
|
62
|
+
|
63
|
+
export default getCdnModuleFiles()
|
@@ -0,0 +1,26 @@
|
|
1
|
+
import type { GetManualChunk } from 'rollup'
|
2
|
+
|
3
|
+
const vendorLibs: { match: string[]; output: string }[] = [
|
4
|
+
{
|
5
|
+
match: ['ant-design-vue'],
|
6
|
+
output: 'ant-design-vue',
|
7
|
+
},
|
8
|
+
{
|
9
|
+
match: ['@gx-design-vue/pro-field'],
|
10
|
+
output: 'pro-field',
|
11
|
+
},
|
12
|
+
{
|
13
|
+
match: ['@gx-design-vue/pro-form'],
|
14
|
+
output: 'pro-form',
|
15
|
+
},
|
16
|
+
]
|
17
|
+
|
18
|
+
export const configManualChunk: GetManualChunk = (id: string) => {
|
19
|
+
if (/[\\/]node_modules[\\/]/.test(id)) {
|
20
|
+
const matchItem = vendorLibs.find((item) => {
|
21
|
+
const reg = new RegExp(`[\\/]node_modules[\\/]_?(${item.match.join('|')})(.*)`, 'ig')
|
22
|
+
return reg.test(id)
|
23
|
+
})
|
24
|
+
return matchItem ? matchItem.output : null
|
25
|
+
}
|
26
|
+
}
|
@@ -0,0 +1,91 @@
|
|
1
|
+
import colors from 'picocolors'
|
2
|
+
import type { PluginOption } from 'vite'
|
3
|
+
import { readPackageJSON } from 'pkg-types'
|
4
|
+
|
5
|
+
import { getEnvConfig, rootPath } from '../../util'
|
6
|
+
import { createContentHash, strToHex } from '../../util/hash'
|
7
|
+
|
8
|
+
const GLOBAL_CONFIG_FILE_NAME = '_app.config.js'
|
9
|
+
const PLUGIN_NAME = 'app-config'
|
10
|
+
|
11
|
+
async function createAppConfigPlugin({
|
12
|
+
isBuild
|
13
|
+
}: {
|
14
|
+
isBuild: boolean;
|
15
|
+
}): Promise<PluginOption> {
|
16
|
+
let publicPath: string
|
17
|
+
let source: string
|
18
|
+
if (!isBuild) {
|
19
|
+
return {
|
20
|
+
name: PLUGIN_NAME
|
21
|
+
}
|
22
|
+
}
|
23
|
+
const { version = '' } = await readPackageJSON(rootPath)
|
24
|
+
|
25
|
+
return {
|
26
|
+
name: PLUGIN_NAME,
|
27
|
+
async configResolved(_config) {
|
28
|
+
const appTitle = _config?.env?.VITE_GLOB_APP_TITLE ?? ''
|
29
|
+
publicPath = _config.base
|
30
|
+
source = await getConfigSource(appTitle)
|
31
|
+
},
|
32
|
+
async transformIndexHtml(html) {
|
33
|
+
publicPath = publicPath.endsWith('/') ? publicPath : `${publicPath}/`
|
34
|
+
|
35
|
+
const appConfigSrc = `${
|
36
|
+
publicPath || '/'
|
37
|
+
}${GLOBAL_CONFIG_FILE_NAME}?v=${version}-${createContentHash(source)}`
|
38
|
+
|
39
|
+
return {
|
40
|
+
html,
|
41
|
+
tags: [
|
42
|
+
{
|
43
|
+
tag: 'script',
|
44
|
+
attrs: {
|
45
|
+
src: appConfigSrc
|
46
|
+
}
|
47
|
+
}
|
48
|
+
]
|
49
|
+
}
|
50
|
+
},
|
51
|
+
async generateBundle() {
|
52
|
+
try {
|
53
|
+
this.emitFile({
|
54
|
+
type: 'asset',
|
55
|
+
fileName: GLOBAL_CONFIG_FILE_NAME,
|
56
|
+
source
|
57
|
+
})
|
58
|
+
} catch (error) {
|
59
|
+
console.log(
|
60
|
+
colors.red(`configuration file configuration file failed to package:\n${error}`)
|
61
|
+
)
|
62
|
+
}
|
63
|
+
}
|
64
|
+
}
|
65
|
+
}
|
66
|
+
|
67
|
+
/**
|
68
|
+
* Get the configuration file variable name
|
69
|
+
* @param env
|
70
|
+
*/
|
71
|
+
const getVariableName = (title: string) => {
|
72
|
+
return `__PRODUCTION__${strToHex(title) || '__APP'}__CONF__`.toUpperCase().replace(/\s/g, '')
|
73
|
+
}
|
74
|
+
|
75
|
+
async function getConfigSource(appTitle: string) {
|
76
|
+
const config = await getEnvConfig()
|
77
|
+
const variableName = getVariableName(appTitle)
|
78
|
+
const windowVariable = `window.${variableName}`
|
79
|
+
// Ensure that the variable will not be modified
|
80
|
+
let source = `${windowVariable}=${JSON.stringify(config)};`
|
81
|
+
source += `
|
82
|
+
Object.freeze(${windowVariable});
|
83
|
+
Object.defineProperty(window, "${variableName}", {
|
84
|
+
configurable: false,
|
85
|
+
writable: false,
|
86
|
+
});
|
87
|
+
`.replace(/\s/g, '')
|
88
|
+
return source
|
89
|
+
}
|
90
|
+
|
91
|
+
export { createAppConfigPlugin }
|
@@ -0,0 +1,26 @@
|
|
1
|
+
import autoImport from 'unplugin-auto-import/vite'
|
2
|
+
import Components from 'unplugin-vue-components/vite'
|
3
|
+
import { AntDesignVueResolver } from 'unplugin-vue-components/resolvers'
|
4
|
+
import { defaultSettings } from '../../../config'
|
5
|
+
|
6
|
+
const importsModules = [ 'vue', 'vue-router' ] as any
|
7
|
+
|
8
|
+
export function createAutoImport() {
|
9
|
+
const useCdnModules = defaultSettings.useCdn && defaultSettings.cdnModules.some(el => importsModules.includes(el.name))
|
10
|
+
return [
|
11
|
+
autoImport({
|
12
|
+
include: [
|
13
|
+
/\.[tj]sx?$/, // .ts, .tsx, .js, .jsx
|
14
|
+
/\.vue$/, /\.vue\?vue/, // .vue
|
15
|
+
/\.md$/ // .md
|
16
|
+
],
|
17
|
+
imports: useCdnModules ? [] : importsModules,
|
18
|
+
dts: 'types/auto-imports.d.ts',
|
19
|
+
dirs: [ 'src/store' ]
|
20
|
+
}),
|
21
|
+
Components({
|
22
|
+
resolvers: [ AntDesignVueResolver({ importStyle: false, resolveIcons: true }) ],
|
23
|
+
dts: 'types/ant-design-import.d.ts'
|
24
|
+
})
|
25
|
+
]
|
26
|
+
}
|
@@ -0,0 +1,31 @@
|
|
1
|
+
import type { Plugin } from 'vite'
|
2
|
+
|
3
|
+
import compressPlugin from 'vite-plugin-compression'
|
4
|
+
|
5
|
+
export function configCompressPlugin(
|
6
|
+
compress: 'gzip' | 'brotli' | 'none',
|
7
|
+
deleteOriginFile = false
|
8
|
+
): Plugin | Plugin[] {
|
9
|
+
const compressList = compress.split(',')
|
10
|
+
|
11
|
+
const plugins: Plugin[] = []
|
12
|
+
|
13
|
+
if (compressList.includes('gzip')) {
|
14
|
+
plugins.push(
|
15
|
+
compressPlugin({
|
16
|
+
ext: '.gz',
|
17
|
+
deleteOriginFile
|
18
|
+
})
|
19
|
+
)
|
20
|
+
}
|
21
|
+
if (compressList.includes('brotli')) {
|
22
|
+
plugins.push(
|
23
|
+
compressPlugin({
|
24
|
+
ext: '.br',
|
25
|
+
algorithm: 'brotliCompress',
|
26
|
+
deleteOriginFile
|
27
|
+
})
|
28
|
+
)
|
29
|
+
}
|
30
|
+
return plugins
|
31
|
+
}
|