@gx-design-vue/create-gx-cli 0.1.19 → 0.1.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -4
- package/dist/index.js +36 -48
- package/package.json +5 -3
- package/template-mobile-vant-cli/.editorconfig +19 -0
- package/template-mobile-vant-cli/.env +3 -0
- package/template-mobile-vant-cli/.env.development +17 -0
- package/template-mobile-vant-cli/.env.pro +28 -0
- package/template-mobile-vant-cli/.env.production +31 -0
- package/template-mobile-vant-cli/.eslintignore +15 -0
- package/template-mobile-vant-cli/.prettierignore +9 -0
- package/template-mobile-vant-cli/README.md +1 -0
- package/template-mobile-vant-cli/commitlint.config.cjs +32 -0
- package/template-mobile-vant-cli/config/default/defaultSettings.ts +70 -0
- package/template-mobile-vant-cli/config/default/network.ts +10 -0
- package/template-mobile-vant-cli/config/default/proxy.ts +50 -0
- package/template-mobile-vant-cli/config/default/theme.ts +3 -0
- package/template-mobile-vant-cli/config/index.ts +11 -0
- package/template-mobile-vant-cli/eslint.config.js +58 -0
- package/template-mobile-vant-cli/index.html +25 -0
- package/template-mobile-vant-cli/internal/vite-config/generate/generateModifyVars.ts +7 -0
- package/template-mobile-vant-cli/internal/vite-config/rollupOptions/index.ts +22 -0
- package/template-mobile-vant-cli/internal/vite-config/util/hash.ts +17 -0
- package/template-mobile-vant-cli/internal/vite-config/util/index.ts +132 -0
- package/template-mobile-vant-cli/internal/vite-config/vite/cdn.ts +65 -0
- package/template-mobile-vant-cli/internal/vite-config/vite/optimizer.ts +26 -0
- package/template-mobile-vant-cli/internal/vite-config/vite/plugin/appConfig.ts +91 -0
- package/template-mobile-vant-cli/internal/vite-config/vite/plugin/autoImport.ts +28 -0
- package/template-mobile-vant-cli/internal/vite-config/vite/plugin/compress.ts +31 -0
- package/template-mobile-vant-cli/internal/vite-config/vite/plugin/html.ts +32 -0
- package/template-mobile-vant-cli/internal/vite-config/vite/plugin/index.ts +74 -0
- package/template-mobile-vant-cli/internal/vite-config/vite/plugin/visualizer.ts +14 -0
- package/template-mobile-vant-cli/internal/vite-config/vite/plugin/viteNotice.ts +40 -0
- package/template-mobile-vant-cli/mock/config/permissions.ts +15 -0
- package/template-mobile-vant-cli/mock/config/user/id.ts +5 -0
- package/template-mobile-vant-cli/mock/config/user/index.ts +96 -0
- package/template-mobile-vant-cli/mock/index.ts +55 -0
- package/template-mobile-vant-cli/mock/routers/table/index.fake.ts +22 -0
- package/template-mobile-vant-cli/mock/routers/user/account.fake.ts +52 -0
- package/template-mobile-vant-cli/mock/routers/user/index.fake.ts +46 -0
- package/template-mobile-vant-cli/mock/utils/crypto.ts +21 -0
- package/template-mobile-vant-cli/mock/utils/table.ts +96 -0
- package/template-mobile-vant-cli/mock/utils/util.ts +91 -0
- package/template-mobile-vant-cli/package.json +74 -0
- package/template-mobile-vant-cli/public/css/default.css +54 -0
- package/template-mobile-vant-cli/public/favicon.ico +0 -0
- package/template-mobile-vant-cli/src/App.vue +8 -0
- package/template-mobile-vant-cli/src/assets/logo.png +0 -0
- package/template-mobile-vant-cli/src/components/PageContainer/ProSkeleton.tsx +29 -0
- package/template-mobile-vant-cli/src/components/PageContainer/index.tsx +207 -0
- package/template-mobile-vant-cli/src/components/PageContainer/style.module.less +17 -0
- package/template-mobile-vant-cli/src/components/TabsMenu/index.vue +45 -0
- package/template-mobile-vant-cli/src/core/gx-design/index.ts +7 -0
- package/template-mobile-vant-cli/src/core/index.ts +5 -0
- package/template-mobile-vant-cli/src/design/color.less +1 -0
- package/template-mobile-vant-cli/src/design/config.less +5 -0
- package/template-mobile-vant-cli/src/design/index.less +3 -0
- package/template-mobile-vant-cli/src/design/mixin.less +65 -0
- package/template-mobile-vant-cli/src/design/reset.less +39 -0
- package/template-mobile-vant-cli/src/design/root.less +3 -0
- package/template-mobile-vant-cli/src/design/vant/index.less +0 -0
- package/template-mobile-vant-cli/src/hooks/web/index.ts +5 -0
- package/template-mobile-vant-cli/src/hooks/web/usePageLoading.ts +56 -0
- package/template-mobile-vant-cli/src/layout/BasicLayout/index.vue +18 -0
- package/template-mobile-vant-cli/src/layout/BasicLayout/style.less +3 -0
- package/template-mobile-vant-cli/src/layout/UserLayout/index.vue +18 -0
- package/template-mobile-vant-cli/src/layout/UserLayout/style.module.less +36 -0
- package/template-mobile-vant-cli/src/main.ts +34 -0
- package/template-mobile-vant-cli/src/pages/Account/details.vue +13 -0
- package/template-mobile-vant-cli/src/pages/Account/index.vue +102 -0
- package/template-mobile-vant-cli/src/pages/Home/index.vue +71 -0
- package/template-mobile-vant-cli/src/pages/user/login/index.vue +76 -0
- package/template-mobile-vant-cli/src/plugins/dayjs/index.ts +3 -0
- package/template-mobile-vant-cli/src/plugins/index.ts +2 -0
- package/template-mobile-vant-cli/src/router/guard/index.ts +18 -0
- package/template-mobile-vant-cli/src/router/guard/permissions.ts +41 -0
- package/template-mobile-vant-cli/src/router/guard/stateGuard.ts +10 -0
- package/template-mobile-vant-cli/src/router/index.ts +31 -0
- package/template-mobile-vant-cli/src/router/routes/index.ts +46 -0
- package/template-mobile-vant-cli/src/router/routes/modules/dataSource.ts +32 -0
- package/template-mobile-vant-cli/src/services/index.ts +31 -0
- package/template-mobile-vant-cli/src/services/userCenter/account.ts +42 -0
- package/template-mobile-vant-cli/src/services/userCenter/index.ts +28 -0
- package/template-mobile-vant-cli/src/store/index.ts +20 -0
- package/template-mobile-vant-cli/src/store/modules/global.ts +23 -0
- package/template-mobile-vant-cli/src/store/modules/user.ts +107 -0
- package/template-mobile-vant-cli/src/utils/accessToken.ts +97 -0
- package/template-mobile-vant-cli/src/utils/crypto/index.ts +56 -0
- package/template-mobile-vant-cli/src/utils/env.ts +50 -0
- package/template-mobile-vant-cli/src/utils/pageTitle.ts +20 -0
- package/template-mobile-vant-cli/src/utils/request/XHR.ts +137 -0
- package/template-mobile-vant-cli/src/utils/request/axiosCancel.ts +69 -0
- package/template-mobile-vant-cli/src/utils/request/checkStatus.ts +25 -0
- package/template-mobile-vant-cli/src/utils/request/index.ts +155 -0
- package/template-mobile-vant-cli/src/utils/request/typings.ts +171 -0
- package/template-mobile-vant-cli/src/utils/storage.ts +215 -0
- package/template-mobile-vant-cli/src/utils/util.ts +27 -0
- package/template-mobile-vant-cli/src/utils/validate.ts +211 -0
- package/template-mobile-vant-cli/tsconfig.json +50 -0
- package/template-mobile-vant-cli/types/auto-imports.d.ts +80 -0
- package/template-mobile-vant-cli/types/components.d.ts +7 -0
- package/template-mobile-vant-cli/types/config.d.ts +56 -0
- package/template-mobile-vant-cli/types/global.d.ts +80 -0
- package/template-mobile-vant-cli/types/mock.d.ts +34 -0
- package/template-mobile-vant-cli/types/module.d.ts +61 -0
- package/template-mobile-vant-cli/types/response.d.ts +17 -0
- package/template-mobile-vant-cli/types/system.d.ts +58 -0
- package/template-mobile-vant-cli/types/vant-import.d.ts +25 -0
- package/template-mobile-vant-cli/unocss.config.ts +161 -0
- package/template-mobile-vant-cli/vite.config.ts +142 -0
- package/template-mobile-vant-html/README.md +4 -0
- package/template-mobile-vant-html/css/global.css +293 -0
- package/template-mobile-vant-html/css/global.css.map +1 -0
- package/template-mobile-vant-html/css/global.less +293 -0
- package/template-mobile-vant-html/css/index.css +20 -0
- package/template-mobile-vant-html/css/index.css.map +1 -0
- package/template-mobile-vant-html/css/index.less +21 -0
- package/template-mobile-vant-html/image/disconnected.svg +60 -0
- package/template-mobile-vant-html/image/empty.svg +52 -0
- package/template-mobile-vant-html/image/error.svg +53 -0
- package/template-mobile-vant-html/image/loading.svg +1 -0
- package/template-mobile-vant-html/index.html +91 -0
- package/template-mobile-vant-html/js/index.js +29 -0
- package/template-mobile-vant-html/js/plugin/day.min.js +1 -0
- package/template-mobile-vant-html/js/plugin/fastclick.js +730 -0
- package/template-mobile-vant-html/js/plugin/jquery.min.js +2 -0
- package/template-mobile-vant-html/js/plugin/rem.js +28 -0
- package/template-mobile-vant-html/js/utils/appUtil.js +70 -0
- package/template-mobile-vant-html/js/utils/config.js +3 -0
- package/template-mobile-vant-html/js/utils/request.js +61 -0
- package/template-mobile-vant-html/js/utils/utils.js +65 -0
- package/template-mobile-vant-html/js/utils/validate.js +292 -0
- package/template-vite-project/.env +5 -0
- package/template-vite-project/.env.development +5 -0
- package/template-vite-project/.env.pro +5 -0
- package/template-vite-project/.env.production +5 -0
- package/template-vite-project/README.md +5 -0
- package/template-vite-project/_gitignore +24 -0
- package/template-vite-project/index.html +46 -0
- package/template-vite-project/internal/proxy/index.ts +47 -0
- package/template-vite-project/internal/vite/generate/generateModifyVars.ts +9 -0
- package/template-vite-project/internal/vite/rollupOptions/index.ts +18 -0
- package/template-vite-project/internal/vite/util/hash.ts +17 -0
- package/template-vite-project/internal/vite/util/index.ts +132 -0
- package/template-vite-project/internal/vite/vite/cdn.ts +65 -0
- package/template-vite-project/internal/vite/vite/plugin/appConfig.ts +91 -0
- package/template-vite-project/internal/vite/vite/plugin/autoImport.ts +28 -0
- package/template-vite-project/internal/vite/vite/plugin/compress.ts +31 -0
- package/template-vite-project/internal/vite/vite/plugin/html.ts +24 -0
- package/template-vite-project/internal/vite/vite/plugin/index.ts +72 -0
- package/template-vite-project/internal/vite/vite/plugin/visualizer.ts +14 -0
- package/template-vite-project/internal/vite/vite/plugin/viteNotice.ts +40 -0
- package/template-vite-project/node_modules/.bin/cross-env +21 -0
- package/template-vite-project/node_modules/.bin/cross-env-shell +21 -0
- package/template-vite-project/node_modules/.bin/esbuild +21 -0
- package/template-vite-project/node_modules/.bin/jiti +21 -0
- package/template-vite-project/node_modules/.bin/lessc +21 -0
- package/template-vite-project/node_modules/.bin/parser +21 -0
- package/template-vite-project/node_modules/.bin/rollup +21 -0
- package/template-vite-project/node_modules/.bin/terser +21 -0
- package/template-vite-project/node_modules/.bin/tsc +21 -0
- package/template-vite-project/node_modules/.bin/tsserver +21 -0
- package/template-vite-project/node_modules/.bin/vite +21 -0
- package/template-vite-project/node_modules/.bin/vue-tsc +21 -0
- package/template-vite-project/node_modules/.bin/yaml +21 -0
- package/template-vite-project/package.json +38 -0
- package/template-vite-project/public/css/index.css +89 -0
- package/template-vite-project/public/css/normalize.css +396 -0
- package/template-vite-project/public/vite.svg +1 -0
- package/template-vite-project/src/App.vue +30 -0
- package/template-vite-project/src/assets/vue.svg +1 -0
- package/template-vite-project/src/components/HelloWorld.vue +41 -0
- package/template-vite-project/src/design/config.less +0 -0
- package/template-vite-project/src/design/index.less +0 -0
- package/template-vite-project/src/main.ts +14 -0
- package/template-vite-project/src/utils/env.ts +50 -0
- package/template-vite-project/tsconfig.app.json +59 -0
- package/template-vite-project/tsconfig.json +7 -0
- package/template-vite-project/tsconfig.node.json +28 -0
- package/template-vite-project/types/global.d.ts +33 -0
- package/template-vite-project/unocss.config.ts +208 -0
- package/template-vite-project/vite.config.ts +88 -0
@@ -0,0 +1,14 @@
|
|
1
|
+
import { visualizer } from 'rollup-plugin-visualizer'
|
2
|
+
import { isReportMode } from '../../util'
|
3
|
+
|
4
|
+
export function configVisualizerConfig() {
|
5
|
+
if (isReportMode()) {
|
6
|
+
return visualizer({
|
7
|
+
filename: './node_modules/.cache/visualizer/stats.html',
|
8
|
+
open: true,
|
9
|
+
gzipSize: true,
|
10
|
+
brotliSize: true
|
11
|
+
}) as Plugin
|
12
|
+
}
|
13
|
+
return []
|
14
|
+
}
|
@@ -0,0 +1,40 @@
|
|
1
|
+
import type { Plugin } from 'vite'
|
2
|
+
import chalk from 'chalk'
|
3
|
+
import { readPackageJSON } from 'pkg-types'
|
4
|
+
import { defaultSettings } from '../../../../config'
|
5
|
+
import { getPackageSize, getRootPath, rootPath } from '../../util'
|
6
|
+
|
7
|
+
const { build } = defaultSettings
|
8
|
+
|
9
|
+
export default async function viteNotice(): Promise<Plugin> {
|
10
|
+
let config: { command: string }
|
11
|
+
const { name = '' } = await readPackageJSON(rootPath)
|
12
|
+
|
13
|
+
return {
|
14
|
+
name: 'vite:notice',
|
15
|
+
configResolved(resolvedConfig) {
|
16
|
+
config = resolvedConfig
|
17
|
+
},
|
18
|
+
buildStart() {
|
19
|
+
console.log(
|
20
|
+
chalk.bold(
|
21
|
+
chalk.green(
|
22
|
+
`👏Welcome to use ${chalk.blue(
|
23
|
+
'[gx-design-pro]'
|
24
|
+
)}, If you feel good, remember to click on the link below to give a star https://github.com/gx12358/vue3-antd-admin`
|
25
|
+
)
|
26
|
+
)
|
27
|
+
)
|
28
|
+
},
|
29
|
+
closeBundle() {
|
30
|
+
if (config.command === 'build') {
|
31
|
+
getPackageSize({
|
32
|
+
folder: getRootPath(build.outputDir),
|
33
|
+
callBack: (size: string) => {
|
34
|
+
console.log(chalk.bold(chalk.green(`✨ ${chalk.blue(`[${name}]`)} all build successfully, Total files ${size}`)))
|
35
|
+
}
|
36
|
+
})
|
37
|
+
}
|
38
|
+
}
|
39
|
+
}
|
40
|
+
}
|
@@ -0,0 +1,15 @@
|
|
1
|
+
export const permissions = {
|
2
|
+
'1': [ '*:*:*' ],
|
3
|
+
'2': [
|
4
|
+
'proTable:button:add',
|
5
|
+
'proTable:button:1',
|
6
|
+
'proTable:button:2',
|
7
|
+
'proTable:button:3'
|
8
|
+
],
|
9
|
+
'3': [
|
10
|
+
'proTable:button:1',
|
11
|
+
'proTable:button:2',
|
12
|
+
'proTable:button:3'
|
13
|
+
],
|
14
|
+
'4': [],
|
15
|
+
}
|
@@ -0,0 +1,96 @@
|
|
1
|
+
import Mockjs from 'mockjs'
|
2
|
+
import { permissions } from '../permissions'
|
3
|
+
import { handleRandomImage, getMobile } from '../../utils/util'
|
4
|
+
import userIds from './id'
|
5
|
+
|
6
|
+
const admin = [ 1, 2 ]
|
7
|
+
|
8
|
+
export interface RolesInfo {
|
9
|
+
roleId: number;
|
10
|
+
roleKey: string;
|
11
|
+
roleName: string;
|
12
|
+
status: string;
|
13
|
+
}
|
14
|
+
|
15
|
+
export interface UserList {
|
16
|
+
id: number;
|
17
|
+
name: string;
|
18
|
+
}
|
19
|
+
|
20
|
+
export const accessTokens = {
|
21
|
+
gx12358: 'gx-accessToken',
|
22
|
+
admin: 'admin-accessToken',
|
23
|
+
editor: 'editor-accessToken',
|
24
|
+
no_editor: 'test-accessToken'
|
25
|
+
}
|
26
|
+
|
27
|
+
export const accounts = {
|
28
|
+
admin: 'gx.design',
|
29
|
+
gx12358: 'aa123456',
|
30
|
+
editor: 'gx.design',
|
31
|
+
no_editor: 'gx.design'
|
32
|
+
}
|
33
|
+
|
34
|
+
export const rolesInfo: RolesInfo[] = [
|
35
|
+
{
|
36
|
+
roleId: 1,
|
37
|
+
roleKey: 'gx-admin',
|
38
|
+
roleName: 'gx12358-超级管理员',
|
39
|
+
status: '0'
|
40
|
+
},
|
41
|
+
{
|
42
|
+
roleId: 2,
|
43
|
+
roleKey: 'admin',
|
44
|
+
roleName: '超级管理员',
|
45
|
+
status: '0'
|
46
|
+
},
|
47
|
+
{
|
48
|
+
roleId: 3,
|
49
|
+
roleKey: 'editor',
|
50
|
+
roleName: '编辑人员',
|
51
|
+
status: '0'
|
52
|
+
}
|
53
|
+
]
|
54
|
+
|
55
|
+
export const tokenAccount = {
|
56
|
+
'1': accessTokens.gx12358,
|
57
|
+
'2': accessTokens.admin,
|
58
|
+
'3': accessTokens.editor,
|
59
|
+
'4': accessTokens.no_editor
|
60
|
+
}
|
61
|
+
|
62
|
+
const rolesInfoAccount = {
|
63
|
+
'1': rolesInfo.filter(item => [ 1 ].includes(item.roleId)),
|
64
|
+
'2': rolesInfo.filter(item => [ 2 ].includes(item.roleId)),
|
65
|
+
'3': rolesInfo.filter(item => [ 3 ].includes(item.roleId)),
|
66
|
+
'4': rolesInfo.filter(item => [ 3 ].includes(item.roleId))
|
67
|
+
}
|
68
|
+
|
69
|
+
export const defaultUser = (id = 2) => ({
|
70
|
+
permissions: permissions[String(id)],
|
71
|
+
roles: rolesInfoAccount[String(id)].map(item => item.roleKey),
|
72
|
+
user: {
|
73
|
+
userId: Number(id),
|
74
|
+
admin: admin.includes(Number(id)),
|
75
|
+
roles: rolesInfoAccount[String(id)],
|
76
|
+
roleIds: rolesInfoAccount[String(id)].map(item => item.roleId),
|
77
|
+
nickName: Mockjs.Random.name(),
|
78
|
+
avatar: handleRandomImage(100, 100),
|
79
|
+
address: Mockjs.Random.city(),
|
80
|
+
email: 'gx12358@gmail.com',
|
81
|
+
phonenumber: getMobile(),
|
82
|
+
remark: Mockjs.Random.paragraph(1),
|
83
|
+
tags: Array.from({ length: Mockjs.Random.integer(4, 8) }).map(_ => Mockjs.Random.word(1)).join(),
|
84
|
+
userName: Object.keys(accessTokens).find(el => tokenAccount[String(id)] === accessTokens[el])
|
85
|
+
} as Partial<UserDetails>
|
86
|
+
})
|
87
|
+
|
88
|
+
export const otherAccountList: UserList[] = [ '付小小', '曲丽丽', '林东东', '周星星', '吴加好', '朱偏右', '鱼酱', '乐哥', '谭小仪', '仲尼' ]
|
89
|
+
.map((name, key) => {
|
90
|
+
return {
|
91
|
+
id: key + 1,
|
92
|
+
name
|
93
|
+
}
|
94
|
+
})
|
95
|
+
|
96
|
+
export const userList: UserInfo[] = userIds.map(item => defaultUser(item.id)) as unknown as UserInfo[]
|
@@ -0,0 +1,55 @@
|
|
1
|
+
import { defaultSettings } from '@gx-config'
|
2
|
+
import { isArray, isBoolean, isFunction } from '@gx-design-vue/pro-utils'
|
3
|
+
import { omit } from 'lodash-es'
|
4
|
+
// @ts-ignore
|
5
|
+
import { defineFakeRoute } from 'vite-plugin-fake-server/client'
|
6
|
+
import { checkBackDataFun, getToken } from './utils/util'
|
7
|
+
|
8
|
+
const { mock } = defaultSettings
|
9
|
+
|
10
|
+
export interface MockResponse {
|
11
|
+
body: any;
|
12
|
+
query: any;
|
13
|
+
headers: RequestHeater
|
14
|
+
}
|
15
|
+
|
16
|
+
export type MockResponseCallback =
|
17
|
+
| ((response: MockResponse, token?: string) => any)
|
18
|
+
| string | number | Recordable | any[] | null
|
19
|
+
|
20
|
+
export type MockConfig = FakeRouteConfig & {
|
21
|
+
merageRoot?: boolean;
|
22
|
+
carryToken?: boolean;
|
23
|
+
callback: MockResponseCallback;
|
24
|
+
}
|
25
|
+
|
26
|
+
function getRequestData(callback: MockResponseCallback, request: MockResponse, token?: string) {
|
27
|
+
if (isFunction(callback)) {
|
28
|
+
return callback?.(request, token)
|
29
|
+
}
|
30
|
+
|
31
|
+
return callback
|
32
|
+
}
|
33
|
+
|
34
|
+
function getMockRouteConfig(config: MockConfig) {
|
35
|
+
const carryToken = isBoolean(config.carryToken) ? config.carryToken : true
|
36
|
+
return {
|
37
|
+
...omit(config, 'callback'),
|
38
|
+
url: `${mock.prefix}${config.url}`,
|
39
|
+
response: (request: MockResponse) => {
|
40
|
+
if (carryToken) {
|
41
|
+
const token = getToken(request.headers)
|
42
|
+
return checkBackDataFun(getRequestData(config.callback, request, token) || {}, token || '', config.merageRoot)
|
43
|
+
}
|
44
|
+
return getRequestData(config.callback, request)
|
45
|
+
}
|
46
|
+
}
|
47
|
+
}
|
48
|
+
|
49
|
+
export function createMockRoute(router: MockConfig | MockConfig[]) {
|
50
|
+
const fakeRoute = isArray(router)
|
51
|
+
? router.map(item => getMockRouteConfig(item))
|
52
|
+
: getMockRouteConfig(router)
|
53
|
+
|
54
|
+
return defineFakeRoute(fakeRoute)
|
55
|
+
}
|
@@ -0,0 +1,22 @@
|
|
1
|
+
import type { ListSearchParams } from '../../utils/table'
|
2
|
+
import Mockjs from 'mockjs'
|
3
|
+
import { createMockRoute } from '../../../mock'
|
4
|
+
import { handlePageList, initContent } from '../../utils/table'
|
5
|
+
|
6
|
+
const dataSource = initContent<TableRecord<any>>(120, () => ({
|
7
|
+
title: Mockjs.Random.ctitle(),
|
8
|
+
}))
|
9
|
+
|
10
|
+
export default createMockRoute({
|
11
|
+
url: '/table/list',
|
12
|
+
method: 'post',
|
13
|
+
timeout: 200,
|
14
|
+
callback: ({ body }) => {
|
15
|
+
const { pageNum = 1, pageSize = 10 }: ListSearchParams = body
|
16
|
+
|
17
|
+
return {
|
18
|
+
list: handlePageList(dataSource, { pageNum, pageSize }),
|
19
|
+
totalCount: dataSource.length
|
20
|
+
}
|
21
|
+
}
|
22
|
+
})
|
@@ -0,0 +1,52 @@
|
|
1
|
+
import dayjs from 'dayjs'
|
2
|
+
import { cloneDeep } from 'lodash-es'
|
3
|
+
import { createMockRoute } from '../../../mock'
|
4
|
+
import { otherAccountList, userList } from '../../config/user'
|
5
|
+
import { tokenByUserInfo } from '../../utils/util'
|
6
|
+
|
7
|
+
export default createMockRoute([
|
8
|
+
{
|
9
|
+
url: '/user/queryUserDetail',
|
10
|
+
method: 'get',
|
11
|
+
merageRoot: true,
|
12
|
+
callback: (_, token) => {
|
13
|
+
if (token) {
|
14
|
+
const tokenUserInfo = tokenByUserInfo(token)
|
15
|
+
if (tokenUserInfo && tokenUserInfo?.userId) {
|
16
|
+
const userInfo = userList.find(item => item.user.userId === tokenUserInfo?.userId)
|
17
|
+
if (userInfo) {
|
18
|
+
userInfo.user.loginDate = dayjs().format('YYYY-MM-DD HH:mm:ss')
|
19
|
+
return userInfo
|
20
|
+
}
|
21
|
+
}
|
22
|
+
}
|
23
|
+
|
24
|
+
return {
|
25
|
+
code: 500,
|
26
|
+
message: '用户信息获取失败'
|
27
|
+
}
|
28
|
+
}
|
29
|
+
},
|
30
|
+
{
|
31
|
+
url: '/user/account/update',
|
32
|
+
method: 'post',
|
33
|
+
timeout: 200,
|
34
|
+
callback: () => null
|
35
|
+
},
|
36
|
+
{
|
37
|
+
url: '/user/account/list',
|
38
|
+
method: 'get',
|
39
|
+
timeout: 200,
|
40
|
+
callback: () => cloneDeep(otherAccountList)
|
41
|
+
},
|
42
|
+
{
|
43
|
+
url: '/user/account/count',
|
44
|
+
method: 'get',
|
45
|
+
timeout: 200,
|
46
|
+
callback: () => ({
|
47
|
+
articles: 50,
|
48
|
+
applications: 40,
|
49
|
+
projects: 60
|
50
|
+
})
|
51
|
+
}
|
52
|
+
])
|
@@ -0,0 +1,46 @@
|
|
1
|
+
import { createMockRoute } from '../../../mock'
|
2
|
+
import { accessTokens, accounts } from '../../config/user'
|
3
|
+
import { createrToken } from '../../utils/util'
|
4
|
+
|
5
|
+
export default createMockRoute([
|
6
|
+
{
|
7
|
+
url: '/user/login',
|
8
|
+
method: 'post',
|
9
|
+
carryToken: false,
|
10
|
+
callback: ({ body }) => {
|
11
|
+
const { userName, password } = body
|
12
|
+
const accessToken = accessTokens[userName]
|
13
|
+
if (accounts[userName] !== password || !accessToken) {
|
14
|
+
return {
|
15
|
+
code: 500,
|
16
|
+
msg: '帐户或密码不正确。'
|
17
|
+
}
|
18
|
+
}
|
19
|
+
return {
|
20
|
+
code: 200,
|
21
|
+
msg: 'success',
|
22
|
+
data: {
|
23
|
+
token: createrToken(accessToken),
|
24
|
+
expiresIn: 720
|
25
|
+
}
|
26
|
+
}
|
27
|
+
}
|
28
|
+
},
|
29
|
+
{
|
30
|
+
url: '/user/register',
|
31
|
+
method: 'post',
|
32
|
+
carryToken: false,
|
33
|
+
callback: () => {
|
34
|
+
return {
|
35
|
+
code: 200,
|
36
|
+
msg: '模拟注册成功'
|
37
|
+
}
|
38
|
+
}
|
39
|
+
},
|
40
|
+
{
|
41
|
+
url: '/user/logout',
|
42
|
+
method: 'get',
|
43
|
+
timeout: 200,
|
44
|
+
callback: null
|
45
|
+
}
|
46
|
+
])
|
@@ -0,0 +1,21 @@
|
|
1
|
+
import { Base64, isArray, isJSONStr, isObject } from '@gx-design-vue/pro-utils'
|
2
|
+
|
3
|
+
const cryptoBase64 = new Base64()
|
4
|
+
|
5
|
+
// 加密方法
|
6
|
+
export function Encrypt(word: string | object) {
|
7
|
+
let str: string
|
8
|
+
if (isObject(word) || isArray(word)) {
|
9
|
+
str = JSON.stringify(word)
|
10
|
+
} else {
|
11
|
+
str = word as string
|
12
|
+
}
|
13
|
+
|
14
|
+
return cryptoBase64.encode(str as string)
|
15
|
+
}
|
16
|
+
|
17
|
+
// 解密方法
|
18
|
+
export function Decrypt(word: string) {
|
19
|
+
const decryptedStr = cryptoBase64.decode(word)
|
20
|
+
return isJSONStr(decryptedStr) ? JSON.parse(decryptedStr) : decryptedStr
|
21
|
+
}
|
@@ -0,0 +1,96 @@
|
|
1
|
+
import { getRandomNumber } from '@gx-design-vue/pro-utils'
|
2
|
+
import dayjs from 'dayjs'
|
3
|
+
import { cloneDeep } from 'lodash-es'
|
4
|
+
import Mockjs from 'mockjs'
|
5
|
+
import { getArraryList } from './util'
|
6
|
+
|
7
|
+
export interface ListItem {
|
8
|
+
createTime: string | null;
|
9
|
+
id: number;
|
10
|
+
}
|
11
|
+
|
12
|
+
export interface ListSearchParams {
|
13
|
+
pageNum?: number;
|
14
|
+
pageSize?: number;
|
15
|
+
sord?: 'asc' | 'desc';
|
16
|
+
sidx?: 'createTime';
|
17
|
+
}
|
18
|
+
|
19
|
+
export function initContent<T>(
|
20
|
+
max,
|
21
|
+
callbackParams?: (key: number) => Omit<T, 'id' | 'createTime'> & Partial<ListItem>
|
22
|
+
): (Omit<T, 'id' | 'createTime'> & ListItem)[] {
|
23
|
+
const mockParams = (index: number) => ({
|
24
|
+
id: index + 1,
|
25
|
+
uuid: getRandomNumber().uuid(10),
|
26
|
+
createTime: dayjs().format('YYYY-MM-DD HH:mm:ss')
|
27
|
+
}) as any
|
28
|
+
const list: (T & ListItem)[] = getArraryList(max, index => mockParams(index))
|
29
|
+
|
30
|
+
return list.map((item, index) => {
|
31
|
+
return {
|
32
|
+
...item,
|
33
|
+
createTime: dayjs()
|
34
|
+
.subtract(Mockjs.Random.integer(3, 60), 'day')
|
35
|
+
.subtract(Mockjs.Random.integer(2, 6), 'hour')
|
36
|
+
.subtract(Mockjs.Random.integer(1, 59), 'minute')
|
37
|
+
.subtract(Mockjs.Random.integer(1, 59), 'second')
|
38
|
+
.format('YYYY-MM-DD HH:mm:ss'),
|
39
|
+
...callbackParams?.(index)
|
40
|
+
}
|
41
|
+
})
|
42
|
+
}
|
43
|
+
|
44
|
+
export function handlePageList<T>(
|
45
|
+
dataSource: T[],
|
46
|
+
{ pageNum, pageSize, callBack }: {
|
47
|
+
pageNum: number;
|
48
|
+
pageSize: number;
|
49
|
+
callBack?: (data: T[]) => T[]
|
50
|
+
}
|
51
|
+
): T[] {
|
52
|
+
if (callBack)
|
53
|
+
dataSource = callBack?.(dataSource)
|
54
|
+
return cloneDeep(dataSource).filter(
|
55
|
+
(_, sort) => (sort < pageNum * pageSize) && (sort >= pageSize * (pageNum - 1))
|
56
|
+
)
|
57
|
+
}
|
58
|
+
|
59
|
+
export function compareToMaxTime(obj1, obj2, key, type: 0 | 1 = 0) {
|
60
|
+
const val1 = obj1[key]
|
61
|
+
const val2 = obj2[key]
|
62
|
+
let result = 0
|
63
|
+
if (dayjs(val1).isBefore(dayjs(val2))) {
|
64
|
+
result = type === 0 ? -1 : 0
|
65
|
+
} else if (dayjs(val1).isAfter(dayjs(val2))) {
|
66
|
+
result = type === 0 ? 0 : (-1)
|
67
|
+
}
|
68
|
+
return result
|
69
|
+
}
|
70
|
+
|
71
|
+
export function postDataSource<T>(
|
72
|
+
dataSource: (Omit<T, 'id' | 'createTime'> & ListItem)[],
|
73
|
+
type: 'delete' | 'add' | 'update' = 'update',
|
74
|
+
options?: { key?: string; params: Partial<(Omit<T, 'id' | 'createTime'> & ListItem)> }
|
75
|
+
) {
|
76
|
+
if (type === 'update') {
|
77
|
+
dataSource = dataSource.map((item: any) => {
|
78
|
+
// @ts-ignore
|
79
|
+
if (options?.params?.[options.key] === item[options?.key])
|
80
|
+
return { ...item, ...options?.params }
|
81
|
+
return item
|
82
|
+
})
|
83
|
+
}
|
84
|
+
if (type === 'add') {
|
85
|
+
dataSource.unshift({
|
86
|
+
...options?.params as (Omit<T, 'id' | 'createTime'> & ListItem),
|
87
|
+
id: dataSource.length + 1
|
88
|
+
})
|
89
|
+
}
|
90
|
+
if (type === 'delete') {
|
91
|
+
// @ts-ignore
|
92
|
+
dataSource = dataSource.filter(item => options?.params?.[options.key] !== item[options?.key])
|
93
|
+
}
|
94
|
+
|
95
|
+
return dataSource
|
96
|
+
}
|
@@ -0,0 +1,91 @@
|
|
1
|
+
import Mockjs from 'mockjs'
|
2
|
+
import { defaultSettings } from '@gx-config'
|
3
|
+
import { deepMerge, isObject, getRandomNumber } from '@gx-design-vue/pro-utils'
|
4
|
+
import { toLower } from 'lodash-es'
|
5
|
+
import { tokenAccount, userList } from '../config/user'
|
6
|
+
import userIds from '../config/user/id'
|
7
|
+
import { Decrypt, Encrypt } from './crypto'
|
8
|
+
|
9
|
+
const { mock, token } = defaultSettings
|
10
|
+
|
11
|
+
export function handleRandomImage(width = 50, height = 50) {
|
12
|
+
return `https://picsum.photos/${width}/${height}?random=${getRandomNumber().uuid(10)}`
|
13
|
+
}
|
14
|
+
|
15
|
+
export function getMobile() {
|
16
|
+
const mobile_prefix = [ '134', '135', '136', '137', '138', '139', '150', '151',
|
17
|
+
'152', '157', '158', '159', '130', '131', '132', '155', '156', '133', '153' ]
|
18
|
+
return getMockRandowList(mobile_prefix) + Mockjs.mock(/\d{8}/)
|
19
|
+
}
|
20
|
+
|
21
|
+
export function getTokenBuUserId(token) {
|
22
|
+
return Number(Object.keys(tokenAccount).find(item => tokenAccount[item] === token))
|
23
|
+
}
|
24
|
+
|
25
|
+
export function getToken(headers: RequestHeater): string | undefined {
|
26
|
+
return headers?.[toLower(token.name)]
|
27
|
+
}
|
28
|
+
|
29
|
+
export function tokenByUserInfo(token): UserDetails {
|
30
|
+
return Decrypt(token)
|
31
|
+
}
|
32
|
+
|
33
|
+
export function createrToken(token) {
|
34
|
+
const userInfo = userList.find(item => item.user?.userId === getTokenBuUserId(token))
|
35
|
+
return Encrypt({ userId: userInfo?.user?.userId })
|
36
|
+
}
|
37
|
+
|
38
|
+
export function checkToken(token) {
|
39
|
+
if (mock.checkToken === -1) return true
|
40
|
+
if (token) {
|
41
|
+
if (mock.checkToken === 0) return true
|
42
|
+
|
43
|
+
const useInfo: UserDetails = tokenByUserInfo(token)
|
44
|
+
return useInfo ? useInfo?.userId && userIds.some(item => useInfo?.userId === item.id) : false
|
45
|
+
}
|
46
|
+
return false
|
47
|
+
}
|
48
|
+
|
49
|
+
export const checkBackDataFun = (
|
50
|
+
config: Partial<ResponseResult>,
|
51
|
+
token: string,
|
52
|
+
merageRoot?: boolean
|
53
|
+
): ResponseResult => {
|
54
|
+
let result: Partial<ResponseResult> = {
|
55
|
+
code: 200,
|
56
|
+
data: null
|
57
|
+
}
|
58
|
+
if (isObject(config)) {
|
59
|
+
const { data } = config
|
60
|
+
if (merageRoot) {
|
61
|
+
result = deepMerge(result, config, {
|
62
|
+
omitEmpty: false,
|
63
|
+
omitNil: false
|
64
|
+
})
|
65
|
+
} else {
|
66
|
+
result.data = config
|
67
|
+
}
|
68
|
+
if (data) {
|
69
|
+
result.data = data
|
70
|
+
}
|
71
|
+
} else {
|
72
|
+
result.data = config as any
|
73
|
+
}
|
74
|
+
|
75
|
+
const invaiteToken = checkToken(token)
|
76
|
+
|
77
|
+
return deepMerge<ResponseResult>(result as unknown as ResponseResult, {
|
78
|
+
code: invaiteToken ? 200 : 401,
|
79
|
+
message: invaiteToken
|
80
|
+
? (result.message || result.code) ? 'success' : 'Request failed'
|
81
|
+
: 'Invalid token!'
|
82
|
+
})
|
83
|
+
}
|
84
|
+
|
85
|
+
export function getArraryList<T>(length: number, callback: (key: number) => T) {
|
86
|
+
return Array.from({ length }).map((_, key) => callback(key))
|
87
|
+
}
|
88
|
+
|
89
|
+
export function getMockRandowList<T = any>(data: T[]) {
|
90
|
+
return data[Mockjs.Random.integer(0, data.length - 1)] as T
|
91
|
+
}
|
@@ -0,0 +1,74 @@
|
|
1
|
+
{
|
2
|
+
"name": "gx-vant-mobile",
|
3
|
+
"type": "module",
|
4
|
+
"version": "0.0.0",
|
5
|
+
"scripts": {
|
6
|
+
"bootstrap": "pnpm i",
|
7
|
+
"dev": "pnpm run start:dev",
|
8
|
+
"start:dev": "cross-env VITE_APP_ENV=dev vite",
|
9
|
+
"start:pro": "cross-env VITE_APP_ENV=pro vite",
|
10
|
+
"build": "vite build",
|
11
|
+
"build:pro": "vite build --mode pro",
|
12
|
+
"report": "cross-env REPORT=true npm run build",
|
13
|
+
"preview": "vite preview",
|
14
|
+
"clean:lib": "rimraf pnpm-lock.yaml && rimraf node_modules",
|
15
|
+
"lint": "eslint .",
|
16
|
+
"lint:fix": "eslint . --fix"
|
17
|
+
},
|
18
|
+
"dependencies": {
|
19
|
+
"@gx-design-vue/pro-hooks": "^0.2.0-beta.54",
|
20
|
+
"@gx-design-vue/pro-utils": "^0.2.0-beta.80",
|
21
|
+
"@multiavatar/multiavatar": "^1.0.7",
|
22
|
+
"@vueuse/core": "^13.1.0",
|
23
|
+
"@vueuse/shared": "^13.1.0",
|
24
|
+
"axios": "^1.6.7",
|
25
|
+
"crypto-js": "^4.1.1",
|
26
|
+
"dayjs": "^1.11.13",
|
27
|
+
"lodash-es": "^4.17.21",
|
28
|
+
"pinia": "^3.0.2",
|
29
|
+
"qs": "^6.11.0",
|
30
|
+
"unocss": "^66.1.0-beta.12",
|
31
|
+
"vant": "^4.9.15",
|
32
|
+
"vue": "^3.5.13",
|
33
|
+
"vue-router": "^4.5.0"
|
34
|
+
},
|
35
|
+
"devDependencies": {
|
36
|
+
"@antfu/eslint-config": "^4.4.0",
|
37
|
+
"@commitlint/cli": "^19.5.0",
|
38
|
+
"@commitlint/config-conventional": "^19.5.0",
|
39
|
+
"@iconify-json/carbon": "^1.2.5",
|
40
|
+
"@types/lodash-es": "^4.17.10",
|
41
|
+
"@types/mockjs": "^1.0.10",
|
42
|
+
"@types/node": "^22.8.4",
|
43
|
+
"@types/qs": "^6.9.7",
|
44
|
+
"@unocss/preset-rem-to-px": "^0.65.3",
|
45
|
+
"@vant/auto-import-resolver": "^1.2.1",
|
46
|
+
"@vitejs/plugin-legacy": "^6.1.0",
|
47
|
+
"@vitejs/plugin-vue": "^5.2.3",
|
48
|
+
"@vitejs/plugin-vue-jsx": "^4.1.2",
|
49
|
+
"autoprefixer": "^10.4.5",
|
50
|
+
"bundle-require": "^5.0.0",
|
51
|
+
"cross-env": "^7.0.3",
|
52
|
+
"husky": "^9.1.6",
|
53
|
+
"less": "^4.1.3",
|
54
|
+
"mockjs": "^1.1.0",
|
55
|
+
"postcss": "^8.4.35",
|
56
|
+
"postcss-html": "^1.6.0",
|
57
|
+
"postcss-less": "^6.0.0",
|
58
|
+
"postcss-mobile-forever": "^4.3.1",
|
59
|
+
"postcss-pxtorem": "^6.0.0",
|
60
|
+
"prettier": "^3.3.3",
|
61
|
+
"rimraf": "^6.0.1",
|
62
|
+
"rollup-plugin-external-globals": "^0.13.0",
|
63
|
+
"rollup-plugin-visualizer": "^5.14.0",
|
64
|
+
"typescript": "^5.3.3",
|
65
|
+
"unplugin-auto-import": "^0.19.0",
|
66
|
+
"unplugin-turbo-console": "^1.10.4",
|
67
|
+
"unplugin-vue-components": "^0.28.0",
|
68
|
+
"vite": "^6.2.6",
|
69
|
+
"vite-plugin-compression": "0.5.1",
|
70
|
+
"vite-plugin-fake-server": "^2.1.4",
|
71
|
+
"vite-plugin-html": "^3.2.2",
|
72
|
+
"vue-tsc": "^2.1.6"
|
73
|
+
}
|
74
|
+
}
|
@@ -0,0 +1,54 @@
|
|
1
|
+
:root {
|
2
|
+
--van-base-font: -apple-system, BlinkMacSystemFont, "Helvetica Neue", Helvetica, Segoe UI, Arial, Roboto, "PingFang SC", "miui", "Hiragino Sans GB", "Microsoft Yahei", sans-serif;
|
3
|
+
}
|
4
|
+
|
5
|
+
body {
|
6
|
+
font-family: var(--van-base-font);
|
7
|
+
}
|
8
|
+
|
9
|
+
.gx-toast-loading {
|
10
|
+
position: fixed;
|
11
|
+
top: 0;
|
12
|
+
left: 0;
|
13
|
+
width: 100%;
|
14
|
+
height: 100%;
|
15
|
+
display: flex;
|
16
|
+
justify-content: center;
|
17
|
+
align-items: center;
|
18
|
+
text-align: center;
|
19
|
+
z-index: 9999999999;
|
20
|
+
}
|
21
|
+
.gx-toast-loading .gx-toast-loading-cont {
|
22
|
+
display: flex;
|
23
|
+
flex-direction: column;
|
24
|
+
justify-content: center;
|
25
|
+
align-items: center;
|
26
|
+
box-sizing: content-box;
|
27
|
+
width: min(23.467vw, 140.8px);
|
28
|
+
min-height: min(23.467vw, 140.8px);
|
29
|
+
max-width: 70%;
|
30
|
+
padding: min(4.267vw, 25.6px);
|
31
|
+
border-radius: min(2.133vw, 12.8px);
|
32
|
+
background-clip: padding-box;
|
33
|
+
color: #fff;
|
34
|
+
background-color: rgba(58, 58, 58, 0.9);
|
35
|
+
font-size: min(3.733vw, 22.4px);
|
36
|
+
line-height: min(5.333vw, 32px);
|
37
|
+
}
|
38
|
+
.gx-toast-loading .gx-toast-loading-cont .gx-toast-svg {
|
39
|
+
margin: 0;
|
40
|
+
width: min(8vw, 48px);
|
41
|
+
height: min(8vw, 48px);
|
42
|
+
display: inline-block;
|
43
|
+
animation: spinner-anime 1s linear infinite;
|
44
|
+
}
|
45
|
+
.gx-toast-loading .gx-toast-loading-cont .gx-toast-svg-text {
|
46
|
+
display: inline-block;
|
47
|
+
margin-top: min(2.133vw, 12.8px);
|
48
|
+
}
|
49
|
+
|
50
|
+
@keyframes spinner-anime {
|
51
|
+
100% {
|
52
|
+
transform: rotate(360deg);
|
53
|
+
}
|
54
|
+
}
|