build(projects): update tsconfig、eslintrc

This commit is contained in:
Soybean 2022-03-12 16:21:40 +08:00
parent 4093dcd6dc
commit 75de2b0604
131 changed files with 1174 additions and 1140 deletions

View File

@ -1,12 +1,11 @@
# Editor configuration, see http://editorconfig.org # Editor configuration, see http://editorconfig.org
# 表示是最顶层的 EditorConfig 配置文件
root = true root = true
[*] # 表示所有文件适用 [*]
charset = utf-8 # 设置文件字符集为 utf-8 charset = utf-8
indent_style = tab # 缩进风格tab | space indent_style = tab
indent_size = 2 # 缩进大小 indent_size = 2
end_of_line = lf # 控制换行类型(lf | cr | crlf) end_of_line = lf
trim_trailing_whitespace = true # 去除行首的任意空白字符 trim_trailing_whitespace = true
insert_final_newline = true # 始终在文件末尾插入一个新行 insert_final_newline = true

View File

@ -13,10 +13,10 @@ type ServiceEnv = Record<
export const serviceEnv: ServiceEnv = { export const serviceEnv: ServiceEnv = {
test: { test: {
env: 'test', env: 'test',
url: 'http://www.baidu.com' url: 'http://www.baidu.com',
}, },
prod: { prod: {
env: 'prod', env: 'prod',
url: 'http://www.baidu.com' url: 'http://www.baidu.com',
} },
}; };

View File

@ -1 +1,2 @@
# 是否开启打包文件大小结果分析
VITE_VISUALIZER=false VITE_VISUALIZER=false

View File

@ -11,6 +11,6 @@ lib
/docs /docs
.vscode .vscode
.local .local
package.json
components.d.ts components.d.ts
!.env-config.ts !.env-config.ts
package.json

View File

@ -1,30 +1,34 @@
module.exports = { module.exports = {
env: { env: {
browser: true, browser: true,
es2021: true es2021: true,
'vue/setup-compiler-macros': true,
}, },
globals: { globals: {
defineProps: 'readonly',
defineEmits: 'readonly',
defineExpose: 'readonly',
withDefaults: 'readonly',
PROJECT_BUILD_TIME: 'readonly', PROJECT_BUILD_TIME: 'readonly',
AMap: 'readonly', AMap: 'readonly',
BMap: 'readonly', BMap: 'readonly',
TMap: 'readonly' TMap: 'readonly',
}, },
parser: 'vue-eslint-parser', parser: 'vue-eslint-parser',
parserOptions: { parserOptions: {
ecmaVersion: 12, ecmaVersion: 12,
parser: '@typescript-eslint/parser', parser: '@typescript-eslint/parser',
sourceType: 'module' sourceType: 'module',
}, },
plugins: ['vue', '@typescript-eslint'], plugins: ['vue', '@typescript-eslint'],
extends: ['plugin:vue/vue3-recommended', 'airbnb-base', '@vue/typescript/recommended', 'plugin:prettier/recommended'], extends: [
'airbnb-base',
'eslint:recommended',
'plugin:vue/vue3-recommended',
'plugin:prettier/recommended',
'@vue/eslint-config-typescript/recommended',
'@vue/eslint-config-prettier',
'@vue/typescript/recommended',
],
rules: { rules: {
'import/extensions': 'off', 'import/extensions': 'off',
'import/no-extraneous-dependencies': 'off', 'import/no-extraneous-dependencies': 'off',
'import/no-unresolved': 0,
'import/order': [ 'import/order': [
'error', 'error',
{ {
@ -34,129 +38,167 @@ module.exports = {
{ {
pattern: 'vue', pattern: 'vue',
group: 'external', group: 'external',
position: 'before' position: 'before',
}, },
{ {
pattern: 'vue-router', pattern: 'vue-router',
group: 'external', group: 'external',
position: 'before' position: 'before',
},
{
pattern: 'vuex',
group: 'external',
position: 'before',
}, },
{ {
pattern: 'pinia', pattern: 'pinia',
group: 'external', group: 'external',
position: 'before' position: 'before',
},
{
pattern: 'naive-ui',
group: 'external',
position: 'before'
}, },
// ui framework, such as "naive-ui"
// {
// pattern: 'naive-ui',
// group: 'external',
// position: 'before'
// },
{ {
pattern: '@/config', pattern: '@/config',
group: 'internal', group: 'internal',
position: 'before' position: 'before',
}, },
{ {
pattern: '@/settings', pattern: '@/settings',
group: 'internal', group: 'internal',
position: 'before' position: 'before',
}, },
{ {
pattern: '@/enum', pattern: '@/enum',
group: 'internal', group: 'internal',
position: 'before' position: 'before',
}, },
{ {
pattern: '@/plugins', pattern: '@/plugins',
group: 'internal', group: 'internal',
position: 'before' position: 'before',
}, },
{ {
pattern: '@/layouts', pattern: '@/layouts',
group: 'internal', group: 'internal',
position: 'before' position: 'before',
},
{
pattern: '@/layouts',
group: 'internal',
position: 'before'
}, },
{ {
pattern: '@/views', pattern: '@/views',
group: 'internal', group: 'internal',
position: 'before' position: 'before',
}, },
{ {
pattern: '@/components', pattern: '@/components',
group: 'internal', group: 'internal',
position: 'before' position: 'before',
}, },
{ {
pattern: '@/router', pattern: '@/router',
group: 'internal', group: 'internal',
position: 'before' position: 'before',
}, },
{ {
pattern: '@/store', pattern: '@/store',
group: 'internal', group: 'internal',
position: 'before' position: 'before',
}, },
{ {
pattern: '@/composables', pattern: '@/composables',
group: 'internal', group: 'internal',
position: 'before' position: 'before',
}, },
{ {
pattern: '@/hooks', pattern: '@/hooks',
group: 'internal', group: 'internal',
position: 'before' position: 'before',
}, },
{ {
pattern: '@/service', pattern: '@/service',
group: 'internal', group: 'internal',
position: 'before' position: 'before',
}, },
{ {
pattern: '@/utils', pattern: '@/utils',
group: 'internal', group: 'internal',
position: 'before' position: 'before',
}, },
{ {
pattern: '@/assets', pattern: '@/assets',
group: 'internal', group: 'internal',
position: 'before' position: 'before',
}, },
{ {
pattern: '@/**', pattern: '@/**',
group: 'internal', group: 'internal',
position: 'before' position: 'before',
}, },
{ {
pattern: '@/interface', pattern: '@/interface',
group: 'internal', group: 'internal',
position: 'before' position: 'before',
} },
], ],
pathGroupsExcludedImportTypes: ['vue', 'vue-router', 'pinia', 'naive-ui'] pathGroupsExcludedImportTypes: [
} 'vue',
'vue-router',
'vuex',
'pinia',
// 'naive-ui'
],
},
], ],
'import/prefer-default-export': 0, 'import/no-unresolved': 'off',
'max-classes-per-file': 0, 'import/prefer-default-export': 'off',
'no-shadow': 0, 'max-classes-per-file': 'off',
'no-param-reassign': [
'error',
{
props: true,
ignorePropertyModificationsFor: ['state', 'acc', 'e'],
},
],
'no-plusplus': 'off',
'no-shadow': 'off',
'no-unused-vars': 'off', 'no-unused-vars': 'off',
'no-use-before-define': 'off', 'no-use-before-define': 'off',
'vue/comment-directive': 0, 'vue/multi-word-component-names': [
'vue/multi-word-component-names': 0, 'error',
'@typescript-eslint/ban-types': 'off', {
'@typescript-eslint/ban-ts-ignore': 'off', ignores: ['index'],
'@typescript-eslint/explicit-function-return-type': 'off', },
'@typescript-eslint/explicit-module-boundary-types': 'off', ],
'@typescript-eslint/no-empty-function': 'off', '@typescript-eslint/ban-types': [
'@typescript-eslint/no-explicit-any': 0, 'error',
'@typescript-eslint/no-inferrable-types': 0, {
'@typescript-eslint/no-non-null-assertion': 'off', types: {
'@typescript-eslint/no-unused-vars': ['warn', { ignoreRestSiblings: true, varsIgnorePattern: 'Ignored' }], '{}': {
message: 'Use object instead',
fixWith: 'object',
},
},
},
],
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-shadow': 'error',
'@typescript-eslint/no-unused-vars': ['warn', { ignoreRestSiblings: true, varsIgnorePattern: '^_' }],
'@typescript-eslint/no-use-before-define': ['error', { classes: true, functions: false, typedefs: false }], '@typescript-eslint/no-use-before-define': ['error', { classes: true, functions: false, typedefs: false }],
'@typescript-eslint/no-var-requires': 'off' },
} overrides: [
{
files: ['*.vue'],
rules: {
'no-undef': 'off',
},
},
{
files: ['*.html'],
rules: {
'vue/comment-directive': 'off',
},
},
],
}; };

7
.gitignore vendored
View File

@ -11,17 +11,20 @@ node_modules
.DS_Store .DS_Store
dist dist
dist-ssr dist-ssr
coverage
*.local *.local
stats.html
/cypress/videos/ /cypress/videos/
/cypress/screenshots/ /cypress/screenshots/
# Editor directories and files # Editor directories and files
.vscode/*
!.vscode/extensions.json
!.vscode/settings.json
.idea .idea
*.suo *.suo
*.ntvs* *.ntvs*
*.njsproj *.njsproj
*.sln *.sln
*.sw? *.sw?
stats.html

View File

@ -1,27 +1,27 @@
module.exports = { module.exports = { // https://prettier.io/docs/en/options.html
printWidth: 120, // 超过最大值换行 arrowParens: 'always',
tabWidth: 2, // 缩进字节数 bracketSameLine: false,
useTabs: false, // 缩进使用tab不使用空格 bracketSpacing: true,
semi: true, // 句尾添加分号 embeddedLanguageFormatting: 'auto',
singleQuote: true, // 使用单引号代替双引号 htmlWhitespaceSensitivity: 'css',
proseWrap: 'preserve', // 默认值。因为使用了一些折行敏感型的渲染器如GitHub comment而按照markdown文本样式进行折行 insertPragma: false,
arrowParens: 'avoid', // (x) => {} 箭头函数参数只有一个时是否要有小括号。avoid省略括号 jsxSingleQuote: false,
bracketSpacing: true, // 在对象,数组括号与文字之间加空格 "{ foo: bar }" printWidth: 120,
endOfLine: 'auto', // 结尾是 \n \r \n\r auto proseWrap: 'preserve',
eslintIntegration: false, //不让prettier使用eslint的代码格式进行校验 quoteProps: 'as-needed',
htmlWhitespaceSensitivity: 'ignore', // 指定HTML文件的全局空白区域敏感度 有效选项:"css"- 遵守CSS display属性的默认值。"strict" - 空格被认为是敏感的。"ignore" - 空格被认为是不敏感的。html 中空格也会占位影响布局prettier 格式化的时候可能会将文本换行,造成布局错乱 requirePragma: false,
ignorePath: '.prettierignore', // 不使用prettier格式化的文件填写在项目的.prettierignore文件中 semi: true,
jsxSingleQuote: false, // 在jsx中使用单引号代替双引号 singleQuote: true,
requireConfig: false, // Require a 'prettierconfig' to format prettier tabWidth: 2,
stylelintIntegration: false, //不让prettier使用stylelint的代码格式进行校验 trailingComma: 'es5',
trailingComma: 'none', // 在对象或数组最后一个元素后面是否加逗号在ES5中加尾逗号 useTabs: false,
tslintIntegration: false, // 不让prettier使用tslint的代码格式进行校验 vueIndentScriptAndStyle: false,
overrides: [ overrides: [
{ {
files: '*.html', files: '*.html',
options: { options: {
parser: 'html' parser: 'html',
} },
} },
] ],
}; };

View File

@ -4,5 +4,5 @@ import dayjs from 'dayjs';
const PROJECT_BUILD_TIME = JSON.stringify(dayjs().format('YYYY-MM-DD HH:mm:ss')); const PROJECT_BUILD_TIME = JSON.stringify(dayjs().format('YYYY-MM-DD HH:mm:ss'));
export const define = { export const define = {
PROJECT_BUILD_TIME PROJECT_BUILD_TIME,
}; };

View File

@ -10,8 +10,8 @@ export default (config: ConfigEnv): PluginOption[] => {
inject: { inject: {
data: { data: {
appName: viteEnv.VITE_APP_NAME, appName: viteEnv.VITE_APP_NAME,
appTitle: viteEnv.VITE_APP_TITLE appTitle: viteEnv.VITE_APP_TITLE,
} },
} },
}); });
}; };

View File

@ -8,14 +8,14 @@ export default (srcPath: string) => {
Icons({ Icons({
compiler: 'vue3', compiler: 'vue3',
customCollections: { customCollections: {
custom: FileSystemIconLoader(`${srcPath}/assets/svg`) custom: FileSystemIconLoader(`${srcPath}/assets/svg`),
}, },
scale: 1, scale: 1,
defaultClass: 'inline-block' defaultClass: 'inline-block',
}), }),
Components({ Components({
dts: false, dts: false,
resolvers: [IconsResolver({ customCollections: ['custom'], componentPrefix: 'icon' })] resolvers: [IconsResolver({ customCollections: ['custom'], componentPrefix: 'icon' })],
}) }),
]; ];
}; };

View File

@ -5,5 +5,5 @@ export default viteMockServe({
injectCode: ` injectCode: `
import { setupMockServer } from '../mock'; import { setupMockServer } from '../mock';
setupMockServer(); setupMockServer();
` `,
}); });

View File

@ -2,5 +2,5 @@ import { visualizer } from 'rollup-plugin-visualizer';
export default visualizer({ export default visualizer({
gzipSize: true, gzipSize: true,
brotliSize: true brotliSize: true,
}); });

View File

@ -2,7 +2,7 @@ import type { MockMethod } from 'vite-plugin-mock';
const token: ApiAuth.Token = { const token: ApiAuth.Token = {
token: '__TEMP_TOKEN__', token: '__TEMP_TOKEN__',
refreshToken: '__TEMP_REFRESH_TOKEN__' refreshToken: '__TEMP_REFRESH_TOKEN__',
}; };
const apis: MockMethod[] = [ const apis: MockMethod[] = [
@ -14,9 +14,9 @@ const apis: MockMethod[] = [
return { return {
code: 200, code: 200,
message: 'ok', message: 'ok',
data: true data: true,
}; };
} },
}, },
// 密码登录 // 密码登录
{ {
@ -26,9 +26,9 @@ const apis: MockMethod[] = [
return { return {
code: 200, code: 200,
message: 'ok', message: 'ok',
data: token data: token,
}; };
} },
}, },
// 验证码登录 // 验证码登录
{ {
@ -38,9 +38,9 @@ const apis: MockMethod[] = [
return { return {
code: 200, code: 200,
message: 'ok', message: 'ok',
data: token data: token,
}; };
} },
}, },
// 获取用户信息(请求头携带token) // 获取用户信息(请求头携带token)
{ {
@ -54,10 +54,10 @@ const apis: MockMethod[] = [
userId: '0', userId: '0',
userName: 'Soybean', userName: 'Soybean',
userPhone: '15170283876', userPhone: '15170283876',
userRole: 'super' userRole: 'super',
} },
}; };
} },
}, },
{ {
url: '/mock/testToken', url: '/mock/testToken',
@ -67,15 +67,15 @@ const apis: MockMethod[] = [
return { return {
code: 66666, code: 66666,
message: 'token 失效', message: 'token 失效',
data: null data: null,
}; };
} }
return { return {
code: 200, code: 200,
message: 'ok', message: 'ok',
data: true data: true,
}; };
} },
}, },
{ {
url: '/mock/updateToken', url: '/mock/updateToken',
@ -84,10 +84,10 @@ const apis: MockMethod[] = [
return { return {
code: 200, code: 200,
message: 'ok', message: 'ok',
data: token data: token,
}; };
} },
} },
]; ];
export default apis; export default apis;

View File

@ -13,8 +13,8 @@ const routes: AuthRoute.Route[] = [
meta: { meta: {
title: '分析页', title: '分析页',
requiresAuth: true, requiresAuth: true,
icon: 'icon-park-outline:analysis' icon: 'icon-park-outline:analysis',
} },
}, },
{ {
name: 'dashboard_workbench', name: 'dashboard_workbench',
@ -24,15 +24,15 @@ const routes: AuthRoute.Route[] = [
title: '工作台', title: '工作台',
requiresAuth: true, requiresAuth: true,
permissions: ['super', 'admin'], permissions: ['super', 'admin'],
icon: 'icon-park-outline:workbench' icon: 'icon-park-outline:workbench',
} },
} },
], ],
meta: { meta: {
title: '仪表盘', title: '仪表盘',
icon: 'carbon:dashboard', icon: 'carbon:dashboard',
order: 1 order: 1,
} },
}, },
{ {
name: 'document', name: 'document',
@ -46,8 +46,8 @@ const routes: AuthRoute.Route[] = [
meta: { meta: {
title: 'vue文档', title: 'vue文档',
requiresAuth: true, requiresAuth: true,
icon: 'mdi:vuejs' icon: 'mdi:vuejs',
} },
}, },
{ {
name: 'document_vue-new', name: 'document_vue-new',
@ -56,8 +56,8 @@ const routes: AuthRoute.Route[] = [
meta: { meta: {
title: 'vue文档(新版)', title: 'vue文档(新版)',
requiresAuth: true, requiresAuth: true,
icon: 'mdi:vuejs' icon: 'mdi:vuejs',
} },
}, },
{ {
name: 'document_vite', name: 'document_vite',
@ -66,8 +66,8 @@ const routes: AuthRoute.Route[] = [
meta: { meta: {
title: 'vite文档', title: 'vite文档',
requiresAuth: true, requiresAuth: true,
icon: 'simple-icons:vite' icon: 'simple-icons:vite',
} },
}, },
{ {
name: 'document_naive', name: 'document_naive',
@ -76,8 +76,8 @@ const routes: AuthRoute.Route[] = [
meta: { meta: {
title: 'naive文档', title: 'naive文档',
requiresAuth: true, requiresAuth: true,
icon: 'mdi:alpha-n-box-outline' icon: 'mdi:alpha-n-box-outline',
} },
}, },
{ {
name: 'document_project', name: 'document_project',
@ -86,15 +86,15 @@ const routes: AuthRoute.Route[] = [
title: '项目文档(外链)', title: '项目文档(外链)',
requiresAuth: true, requiresAuth: true,
icon: 'mdi:file-link-outline', icon: 'mdi:file-link-outline',
href: 'https://docs.soybean.pro/' href: 'https://docs.soybean.pro/',
} },
} },
], ],
meta: { meta: {
title: '文档', title: '文档',
icon: 'carbon:document', icon: 'carbon:document',
order: 2 order: 2,
} },
}, },
{ {
name: 'component', name: 'component',
@ -108,8 +108,8 @@ const routes: AuthRoute.Route[] = [
meta: { meta: {
title: '按钮', title: '按钮',
requiresAuth: true, requiresAuth: true,
icon: 'ic:baseline-radio-button-checked' icon: 'ic:baseline-radio-button-checked',
} },
}, },
{ {
name: 'component_card', name: 'component_card',
@ -118,8 +118,8 @@ const routes: AuthRoute.Route[] = [
meta: { meta: {
title: '卡片', title: '卡片',
requiresAuth: true, requiresAuth: true,
icon: 'mdi:card-outline' icon: 'mdi:card-outline',
} },
}, },
{ {
name: 'component_table', name: 'component_table',
@ -128,15 +128,15 @@ const routes: AuthRoute.Route[] = [
meta: { meta: {
title: '表格', title: '表格',
requiresAuth: true, requiresAuth: true,
icon: 'mdi:table-large' icon: 'mdi:table-large',
} },
} },
], ],
meta: { meta: {
title: '组件示例', title: '组件示例',
icon: 'fluent:app-store-24-regular', icon: 'fluent:app-store-24-regular',
order: 3 order: 3,
} },
}, },
{ {
name: 'plugin', name: 'plugin',
@ -150,8 +150,8 @@ const routes: AuthRoute.Route[] = [
meta: { meta: {
title: '地图', title: '地图',
requiresAuth: true, requiresAuth: true,
icon: 'mdi:map' icon: 'mdi:map',
} },
}, },
{ {
name: 'plugin_video', name: 'plugin_video',
@ -160,8 +160,8 @@ const routes: AuthRoute.Route[] = [
meta: { meta: {
title: '视频', title: '视频',
requiresAuth: true, requiresAuth: true,
icon: 'mdi:video' icon: 'mdi:video',
} },
}, },
{ {
name: 'plugin_editor', name: 'plugin_editor',
@ -175,8 +175,8 @@ const routes: AuthRoute.Route[] = [
meta: { meta: {
title: '富文本编辑器', title: '富文本编辑器',
requiresAuth: true, requiresAuth: true,
icon: 'mdi:file-document-edit-outline' icon: 'mdi:file-document-edit-outline',
} },
}, },
{ {
name: 'plugin_editor_markdown', name: 'plugin_editor_markdown',
@ -185,14 +185,14 @@ const routes: AuthRoute.Route[] = [
meta: { meta: {
title: 'markdown编辑器', title: 'markdown编辑器',
requiresAuth: true, requiresAuth: true,
icon: 'ri:markdown-line' icon: 'ri:markdown-line',
} },
} },
], ],
meta: { meta: {
title: '编辑器', title: '编辑器',
icon: 'icon-park-outline:editor' icon: 'icon-park-outline:editor',
} },
}, },
{ {
name: 'plugin_swiper', name: 'plugin_swiper',
@ -201,8 +201,8 @@ const routes: AuthRoute.Route[] = [
meta: { meta: {
title: 'Swiper插件', title: 'Swiper插件',
requiresAuth: true, requiresAuth: true,
icon: 'simple-icons:swiper' icon: 'simple-icons:swiper',
} },
}, },
{ {
name: 'plugin_copy', name: 'plugin_copy',
@ -211,8 +211,8 @@ const routes: AuthRoute.Route[] = [
meta: { meta: {
title: '剪贴板', title: '剪贴板',
requiresAuth: true, requiresAuth: true,
icon: 'mdi:clipboard-outline' icon: 'mdi:clipboard-outline',
} },
}, },
{ {
name: 'plugin_icon', name: 'plugin_icon',
@ -221,8 +221,8 @@ const routes: AuthRoute.Route[] = [
meta: { meta: {
title: '图标', title: '图标',
requiresAuth: true, requiresAuth: true,
icon: 'ic:baseline-insert-emoticon' icon: 'ic:baseline-insert-emoticon',
} },
}, },
{ {
name: 'plugin_print', name: 'plugin_print',
@ -231,15 +231,15 @@ const routes: AuthRoute.Route[] = [
meta: { meta: {
title: '打印', title: '打印',
requiresAuth: true, requiresAuth: true,
icon: 'ic:baseline-local-printshop' icon: 'ic:baseline-local-printshop',
} },
} },
], ],
meta: { meta: {
title: '插件示例', title: '插件示例',
icon: 'clarity:plugin-line', icon: 'clarity:plugin-line',
order: 4 order: 4,
} },
}, },
{ {
name: 'exception', name: 'exception',
@ -253,8 +253,8 @@ const routes: AuthRoute.Route[] = [
meta: { meta: {
title: '异常页403', title: '异常页403',
requiresAuth: true, requiresAuth: true,
icon: 'ic:baseline-block' icon: 'ic:baseline-block',
} },
}, },
{ {
name: 'exception_404', name: 'exception_404',
@ -263,8 +263,8 @@ const routes: AuthRoute.Route[] = [
meta: { meta: {
title: '异常页404', title: '异常页404',
requiresAuth: true, requiresAuth: true,
icon: 'ic:baseline-web-asset-off' icon: 'ic:baseline-web-asset-off',
} },
}, },
{ {
name: 'exception_500', name: 'exception_500',
@ -273,15 +273,15 @@ const routes: AuthRoute.Route[] = [
meta: { meta: {
title: '异常页500', title: '异常页500',
requiresAuth: true, requiresAuth: true,
icon: 'ic:baseline-wifi-off' icon: 'ic:baseline-wifi-off',
} },
} },
], ],
meta: { meta: {
title: '异常页', title: '异常页',
icon: 'ant-design:exception-outlined', icon: 'ant-design:exception-outlined',
order: 5 order: 5,
} },
}, },
{ {
name: 'multi-menu', name: 'multi-menu',
@ -300,8 +300,8 @@ const routes: AuthRoute.Route[] = [
meta: { meta: {
title: '二级菜单', title: '二级菜单',
requiresAuth: true, requiresAuth: true,
icon: 'ic:outline-menu' icon: 'ic:outline-menu',
} },
}, },
{ {
name: 'multi-menu_first_second-new', name: 'multi-menu_first_second-new',
@ -315,27 +315,27 @@ const routes: AuthRoute.Route[] = [
meta: { meta: {
title: '三级菜单', title: '三级菜单',
requiresAuth: true, requiresAuth: true,
icon: 'ic:outline-menu' icon: 'ic:outline-menu',
} },
} },
], ],
meta: { meta: {
title: '二级菜单(有子菜单)', title: '二级菜单(有子菜单)',
icon: 'ic:outline-menu' icon: 'ic:outline-menu',
} },
} },
], ],
meta: { meta: {
title: '一级菜单', title: '一级菜单',
icon: 'ic:outline-menu' icon: 'ic:outline-menu',
} },
} },
], ],
meta: { meta: {
title: '多级菜单', title: '多级菜单',
icon: 'carbon:menu', icon: 'carbon:menu',
order: 6 order: 6,
} },
}, },
{ {
name: 'about', name: 'about',
@ -347,9 +347,9 @@ const routes: AuthRoute.Route[] = [
singleLayout: 'basic', singleLayout: 'basic',
permissions: ['super', 'admin', 'test'], permissions: ['super', 'admin', 'test'],
icon: 'fluent:book-information-24-regular', icon: 'fluent:book-information-24-regular',
order: 7 order: 7,
} },
} },
]; ];
function dataMiddleware(data: AuthRoute.Route[]): ApiRoute.Route { function dataMiddleware(data: AuthRoute.Route[]): ApiRoute.Route {
@ -361,7 +361,7 @@ function dataMiddleware(data: AuthRoute.Route[]): ApiRoute.Route {
return { return {
routes: sortRoutes(data), routes: sortRoutes(data),
home: routeHomeName home: routeHomeName,
}; };
} }
@ -373,10 +373,10 @@ const apis: MockMethod[] = [
return { return {
code: 200, code: 200,
message: 'ok', message: 'ok',
data: dataMiddleware(routes) data: dataMiddleware(routes),
}; };
} },
} },
]; ];
export default apis; export default apis;

View File

@ -4,16 +4,16 @@
"scripts": { "scripts": {
"dev": "cross-env VITE_HTTP_ENV=test vite", "dev": "cross-env VITE_HTTP_ENV=test vite",
"dev:prod": "cross-env VITE_HTTP_ENV=prod vite", "dev:prod": "cross-env VITE_HTTP_ENV=prod vite",
"typecheck": "vue-tsc --noEmit",
"build": "npm run typecheck && cross-env VITE_HTTP_ENV=prod vite build", "build": "npm run typecheck && cross-env VITE_HTTP_ENV=prod vite build",
"build:test": "npm run typecheck && cross-env VITE_HTTP_ENV=test vite build", "build:test": "npm run typecheck && cross-env VITE_HTTP_ENV=test vite build",
"build:vercel": "cross-env VITE_HASH_ROUTE=true vite build", "build:vercel": "cross-env VITE_HASH_ROUTE=true vite build",
"preview": "vite preview --port 5050", "preview": "vite preview --port 5050",
"release": "standard-version", "typecheck": "vue-tsc --noEmit",
"changelog": "conventional-changelog -p angular -i CHANGELOG.md -s -r 0 && git add CHANGELOG.md", "lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --fix --ignore-path .gitignore",
"lint": "eslint --fix ./ --ext .vue,.js,jsx,.ts,tsx",
"prepare": "husky install", "prepare": "husky install",
"postinstall": "patch-package" "postinstall": "patch-package",
"release": "standard-version",
"changelog": "conventional-changelog -p angular -i CHANGELOG.md -s -r 0 && git add CHANGELOG.md"
}, },
"lint-staged": { "lint-staged": {
"*.{vue,js,jsx,ts,tsx}": "eslint --fix" "*.{vue,js,jsx,ts,tsx}": "eslint --fix"
@ -24,17 +24,17 @@
} }
}, },
"dependencies": { "dependencies": {
"@antv/g2plot": "^2.4.9", "@antv/g2plot": "^2.4.10",
"@better-scroll/core": "^2.4.2", "@better-scroll/core": "^2.4.2",
"@vueuse/core": "^7.7.1", "@vueuse/core": "^8.0.0",
"axios": "^0.26.0", "axios": "^0.26.1",
"clipboard": "^2.0.10", "clipboard": "^2.0.10",
"colord": "^2.9.2", "colord": "^2.9.2",
"crypto-js": "^4.1.1", "crypto-js": "^4.1.1",
"dayjs": "^1.10.8", "dayjs": "^1.10.8",
"form-data": "^4.0.0", "form-data": "^4.0.0",
"lodash-es": "^4.17.21", "lodash-es": "^4.17.21",
"naive-ui": "^2.26.0", "naive-ui": "^2.26.4",
"pinia": "^2.0.11", "pinia": "^2.0.11",
"print-js": "^1.6.0", "print-js": "^1.6.0",
"qs": "^6.10.3", "qs": "^6.10.3",
@ -44,7 +44,7 @@
"ua-parser-js": "^1.0.2", "ua-parser-js": "^1.0.2",
"vditor": "^3.8.12", "vditor": "^3.8.12",
"vue": "^3.2.31", "vue": "^3.2.31",
"vue-router": "^4.0.13", "vue-router": "^4.0.14",
"wangeditor": "^4.7.12", "wangeditor": "^4.7.12",
"xgplayer": "^2.31.4" "xgplayer": "^2.31.4"
}, },
@ -52,15 +52,15 @@
"@amap/amap-jsapi-types": "^0.0.8", "@amap/amap-jsapi-types": "^0.0.8",
"@commitlint/cli": "^16.2.1", "@commitlint/cli": "^16.2.1",
"@commitlint/config-conventional": "^16.2.1", "@commitlint/config-conventional": "^16.2.1",
"@iconify/json": "^2.1.11", "@iconify/json": "^2.1.14",
"@iconify/vue": "^3.1.4", "@iconify/vue": "^3.1.4",
"@types/bmapgl": "^0.0.5", "@types/bmapgl": "^0.0.5",
"@types/crypto-js": "^4.1.1", "@types/crypto-js": "^4.1.1",
"@types/node": "^17.0.21", "@types/node": "^17.0.21",
"@types/qs": "^6.9.7", "@types/qs": "^6.9.7",
"@types/ua-parser-js": "^0.7.36", "@types/ua-parser-js": "^0.7.36",
"@typescript-eslint/eslint-plugin": "^5.13.0", "@typescript-eslint/eslint-plugin": "^5.14.0",
"@typescript-eslint/parser": "^5.13.0", "@typescript-eslint/parser": "^5.14.0",
"@vitejs/plugin-vue": "^2.2.4", "@vitejs/plugin-vue": "^2.2.4",
"@vue/eslint-config-prettier": "^7.0.0", "@vue/eslint-config-prettier": "^7.0.0",
"@vue/eslint-config-typescript": "^10.0.0", "@vue/eslint-config-typescript": "^10.0.0",
@ -69,7 +69,7 @@
"cross-env": "^7.0.3", "cross-env": "^7.0.3",
"cz-conventional-changelog": "^3.3.0", "cz-conventional-changelog": "^3.3.0",
"cz-customizable": "^6.3.0", "cz-customizable": "^6.3.0",
"eslint": "^8.10.0", "eslint": "^8.11.0",
"eslint-config-airbnb-base": "^15.0.0", "eslint-config-airbnb-base": "^15.0.0",
"eslint-config-prettier": "^8.5.0", "eslint-config-prettier": "^8.5.0",
"eslint-plugin-import": "^2.25.4", "eslint-plugin-import": "^2.25.4",
@ -83,9 +83,9 @@
"prettier": "^2.5.1", "prettier": "^2.5.1",
"rollup-plugin-visualizer": "^5.6.0", "rollup-plugin-visualizer": "^5.6.0",
"sass": "^1.49.9", "sass": "^1.49.9",
"typescript": "~4.5.5", "typescript": "~4.6.2",
"unplugin-icons": "^0.13.2", "unplugin-icons": "^0.13.3",
"unplugin-vue-components": "^0.17.21", "unplugin-vue-components": "^0.18.0",
"vite": "2.8.6", "vite": "2.8.6",
"vite-plugin-html": "^3.1.0", "vite-plugin-html": "^3.1.0",
"vite-plugin-mock": "^2.9.6", "vite-plugin-mock": "^2.9.6",

File diff suppressed because it is too large Load Diff

View File

@ -53,7 +53,7 @@ const props = withDefaults(defineProps<Props>(), {
emptyDesc: '暂无数据', emptyDesc: '暂无数据',
iconClass: 'text-320px text-primary', iconClass: 'text-320px text-primary',
descClass: 'text-16px text-[#666]', descClass: 'text-16px text-[#666]',
showNetworkReload: false showNetworkReload: false,
}); });
// //
@ -79,7 +79,7 @@ function handleReload() {
const stopHandle = watch( const stopHandle = watch(
() => props.loading, () => props.loading,
newValue => { (newValue) => {
// //
if (!newValue) { if (!newValue) {
setNetwork(window.navigator.onLine); setNetwork(window.navigator.onLine);

View File

@ -23,7 +23,7 @@ interface Emits {
} }
const props = withDefaults(defineProps<Props>(), { const props = withDefaults(defineProps<Props>(), {
value: true value: true,
}); });
const emit = defineEmits<Emits>(); const emit = defineEmits<Emits>();
@ -34,7 +34,7 @@ const checked = computed({
}, },
set(newValue: boolean) { set(newValue: boolean) {
emit('update:value', newValue); emit('update:value', newValue);
} },
}); });
function handleClickProtocol() { function handleClickProtocol() {

View File

@ -18,7 +18,7 @@ interface Emits {
} }
const props = withDefaults(defineProps<Props>(), { const props = withDefaults(defineProps<Props>(), {
dark: false dark: false,
}); });
const emit = defineEmits<Emits>(); const emit = defineEmits<Emits>();
@ -29,7 +29,7 @@ const darkMode = computed({
}, },
set(newValue: boolean) { set(newValue: boolean) {
emit('update:dark', newValue); emit('update:dark', newValue);
} },
}); });
function handleSwitch() { function handleSwitch() {

View File

@ -29,7 +29,7 @@ interface Props {
const props = withDefaults(defineProps<Props>(), { const props = withDefaults(defineProps<Props>(), {
tooltipContent: '', tooltipContent: '',
placement: 'bottom', placement: 'bottom',
contentClass: '' contentClass: '',
}); });
const showTooltip = computed(() => Boolean(props.tooltipContent)); const showTooltip = computed(() => Boolean(props.tooltipContent));

View File

@ -29,7 +29,7 @@ const NaiveProviderContent = defineComponent({
}, },
render() { render() {
return h('div'); return h('div');
} },
}); });
</script> </script>
<style scoped></style> <style scoped></style>

View File

@ -10,7 +10,7 @@ interface Props {
} }
withDefaults(defineProps<Props>(), { withDefaults(defineProps<Props>(), {
fill: false fill: false,
}); });
</script> </script>
<style scoped></style> <style scoped></style>

View File

@ -42,7 +42,7 @@ const props = withDefaults(defineProps<Props>(), {
separator: ',', separator: ',',
decimal: '.', decimal: '.',
useEasing: true, useEasing: true,
transition: 'linear' transition: 'linear',
}); });
const emit = defineEmits<{ const emit = defineEmits<{
@ -61,7 +61,7 @@ function run() {
duration: props.duration, duration: props.duration,
onStarted: () => emit('on-started'), onStarted: () => emit('on-started'),
onFinished: () => emit('on-finished'), onFinished: () => emit('on-finished'),
...(props.useEasing ? { transition: TransitionPresets[props.transition] } : {}) ...(props.useEasing ? { transition: TransitionPresets[props.transition] } : {}),
}); });
} }

View File

@ -43,7 +43,7 @@ interface Emits {
} }
const props = withDefaults(defineProps<Props>(), { const props = withDefaults(defineProps<Props>(), {
emptyIcon: 'mdi:apps' emptyIcon: 'mdi:apps',
}); });
const emit = defineEmits<Emits>(); const emit = defineEmits<Emits>();
@ -51,7 +51,7 @@ const emit = defineEmits<Emits>();
const theme = useThemeStore(); const theme = useThemeStore();
const searchValue = ref(''); const searchValue = ref('');
const iconsList = computed(() => props.icons.filter(v => v.includes(searchValue.value))); const iconsList = computed(() => props.icons.filter((v) => v.includes(searchValue.value)));
const modelValue = computed({ const modelValue = computed({
get() { get() {
@ -59,7 +59,7 @@ const modelValue = computed({
}, },
set(val: string) { set(val: string) {
emit('update:value', val); emit('update:value', val);
} },
}); });
function handleChange(iconItem: string) { function handleChange(iconItem: string) {

View File

@ -17,7 +17,7 @@ interface Emits {
} }
const props = withDefaults(defineProps<Props>(), { const props = withDefaults(defineProps<Props>(), {
code: '' code: '',
}); });
const emit = defineEmits<Emits>(); const emit = defineEmits<Emits>();
@ -26,11 +26,11 @@ const { domRef, imgCode, setImgCode, getImgCode } = useImageVerify();
watch( watch(
() => props.code, () => props.code,
newValue => { (newValue) => {
setImgCode(newValue); setImgCode(newValue);
} }
); );
watch(imgCode, newValue => { watch(imgCode, (newValue) => {
emit('update:code', newValue); emit('update:code', newValue);
}); });

View File

@ -19,23 +19,23 @@ export function useBasicLayout() {
vertical: { vertical: {
showLogo: false, showLogo: false,
showHeaderMenu: false, showHeaderMenu: false,
showMenuCollape: true showMenuCollape: true,
}, },
'vertical-mix': { 'vertical-mix': {
showLogo: false, showLogo: false,
showHeaderMenu: false, showHeaderMenu: false,
showMenuCollape: false showMenuCollape: false,
}, },
horizontal: { horizontal: {
showLogo: true, showLogo: true,
showHeaderMenu: true, showHeaderMenu: true,
showMenuCollape: false showMenuCollape: false,
}, },
'horizontal-mix': { 'horizontal-mix': {
showLogo: true, showLogo: true,
showHeaderMenu: false, showHeaderMenu: false,
showMenuCollape: true showMenuCollape: true,
} },
}; };
const headerProps = computed(() => layoutHeaderProps[theme.layout.mode]); const headerProps = computed(() => layoutHeaderProps[theme.layout.mode]);
@ -65,6 +65,6 @@ export function useBasicLayout() {
headerProps, headerProps,
siderVisible, siderVisible,
siderWidth, siderWidth,
siderCollapsedWidth siderCollapsedWidth,
}; };
} }

View File

@ -7,7 +7,7 @@ import type { LoginModuleKey } from '@/interface';
* *
* @param inSetup - vue页面/setup里面调用axios里面无法使用useRouter和useRoute * @param inSetup - vue页面/setup里面调用axios里面无法使用useRouter和useRoute
*/ */
export function useRouterPush(inSetup: boolean = true) { export function useRouterPush(inSetup = true) {
const router = inSetup ? useRouter() : globalRouter; const router = inSetup ? useRouter() : globalRouter;
const route = globalRouter.currentRoute; const route = globalRouter.currentRoute;
@ -47,7 +47,7 @@ export function useRouterPush(inSetup: boolean = true) {
const module: LoginModuleKey = loginModule || 'pwd-login'; const module: LoginModuleKey = loginModule || 'pwd-login';
const routeLocation: RouteLocationRaw = { const routeLocation: RouteLocationRaw = {
name: routeName('login'), name: routeName('login'),
params: { module } params: { module },
}; };
const redirect = redirectUrl || route.value.fullPath; const redirect = redirectUrl || route.value.fullPath;
Object.assign(routeLocation, { query: { redirect } }); Object.assign(routeLocation, { query: { redirect } });
@ -81,6 +81,6 @@ export function useRouterPush(inSetup: boolean = true) {
toHome, toHome,
toLogin, toLogin,
toLoginModule, toLoginModule,
toLoginRedirect toLoginRedirect,
}; };
} }

View File

@ -16,7 +16,7 @@ export function useAppInfo(): AppInfo {
return { return {
name, name,
title, title,
desc desc,
}; };
} }

View File

@ -36,7 +36,7 @@ export const ERROR_STATUS = {
503: '503: 服务不可用~', 503: '503: 服务不可用~',
504: '504: 网关超时~', 504: '504: 网关超时~',
505: '505: http版本不支持该请求~', 505: '505: http版本不支持该请求~',
[DEFAULT_REQUEST_ERROR_CODE]: DEFAULT_REQUEST_ERROR_MSG [DEFAULT_REQUEST_ERROR_CODE]: DEFAULT_REQUEST_ERROR_MSG,
}; };
/** 不弹出错误信息的code */ /** 不弹出错误信息的code */

View File

@ -20,7 +20,7 @@ export default function setupLoginDirective(app: App) {
unmounted(el: HTMLElement, binding) { unmounted(el: HTMLElement, binding) {
if (binding.value === false) return; if (binding.value === false) return;
el.removeEventListener('click', listenerHandler); el.removeEventListener('click', listenerHandler);
} },
}; };
app.directive('login', loginDirective); app.directive('login', loginDirective);

View File

@ -18,7 +18,7 @@ export default function setupNetworkDirective(app: App) {
unmounted(el: HTMLElement, binding) { unmounted(el: HTMLElement, binding) {
if (binding.value === false) return; if (binding.value === false) return;
el.removeEventListener('click', listenerHandler); el.removeEventListener('click', listenerHandler);
} },
}; };
app.directive('network', networkDirective); app.directive('network', networkDirective);

View File

@ -2,5 +2,5 @@
export enum ContentType { export enum ContentType {
json = 'application/json', json = 'application/json',
formUrlencoded = 'application/x-www-form-urlencoded', formUrlencoded = 'application/x-www-form-urlencoded',
formData = 'multipart/form-data' formData = 'multipart/form-data',
} }

View File

@ -8,5 +8,5 @@ export enum EnumStorageKey {
/** 用户信息 */ /** 用户信息 */
'user-info' = '__USER_INFO__', 'user-info' = '__USER_INFO__',
/** 多页签路由信息 */ /** 多页签路由信息 */
'tab-routes' = '__TAB_ROUTES__' 'tab-routes' = '__TAB_ROUTES__',
} }

View File

@ -1,7 +1,7 @@
/** 布局组件的名称 */ /** 布局组件的名称 */
export enum EnumLayoutComponentName { export enum EnumLayoutComponentName {
basic = 'basic-layout', basic = 'basic-layout',
blank = 'blank-layout' blank = 'blank-layout',
} }
/** 登录模块 */ /** 登录模块 */
@ -10,5 +10,5 @@ export enum EnumLoginModule {
'code-login' = '手机验证码登录', 'code-login' = '手机验证码登录',
'register' = '注册', 'register' = '注册',
'reset-pwd' = '重置密码', 'reset-pwd' = '重置密码',
'bind-wechat' = '微信绑定' 'bind-wechat' = '微信绑定',
} }

View File

@ -3,20 +3,20 @@ export enum EnumThemeLayoutMode {
'vertical' = '左侧菜单模式', 'vertical' = '左侧菜单模式',
'horizontal' = '顶部菜单模式', 'horizontal' = '顶部菜单模式',
'vertical-mix' = '左侧菜单混合模式', 'vertical-mix' = '左侧菜单混合模式',
'horizontal-mix' = '顶部菜单混合模式' 'horizontal-mix' = '顶部菜单混合模式',
} }
/** 多页签风格 */ /** 多页签风格 */
export enum EnumThemeTabMode { export enum EnumThemeTabMode {
'chrome' = '谷歌风格', 'chrome' = '谷歌风格',
'button' = '按钮风格' 'button' = '按钮风格',
} }
/** 水平模式的菜单位置 */ /** 水平模式的菜单位置 */
export enum EnumThemeHorizontalMenuPosition { export enum EnumThemeHorizontalMenuPosition {
'flex-start' = '居左', 'flex-start' = '居左',
'center' = '居中', 'center' = '居中',
'flex-end' = '居右' 'flex-end' = '居右',
} }
/** 过渡动画类型 */ /** 过渡动画类型 */
@ -26,5 +26,5 @@ export enum EnumThemeAnimateMode {
'fade-slide' = '滑动', 'fade-slide' = '滑动',
'fade' = '消退', 'fade' = '消退',
'fade-bottom' = '底部消退', 'fade-bottom' = '底部消退',
'fade-scale' = '缩放消退' 'fade-scale' = '缩放消退',
} }

View File

@ -10,5 +10,5 @@ export enum EnumDataType {
date = '[object Date]', date = '[object Date]',
regexp = '[object RegExp]', regexp = '[object RegExp]',
set = '[object Set]', set = '[object Set]',
map = '[object Map]' map = '[object Map]',
} }

View File

@ -47,6 +47,6 @@ export default function useCountDown(second: number) {
isCounting, isCounting,
start, start,
stop, stop,
isComplete isComplete,
}; };
} }

View File

@ -26,7 +26,7 @@ export default function useImageVerify(width = 152, height = 40) {
domRef, domRef,
imgCode, imgCode,
setImgCode, setImgCode,
getImgCode getImgCode,
}; };
} }

View File

@ -54,6 +54,6 @@ export default function useSmsCode() {
start, start,
isCounting, isCounting,
getSmsCode, getSmsCode,
loading loading,
}; };
} }

View File

@ -10,7 +10,7 @@ interface ScrollBodyStyle {
export default function useBodyScroll(duration = 300) { export default function useBodyScroll(duration = 300) {
const defaultStyle: ScrollBodyStyle = { const defaultStyle: ScrollBodyStyle = {
overflow: '', overflow: '',
paddingRight: '' paddingRight: '',
}; };
function getInitBodyStyle() { function getInitBodyStyle() {
const { overflow, paddingRight } = document.body.style; const { overflow, paddingRight } = document.body.style;
@ -42,6 +42,6 @@ export default function useBodyScroll(duration = 300) {
getInitBodyStyle(); getInitBodyStyle();
return { return {
scrollBodyHandler scrollBodyHandler,
}; };
} }

View File

@ -1,6 +1,6 @@
import { ref } from 'vue'; import { ref } from 'vue';
export default function useBoolean(initValue: boolean = false) { export default function useBoolean(initValue = false) {
const bool = ref(initValue); const bool = ref(initValue);
function setBool(value: boolean) { function setBool(value: boolean) {
@ -21,6 +21,6 @@ export default function useBoolean(initValue: boolean = false) {
setBool, setBool,
setTrue, setTrue,
setFalse, setFalse,
toggle toggle,
}; };
} }

View File

@ -2,7 +2,7 @@ import { provide, inject } from 'vue';
import type { InjectionKey } from 'vue'; import type { InjectionKey } from 'vue';
/** 创建共享上下文状态 */ /** 创建共享上下文状态 */
export default function useContext<T>(contextName: string = 'context') { export default function useContext<T>(contextName = 'context') {
const injectKey: InjectionKey<T> = Symbol(contextName); const injectKey: InjectionKey<T> = Symbol(contextName);
function useProvide(context: T) { function useProvide(context: T) {
@ -10,11 +10,11 @@ export default function useContext<T>(contextName: string = 'context') {
} }
function useInject() { function useInject() {
return inject(injectKey)!; return inject(injectKey) as T;
} }
return { return {
useProvide, useProvide,
useInject useInject,
}; };
} }

View File

@ -1,11 +1,11 @@
import useBoolean from './useBoolean'; import useBoolean from './useBoolean';
export default function useLoading(initValue: boolean = false) { export default function useLoading(initValue = false) {
const { bool: loading, setTrue: startLoading, setFalse: endLoading } = useBoolean(initValue); const { bool: loading, setTrue: startLoading, setFalse: endLoading } = useBoolean(initValue);
return { return {
loading, loading,
startLoading, startLoading,
endLoading endLoading,
}; };
} }

View File

@ -9,6 +9,6 @@ export default function useLoadingEmpty(initLoading = false, initEmpty = false)
startLoading, startLoading,
endLoading, endLoading,
empty, empty,
setEmpty setEmpty,
}; };
} }

View File

@ -11,7 +11,7 @@ export default function useModalVisible(hideScroll = true) {
const { scrollBodyHandler } = useBodyScroll(); const { scrollBodyHandler } = useBodyScroll();
function modalVisibleWatcher() { function modalVisibleWatcher() {
const stopHandle = watch(visible, async newValue => { const stopHandle = watch(visible, async (newValue) => {
scrollBodyHandler(newValue); scrollBodyHandler(newValue);
}); });
@ -28,6 +28,6 @@ export default function useModalVisible(hideScroll = true) {
visible, visible,
openModal, openModal,
closeModal, closeModal,
toggleModal toggleModal,
}; };
} }

View File

@ -24,6 +24,6 @@ export default function useReload() {
return { return {
reloadFlag, reloadFlag,
handleReload handleReload,
}; };
} }

View File

@ -4,7 +4,7 @@ import type {
EnumThemeTabMode, EnumThemeTabMode,
EnumThemeHorizontalMenuPosition, EnumThemeHorizontalMenuPosition,
EnumThemeAnimateMode, EnumThemeAnimateMode,
EnumLoginModule EnumLoginModule,
} from '@/enum'; } from '@/enum';
/** 布局组件名称 */ /** 布局组件名称 */

View File

@ -2,7 +2,7 @@ import type {
EnumThemeLayoutMode, EnumThemeLayoutMode,
EnumThemeTabMode, EnumThemeTabMode,
EnumThemeHorizontalMenuPosition, EnumThemeHorizontalMenuPosition,
EnumThemeAnimateMode EnumThemeAnimateMode,
} from '@/enum'; } from '@/enum';
import type { ThemeLayoutMode, ThemeTabMode, ThemeHorizontalMenuPosition, ThemeAnimateMode } from './enum'; import type { ThemeLayoutMode, ThemeTabMode, ThemeHorizontalMenuPosition, ThemeAnimateMode } from './enum';

View File

@ -22,7 +22,7 @@ interface Props {
} }
withDefaults(defineProps<Props>(), { withDefaults(defineProps<Props>(), {
showPadding: true showPadding: true,
}); });
const app = useAppStore(); const app = useAppStore();

View File

@ -20,17 +20,17 @@ const options = [
{ {
label: '用户中心', label: '用户中心',
key: 'user-center', key: 'user-center',
icon: iconifyRender('carbon:user-avatar') icon: iconifyRender('carbon:user-avatar'),
}, },
{ {
type: 'divider', type: 'divider',
key: 'divider' key: 'divider',
}, },
{ {
label: '退出登录', label: '退出登录',
key: 'logout', key: 'logout',
icon: iconifyRender('carbon:logout') icon: iconifyRender('carbon:logout'),
} },
]; ];
function handleDropdown(optionKey: string) { function handleDropdown(optionKey: string) {
@ -43,7 +43,7 @@ function handleDropdown(optionKey: string) {
negativeText: '取消', negativeText: '取消',
onPositiveClick: () => { onPositiveClick: () => {
auth.resetAuthStore(); auth.resetAuthStore();
} },
}); });
} }
} }

View File

@ -31,7 +31,7 @@ import {
GithubSite, GithubSite,
FullScreen, FullScreen,
ThemeMode, ThemeMode,
UserAvatar UserAvatar,
} from './components'; } from './components';
interface Props { interface Props {

View File

@ -61,10 +61,10 @@ const show = computed({
}, },
set(val: boolean) { set(val: boolean) {
emit('update:value', val); emit('update:value', val);
} },
}); });
watch(show, async val => { watch(show, async (val) => {
if (val) { if (val) {
/** 自动聚焦 */ /** 自动聚焦 */
await nextTick(); await nextTick();
@ -75,7 +75,7 @@ watch(show, async val => {
/** 查询 */ /** 查询 */
function search() { function search() {
resultOptions.value = routeStore.searchMenus.filter( resultOptions.value = routeStore.searchMenus.filter(
menu => keyword.value && menu.meta?.title.toLocaleLowerCase().includes(keyword.value.toLocaleLowerCase().trim()) (menu) => keyword.value && menu.meta?.title.toLocaleLowerCase().includes(keyword.value.toLocaleLowerCase().trim())
); );
if (resultOptions.value?.length > 0) { if (resultOptions.value?.length > 0) {
activePath.value = resultOptions.value[0].path; activePath.value = resultOptions.value[0].path;
@ -97,7 +97,7 @@ function handleClose() {
function handleUp() { function handleUp() {
const { length } = resultOptions.value; const { length } = resultOptions.value;
if (length === 0) return; if (length === 0) return;
const index = resultOptions.value.findIndex(item => item.path === activePath.value); const index = resultOptions.value.findIndex((item) => item.path === activePath.value);
if (index === 0) { if (index === 0) {
activePath.value = resultOptions.value[length - 1].path; activePath.value = resultOptions.value[length - 1].path;
} else { } else {
@ -109,7 +109,7 @@ function handleUp() {
function handleDown() { function handleDown() {
const { length } = resultOptions.value; const { length } = resultOptions.value;
if (length === 0) return; if (length === 0) return;
const index = resultOptions.value.findIndex(item => item.path === activePath.value); const index = resultOptions.value.findIndex((item) => item.path === activePath.value);
if (index + 1 === length) { if (index + 1 === length) {
activePath.value = resultOptions.value[0].path; activePath.value = resultOptions.value[0].path;
} else { } else {
@ -121,8 +121,8 @@ function handleDown() {
function handleEnter() { function handleEnter() {
const { length } = resultOptions.value; const { length } = resultOptions.value;
if (length === 0 || activePath.value === '') return; if (length === 0 || activePath.value === '') return;
const item = resultOptions.value.find(item => item.path === activePath.value); const routeItem = resultOptions.value.find((item) => item.path === activePath.value);
if (item?.meta?.href) { if (routeItem?.meta?.href) {
window.open(activePath.value, '__blank'); window.open(activePath.value, '__blank');
} else { } else {
router.push(activePath.value); router.push(activePath.value);

View File

@ -6,7 +6,7 @@
class="bg-[#e5e7eb] dark:bg-dark h-56px mt-8px px-14px rounded-4px cursor-pointer flex-y-center justify-between" class="bg-[#e5e7eb] dark:bg-dark h-56px mt-8px px-14px rounded-4px cursor-pointer flex-y-center justify-between"
:style="{ :style="{
background: item.path === active ? theme.themeColor : '', background: item.path === active ? theme.themeColor : '',
color: item.path === active ? '#fff' : '' color: item.path === active ? '#fff' : '',
}" }"
@click="handleTo" @click="handleTo"
@mouseenter="handleMouse(item)" @mouseenter="handleMouse(item)"
@ -48,7 +48,7 @@ const active = computed({
}, },
set(val: string) { set(val: string) {
emit('update:value', val); emit('update:value', val);
} },
}); });
/** 鼠标移入 */ /** 鼠标移入 */

View File

@ -35,7 +35,7 @@ interface Props {
const props = withDefaults(defineProps<Props>(), { const props = withDefaults(defineProps<Props>(), {
icon: undefined, icon: undefined,
isMini: false isMini: false,
}); });
const { bool: isHover, setTrue, setFalse } = useBoolean(); const { bool: isHover, setTrue, setFalse } = useBoolean();

View File

@ -44,7 +44,7 @@ function setActiveParentRouteName(routeName: string) {
} }
const firstDegreeMenus = computed(() => const firstDegreeMenus = computed(() =>
routeStore.menus.map(item => { routeStore.menus.map((item) => {
const { routeName, label } = item; const { routeName, label } = item;
const icon = item?.icon; const icon = item?.icon;
const hasChildren = Boolean(item.children && item.children.length); const hasChildren = Boolean(item.children && item.children.length);
@ -53,13 +53,13 @@ const firstDegreeMenus = computed(() =>
routeName, routeName,
label, label,
icon, icon,
hasChildren hasChildren,
}; };
}) })
); );
function getActiveParentRouteName() { function getActiveParentRouteName() {
firstDegreeMenus.value.some(item => { firstDegreeMenus.value.some((item) => {
const routeName = route.name as string; const routeName = route.name as string;
const flag = routeName?.includes(item.routeName); const flag = routeName?.includes(item.routeName);
if (flag) { if (flag) {
@ -85,10 +85,10 @@ function resetFirstDegreeMenus() {
const activeChildMenus = computed(() => { const activeChildMenus = computed(() => {
const menus: GlobalMenuOption[] = []; const menus: GlobalMenuOption[] = [];
routeStore.menus.some(item => { routeStore.menus.some((item) => {
const flag = item.routeName === activeParentRouteName.value && Boolean(item.children?.length); const flag = item.routeName === activeParentRouteName.value && Boolean(item.children?.length);
if (flag) { if (flag) {
menus.push(...item.children!); menus.push(...(item.children || []));
} }
return flag; return flag;
}); });

View File

@ -38,7 +38,7 @@ type Option = DropdownOption & {
const props = withDefaults(defineProps<Props>(), { const props = withDefaults(defineProps<Props>(), {
visible: false, visible: false,
currentPath: '' currentPath: '',
}); });
const emit = defineEmits<Emits>(); const emit = defineEmits<Emits>();
@ -52,7 +52,7 @@ const dropdownVisible = computed({
}, },
set(visible: boolean) { set(visible: boolean) {
emit('update:visible', visible); emit('update:visible', visible);
} },
}); });
function hide() { function hide() {
@ -64,29 +64,29 @@ const options = computed<Option[]>(() => [
label: '重新加载', label: '重新加载',
key: 'reload-current', key: 'reload-current',
disabled: props.currentPath !== tab.activeTab, disabled: props.currentPath !== tab.activeTab,
icon: iconifyRender('ant-design:reload-outlined') icon: iconifyRender('ant-design:reload-outlined'),
}, },
{ {
label: '关闭', label: '关闭',
key: 'close-current', key: 'close-current',
disabled: props.currentPath === tab.homeTab.path, disabled: props.currentPath === tab.homeTab.path,
icon: iconifyRender('ant-design:close-outlined') icon: iconifyRender('ant-design:close-outlined'),
}, },
{ {
label: '关闭其他', label: '关闭其他',
key: 'close-other', key: 'close-other',
icon: iconifyRender('ant-design:column-width-outlined') icon: iconifyRender('ant-design:column-width-outlined'),
}, },
{ {
label: '关闭左侧', label: '关闭左侧',
key: 'close-left', key: 'close-left',
icon: iconifyRender('mdi:format-horizontal-align-left') icon: iconifyRender('mdi:format-horizontal-align-left'),
}, },
{ {
label: '关闭右侧', label: '关闭右侧',
key: 'close-right', key: 'close-right',
icon: iconifyRender('mdi:format-horizontal-align-right') icon: iconifyRender('mdi:format-horizontal-align-right'),
} },
]); ]);
const actionMap = new Map<DropdownKey, () => void>([ const actionMap = new Map<DropdownKey, () => void>([
@ -94,32 +94,32 @@ const actionMap = new Map<DropdownKey, () => void>([
'reload-current', 'reload-current',
() => { () => {
app.reloadPage(); app.reloadPage();
} },
], ],
[ [
'close-current', 'close-current',
() => { () => {
tab.removeTab(props.currentPath); tab.removeTab(props.currentPath);
} },
], ],
[ [
'close-other', 'close-other',
() => { () => {
tab.clearTab([props.currentPath]); tab.clearTab([props.currentPath]);
} },
], ],
[ [
'close-left', 'close-left',
() => { () => {
tab.clearLeftTab(props.currentPath); tab.clearLeftTab(props.currentPath);
} },
], ],
[ [
'close-right', 'close-right',
() => { () => {
tab.clearRightTab(props.currentPath); tab.clearRightTab(props.currentPath);
} },
] ],
]); ]);
function handleDropdown(optionKey: string) { function handleDropdown(optionKey: string) {

View File

@ -64,7 +64,7 @@ const dropdown = reactive({
visible: false, visible: false,
x: 0, x: 0,
y: 0, y: 0,
currentPath: '' currentPath: '',
}); });
function showDropdown() { function showDropdown() {
dropdown.visible = true; dropdown.visible = true;
@ -92,7 +92,7 @@ watch(
getActiveTabClientX(); getActiveTabClientX();
}, },
{ {
immediate: true immediate: true,
} }
); );

View File

@ -45,23 +45,23 @@ const layoutConfig: LayoutConfig = {
vertical: { vertical: {
placement: 'bottom-start', placement: 'bottom-start',
menuClass: 'w-1/3 h-full', menuClass: 'w-1/3 h-full',
mainClass: 'w-2/3 h-3/4' mainClass: 'w-2/3 h-3/4',
}, },
'vertical-mix': { 'vertical-mix': {
placement: 'bottom', placement: 'bottom',
menuClass: 'w-1/4 h-full', menuClass: 'w-1/4 h-full',
mainClass: 'w-2/3 h-3/4' mainClass: 'w-2/3 h-3/4',
}, },
horizontal: { horizontal: {
placement: 'bottom', placement: 'bottom',
menuClass: 'w-full h-1/4', menuClass: 'w-full h-1/4',
mainClass: 'w-full h-3/4' mainClass: 'w-full h-3/4',
}, },
'horizontal-mix': { 'horizontal-mix': {
placement: 'bottom-end', placement: 'bottom-end',
menuClass: 'w-full h-1/4', menuClass: 'w-full h-1/4',
mainClass: 'w-2/3 h-3/4' mainClass: 'w-2/3 h-3/4',
} },
}; };
const activeConfig = computed(() => layoutConfig[props.mode]); const activeConfig = computed(() => layoutConfig[props.mode]);

View File

@ -17,7 +17,7 @@ interface Props {
} }
const props = withDefaults(defineProps<Props>(), { const props = withDefaults(defineProps<Props>(), {
iconClass: 'text-14px' iconClass: 'text-14px',
}); });
const whiteColors = ['#ffffff', '#fff', 'rgb(255,255,255)']; const whiteColors = ['#ffffff', '#fff', 'rgb(255,255,255)'];

View File

@ -30,12 +30,13 @@ function handleResetConfig() {
} }
function clipboardEventListener() { function clipboardEventListener() {
const copy = new Clipboard(copyRef.value!); if (!copyRef.value) return;
const copy = new Clipboard(copyRef.value);
copy.on('success', () => { copy.on('success', () => {
window.$dialog?.success({ window.$dialog?.success({
title: '操作成功', title: '操作成功',
content: '复制成功,请替换 src/settings/theme.json的内容', content: '复制成功,请替换 src/settings/theme.json的内容',
positiveText: '确定' positiveText: '确定',
}); });
}); });
} }

View File

@ -5,4 +5,6 @@ import 'swiper/css/pagination';
import '../styles/css/global.css'; import '../styles/css/global.css';
/** 引入静态资源(全局引入css、字体等) */ /** 引入静态资源(全局引入css、字体等) */
export default function setupAssets() {} export default function setupAssets() {
//
}

View File

@ -45,7 +45,7 @@ import {
NThing, NThing,
NTimeline, NTimeline,
NTimelineItem, NTimelineItem,
NTooltip NTooltip,
} from 'naive-ui'; } from 'naive-ui';
/** 按需引入naiveUI */ /** 按需引入naiveUI */
@ -96,8 +96,8 @@ export default function setupNaiveUI(app: App) {
NThing, NThing,
NTimeline, NTimeline,
NTimelineItem, NTimelineItem,
NTooltip NTooltip,
] ],
}); });
app.use(naive); app.use(naive);
} }

View File

@ -13,7 +13,7 @@ export function createRouterGuard(router: Router) {
// 页面跳转权限处理 // 页面跳转权限处理
await createPermissionGuard(to, from, next, router); await createPermissionGuard(to, from, next, router);
}); });
router.afterEach(to => { router.afterEach((to) => {
// 设置document title // 设置document title
useTitle(to.meta.title); useTitle(to.meta.title);
// 结束 loadingBar // 结束 loadingBar

View File

@ -34,14 +34,14 @@ export async function createPermissionGuard(
isLogin && to.name === routeName('login'), isLogin && to.name === routeName('login'),
() => { () => {
next({ name: routeName('root') }); next({ name: routeName('root') });
} },
], ],
// 不需要登录权限的页面直接通行 // 不需要登录权限的页面直接通行
[ [
!needLogin, !needLogin,
() => { () => {
next(); next();
} },
], ],
// 未登录状态进入需要登录权限的页面 // 未登录状态进入需要登录权限的页面
[ [
@ -49,22 +49,22 @@ export async function createPermissionGuard(
() => { () => {
const redirect = to.fullPath; const redirect = to.fullPath;
next({ name: routeName('login'), query: { redirect } }); next({ name: routeName('login'), query: { redirect } });
} },
], ],
// 登录状态进入需要登录权限的页面,有权限直接通行 // 登录状态进入需要登录权限的页面,有权限直接通行
[ [
isLogin && needLogin && hasPermission, isLogin && needLogin && hasPermission,
() => { () => {
next(); next();
} },
], ],
[ [
// 登录状态进入需要登录权限的页面,无权限,重定向到无权限页面 // 登录状态进入需要登录权限的页面,无权限,重定向到无权限页面
isLogin && needLogin && !hasPermission, isLogin && needLogin && !hasPermission,
() => { () => {
next({ name: routeName('no-permission') }); next({ name: routeName('no-permission') });
} },
] ],
]; ];
exeStrategyActions(actions); exeStrategyActions(actions);

View File

@ -2,20 +2,20 @@ import type { RouterScrollBehavior } from 'vue-router';
import { useTabStore } from '@/store'; import { useTabStore } from '@/store';
export const scrollBehavior: RouterScrollBehavior = (to, from) => { export const scrollBehavior: RouterScrollBehavior = (to, from) => {
return new Promise(resolve => { return new Promise((resolve) => {
const tab = useTabStore(); const tab = useTabStore();
if (to.hash) { if (to.hash) {
resolve({ resolve({
el: to.hash, el: to.hash,
behavior: 'smooth' behavior: 'smooth',
}); });
} }
const { left, top } = tab.getTabScrollPosition(to.path); const { left, top } = tab.getTabScrollPosition(to.path);
const scrollPosition = { const scrollPosition = {
left, left,
top top,
}; };
const { scrollLeft, scrollTop } = document.documentElement; const { scrollLeft, scrollTop } = document.documentElement;

View File

@ -11,7 +11,7 @@ const history = VITE_HASH_ROUTE === 'true' ? createWebHashHistory(VITE_BASE_URL)
export const router = createRouter({ export const router = createRouter({
history, history,
routes: transformAuthRoutesToVueRoutes(constantRoutes), routes: transformAuthRoutesToVueRoutes(constantRoutes),
scrollBehavior scrollBehavior,
}); });
export async function setupRouter(app: App) { export async function setupRouter(app: App) {

View File

@ -8,24 +8,24 @@ export const constantRoutes: AuthRoute.Route[] = [
path: '/', path: '/',
redirect: '/dashboard/analysis', redirect: '/dashboard/analysis',
meta: { meta: {
title: 'Root' title: 'Root',
} },
}, },
{ {
name: 'login', name: 'login',
path: '/login', path: '/login',
component: 'self', component: 'self',
props: route => { props: (route) => {
const moduleType = (route.params.module as LoginModuleKey) || 'pwd-login'; const moduleType = (route.params.module as LoginModuleKey) || 'pwd-login';
return { return {
module: moduleType module: moduleType,
}; };
}, },
meta: { meta: {
title: '登录', title: '登录',
dynamicPath: `/login/:module(${getLoginModuleRegExp()})?`, dynamicPath: `/login/:module(${getLoginModuleRegExp()})?`,
singleLayout: 'blank' singleLayout: 'blank',
} },
}, },
{ {
name: 'no-permission', name: 'no-permission',
@ -33,8 +33,8 @@ export const constantRoutes: AuthRoute.Route[] = [
component: 'self', component: 'self',
meta: { meta: {
title: '无权限', title: '无权限',
singleLayout: 'blank' singleLayout: 'blank',
} },
}, },
{ {
name: 'not-found', name: 'not-found',
@ -42,8 +42,8 @@ export const constantRoutes: AuthRoute.Route[] = [
component: 'self', component: 'self',
meta: { meta: {
title: '未找到', title: '未找到',
singleLayout: 'blank' singleLayout: 'blank',
} },
}, },
{ {
name: 'service-error', name: 'service-error',
@ -51,8 +51,8 @@ export const constantRoutes: AuthRoute.Route[] = [
component: 'self', component: 'self',
meta: { meta: {
title: '服务器错误', title: '服务器错误',
singleLayout: 'blank' singleLayout: 'blank',
} },
}, },
// 匹配无效路径的路由 // 匹配无效路径的路由
{ {
@ -61,9 +61,9 @@ export const constantRoutes: AuthRoute.Route[] = [
component: 'blank', component: 'blank',
meta: { meta: {
title: '未找到', title: '未找到',
singleLayout: 'blank' singleLayout: 'blank',
} },
} },
]; ];
/** 路由名称 */ /** 路由名称 */

View File

@ -9,8 +9,8 @@ import { fetchUpdateToken } from '../api';
*/ */
export async function refreshToken(axiosConfig: AxiosRequestConfig) { export async function refreshToken(axiosConfig: AxiosRequestConfig) {
const { resetAuthStore } = useAuthStore(); const { resetAuthStore } = useAuthStore();
const refreshToken = getRefreshToken(); const rToken = getRefreshToken();
const { data } = await fetchUpdateToken(refreshToken); const { data } = await fetchUpdateToken(rToken);
if (data) { if (data) {
setToken(data.token); setToken(data.token);
setRefreshToken(data.refreshToken); setRefreshToken(data.refreshToken);

View File

@ -7,7 +7,7 @@ import {
handleAxiosError, handleAxiosError,
handleResponseError, handleResponseError,
handleBackendError, handleBackendError,
handleServiceResult handleServiceResult,
} from '@/utils'; } from '@/utils';
import { refreshToken } from './helpers'; import { refreshToken } from './helpers';
@ -31,7 +31,7 @@ export default class CustomAxiosInstance {
codeKey: 'code', codeKey: 'code',
dataKey: 'data', dataKey: 'data',
msgKey: 'message', msgKey: 'message',
successCode: 200 successCode: 200,
} }
) { ) {
this.backendConfig = backendConfig; this.backendConfig = backendConfig;
@ -42,7 +42,7 @@ export default class CustomAxiosInstance {
/** 设置请求拦截器 */ /** 设置请求拦截器 */
setInterceptor() { setInterceptor() {
this.instance.interceptors.request.use( this.instance.interceptors.request.use(
async config => { async (config) => {
const handleConfig = { ...config }; const handleConfig = { ...config };
if (handleConfig.headers) { if (handleConfig.headers) {
// 数据转换 // 数据转换
@ -59,7 +59,7 @@ export default class CustomAxiosInstance {
} }
); );
this.instance.interceptors.response.use( this.instance.interceptors.response.use(
async response => { async (response) => {
const { status } = response; const { status } = response;
if (status === 200 || status < 300 || status === 304) { if (status === 200 || status < 300 || status === 304) {
const backend = response.data; const backend = response.data;

View File

@ -85,7 +85,7 @@ export function createRequest(axiosConfig: AxiosRequestConfig, backendConfig?: S
get, get,
post, post,
put, put,
delete: handleDelete delete: handleDelete,
}; };
} }
@ -138,7 +138,7 @@ export function createHookRequest(axiosConfig: AxiosRequestConfig, backendConfig
data, data,
error, error,
loading, loading,
network network,
}; };
} }
@ -183,7 +183,7 @@ export function createHookRequest(axiosConfig: AxiosRequestConfig, backendConfig
get, get,
post, post,
put, put,
delete: handleDelete delete: handleDelete,
}; };
} }

View File

@ -13,8 +13,8 @@ interface TraditionColor {
export const traditionColors = colorJson as TraditionColor[]; export const traditionColors = colorJson as TraditionColor[];
export function isInTraditionColors(color: string) { export function isInTraditionColors(color: string) {
return traditionColors.some(item => { return traditionColors.some((item) => {
const flag = item.data.some(v => v.color === color); const flag = item.data.some((v) => v.color === color);
return flag; return flag;
}); });
} }

View File

@ -26,7 +26,7 @@ const themeColorList = [
'#ffb300', '#ffb300',
'#fdd835', '#fdd835',
'#6d4c41', '#6d4c41',
'#546e7a' '#546e7a',
]; ];
const defaultThemeSetting: ThemeSetting = { const defaultThemeSetting: ThemeSetting = {
@ -38,8 +38,8 @@ const defaultThemeSetting: ThemeSetting = {
{ value: 'vertical', label: EnumThemeLayoutMode.vertical }, { value: 'vertical', label: EnumThemeLayoutMode.vertical },
{ value: 'vertical-mix', label: EnumThemeLayoutMode['vertical-mix'] }, { value: 'vertical-mix', label: EnumThemeLayoutMode['vertical-mix'] },
{ value: 'horizontal', label: EnumThemeLayoutMode.horizontal }, { value: 'horizontal', label: EnumThemeLayoutMode.horizontal },
{ value: 'horizontal-mix', label: EnumThemeLayoutMode['horizontal-mix'] } { value: 'horizontal-mix', label: EnumThemeLayoutMode['horizontal-mix'] },
] ],
}, },
themeColor: themeColorList[0], themeColor: themeColorList[0],
themeColorList, themeColorList,
@ -47,7 +47,7 @@ const defaultThemeSetting: ThemeSetting = {
info: '#2080f0', info: '#2080f0',
success: '#52c41a', success: '#52c41a',
warning: '#faad14', warning: '#faad14',
error: '#f5222d' error: '#f5222d',
}, },
isCustomizeInfoColor: false, isCustomizeInfoColor: false,
fixedHeaderAndTab: true, fixedHeaderAndTab: true,
@ -56,8 +56,8 @@ const defaultThemeSetting: ThemeSetting = {
height: 56, height: 56,
crumb: { crumb: {
visible: true, visible: true,
showIcon: true showIcon: true,
} },
}, },
tab: { tab: {
visible: true, visible: true,
@ -65,28 +65,28 @@ const defaultThemeSetting: ThemeSetting = {
mode: 'chrome', mode: 'chrome',
modeList: [ modeList: [
{ value: 'chrome', label: EnumThemeTabMode.chrome }, { value: 'chrome', label: EnumThemeTabMode.chrome },
{ value: 'button', label: EnumThemeTabMode.button } { value: 'button', label: EnumThemeTabMode.button },
], ],
isCache: true isCache: true,
}, },
sider: { sider: {
width: 220, width: 220,
collapsedWidth: 64, collapsedWidth: 64,
mixWidth: 80, mixWidth: 80,
mixCollapsedWidth: 48, mixCollapsedWidth: 48,
mixChildMenuWidth: 200 mixChildMenuWidth: 200,
}, },
menu: { menu: {
horizontalPosition: 'flex-start', horizontalPosition: 'flex-start',
horizontalPositionList: [ horizontalPositionList: [
{ value: 'flex-start', label: EnumThemeHorizontalMenuPosition['flex-start'] }, { value: 'flex-start', label: EnumThemeHorizontalMenuPosition['flex-start'] },
{ value: 'center', label: EnumThemeHorizontalMenuPosition.center }, { value: 'center', label: EnumThemeHorizontalMenuPosition.center },
{ value: 'flex-end', label: EnumThemeHorizontalMenuPosition['flex-end'] } { value: 'flex-end', label: EnumThemeHorizontalMenuPosition['flex-end'] },
] ],
}, },
footer: { footer: {
fixed: false, fixed: false,
height: 48 height: 48,
}, },
page: { page: {
animate: true, animate: true,
@ -97,9 +97,9 @@ const defaultThemeSetting: ThemeSetting = {
{ value: 'fade-bottom', label: EnumThemeAnimateMode['fade-bottom'] }, { value: 'fade-bottom', label: EnumThemeAnimateMode['fade-bottom'] },
{ value: 'fade-scale', label: EnumThemeAnimateMode['fade-scale'] }, { value: 'fade-scale', label: EnumThemeAnimateMode['fade-scale'] },
{ value: 'zoom-fade', label: EnumThemeAnimateMode['zoom-fade'] }, { value: 'zoom-fade', label: EnumThemeAnimateMode['zoom-fade'] },
{ value: 'zoom-out', label: EnumThemeAnimateMode['zoom-out'] } { value: 'zoom-out', label: EnumThemeAnimateMode['zoom-out'] },
] ],
} },
}; };
export const themeSetting = (jsonSetting as ThemeSetting) || defaultThemeSetting; export const themeSetting = (jsonSetting as ThemeSetting) || defaultThemeSetting;

View File

@ -17,7 +17,7 @@ export const useAppStore = defineStore('app-store', {
reloadFlag: true, reloadFlag: true,
settingDrawerVisible: false, settingDrawerVisible: false,
siderCollapse: false, siderCollapse: false,
mixSiderFixed: false mixSiderFixed: false,
}), }),
actions: { actions: {
/** /**
@ -65,6 +65,6 @@ export const useAppStore = defineStore('app-store', {
/** 设置 vertical-mix模式下 侧边栏的固定状态 */ /** 设置 vertical-mix模式下 侧边栏的固定状态 */
toggleMixSiderFixed() { toggleMixSiderFixed() {
this.mixSiderFixed = !this.mixSiderFixed; this.mixSiderFixed = !this.mixSiderFixed;
} },
} },
}); });

View File

@ -18,13 +18,13 @@ export const useAuthStore = defineStore('auth-store', {
state: (): AuthState => ({ state: (): AuthState => ({
userInfo: getUserInfo(), userInfo: getUserInfo(),
token: getToken(), token: getToken(),
loginLoding: false loginLoding: false,
}), }),
getters: { getters: {
/** 是否登录 */ /** 是否登录 */
isLogin(state) { isLogin(state) {
return Boolean(state.token); return Boolean(state.token);
} },
}, },
actions: { actions: {
/** 重置auth状态 */ /** 重置auth状态 */
@ -67,7 +67,7 @@ export const useAuthStore = defineStore('auth-store', {
window.$notification?.success({ window.$notification?.success({
title: '登录成功!', title: '登录成功!',
content: `欢迎回来,${data.userName}!`, content: `欢迎回来,${data.userName}!`,
duration: 3000 duration: 3000,
}); });
} else { } else {
// 不成功则重置状态 // 不成功则重置状态
@ -87,6 +87,6 @@ export const useAuthStore = defineStore('auth-store', {
await this.loginByToken(data); await this.loginByToken(data);
} }
this.loginLoding = false; this.loginLoding = false;
} },
} },
}); });

View File

@ -6,7 +6,7 @@ import {
transformAuthRouteToMenu, transformAuthRouteToMenu,
transformAuthRoutesToVueRoutes, transformAuthRoutesToVueRoutes,
transformAuthRoutesToSearchMenus, transformAuthRoutesToSearchMenus,
getCacheRoutes getCacheRoutes,
} from '@/utils'; } from '@/utils';
import type { GlobalMenuOption, SearchMenu } from '@/interface'; import type { GlobalMenuOption, SearchMenu } from '@/interface';
import { useTabStore } from '../tab'; import { useTabStore } from '../tab';
@ -30,7 +30,7 @@ export const useRouteStore = defineStore('route-store', {
routeHomeName: 'dashboard_analysis', routeHomeName: 'dashboard_analysis',
menus: [], menus: [],
searchMenus: [], searchMenus: [],
cacheRoutes: [] cacheRoutes: [],
}), }),
actions: { actions: {
/** /**
@ -49,7 +49,7 @@ export const useRouteStore = defineStore('route-store', {
this.searchMenus = transformAuthRoutesToSearchMenus(data.routes); this.searchMenus = transformAuthRoutesToSearchMenus(data.routes);
const vueRoutes = transformAuthRoutesToVueRoutes(data.routes); const vueRoutes = transformAuthRoutesToVueRoutes(data.routes);
vueRoutes.forEach(route => { vueRoutes.forEach((route) => {
router.addRoute(route); router.addRoute(route);
}); });
@ -58,6 +58,6 @@ export const useRouteStore = defineStore('route-store', {
initHomeTab(data.home, router); initHomeTab(data.home, router);
this.isAddedDynamicRoute = true; this.isAddedDynamicRoute = true;
} }
} },
} },
}); });

View File

@ -12,8 +12,8 @@ export function getTabRouteByVueRoute(route: RouteRecordNormalized | RouteLocati
meta: route.meta, meta: route.meta,
scrollPosition: { scrollPosition: {
left: 0, left: 0,
top: 0 top: 0,
} },
}; };
return tabRoute; return tabRoute;
} }
@ -24,7 +24,7 @@ export function getTabRouteByVueRoute(route: RouteRecordNormalized | RouteLocati
* @param path - * @param path -
*/ */
export function getIndexInTabRoutes(tabs: GlobalTabRoute[], path: string) { export function getIndexInTabRoutes(tabs: GlobalTabRoute[], path: string) {
return tabs.findIndex(tab => tab.path === path); return tabs.findIndex((tab) => tab.path === path);
} }
/** /**

View File

@ -22,21 +22,21 @@ export const useTabStore = defineStore('tab-store', {
name: 'root', name: 'root',
path: '/', path: '/',
meta: { meta: {
title: 'root' title: 'root',
}, },
scrollPosition: { scrollPosition: {
left: 0, left: 0,
top: 0 top: 0,
} },
}, },
activeTab: '' activeTab: '',
}), }),
getters: { getters: {
/** 当前激活状态的页签索引 */ /** 当前激活状态的页签索引 */
activeTabIndex(state) { activeTabIndex(state) {
const { tabs, activeTab } = state; const { tabs, activeTab } = state;
return tabs.findIndex(tab => tab.path === activeTab); return tabs.findIndex((tab) => tab.path === activeTab);
} },
}, },
actions: { actions: {
/** /**
@ -53,7 +53,7 @@ export const useTabStore = defineStore('tab-store', {
*/ */
initHomeTab(routeHomeName: string, router: Router) { initHomeTab(routeHomeName: string, router: Router) {
const routes = router.getRoutes(); const routes = router.getRoutes();
const findHome = routes.find(item => item.name === routeHomeName); const findHome = routes.find((item) => item.name === routeHomeName);
if (findHome) { if (findHome) {
this.homeTab = getTabRouteByVueRoute(findHome); this.homeTab = getTabRouteByVueRoute(findHome);
} }
@ -75,7 +75,7 @@ export const useTabStore = defineStore('tab-store', {
const { routerPush } = useRouterPush(false); const { routerPush } = useRouterPush(false);
const isActive = this.activeTab === path; const isActive = this.activeTab === path;
const updateTabs = this.tabs.filter(tab => tab.path !== path); const updateTabs = this.tabs.filter((tab) => tab.path !== path);
this.tabs = updateTabs; this.tabs = updateTabs;
if (isActive && updateTabs.length) { if (isActive && updateTabs.length) {
const activePath = updateTabs[updateTabs.length - 1].path; const activePath = updateTabs[updateTabs.length - 1].path;
@ -93,7 +93,7 @@ export const useTabStore = defineStore('tab-store', {
const homePath = this.homeTab.path; const homePath = this.homeTab.path;
const remain = [homePath, ...excludes]; const remain = [homePath, ...excludes];
const hasActive = remain.includes(this.activeTab); const hasActive = remain.includes(this.activeTab);
const updateTabs = this.tabs.filter(tab => remain.includes(tab.path)); const updateTabs = this.tabs.filter((tab) => remain.includes(tab.path));
this.tabs = updateTabs; this.tabs = updateTabs;
if (!hasActive && updateTabs.length) { if (!hasActive && updateTabs.length) {
const activePath = updateTabs[updateTabs.length - 1].path; const activePath = updateTabs[updateTabs.length - 1].path;
@ -108,7 +108,7 @@ export const useTabStore = defineStore('tab-store', {
clearLeftTab(path: string) { clearLeftTab(path: string) {
const index = getIndexInTabRoutes(this.tabs, path); const index = getIndexInTabRoutes(this.tabs, path);
if (index > -1) { if (index > -1) {
const excludes = this.tabs.slice(index).map(item => item.path); const excludes = this.tabs.slice(index).map((item) => item.path);
this.clearTab(excludes); this.clearTab(excludes);
} }
}, },
@ -119,7 +119,7 @@ export const useTabStore = defineStore('tab-store', {
clearRightTab(path: string) { clearRightTab(path: string) {
const index = getIndexInTabRoutes(this.tabs, path); const index = getIndexInTabRoutes(this.tabs, path);
if (index > -1) { if (index > -1) {
const excludes = this.tabs.slice(0, index + 1).map(item => item.path); const excludes = this.tabs.slice(0, index + 1).map((item) => item.path);
this.clearTab(excludes); this.clearTab(excludes);
} }
}, },
@ -154,7 +154,7 @@ export const useTabStore = defineStore('tab-store', {
getTabScrollPosition(path: string) { getTabScrollPosition(path: string) {
const position = { const position = {
left: 0, left: 0,
top: 0 top: 0,
}; };
const index = getIndexInTabRoutes(this.tabs, path); const index = getIndexInTabRoutes(this.tabs, path);
if (index > -1) { if (index > -1) {
@ -178,6 +178,6 @@ export const useTabStore = defineStore('tab-store', {
} }
this.tabs = tabs; this.tabs = tabs;
this.setActiveTab(currentRoute.path); this.setActiveTab(currentRoute.path);
} },
} },
}); });

View File

@ -26,17 +26,17 @@ interface ColorAction {
/** 获取主题颜色的各种场景对应的颜色 */ /** 获取主题颜色的各种场景对应的颜色 */
function getThemeColors(colors: [ColorType, string][]) { function getThemeColors(colors: [ColorType, string][]) {
const colorActions: ColorAction[] = [ const colorActions: ColorAction[] = [
{ scene: '', handler: color => color }, { scene: '', handler: (color) => color },
{ scene: 'Suppl', handler: color => color }, { scene: 'Suppl', handler: (color) => color },
{ scene: 'Hover', handler: color => getColorPalette(color, 5) }, { scene: 'Hover', handler: (color) => getColorPalette(color, 5) },
{ scene: 'Pressed', handler: color => getColorPalette(color, 7) }, { scene: 'Pressed', handler: (color) => getColorPalette(color, 7) },
{ scene: 'Active', handler: color => addColorAlpha(color, 0.1) } { scene: 'Active', handler: (color) => addColorAlpha(color, 0.1) },
]; ];
const themeColor: ThemeColor = {}; const themeColor: ThemeColor = {};
colors.forEach(color => { colors.forEach((color) => {
colorActions.forEach(action => { colorActions.forEach((action) => {
const [colorType, colorValue] = color; const [colorType, colorValue] = color;
const colorKey: ColorKey = `${colorType}Color${action.scene}`; const colorKey: ColorKey = `${colorType}Color${action.scene}`;
themeColor[colorKey] = action.handler(colorValue); themeColor[colorKey] = action.handler(colorValue);
@ -57,18 +57,18 @@ export function getNaiveThemeOverrides(colors: Record<ColorType, string>): Globa
['info', info], ['info', info],
['success', success], ['success', success],
['warning', warning], ['warning', warning],
['error', error] ['error', error],
]); ]);
const colorLoading = primary; const colorLoading = primary;
return { return {
common: { common: {
...themeColors ...themeColors,
}, },
LoadingBar: { LoadingBar: {
colorLoading colorLoading,
} },
}; };
} }
@ -79,7 +79,7 @@ type ThemeVarsKeys = keyof ThemeVars;
export function addThemeCssVarsToHtml(themeVars: ThemeVars) { export function addThemeCssVarsToHtml(themeVars: ThemeVars) {
const keys = Object.keys(themeVars) as ThemeVarsKeys[]; const keys = Object.keys(themeVars) as ThemeVarsKeys[];
const style: string[] = []; const style: string[] = [];
keys.forEach(key => { keys.forEach((key) => {
style.push(`--${kebabCase(key)}: ${themeVars[key]}`); style.push(`--${kebabCase(key)}: ${themeVars[key]}`);
}); });
const styleStr = style.join(';'); const styleStr = style.join(';');
@ -97,6 +97,6 @@ export function handleWindicssDarkMode() {
} }
return { return {
addDarkClass, addDarkClass,
removeDarkClass removeDarkClass,
}; };
} }

View File

@ -5,7 +5,7 @@ import type {
ThemeLayoutMode, ThemeLayoutMode,
ThemeTabMode, ThemeTabMode,
ThemeHorizontalMenuPosition, ThemeHorizontalMenuPosition,
ThemeAnimateMode ThemeAnimateMode,
} from '@/interface'; } from '@/interface';
import { getThemeSettings, getNaiveThemeOverrides, addThemeCssVarsToHtml } from './helpers'; import { getThemeSettings, getNaiveThemeOverrides, addThemeCssVarsToHtml } from './helpers';
@ -17,13 +17,15 @@ export const useThemeStore = defineStore('theme-store', {
/** naiveUI的主题配置 */ /** naiveUI的主题配置 */
naiveThemeOverrides(state) { naiveThemeOverrides(state) {
const overrides = getNaiveThemeOverrides({ primary: state.themeColor, ...state.otherColor }); const overrides = getNaiveThemeOverrides({ primary: state.themeColor, ...state.otherColor });
addThemeCssVarsToHtml(overrides.common!); if (overrides.common) {
addThemeCssVarsToHtml(overrides.common);
}
return overrides; return overrides;
}, },
/** naive-ui暗黑主题 */ /** naive-ui暗黑主题 */
naiveTheme(state) { naiveTheme(state) {
return state.darkMode ? darkTheme : undefined; return state.darkMode ? darkTheme : undefined;
} },
}, },
actions: { actions: {
/** 重置theme状态 */ /** 重置theme状态 */
@ -133,6 +135,6 @@ export const useThemeStore = defineStore('theme-store', {
/** 设置页面过渡动画类型 */ /** 设置页面过渡动画类型 */
setPageAnimateMode(mode: ThemeAnimateMode) { setPageAnimateMode(mode: ThemeAnimateMode) {
this.page.animateMode = mode; this.page.animateMode = mode;
} },
} },
}); });

View File

@ -10,7 +10,7 @@ export default function subscribeAppStore() {
// 弹窗打开时禁止滚动条 // 弹窗打开时禁止滚动条
const stopHandle = watch( const stopHandle = watch(
() => app.settingDrawerVisible, () => app.settingDrawerVisible,
newValue => { (newValue) => {
scrollBodyHandler(newValue); scrollBodyHandler(newValue);
} }
); );

View File

@ -13,7 +13,7 @@ export default function subscribeThemeStore() {
const stopThemeColor = watch( const stopThemeColor = watch(
() => theme.themeColor, () => theme.themeColor,
newValue => { (newValue) => {
setThemeColor(newValue); setThemeColor(newValue);
}, },
{ immediate: true } { immediate: true }
@ -22,7 +22,7 @@ export default function subscribeThemeStore() {
// 监听暗黑模式 // 监听暗黑模式
const stopDarkMode = watch( const stopDarkMode = watch(
() => theme.darkMode, () => theme.darkMode,
newValue => { (newValue) => {
if (newValue) { if (newValue) {
addDarkClass(); addDarkClass();
} else { } else {
@ -34,7 +34,7 @@ export default function subscribeThemeStore() {
// 监听操作系统主题模式 // 监听操作系统主题模式
const stopOsTheme = watch( const stopOsTheme = watch(
osTheme, osTheme,
newValue => { (newValue) => {
const isDark = newValue === 'dark'; const isDark = newValue === 'dark';
theme.setDarkMode(isDark); theme.setDarkMode(isDark);
}, },
@ -42,7 +42,7 @@ export default function subscribeThemeStore() {
); );
// 禁用横向滚动(页面切换时,过渡动画会产生水平方向的滚动条, 小于最小宽度时,不禁止) // 禁用横向滚动(页面切换时,过渡动画会产生水平方向的滚动条, 小于最小宽度时,不禁止)
const stopWidth = watch(width, newValue => { const stopWidth = watch(width, (newValue) => {
if (newValue < theme.layout.minWidth) { if (newValue < theme.layout.minWidth) {
document.documentElement.style.overflowX = 'auto'; document.documentElement.style.overflowX = 'auto';
} else { } else {
@ -69,6 +69,6 @@ function handleWindicssDarkMode() {
} }
return { return {
addDarkClass, addDarkClass,
removeDarkClass removeDarkClass,
}; };
} }

View File

@ -3,7 +3,7 @@
declare module '*.vue' { declare module '*.vue' {
import { DefineComponent } from 'vue'; import { DefineComponent } from 'vue';
const component: DefineComponent<{}, {}, any>; const component: DefineComponent<object, object, any>;
export default component; export default component;
} }

View File

@ -136,11 +136,12 @@ declare namespace AuthRoute {
| `${Path}/:module(${string})?`; | `${Path}/:module(${string})?`;
/** 获取一级路由(包括有子路由的一级路由) */ /** 获取一级路由(包括有子路由的一级路由) */
type GetSingleRouteKey<Key extends RouteKey> = type GetSingleRouteKey<Key extends RouteKey> = Key extends `${infer _Left}${RouteSplitMark}${infer _Right}`
Key extends `${infer IgnoredLeft}${RouteSplitMark}${infer IgnoredRight}` ? never : Key; ? never
: Key;
/** 获取子路由的一级父路由 */ /** 获取子路由的一级父路由 */
type GetRouteFirstParentKey<Key extends RouteKey> = Key extends `${infer Left}${RouteSplitMark}${infer IgnoredRight}` type GetRouteFirstParentKey<Key extends RouteKey> = Key extends `${infer Left}${RouteSplitMark}${infer _Right}`
? Left ? Left
: never; : never;
} }

View File

@ -2,7 +2,7 @@ import type {
LoadingBarProviderInst, LoadingBarProviderInst,
DialogProviderInst, DialogProviderInst,
MessageProviderInst, MessageProviderInst,
NotificationProviderInst NotificationProviderInst,
} from 'naive-ui'; } from 'naive-ui';
declare global { declare global {

View File

@ -37,7 +37,7 @@ export function getUserInfo() {
userId: '', userId: '',
userName: '', userName: '',
userPhone: '', userPhone: '',
userRole: 'visitor' userRole: 'visitor',
}; };
const userInfo: Auth.UserInfo = getLocal<Auth.UserInfo>(EnumStorageKey['user-info']) || emptyInfo; const userInfo: Auth.UserInfo = getLocal<Auth.UserInfo>(EnumStorageKey['user-info']) || emptyInfo;
return userInfo; return userInfo;

View File

@ -30,7 +30,7 @@ export function getColorPalette(color: string, index: ColorIndex) {
const newHsv: HsvColor = { const newHsv: HsvColor = {
h: getHue(hsv, i, isLight), h: getHue(hsv, i, isLight),
s: getSaturation(hsv, i, isLight), s: getSaturation(hsv, i, isLight),
v: getValue(hsv, i, isLight) v: getValue(hsv, i, isLight),
}; };
return colord(newHsv).toHex(); return colord(newHsv).toHex();
@ -42,7 +42,7 @@ export function getColorPalette(color: string, index: ColorIndex) {
*/ */
export function getAllColorPalette(color: string) { export function getAllColorPalette(color: string) {
const indexs: ColorIndex[] = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; const indexs: ColorIndex[] = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
return indexs.map(index => getColorPalette(color, index)); return indexs.map((index) => getColorPalette(color, index));
} }
/** /**

View File

@ -1,6 +1,6 @@
/** 执行策略模式 */ /** 执行策略模式 */
export function exeStrategyActions(actions: Common.StrategyAction[]) { export function exeStrategyActions(actions: Common.StrategyAction[]) {
actions.some(item => { actions.some((item) => {
const [flag, action] = item; const [flag, action] = item;
if (flag) { if (flag) {
action(); action();

View File

@ -27,7 +27,7 @@ export function transformToTimeCountDown(seconds: number) {
* @param start - * @param start -
* @param end - * @param end -
*/ */
export function getRandomInterger(end: number, start: number = 0) { export function getRandomInterger(end: number, start = 0) {
const range = end - start; const range = end - start;
const random = Math.floor(Math.random() * range + start); const random = Math.floor(Math.random() * range + start);
return random; return random;

View File

@ -18,17 +18,17 @@ interface CustomFormRules {
export const formRules: CustomFormRules = { export const formRules: CustomFormRules = {
phone: [ phone: [
{ required: true, message: '请输入手机号码' }, { required: true, message: '请输入手机号码' },
{ pattern: REGEXP_PHONE, message: '手机号码格式错误', trigger: 'input' } { pattern: REGEXP_PHONE, message: '手机号码格式错误', trigger: 'input' },
], ],
pwd: [ pwd: [
{ required: true, message: '请输入密码' }, { required: true, message: '请输入密码' },
{ pattern: REGEXP_PWD, message: '密码为8-18位数字/字符/符号至少2种组合', trigger: 'input' } { pattern: REGEXP_PWD, message: '密码为8-18位数字/字符/符号至少2种组合', trigger: 'input' },
], ],
code: [ code: [
{ required: true, message: '请输入验证码' }, { required: true, message: '请输入验证码' },
{ pattern: REGEXP_CODE_SIX, message: '验证码格式错误', trigger: 'input' } { pattern: REGEXP_CODE_SIX, message: '验证码格式错误', trigger: 'input' },
], ],
email: [{ pattern: REGEXP_EMAIL, message: '邮箱格式错误', trigger: 'blur' }] email: [{ pattern: REGEXP_EMAIL, message: '邮箱格式错误', trigger: 'blur' }],
}; };
/** 获取确认密码的表单规则 */ /** 获取确认密码的表单规则 */
@ -43,8 +43,8 @@ export function getConfirmPwdRule(pwd: Ref<string>) {
return Promise.resolve(); return Promise.resolve();
}, },
message: '输入的值与密码不一致', message: '输入的值与密码不一致',
trigger: 'input' trigger: 'input',
} },
]; ];
return confirmPwdRule; return confirmPwdRule;
} }
@ -61,8 +61,8 @@ export function getImgCodeRule(imgCode: Ref<string>) {
return Promise.resolve(); return Promise.resolve();
}, },
message: '验证码不正确', message: '验证码不正确',
trigger: 'blur' trigger: 'blur',
} },
]; ];
return imgCodeRule; return imgCodeRule;
} }

View File

@ -8,7 +8,7 @@ import type { GlobalMenuOption, GlobalBreadcrumb } from '@/interface';
*/ */
export function getBreadcrumbByRouteKey(activeKey: string, menus: GlobalMenuOption[], rootPath: string) { export function getBreadcrumbByRouteKey(activeKey: string, menus: GlobalMenuOption[], rootPath: string) {
const breadcrumbMenu = getBreadcrumbMenu(activeKey, menus); const breadcrumbMenu = getBreadcrumbMenu(activeKey, menus);
const breadcrumb = breadcrumbMenu.map(item => transformBreadcrumbMenuToBreadcrumb(item, rootPath)); const breadcrumb = breadcrumbMenu.map((item) => transformBreadcrumbMenuToBreadcrumb(item, rootPath));
return breadcrumb; return breadcrumb;
} }
@ -19,7 +19,7 @@ export function getBreadcrumbByRouteKey(activeKey: string, menus: GlobalMenuOpti
*/ */
function getBreadcrumbMenu(activeKey: string, menus: GlobalMenuOption[]) { function getBreadcrumbMenu(activeKey: string, menus: GlobalMenuOption[]) {
const breadcrumbMenu: GlobalMenuOption[] = []; const breadcrumbMenu: GlobalMenuOption[] = [];
menus.some(menu => { menus.some((menu) => {
const flag = activeKey.includes(menu.routeName); const flag = activeKey.includes(menu.routeName);
if (flag) { if (flag) {
breadcrumbMenu.push(...getBreadcrumbMenuItem(activeKey, menu)); breadcrumbMenu.push(...getBreadcrumbMenuItem(activeKey, menu));
@ -42,7 +42,7 @@ function getBreadcrumbMenuItem(activeKey: string, menu: GlobalMenuOption) {
if (activeKey.includes(menu.routeName) && menu.children && menu.children.length) { if (activeKey.includes(menu.routeName) && menu.children && menu.children.length) {
breadcrumbMenu.push(menu); breadcrumbMenu.push(menu);
breadcrumbMenu.push( breadcrumbMenu.push(
...menu.children.map(item => getBreadcrumbMenuItem(activeKey, item as GlobalMenuOption)).flat(1) ...menu.children.map((item) => getBreadcrumbMenuItem(activeKey, item as GlobalMenuOption)).flat(1)
); );
} }
@ -61,13 +61,13 @@ function transformBreadcrumbMenuToBreadcrumb(menu: GlobalMenuOption, rootPath: s
label: menu.label as string, label: menu.label as string,
routeName: menu.routeName, routeName: menu.routeName,
disabled: menu.routePath === rootPath, disabled: menu.routePath === rootPath,
hasChildren hasChildren,
}; };
if (menu.icon) { if (menu.icon) {
breadcrumb.icon = menu.icon; breadcrumb.icon = menu.icon;
} }
if (hasChildren) { if (hasChildren) {
breadcrumb.children = menu.children?.map(item => breadcrumb.children = menu.children?.map((item) =>
transformBreadcrumbMenuToBreadcrumb(item as GlobalMenuOption, rootPath) transformBreadcrumbMenuToBreadcrumb(item as GlobalMenuOption, rootPath)
); );
} }

View File

@ -6,10 +6,10 @@ import type { RouteRecordRaw } from 'vue-router';
*/ */
export function getCacheRoutes(routes: RouteRecordRaw[]) { export function getCacheRoutes(routes: RouteRecordRaw[]) {
const cacheNames: string[] = []; const cacheNames: string[] = [];
routes.forEach(route => { routes.forEach((route) => {
// 只需要获取二级路由的缓存的组件名 // 只需要获取二级路由的缓存的组件名
if (hasChildren(route)) { if (hasChildren(route)) {
route.children!.forEach(item => { (route.children as RouteRecordRaw[]).forEach((item) => {
if (isKeepAlive(item)) { if (isKeepAlive(item)) {
cacheNames.push(item.name as string); cacheNames.push(item.name as string);
} }

View File

@ -13,7 +13,7 @@ type LayoutComponent = Record<LayoutComponentName, () => Promise<Component>>;
export function getLayoutComponent(layoutType: LayoutComponentName) { export function getLayoutComponent(layoutType: LayoutComponentName) {
const layoutComponent: LayoutComponent = { const layoutComponent: LayoutComponent = {
basic: BasicLayout, basic: BasicLayout,
blank: BlankLayout blank: BlankLayout,
}; };
return () => setViewComponentName(layoutComponent[layoutType], EnumLayoutComponentName[layoutType]); return () => setViewComponentName(layoutComponent[layoutType], EnumLayoutComponentName[layoutType]);
} }

View File

@ -10,7 +10,7 @@ type ComponentAction = Record<AuthRoute.RouteComponent, () => void>;
* @description * @description
*/ */
export function transformAuthRoutesToVueRoutes(routes: AuthRoute.Route[]) { export function transformAuthRoutesToVueRoutes(routes: AuthRoute.Route[]) {
return routes.map(route => transformAuthRouteToVueRoute(route)).flat(1); return routes.map((route) => transformAuthRouteToVueRoute(route)).flat(1);
} }
/** /**
@ -70,10 +70,14 @@ function transformAuthRouteToVueRoute(item: AuthRoute.Route) {
}, },
self() { self() {
itemRoute.component = getViewComponent(item.name); itemRoute.component = getViewComponent(item.name);
} },
}; };
try { try {
action[item.component!](); if (item.component) {
action[item.component]();
} else {
consoleError('路由组件解析失败: ', item);
}
} catch { } catch {
consoleError('路由组件解析失败: ', item); consoleError('路由组件解析失败: ', item);
} }
@ -91,8 +95,8 @@ function transformAuthRouteToVueRoute(item: AuthRoute.Route) {
{ {
path: '', path: '',
name: item.name, name: item.name,
component: getViewComponent('not-found-page') component: getViewComponent('not-found-page'),
} },
]; ];
} else { } else {
const parentPath = `${itemRoute.path}-parent` as AuthRoute.SingleRouteParentPath; const parentPath = `${itemRoute.path}-parent` as AuthRoute.SingleRouteParentPath;
@ -103,7 +107,7 @@ function transformAuthRouteToVueRoute(item: AuthRoute.Route) {
path: parentPath, path: parentPath,
component: layout, component: layout,
redirect: item.path, redirect: item.path,
children: [itemRoute] children: [itemRoute],
}; };
return [parentRoute]; return [parentRoute];
@ -112,10 +116,10 @@ function transformAuthRouteToVueRoute(item: AuthRoute.Route) {
// 子路由 // 子路由
if (hasChildren(item)) { if (hasChildren(item)) {
const children = item.children!.map(child => transformAuthRouteToVueRoute(child)).flat(); const children = (item.children as AuthRoute.Route[]).map((child) => transformAuthRouteToVueRoute(child)).flat();
// 找出第一个不为多级路由中间级的子路由路径作为重定向路径 // 找出第一个不为多级路由中间级的子路由路径作为重定向路径
const redirectPath: AuthRoute.RoutePath = (children.find(item => !item.meta?.multi)?.path || const redirectPath: AuthRoute.RoutePath = (children.find((v) => !v.meta?.multi)?.path ||
'/') as AuthRoute.RoutePath; '/') as AuthRoute.RoutePath;
if (redirectPath === '/') { if (redirectPath === '/') {
consoleError('该多级路由没有有效的子路径', item); consoleError('该多级路由没有有效的子路径', item);

View File

@ -24,7 +24,7 @@ function addPartialProps(menuItem: GlobalMenuOption, icon?: string, children?: G
*/ */
export function transformAuthRouteToMenu(routes: AuthRoute.Route[]): GlobalMenuOption[] { export function transformAuthRouteToMenu(routes: AuthRoute.Route[]): GlobalMenuOption[] {
const globalMenu: GlobalMenuOption[] = []; const globalMenu: GlobalMenuOption[] = [];
routes.forEach(route => { routes.forEach((route) => {
const { name, path, meta } = route; const { name, path, meta } = route;
const routeName = name as string; const routeName = name as string;
let menuChildren: GlobalMenuOption[] | undefined; let menuChildren: GlobalMenuOption[] | undefined;
@ -36,7 +36,7 @@ export function transformAuthRouteToMenu(routes: AuthRoute.Route[]): GlobalMenuO
key: routeName, key: routeName,
label: meta.title, label: meta.title,
routeName, routeName,
routePath: path routePath: path,
}, },
meta?.icon, meta?.icon,
menuChildren menuChildren
@ -56,7 +56,7 @@ export function transformAuthRouteToMenu(routes: AuthRoute.Route[]): GlobalMenuO
* @param menus - * @param menus -
*/ */
export function getActiveKeyPathsOfMenus(activeKey: string, menus: GlobalMenuOption[]) { export function getActiveKeyPathsOfMenus(activeKey: string, menus: GlobalMenuOption[]) {
const keys = menus.map(menu => getActiveKeyPathsOfMenu(activeKey, menu)).flat(1); const keys = menus.map((menu) => getActiveKeyPathsOfMenu(activeKey, menu)).flat(1);
return keys; return keys;
} }
@ -66,7 +66,7 @@ function getActiveKeyPathsOfMenu(activeKey: string, menu: GlobalMenuOption) {
keys.push(menu.routeName); keys.push(menu.routeName);
} }
if (menu.children) { if (menu.children) {
keys.push(...menu.children.map(item => getActiveKeyPathsOfMenu(activeKey, item)).flat(1)); keys.push(...menu.children.map((item) => getActiveKeyPathsOfMenu(activeKey, item)).flat(1));
} }
return keys; return keys;
} }

View File

@ -12,12 +12,12 @@ export function getTabRoutes() {
const routes: GlobalTabRoute[] = []; const routes: GlobalTabRoute[] = [];
const data = getLocal<GlobalTabRoute[]>(EnumStorageKey['tab-routes']); const data = getLocal<GlobalTabRoute[]>(EnumStorageKey['tab-routes']);
if (data) { if (data) {
const defaultTabRoutes = data.map(item => ({ const defaultTabRoutes = data.map((item) => ({
...item, ...item,
scrollPosition: { scrollPosition: {
left: 0, left: 0,
top: 0 top: 0,
} },
})); }));
routes.push(...defaultTabRoutes); routes.push(...defaultTabRoutes);
} }

View File

@ -6,7 +6,7 @@ import {
NETWORK_ERROR_MSG, NETWORK_ERROR_MSG,
REQUEST_TIMEOUT_CODE, REQUEST_TIMEOUT_CODE,
REQUEST_TIMEOUT_MSG, REQUEST_TIMEOUT_MSG,
ERROR_STATUS ERROR_STATUS,
} from '@/config'; } from '@/config';
import { exeStrategyActions } from '../common'; import { exeStrategyActions } from '../common';
import { showErrorMsg } from './msg'; import { showErrorMsg } from './msg';
@ -21,7 +21,7 @@ export function handleAxiosError(axiosError: AxiosError) {
const error: Service.RequestError = { const error: Service.RequestError = {
type: 'axios', type: 'axios',
code: DEFAULT_REQUEST_ERROR_CODE, code: DEFAULT_REQUEST_ERROR_CODE,
msg: DEFAULT_REQUEST_ERROR_MSG msg: DEFAULT_REQUEST_ERROR_MSG,
}; };
const actions: Common.StrategyAction[] = [ const actions: Common.StrategyAction[] = [
@ -30,14 +30,14 @@ export function handleAxiosError(axiosError: AxiosError) {
!window.navigator.onLine || axiosError.message === 'Network Error', !window.navigator.onLine || axiosError.message === 'Network Error',
() => { () => {
Object.assign(error, { code: NETWORK_ERROR_CODE, msg: NETWORK_ERROR_MSG }); Object.assign(error, { code: NETWORK_ERROR_CODE, msg: NETWORK_ERROR_MSG });
} },
], ],
[ [
// 超时错误 // 超时错误
axiosError.code === REQUEST_TIMEOUT_CODE && axiosError.message.includes('timeout'), axiosError.code === REQUEST_TIMEOUT_CODE && axiosError.message.includes('timeout'),
() => { () => {
Object.assign(error, { code: REQUEST_TIMEOUT_CODE, msg: REQUEST_TIMEOUT_MSG }); Object.assign(error, { code: REQUEST_TIMEOUT_CODE, msg: REQUEST_TIMEOUT_MSG });
} },
], ],
[ [
// 请求不成功的错误 // 请求不成功的错误
@ -46,8 +46,8 @@ export function handleAxiosError(axiosError: AxiosError) {
const errorCode: ErrorStatus = (axiosError.response?.status as ErrorStatus) || 'DEFAULT'; const errorCode: ErrorStatus = (axiosError.response?.status as ErrorStatus) || 'DEFAULT';
const msg = ERROR_STATUS[errorCode]; const msg = ERROR_STATUS[errorCode];
Object.assign(error, { code: errorCode, msg }); Object.assign(error, { code: errorCode, msg });
} },
] ],
]; ];
exeStrategyActions(actions); exeStrategyActions(actions);
@ -65,7 +65,7 @@ export function handleResponseError(response: AxiosResponse) {
const error: Service.RequestError = { const error: Service.RequestError = {
type: 'axios', type: 'axios',
code: DEFAULT_REQUEST_ERROR_CODE, code: DEFAULT_REQUEST_ERROR_CODE,
msg: DEFAULT_REQUEST_ERROR_MSG msg: DEFAULT_REQUEST_ERROR_MSG,
}; };
if (!window.navigator.onLine) { if (!window.navigator.onLine) {
@ -92,7 +92,7 @@ export function handleBackendError(backendResult: Record<string, any>, config: S
const error: Service.RequestError = { const error: Service.RequestError = {
type: 'backend', type: 'backend',
code: backendResult[codeKey], code: backendResult[codeKey],
msg: backendResult[msgKey] msg: backendResult[msgKey],
}; };
showErrorMsg(error); showErrorMsg(error);

View File

@ -3,13 +3,13 @@ export async function handleServiceResult<T = any>(error: Service.RequestError |
if (error) { if (error) {
const fail: Service.FailedResult = { const fail: Service.FailedResult = {
error, error,
data: null data: null,
}; };
return fail; return fail;
} }
const success: Service.SuccessResult<T> = { const success: Service.SuccessResult<T> = {
error: null, error: null,
data data,
}; };
return success; return success;
} }

View File

@ -34,7 +34,7 @@ async function transformFile(file: File[] | File, key: string) {
if (isArray(file)) { if (isArray(file)) {
// 多文件 // 多文件
await Promise.all( await Promise.all(
(file as File[]).map(item => { (file as File[]).map((item) => {
formData.append(key, item); formData.append(key, item);
return true; return true;
}) })

View File

@ -27,13 +27,13 @@ function transformVersionData(tuple: [string, string]): PkgVersionInfo {
const [name, version] = tuple; const [name, version] = tuple;
return { return {
name, name,
version version,
}; };
} }
export const pkgJson: PkgJson = { export const pkgJson: PkgJson = {
name: pkgWithType.name, name: pkgWithType.name,
version: pkgWithType.version, version: pkgWithType.version,
dependencies: Object.entries(pkgWithType.dependencies).map(item => transformVersionData(item)), dependencies: Object.entries(pkgWithType.dependencies).map((item) => transformVersionData(item)),
devDependencies: Object.entries(pkgWithType.devDependencies).map(item => transformVersionData(item)) devDependencies: Object.entries(pkgWithType.devDependencies).map((item) => transformVersionData(item)),
}; };

View File

@ -63,40 +63,40 @@ const buttonExample: ButtonExample[] = [
{ {
id: 0, id: 0,
props: {}, props: {},
label: 'Default' label: 'Default',
}, },
{ {
id: 1, id: 1,
props: { type: 'tertiary' }, props: { type: 'tertiary' },
label: 'Tertiary' label: 'Tertiary',
}, },
{ {
id: 2, id: 2,
props: { type: 'primary' }, props: { type: 'primary' },
label: 'Primary' label: 'Primary',
}, },
{ {
id: 3, id: 3,
props: { type: 'info' }, props: { type: 'info' },
label: 'Info' label: 'Info',
}, },
{ {
id: 4, id: 4,
props: { type: 'success' }, props: { type: 'success' },
label: 'Success' label: 'Success',
}, },
{ {
id: 5, id: 5,
props: { type: 'warning' }, props: { type: 'warning' },
label: 'Warning' label: 'Warning',
}, },
{ {
id: 6, id: 6,
props: { type: 'error' }, props: { type: 'error' },
label: 'Error' label: 'Error',
} },
], ],
desc: '按钮的 type 分别为 default、primary、info、success、warning 和 error。' desc: '按钮的 type 分别为 default、primary、info、success、warning 和 error。',
}, },
{ {
id: 1, id: 1,
@ -105,74 +105,74 @@ const buttonExample: ButtonExample[] = [
{ {
id: 0, id: 0,
props: { strong: true, secondary: true }, props: { strong: true, secondary: true },
label: 'Default' label: 'Default',
}, },
{ {
id: 1, id: 1,
props: { strong: true, secondary: true, type: 'tertiary' }, props: { strong: true, secondary: true, type: 'tertiary' },
label: 'Tertiary' label: 'Tertiary',
}, },
{ {
id: 2, id: 2,
props: { strong: true, secondary: true, type: 'primary' }, props: { strong: true, secondary: true, type: 'primary' },
label: 'Primary' label: 'Primary',
}, },
{ {
id: 3, id: 3,
props: { strong: true, secondary: true, type: 'info' }, props: { strong: true, secondary: true, type: 'info' },
label: 'Info' label: 'Info',
}, },
{ {
id: 4, id: 4,
props: { strong: true, secondary: true, type: 'success' }, props: { strong: true, secondary: true, type: 'success' },
label: 'Success' label: 'Success',
}, },
{ {
id: 5, id: 5,
props: { strong: true, secondary: true, type: 'warning' }, props: { strong: true, secondary: true, type: 'warning' },
label: 'Warning' label: 'Warning',
}, },
{ {
id: 6, id: 6,
props: { strong: true, secondary: true, type: 'error' }, props: { strong: true, secondary: true, type: 'error' },
label: 'Error' label: 'Error',
}, },
{ {
id: 7, id: 7,
props: { strong: true, secondary: true, round: true }, props: { strong: true, secondary: true, round: true },
label: 'Default' label: 'Default',
}, },
{ {
id: 8, id: 8,
props: { strong: true, secondary: true, round: true, type: 'tertiary' }, props: { strong: true, secondary: true, round: true, type: 'tertiary' },
label: 'Tertiary' label: 'Tertiary',
}, },
{ {
id: 9, id: 9,
props: { strong: true, secondary: true, round: true, type: 'primary' }, props: { strong: true, secondary: true, round: true, type: 'primary' },
label: 'Primary' label: 'Primary',
}, },
{ {
id: 10, id: 10,
props: { strong: true, secondary: true, round: true, type: 'info' }, props: { strong: true, secondary: true, round: true, type: 'info' },
label: 'Info' label: 'Info',
}, },
{ {
id: 11, id: 11,
props: { strong: true, secondary: true, round: true, type: 'success' }, props: { strong: true, secondary: true, round: true, type: 'success' },
label: 'Success' label: 'Success',
}, },
{ {
id: 12, id: 12,
props: { strong: true, secondary: true, round: true, type: 'warning' }, props: { strong: true, secondary: true, round: true, type: 'warning' },
label: 'Warning' label: 'Warning',
}, },
{ {
id: 13, id: 13,
props: { strong: true, secondary: true, round: true, type: 'error' }, props: { strong: true, secondary: true, round: true, type: 'error' },
label: 'Error' label: 'Error',
} },
] ],
}, },
{ {
id: 2, id: 2,
@ -181,64 +181,64 @@ const buttonExample: ButtonExample[] = [
{ {
id: 0, id: 0,
props: { tertiary: true }, props: { tertiary: true },
label: 'Default' label: 'Default',
}, },
{ {
id: 1, id: 1,
props: { tertiary: true, type: 'primary' }, props: { tertiary: true, type: 'primary' },
label: 'Primary' label: 'Primary',
}, },
{ {
id: 2, id: 2,
props: { tertiary: true, type: 'info' }, props: { tertiary: true, type: 'info' },
label: 'Info' label: 'Info',
}, },
{ {
id: 3, id: 3,
props: { tertiary: true, type: 'success' }, props: { tertiary: true, type: 'success' },
label: 'Success' label: 'Success',
}, },
{ {
id: 4, id: 4,
props: { tertiary: true, type: 'warning' }, props: { tertiary: true, type: 'warning' },
label: 'Warning' label: 'Warning',
}, },
{ {
id: 5, id: 5,
props: { tertiary: true, type: 'error' }, props: { tertiary: true, type: 'error' },
label: 'Error' label: 'Error',
}, },
{ {
id: 6, id: 6,
props: { tertiary: true, round: true }, props: { tertiary: true, round: true },
label: 'Default' label: 'Default',
}, },
{ {
id: 7, id: 7,
props: { tertiary: true, round: true, type: 'primary' }, props: { tertiary: true, round: true, type: 'primary' },
label: 'Primary' label: 'Primary',
}, },
{ {
id: 8, id: 8,
props: { tertiary: true, round: true, type: 'info' }, props: { tertiary: true, round: true, type: 'info' },
label: 'Info' label: 'Info',
}, },
{ {
id: 9, id: 9,
props: { tertiary: true, round: true, type: 'success' }, props: { tertiary: true, round: true, type: 'success' },
label: 'Success' label: 'Success',
}, },
{ {
id: 10, id: 10,
props: { tertiary: true, round: true, type: 'warning' }, props: { tertiary: true, round: true, type: 'warning' },
label: 'Warning' label: 'Warning',
}, },
{ {
id: 11, id: 11,
props: { tertiary: true, round: true, type: 'error' }, props: { tertiary: true, round: true, type: 'error' },
label: 'Error' label: 'Error',
} },
] ],
}, },
{ {
id: 3, id: 3,
@ -247,64 +247,64 @@ const buttonExample: ButtonExample[] = [
{ {
id: 0, id: 0,
props: { quaternary: true }, props: { quaternary: true },
label: 'Default' label: 'Default',
}, },
{ {
id: 1, id: 1,
props: { quaternary: true, type: 'primary' }, props: { quaternary: true, type: 'primary' },
label: 'Primary' label: 'Primary',
}, },
{ {
id: 2, id: 2,
props: { quaternary: true, type: 'info' }, props: { quaternary: true, type: 'info' },
label: 'Info' label: 'Info',
}, },
{ {
id: 3, id: 3,
props: { quaternary: true, type: 'success' }, props: { quaternary: true, type: 'success' },
label: 'Success' label: 'Success',
}, },
{ {
id: 4, id: 4,
props: { quaternary: true, type: 'warning' }, props: { quaternary: true, type: 'warning' },
label: 'Warning' label: 'Warning',
}, },
{ {
id: 5, id: 5,
props: { quaternary: true, type: 'error' }, props: { quaternary: true, type: 'error' },
label: 'Error' label: 'Error',
}, },
{ {
id: 6, id: 6,
props: { quaternary: true, round: true }, props: { quaternary: true, round: true },
label: 'Default' label: 'Default',
}, },
{ {
id: 7, id: 7,
props: { quaternary: true, round: true, type: 'primary' }, props: { quaternary: true, round: true, type: 'primary' },
label: 'Primary' label: 'Primary',
}, },
{ {
id: 8, id: 8,
props: { quaternary: true, round: true, type: 'info' }, props: { quaternary: true, round: true, type: 'info' },
label: 'Info' label: 'Info',
}, },
{ {
id: 9, id: 9,
props: { quaternary: true, round: true, type: 'success' }, props: { quaternary: true, round: true, type: 'success' },
label: 'Success' label: 'Success',
}, },
{ {
id: 10, id: 10,
props: { quaternary: true, round: true, type: 'warning' }, props: { quaternary: true, round: true, type: 'warning' },
label: 'Warning' label: 'Warning',
}, },
{ {
id: 11, id: 11,
props: { quaternary: true, round: true, type: 'error' }, props: { quaternary: true, round: true, type: 'error' },
label: 'Error' label: 'Error',
} },
] ],
}, },
{ {
id: 4, id: 4,
@ -313,39 +313,39 @@ const buttonExample: ButtonExample[] = [
{ {
id: 0, id: 0,
props: { dashed: true }, props: { dashed: true },
label: 'Default' label: 'Default',
}, },
{ {
id: 1, id: 1,
props: { dashed: true, type: 'tertiary' }, props: { dashed: true, type: 'tertiary' },
label: 'Tertiary' label: 'Tertiary',
}, },
{ {
id: 2, id: 2,
props: { dashed: true, type: 'primary' }, props: { dashed: true, type: 'primary' },
label: 'Primary' label: 'Primary',
}, },
{ {
id: 3, id: 3,
props: { dashed: true, type: 'info' }, props: { dashed: true, type: 'info' },
label: 'Info' label: 'Info',
}, },
{ {
id: 4, id: 4,
props: { dashed: true, type: 'success' }, props: { dashed: true, type: 'success' },
label: 'Success' label: 'Success',
}, },
{ {
id: 5, id: 5,
props: { dashed: true, type: 'warning' }, props: { dashed: true, type: 'warning' },
label: 'Warning' label: 'Warning',
}, },
{ {
id: 6, id: 6,
props: { dashed: true, type: 'error' }, props: { dashed: true, type: 'error' },
label: 'Error' label: 'Error',
} },
] ],
}, },
{ {
id: 5, id: 5,
@ -354,24 +354,24 @@ const buttonExample: ButtonExample[] = [
{ {
id: 0, id: 0,
props: { size: 'tiny', strong: true }, props: { size: 'tiny', strong: true },
label: '小小' label: '小小',
}, },
{ {
id: 1, id: 1,
props: { size: 'small', strong: true }, props: { size: 'small', strong: true },
label: '小' label: '小',
}, },
{ {
id: 2, id: 2,
props: { size: 'medium', strong: true }, props: { size: 'medium', strong: true },
label: '不小' label: '不小',
}, },
{ {
id: 3, id: 3,
props: { size: 'large', strong: true }, props: { size: 'large', strong: true },
label: '不不小' label: '不不小',
} },
] ],
}, },
{ {
id: 6, id: 6,
@ -381,9 +381,9 @@ const buttonExample: ButtonExample[] = [
id: 0, id: 0,
props: { text: true }, props: { text: true },
label: '那车头依然吐着烟', label: '那车头依然吐着烟',
icon: 'mdi:train' icon: 'mdi:train',
} },
] ],
}, },
{ {
id: 7, id: 7,
@ -396,12 +396,12 @@ const buttonExample: ButtonExample[] = [
tag: 'a', tag: 'a',
href: 'https://github.com/honghuangdc/soybean-admin', href: 'https://github.com/honghuangdc/soybean-admin',
target: '_blank', target: '_blank',
type: 'primary' type: 'primary',
}, },
label: 'soybean-admin' label: 'soybean-admin',
} },
], ],
desc: '你可以把按钮渲染成不同的标签,比如 a标签 。' desc: '你可以把按钮渲染成不同的标签,比如 a标签 。',
}, },
{ {
id: 8, id: 8,
@ -410,12 +410,12 @@ const buttonExample: ButtonExample[] = [
{ {
id: 0, id: 0,
props: { props: {
disabled: true disabled: true,
}, },
label: '不许点' label: '不许点',
} },
], ],
desc: '按钮可以被禁用' desc: '按钮可以被禁用',
}, },
{ {
id: 9, id: 9,
@ -425,23 +425,23 @@ const buttonExample: ButtonExample[] = [
id: 0, id: 0,
props: { props: {
secondary: true, secondary: true,
strong: true strong: true,
}, },
label: '+100元', label: '+100元',
icon: 'mdi:cash-100' icon: 'mdi:cash-100',
}, },
{ {
id: 0, id: 0,
props: { props: {
iconPlacement: 'right', iconPlacement: 'right',
secondary: true, secondary: true,
strong: true strong: true,
}, },
label: '+100元', label: '+100元',
icon: 'mdi:cash-100' icon: 'mdi:cash-100',
} },
], ],
desc: '在按钮上使用图标。' desc: '在按钮上使用图标。',
}, },
{ {
id: 10, id: 10,
@ -450,24 +450,24 @@ const buttonExample: ButtonExample[] = [
{ {
id: 0, id: 0,
props: { props: {
circle: true circle: true,
}, },
icon: 'mdi:cash-100' icon: 'mdi:cash-100',
}, },
{ {
id: 1, id: 1,
props: { props: {
round: true round: true,
}, },
label: '圆角' label: '圆角',
}, },
{ {
id: 2, id: 2,
props: {}, props: {},
label: '方' label: '方',
} },
], ],
desc: '按钮拥有不同的形状。' desc: '按钮拥有不同的形状。',
}, },
{ {
id: 11, id: 11,
@ -476,40 +476,40 @@ const buttonExample: ButtonExample[] = [
{ {
id: 0, id: 0,
props: { ghost: true }, props: { ghost: true },
label: 'Default' label: 'Default',
}, },
{ {
id: 1, id: 1,
props: { ghost: true, type: 'tertiary' }, props: { ghost: true, type: 'tertiary' },
label: 'Tertiary' label: 'Tertiary',
}, },
{ {
id: 2, id: 2,
props: { ghost: true, type: 'primary' }, props: { ghost: true, type: 'primary' },
label: 'Primary' label: 'Primary',
}, },
{ {
id: 3, id: 3,
props: { ghost: true, type: 'info' }, props: { ghost: true, type: 'info' },
label: 'Info' label: 'Info',
}, },
{ {
id: 4, id: 4,
props: { ghost: true, type: 'success' }, props: { ghost: true, type: 'success' },
label: 'Success' label: 'Success',
}, },
{ {
id: 5, id: 5,
props: { ghost: true, type: 'warning' }, props: { ghost: true, type: 'warning' },
label: 'Warning' label: 'Warning',
}, },
{ {
id: 6, id: 6,
props: { ghost: true, type: 'error' }, props: { ghost: true, type: 'error' },
label: 'Error' label: 'Error',
} },
], ],
desc: 'Ghost 按钮有透明的背景。' desc: 'Ghost 按钮有透明的背景。',
}, },
{ {
id: 12, id: 12,
@ -518,58 +518,58 @@ const buttonExample: ButtonExample[] = [
{ {
id: 0, id: 0,
props: { props: {
color: '#8a2be2' color: '#8a2be2',
}, },
label: '#8a2be2', label: '#8a2be2',
icon: 'ic:baseline-color-lens' icon: 'ic:baseline-color-lens',
}, },
{ {
id: 1, id: 1,
props: { props: {
color: '#ff69b4' color: '#ff69b4',
}, },
label: '#ff69b4', label: '#ff69b4',
icon: 'ic:baseline-color-lens' icon: 'ic:baseline-color-lens',
}, },
{ {
id: 2, id: 2,
props: { props: {
color: '#8a2be2', color: '#8a2be2',
ghost: true ghost: true,
}, },
label: '#8a2be2', label: '#8a2be2',
icon: 'ic:baseline-color-lens' icon: 'ic:baseline-color-lens',
}, },
{ {
id: 3, id: 3,
props: { props: {
color: '#ff69b4', color: '#ff69b4',
ghost: true ghost: true,
}, },
label: '#ff69b4', label: '#ff69b4',
icon: 'ic:baseline-color-lens' icon: 'ic:baseline-color-lens',
}, },
{ {
id: 4, id: 4,
props: { props: {
color: '#8a2be2', color: '#8a2be2',
text: true text: true,
}, },
label: '#8a2be2', label: '#8a2be2',
icon: 'ic:baseline-color-lens' icon: 'ic:baseline-color-lens',
}, },
{ {
id: 5, id: 5,
props: { props: {
color: '#ff69b4', color: '#ff69b4',
text: true text: true,
}, },
label: '#ff69b4', label: '#ff69b4',
icon: 'ic:baseline-color-lens' icon: 'ic:baseline-color-lens',
} },
], ],
desc: '这两个颜色看起来像毒蘑菇。' desc: '这两个颜色看起来像毒蘑菇。',
} },
]; ];
</script> </script>
<style scoped></style> <style scoped></style>

Some files were not shown because too many files have changed in this diff Show More