style(projects): update prettier config

This commit is contained in:
Soybean 2022-04-01 14:47:57 +08:00
parent ca2dfa6185
commit df56abe18d
128 changed files with 2237 additions and 2037 deletions

View File

@ -13,16 +13,16 @@ type ServiceEnv = Record<
const serviceEnvConfig: ServiceEnv = {
dev: {
url: 'http://localhost:8080',
proxy: '/api',
proxy: '/api'
},
test: {
url: 'http://localhost:8080',
proxy: '/api',
proxy: '/api'
},
prod: {
url: 'http://localhost:8080',
proxy: '/api',
},
proxy: '/api'
}
};
/**
@ -32,7 +32,7 @@ const serviceEnvConfig: ServiceEnv = {
export function getEnvConfig(env: ImportMetaEnv) {
const { VITE_ENV_TYPE = 'dev' } = env;
const envConfig = {
http: serviceEnvConfig[VITE_ENV_TYPE],
http: serviceEnvConfig[VITE_ENV_TYPE]
};
return envConfig;
}

View File

@ -2,19 +2,19 @@ module.exports = {
env: {
browser: true,
es2021: true,
'vue/setup-compiler-macros': true,
'vue/setup-compiler-macros': true
},
globals: {
PROJECT_BUILD_TIME: 'readonly',
AMap: 'readonly',
BMap: 'readonly',
TMap: 'readonly',
TMap: 'readonly'
},
parser: 'vue-eslint-parser',
parserOptions: {
ecmaVersion: 12,
parser: '@typescript-eslint/parser',
sourceType: 'module',
sourceType: 'module'
},
plugins: ['vue', '@typescript-eslint'],
extends: [
@ -24,7 +24,7 @@ module.exports = {
'plugin:prettier/recommended',
'@vue/eslint-config-typescript/recommended',
'@vue/eslint-config-prettier',
'@vue/typescript/recommended',
'@vue/typescript/recommended'
],
rules: {
'import/extensions': 'off',
@ -38,22 +38,22 @@ module.exports = {
{
pattern: 'vue',
group: 'external',
position: 'before',
position: 'before'
},
{
pattern: 'vue-router',
group: 'external',
position: 'before',
position: 'before'
},
{
pattern: 'vuex',
group: 'external',
position: 'before',
position: 'before'
},
{
pattern: 'pinia',
group: 'external',
position: 'before',
position: 'before'
},
// ui framework, such as "naive-ui"
// {
@ -64,92 +64,92 @@ module.exports = {
{
pattern: '@/config',
group: 'internal',
position: 'before',
position: 'before'
},
{
pattern: '@/settings',
group: 'internal',
position: 'before',
position: 'before'
},
{
pattern: '@/enum',
group: 'internal',
position: 'before',
position: 'before'
},
{
pattern: '@/plugins',
group: 'internal',
position: 'before',
position: 'before'
},
{
pattern: '@/layouts',
group: 'internal',
position: 'before',
position: 'before'
},
{
pattern: '@/views',
group: 'internal',
position: 'before',
position: 'before'
},
{
pattern: '@/components',
group: 'internal',
position: 'before',
position: 'before'
},
{
pattern: '@/router',
group: 'internal',
position: 'before',
position: 'before'
},
{
pattern: '@/store',
group: 'internal',
position: 'before',
position: 'before'
},
{
pattern: '@/composables',
group: 'internal',
position: 'before',
position: 'before'
},
{
pattern: '@/hooks',
group: 'internal',
position: 'before',
position: 'before'
},
{
pattern: '@/service',
group: 'internal',
position: 'before',
position: 'before'
},
{
pattern: '@/utils',
group: 'internal',
position: 'before',
position: 'before'
},
{
pattern: '@/assets',
group: 'internal',
position: 'before',
position: 'before'
},
{
pattern: '@/**',
group: 'internal',
position: 'before',
position: 'before'
},
{
pattern: '@/interface',
group: 'internal',
position: 'before',
},
position: 'before'
}
],
pathGroupsExcludedImportTypes: [
'vue',
'vue-router',
'vuex',
'pinia',
'pinia'
// 'naive-ui'
],
},
]
}
],
'import/no-unresolved': 'off',
'import/prefer-default-export': 'off',
@ -158,8 +158,8 @@ module.exports = {
'error',
{
props: true,
ignorePropertyModificationsFor: ['state', 'acc', 'e'],
},
ignorePropertyModificationsFor: ['state', 'acc', 'e']
}
],
'no-plusplus': 'off',
'no-shadow': 'off',
@ -168,44 +168,44 @@ module.exports = {
'vue/multi-word-component-names': [
'error',
{
ignores: ['index'],
},
ignores: ['index']
}
],
'@typescript-eslint/ban-types': [
'error',
{
types: {
'{}': {
message: 'Use object instead',
fixWith: 'object',
},
},
},
fixWith: 'object'
}
}
}
],
'@typescript-eslint/no-empty-interface': [
'error',
{
allowSingleExtends: true,
},
allowSingleExtends: true
}
],
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-non-null-assertion': '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 }]
},
overrides: [
{
files: ['*.vue'],
rules: {
'no-undef': 'off',
},
'no-undef': 'off'
}
},
{
files: ['*.html'],
rules: {
'vue/comment-directive': 'off',
},
},
],
'vue/comment-directive': 'off'
}
}
]
};

View File

@ -1,5 +1,5 @@
module.exports = { // https://prettier.io/docs/en/options.html
arrowParens: 'always',
arrowParens: 'avoid',
bracketSameLine: false,
bracketSpacing: true,
embeddedLanguageFormatting: 'auto',
@ -13,7 +13,7 @@ module.exports = { // https://prettier.io/docs/en/options.html
semi: true,
singleQuote: true,
tabWidth: 2,
trailingComma: 'es5',
trailingComma: 'none',
useTabs: false,
vueIndentScriptAndStyle: false,
overrides: [

View File

@ -69,6 +69,8 @@
"composables": "hook",
"directive": "tools",
"directives": "tools",
"business": "core"
"business": "core",
"request": "api",
"adapter": "middleware"
}
}

View File

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

View File

@ -10,6 +10,6 @@ export function resolvePath(rootPath: string, basePath: string) {
return {
root,
src,
src
};
}

View File

@ -15,8 +15,8 @@ export function createViteProxy(viteEnv: ImportMetaEnv) {
[http.proxy]: {
target: http.url,
changeOrigin: true,
rewrite: (path) => path.replace(new RegExp(`^${http.proxy}`), ''),
},
rewrite: path => path.replace(new RegExp(`^${http.proxy}`), '')
}
};
return proxy;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -26,9 +26,9 @@
}
},
"dependencies": {
"@antv/g2plot": "^2.4.13",
"@antv/g2plot": "^2.4.14",
"@better-scroll/core": "^2.4.2",
"@vueuse/core": "^8.2.0",
"@vueuse/core": "^8.2.3",
"axios": "^0.26.1",
"clipboard": "^2.0.10",
"colord": "^2.9.2",
@ -37,25 +37,25 @@
"form-data": "^4.0.0",
"lodash-es": "^4.17.21",
"naive-ui": "^2.27.0",
"pinia": "^2.0.12",
"pinia": "^2.0.13",
"print-js": "^1.6.0",
"qs": "^6.10.3",
"soybean-admin-layout": "^1.0.4",
"soybean-admin-tab": "^1.2.3",
"swiper": "^8.0.7",
"ua-parser-js": "^1.0.2",
"vditor": "^3.8.12",
"vditor": "^3.8.13",
"vue": "^3.2.31",
"vue-router": "^4.0.14",
"wangeditor": "^4.7.12",
"xgplayer": "^2.31.4"
"xgplayer": "^2.31.6"
},
"devDependencies": {
"@amap/amap-jsapi-types": "^0.0.8",
"@commitlint/cli": "^16.2.3",
"@commitlint/config-conventional": "^16.2.1",
"@iconify/json": "^2.1.21",
"@iconify/vue": "^3.2.0",
"@iconify/json": "^2.1.23",
"@iconify/vue": "^3.2.1",
"@types/bmapgl": "^0.0.5",
"@types/crypto-js": "^4.1.1",
"@types/node": "^17.0.23",
@ -63,7 +63,7 @@
"@types/ua-parser-js": "^0.7.36",
"@typescript-eslint/eslint-plugin": "^5.17.0",
"@typescript-eslint/parser": "^5.17.0",
"@vitejs/plugin-vue": "^2.2.4",
"@vitejs/plugin-vue": "^2.3.1",
"@vue/eslint-config-prettier": "^7.0.0",
"@vue/eslint-config-typescript": "^10.0.0",
"@vue/tsconfig": "^0.1.3",
@ -84,11 +84,11 @@
"postinstall-postinstall": "^2.1.0",
"prettier": "^2.6.1",
"rollup-plugin-visualizer": "^5.6.0",
"sass": "^1.49.9",
"sass": "^1.49.10",
"typescript": "^4.6.3",
"unplugin-icons": "^0.14.1",
"unplugin-vue-components": "^0.18.5",
"vite": "2.8.6",
"vite": "2.9.1",
"vite-plugin-html": "^3.2.0",
"vite-plugin-html-template": "^1.1.2",
"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: '暂无数据',
iconClass: 'text-320px text-primary',
descClass: 'text-16px text-[#666]',
showNetworkReload: false,
showNetworkReload: false
});
//
@ -79,7 +79,7 @@ function handleReload() {
const stopHandle = watch(
() => props.loading,
(newValue) => {
newValue => {
//
if (!newValue) {
setNetwork(window.navigator.onLine);

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -42,7 +42,7 @@ const props = withDefaults(defineProps<Props>(), {
separator: ',',
decimal: '.',
useEasing: true,
transition: 'linear',
transition: 'linear'
});
const emit = defineEmits<{
@ -61,7 +61,7 @@ function run() {
duration: props.duration,
onStarted: () => emit('on-started'),
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>(), {
emptyIcon: 'mdi:apps',
emptyIcon: 'mdi:apps'
});
const emit = defineEmits<Emits>();
@ -51,7 +51,7 @@ const emit = defineEmits<Emits>();
const theme = useThemeStore();
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({
get() {
@ -59,7 +59,7 @@ const modelValue = computed({
},
set(val: string) {
emit('update:value', val);
},
}
});
function handleChange(iconItem: string) {

View File

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

View File

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

View File

@ -46,7 +46,7 @@ export function useRouterPush(inSetup = true) {
const module: EnumType.LoginModuleKey = loginModule || 'pwd-login';
const routeLocation: RouteLocationRaw = {
name: routeName('login'),
params: { module },
params: { module }
};
const redirect = redirectUrl || route.value.fullPath;
Object.assign(routeLocation, { query: { redirect } });
@ -80,6 +80,6 @@ export function useRouterPush(inSetup = true) {
toHome,
toLogin,
toLoginModule,
toLoginRedirect,
toLoginRedirect
};
}

View File

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

View File

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

View File

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

View File

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

View File

@ -9,7 +9,7 @@ export default function setupLoginDirective(app: App) {
if (binding.value !== auth.userInfo.userRole) {
el.remove();
}
},
}
};
app.directive('login', loginDirective);

View File

@ -4,5 +4,5 @@ export enum EnumLoginModule {
'code-login' = '手机验证码登录',
'register' = '注册',
'reset-pwd' = '重置密码',
'bind-wechat' = '微信绑定',
'bind-wechat' = '微信绑定'
}

View File

@ -2,7 +2,7 @@
export enum EnumContentType {
json = 'application/json',
formUrlencoded = 'application/x-www-form-urlencoded',
formData = 'multipart/form-data',
formData = 'multipart/form-data'
}
/** 缓存的key */
@ -16,7 +16,7 @@ export enum EnumStorageKey {
/** 用户信息 */
'user-info' = '__USER_INFO__',
/** 多页签路由信息 */
'tab-routes' = '__TAB_ROUTES__',
'tab-routes' = '__TAB_ROUTES__'
}
/** 数据类型 */
@ -31,5 +31,5 @@ export enum EnumDataType {
date = '[object Date]',
regexp = '[object RegExp]',
set = '[object Set]',
map = '[object Map]',
map = '[object Map]'
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -21,6 +21,6 @@ export default function useBoolean(initValue = false) {
setBool,
setTrue,
setFalse,
toggle,
toggle
};
}

View File

@ -15,6 +15,6 @@ export default function useContext<T>(contextName = 'context') {
return {
useProvide,
useInject,
useInject
};
}

View File

@ -6,6 +6,6 @@ export default function useLoading(initValue = false) {
return {
loading,
startLoading,
endLoading,
endLoading
};
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -60,10 +60,10 @@ const show = computed({
},
set(val: boolean) {
emit('update:value', val);
},
}
});
watch(show, async (val) => {
watch(show, async val => {
if (val) {
/** 自动聚焦 */
await nextTick();
@ -74,7 +74,7 @@ watch(show, async (val) => {
/** 查询 */
function search() {
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) {
activePath.value = resultOptions.value[0].path;
@ -96,7 +96,7 @@ function handleClose() {
function handleUp() {
const { length } = resultOptions.value;
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) {
activePath.value = resultOptions.value[length - 1].path;
} else {
@ -108,7 +108,7 @@ function handleUp() {
function handleDown() {
const { length } = resultOptions.value;
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) {
activePath.value = resultOptions.value[0].path;
} else {
@ -120,7 +120,7 @@ function handleDown() {
function handleEnter() {
const { length } = resultOptions.value;
if (length === 0 || activePath.value === '') return;
const routeItem = resultOptions.value.find((item) => item.path === activePath.value);
const routeItem = resultOptions.value.find(item => item.path === activePath.value);
if (routeItem?.meta?.href) {
window.open(activePath.value, '__blank');
} else {

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"
:style="{
background: item.path === active ? theme.themeColor : '',
color: item.path === active ? '#fff' : '',
color: item.path === active ? '#fff' : ''
}"
@click="handleTo"
@mouseenter="handleMouse(item)"
@ -47,7 +47,7 @@ const active = computed({
},
set(val: string) {
emit('update:value', val);
},
}
});
/** 鼠标移入 */

View File

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

View File

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

View File

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

View File

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

View File

@ -44,23 +44,23 @@ const layoutConfig: LayoutConfig = {
vertical: {
placement: 'bottom-start',
menuClass: 'w-1/3 h-full',
mainClass: 'w-2/3 h-3/4',
mainClass: 'w-2/3 h-3/4'
},
'vertical-mix': {
placement: 'bottom',
menuClass: 'w-1/4 h-full',
mainClass: 'w-2/3 h-3/4',
mainClass: 'w-2/3 h-3/4'
},
horizontal: {
placement: 'bottom',
menuClass: 'w-full h-1/4',
mainClass: 'w-full h-3/4',
mainClass: 'w-full h-3/4'
},
'horizontal-mix': {
placement: 'bottom-end',
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]);

View File

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

View File

@ -36,7 +36,7 @@ function clipboardEventListener() {
window.$dialog?.success({
title: '操作成功',
content: '复制成功,请替换 src/settings/theme.json的内容',
positiveText: '确定',
positiveText: '确定'
});
});
}

View File

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

View File

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

View File

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

View File

@ -2,20 +2,20 @@ import type { RouterScrollBehavior } from 'vue-router';
import { useTabStore } from '@/store';
export const scrollBehavior: RouterScrollBehavior = (to, from) => {
return new Promise((resolve) => {
return new Promise(resolve => {
const tab = useTabStore();
if (to.hash) {
resolve({
el: to.hash,
behavior: 'smooth',
behavior: 'smooth'
});
}
const { left, top } = tab.getTabScrollPosition(to.path);
const scrollPosition = {
left,
top,
top
};
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({
history,
routes: transformAuthRoutesToVueRoutes(constantRoutes),
scrollBehavior,
scrollBehavior
});
export async function setupRouter(app: App) {

View File

@ -8,8 +8,8 @@ const about: AuthRoute.Route = {
singleLayout: 'basic',
permissions: ['super', 'admin', 'test'],
icon: 'fluent:book-information-24-regular',
order: 7,
},
order: 7
}
};
export default about;

View File

@ -10,8 +10,8 @@ const component: AuthRoute.Route = {
meta: {
title: '按钮',
requiresAuth: true,
icon: 'ic:baseline-radio-button-checked',
},
icon: 'ic:baseline-radio-button-checked'
}
},
{
name: 'component_card',
@ -20,8 +20,8 @@ const component: AuthRoute.Route = {
meta: {
title: '卡片',
requiresAuth: true,
icon: 'mdi:card-outline',
},
icon: 'mdi:card-outline'
}
},
{
name: 'component_table',
@ -30,15 +30,15 @@ const component: AuthRoute.Route = {
meta: {
title: '表格',
requiresAuth: true,
icon: 'mdi:table-large',
},
},
icon: 'mdi:table-large'
}
}
],
meta: {
title: '组件示例',
icon: 'fluent:app-store-24-regular',
order: 3,
},
order: 3
}
};
export default component;

View File

@ -10,8 +10,8 @@ const dashboard: AuthRoute.Route = {
meta: {
title: '分析页',
requiresAuth: true,
icon: 'icon-park-outline:analysis',
},
icon: 'icon-park-outline:analysis'
}
},
{
name: 'dashboard_workbench',
@ -21,15 +21,15 @@ const dashboard: AuthRoute.Route = {
title: '工作台',
requiresAuth: true,
permissions: ['super', 'admin'],
icon: 'icon-park-outline:workbench',
},
},
icon: 'icon-park-outline:workbench'
}
}
],
meta: {
title: '仪表盘',
icon: 'carbon:dashboard',
order: 1,
},
order: 1
}
};
export default dashboard;

View File

@ -10,8 +10,8 @@ const document: AuthRoute.Route = {
meta: {
title: 'vue文档',
requiresAuth: true,
icon: 'mdi:vuejs',
},
icon: 'mdi:vuejs'
}
},
{
name: 'document_vue-new',
@ -20,8 +20,8 @@ const document: AuthRoute.Route = {
meta: {
title: 'vue文档(新版)',
requiresAuth: true,
icon: 'mdi:vuejs',
},
icon: 'mdi:vuejs'
}
},
{
name: 'document_vite',
@ -30,8 +30,8 @@ const document: AuthRoute.Route = {
meta: {
title: 'vite文档',
requiresAuth: true,
icon: 'simple-icons:vite',
},
icon: 'simple-icons:vite'
}
},
{
name: 'document_project',
@ -40,15 +40,15 @@ const document: AuthRoute.Route = {
title: '项目文档(外链)',
requiresAuth: true,
icon: 'mdi:file-link-outline',
href: 'https://docs.soybean.pro/',
},
},
href: 'https://docs.soybean.pro/'
}
}
],
meta: {
title: '文档',
icon: 'carbon:document',
order: 2,
},
order: 2
}
};
export default document;

View File

@ -10,8 +10,8 @@ const exception: AuthRoute.Route = {
meta: {
title: '异常页403',
requiresAuth: true,
icon: 'ic:baseline-block',
},
icon: 'ic:baseline-block'
}
},
{
name: 'exception_404',
@ -20,8 +20,8 @@ const exception: AuthRoute.Route = {
meta: {
title: '异常页404',
requiresAuth: true,
icon: 'ic:baseline-web-asset-off',
},
icon: 'ic:baseline-web-asset-off'
}
},
{
name: 'exception_500',
@ -30,15 +30,15 @@ const exception: AuthRoute.Route = {
meta: {
title: '异常页500',
requiresAuth: true,
icon: 'ic:baseline-wifi-off',
},
},
icon: 'ic:baseline-wifi-off'
}
}
],
meta: {
title: '异常页',
icon: 'ant-design:exception-outlined',
order: 5,
},
order: 5
}
};
export default exception;

View File

@ -15,8 +15,8 @@ const multiMenu: AuthRoute.Route = {
meta: {
title: '二级菜单',
requiresAuth: true,
icon: 'ic:outline-menu',
},
icon: 'ic:outline-menu'
}
},
{
name: 'multi-menu_first_second-new',
@ -30,27 +30,27 @@ const multiMenu: AuthRoute.Route = {
meta: {
title: '三级菜单',
requiresAuth: true,
icon: 'ic:outline-menu',
},
},
icon: 'ic:outline-menu'
}
}
],
meta: {
title: '二级菜单(有子菜单)',
icon: 'ic:outline-menu',
},
},
icon: 'ic:outline-menu'
}
}
],
meta: {
title: '一级菜单',
icon: 'ic:outline-menu',
},
},
icon: 'ic:outline-menu'
}
}
],
meta: {
title: '多级菜单',
icon: 'carbon:menu',
order: 6,
},
order: 6
}
};
export default multiMenu;

View File

@ -10,8 +10,8 @@ const plugin: AuthRoute.Route = {
meta: {
title: '地图',
requiresAuth: true,
icon: 'mdi:map',
},
icon: 'mdi:map'
}
},
{
name: 'plugin_video',
@ -20,8 +20,8 @@ const plugin: AuthRoute.Route = {
meta: {
title: '视频',
requiresAuth: true,
icon: 'mdi:video',
},
icon: 'mdi:video'
}
},
{
name: 'plugin_editor',
@ -35,8 +35,8 @@ const plugin: AuthRoute.Route = {
meta: {
title: '富文本编辑器',
requiresAuth: true,
icon: 'mdi:file-document-edit-outline',
},
icon: 'mdi:file-document-edit-outline'
}
},
{
name: 'plugin_editor_markdown',
@ -45,14 +45,14 @@ const plugin: AuthRoute.Route = {
meta: {
title: 'markdown编辑器',
requiresAuth: true,
icon: 'ri:markdown-line',
},
},
icon: 'ri:markdown-line'
}
}
],
meta: {
title: '编辑器',
icon: 'icon-park-outline:editor',
},
icon: 'icon-park-outline:editor'
}
},
{
name: 'plugin_swiper',
@ -61,8 +61,8 @@ const plugin: AuthRoute.Route = {
meta: {
title: 'Swiper插件',
requiresAuth: true,
icon: 'simple-icons:swiper',
},
icon: 'simple-icons:swiper'
}
},
{
name: 'plugin_copy',
@ -71,8 +71,8 @@ const plugin: AuthRoute.Route = {
meta: {
title: '剪贴板',
requiresAuth: true,
icon: 'mdi:clipboard-outline',
},
icon: 'mdi:clipboard-outline'
}
},
{
name: 'plugin_icon',
@ -81,8 +81,8 @@ const plugin: AuthRoute.Route = {
meta: {
title: '图标',
requiresAuth: true,
icon: 'ic:baseline-insert-emoticon',
},
icon: 'ic:baseline-insert-emoticon'
}
},
{
name: 'plugin_print',
@ -91,15 +91,15 @@ const plugin: AuthRoute.Route = {
meta: {
title: '打印',
requiresAuth: true,
icon: 'ic:baseline-local-printshop',
},
},
icon: 'ic:baseline-local-printshop'
}
}
],
meta: {
title: '插件示例',
icon: 'clarity:plugin-line',
order: 4,
},
order: 4
}
};
export default plugin;

View File

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

View File

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

View File

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

View File

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

View File

@ -25,7 +25,7 @@ const themeColorList = [
'#ffb300',
'#fdd835',
'#6d4c41',
'#546e7a',
'#546e7a'
];
const defaultThemeSetting: Theme.Setting = {
@ -37,8 +37,8 @@ const defaultThemeSetting: Theme.Setting = {
{ value: 'vertical', label: EnumThemeLayoutMode.vertical },
{ value: 'vertical-mix', label: EnumThemeLayoutMode['vertical-mix'] },
{ value: 'horizontal', label: EnumThemeLayoutMode.horizontal },
{ value: 'horizontal-mix', label: EnumThemeLayoutMode['horizontal-mix'] },
],
{ value: 'horizontal-mix', label: EnumThemeLayoutMode['horizontal-mix'] }
]
},
themeColor: themeColorList[0],
themeColorList,
@ -46,7 +46,7 @@ const defaultThemeSetting: Theme.Setting = {
info: '#2080f0',
success: '#52c41a',
warning: '#faad14',
error: '#f5222d',
error: '#f5222d'
},
isCustomizeInfoColor: false,
fixedHeaderAndTab: true,
@ -55,8 +55,8 @@ const defaultThemeSetting: Theme.Setting = {
height: 56,
crumb: {
visible: true,
showIcon: true,
},
showIcon: true
}
},
tab: {
visible: true,
@ -64,28 +64,28 @@ const defaultThemeSetting: Theme.Setting = {
mode: 'chrome',
modeList: [
{ value: 'chrome', label: EnumThemeTabMode.chrome },
{ value: 'button', label: EnumThemeTabMode.button },
{ value: 'button', label: EnumThemeTabMode.button }
],
isCache: true,
isCache: true
},
sider: {
width: 220,
collapsedWidth: 64,
mixWidth: 80,
mixCollapsedWidth: 48,
mixChildMenuWidth: 200,
mixChildMenuWidth: 200
},
menu: {
horizontalPosition: 'flex-start',
horizontalPositionList: [
{ value: 'flex-start', label: EnumThemeHorizontalMenuPosition['flex-start'] },
{ value: 'center', label: EnumThemeHorizontalMenuPosition.center },
{ value: 'flex-end', label: EnumThemeHorizontalMenuPosition['flex-end'] },
],
{ value: 'flex-end', label: EnumThemeHorizontalMenuPosition['flex-end'] }
]
},
footer: {
fixed: false,
height: 48,
height: 48
},
page: {
animate: true,
@ -96,9 +96,9 @@ const defaultThemeSetting: Theme.Setting = {
{ value: 'fade-bottom', label: EnumThemeAnimateMode['fade-bottom'] },
{ value: 'fade-scale', label: EnumThemeAnimateMode['fade-scale'] },
{ 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 Theme.Setting) || defaultThemeSetting;

View File

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

View File

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

View File

@ -7,7 +7,7 @@ import {
transformAuthRouteToMenu,
transformAuthRoutesToVueRoutes,
transformAuthRoutesToSearchMenus,
getCacheRoutes,
getCacheRoutes
} from '@/utils';
import { useTabStore } from '../tab';
@ -37,7 +37,7 @@ export const useRouteStore = defineStore('route-store', {
routeHomeName: 'dashboard_analysis',
menus: [],
searchMenus: [],
cacheRoutes: [],
cacheRoutes: []
}),
actions: {
/**
@ -50,7 +50,7 @@ export const useRouteStore = defineStore('route-store', {
this.searchMenus = transformAuthRoutesToSearchMenus(routes);
const vueRoutes = transformAuthRoutesToVueRoutes(routes);
vueRoutes.forEach((route) => {
vueRoutes.forEach(route => {
router.addRoute(route);
});
@ -95,6 +95,6 @@ export const useRouteStore = defineStore('route-store', {
initHomeTab(this.routeHomeName, router);
this.isInitedAuthRoute = true;
},
},
}
}
});

View File

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

View File

@ -21,21 +21,21 @@ export const useTabStore = defineStore('tab-store', {
name: 'root',
path: '/',
meta: {
title: 'root',
title: 'root'
},
scrollPosition: {
left: 0,
top: 0,
top: 0
}
},
},
activeTab: '',
activeTab: ''
}),
getters: {
/** 当前激活状态的页签索引 */
activeTabIndex(state) {
const { tabs, activeTab } = state;
return tabs.findIndex((tab) => tab.path === activeTab);
},
return tabs.findIndex(tab => tab.path === activeTab);
}
},
actions: {
/**
@ -52,7 +52,7 @@ export const useTabStore = defineStore('tab-store', {
*/
initHomeTab(routeHomeName: string, router: Router) {
const routes = router.getRoutes();
const findHome = routes.find((item) => item.name === routeHomeName);
const findHome = routes.find(item => item.name === routeHomeName);
if (findHome) {
this.homeTab = getTabRouteByVueRoute(findHome);
}
@ -74,7 +74,7 @@ export const useTabStore = defineStore('tab-store', {
const { routerPush } = useRouterPush(false);
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;
if (isActive && updateTabs.length) {
const activePath = updateTabs[updateTabs.length - 1].path;
@ -92,7 +92,7 @@ export const useTabStore = defineStore('tab-store', {
const homePath = this.homeTab.path;
const remain = [homePath, ...excludes];
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;
if (!hasActive && updateTabs.length) {
const activePath = updateTabs[updateTabs.length - 1].path;
@ -107,7 +107,7 @@ export const useTabStore = defineStore('tab-store', {
clearLeftTab(path: string) {
const index = getIndexInTabRoutes(this.tabs, path);
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);
}
},
@ -118,7 +118,7 @@ export const useTabStore = defineStore('tab-store', {
clearRightTab(path: string) {
const index = getIndexInTabRoutes(this.tabs, path);
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);
}
},
@ -153,7 +153,7 @@ export const useTabStore = defineStore('tab-store', {
getTabScrollPosition(path: string) {
const position = {
left: 0,
top: 0,
top: 0
};
const index = getIndexInTabRoutes(this.tabs, path);
if (index > -1) {
@ -177,6 +177,6 @@ export const useTabStore = defineStore('tab-store', {
}
this.tabs = tabs;
this.setActiveTab(currentRoute.path);
},
},
}
}
});

View File

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

View File

@ -18,7 +18,7 @@ export const useThemeStore = defineStore('theme-store', {
/** naive-ui暗黑主题 */
naiveTheme(state) {
return state.darkMode ? darkTheme : undefined;
},
}
},
actions: {
/** 重置theme状态 */
@ -128,6 +128,6 @@ export const useThemeStore = defineStore('theme-store', {
/** 设置页面过渡动画类型 */
setPageAnimateMode(mode: EnumType.ThemeAnimateMode) {
this.page.animateMode = mode;
},
},
}
}
});

View File

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

View File

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

7
src/typings/utils.d.ts vendored Normal file
View File

@ -0,0 +1,7 @@
declare namespace TypeUtil {
type Noop = (...args: any) => any;
type GetFunArgs<F extends Noop> = F extends (...args: infer P) => any ? P : never;
type GetFunReturn<F extends Noop> = F extends (...args: any) => infer R ? R : never;
}

View File

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

View File

@ -30,7 +30,7 @@ export function getColorPalette(color: string, index: ColorIndex) {
const newHsv: HsvColor = {
h: getHue(hsv, i, isLight),
s: getSaturation(hsv, i, isLight),
v: getValue(hsv, i, isLight),
v: getValue(hsv, i, isLight)
};
return colord(newHsv).toHex();
@ -42,7 +42,7 @@ export function getColorPalette(color: string, index: ColorIndex) {
*/
export function getAllColorPalette(color: string) {
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[]) {
actions.some((item) => {
actions.some(item => {
const [flag, action] = item;
if (flag) {
action();

View File

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

View File

@ -7,7 +7,7 @@
export function filterAuthRoutesByUserPermission(routes: AuthRoute.Route[], permission: Auth.RoleType) {
const filters: AuthRoute.Route[] = [];
routes.forEach((route) => {
routes.forEach(route => {
filterAuthRouteByUserPermission(route, permission);
});
return filters;

View File

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

View File

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

View File

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

View File

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

View File

@ -23,7 +23,7 @@ function addPartialProps(menuItem: GlobalMenuOption, icon?: string, children?: G
*/
export function transformAuthRouteToMenu(routes: AuthRoute.Route[]): GlobalMenuOption[] {
const globalMenu: GlobalMenuOption[] = [];
routes.forEach((route) => {
routes.forEach(route => {
const { name, path, meta } = route;
const routeName = name as string;
let menuChildren: GlobalMenuOption[] | undefined;
@ -35,7 +35,7 @@ export function transformAuthRouteToMenu(routes: AuthRoute.Route[]): GlobalMenuO
key: routeName,
label: meta.title,
routeName,
routePath: path,
routePath: path
},
meta?.icon,
menuChildren
@ -55,7 +55,7 @@ export function transformAuthRouteToMenu(routes: AuthRoute.Route[]): GlobalMenuO
* @param menus -
*/
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;
}
@ -65,7 +65,7 @@ function getActiveKeyPathsOfMenu(activeKey: string, menu: GlobalMenuOption) {
keys.push(menu.routeName);
}
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;
}

View File

@ -15,7 +15,7 @@ function sortRoutes(routes: AuthRoute.Route[]) {
export function handleModuleRoutes(modules: AuthRoute.RouteModule) {
const routes: AuthRoute.Route[] = [];
Object.keys(modules).forEach((key) => {
Object.keys(modules).forEach(key => {
const item = modules[key].default;
if (item) {
routes.push(item);

View File

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

View File

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

View File

@ -3,13 +3,43 @@ export async function handleServiceResult<T = any>(error: Service.RequestError |
if (error) {
const fail: Service.FailedResult = {
error,
data: null,
data: null
};
return fail;
}
const success: Service.SuccessResult<T> = {
error: null,
data,
data
};
return success;
}
type Adapter<T = any> = (...args: Service.RequestResult[]) => T;
/**
*
* @param adapter -
* @param args -
*/
export function adapterOfServiceResult<T extends Adapter>(adapter: T, ...args: TypeUtil.GetFunArgs<T>) {
let result: Service.RequestResult | undefined;
const hasError = args.some(item => {
const flag = Boolean(item.error);
if (flag) {
result = {
error: item.error,
data: null
};
}
return flag;
});
if (!hasError) {
result = {
error: null,
data: adapter(...args)
};
}
return result as TypeUtil.GetFunReturn<T>;
}

View File

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

View File

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

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