fix: 顶部菜单刷新高亮失效 (#577)

* fix: 顶部菜单刷新高亮失效

* chore: fix lint error
This commit is contained in:
liweijie0812 2023-07-29 15:33:56 +08:00 committed by GitHub
parent 55e639b360
commit be4cf0818a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 13 additions and 7 deletions

View File

@ -17,7 +17,7 @@
"defineProps": "readonly", "defineProps": "readonly",
"defineEmits": "readonly" "defineEmits": "readonly"
}, },
"plugins": ["vue", "@typescript-eslint", "simple-import-sort"], "plugins": ["vue", "@typescript-eslint","import"],
"parserOptions": { "parserOptions": {
"parser": "@typescript-eslint/parser", "parser": "@typescript-eslint/parser",
"sourceType": "module", "sourceType": "module",
@ -38,6 +38,7 @@
"no-shadow": "off", "no-shadow": "off",
"guard-for-in": "off", "guard-for-in": "off",
"import/order": "error",
"import/extensions": "off", "import/extensions": "off",
"import/no-unresolved": "off", "import/no-unresolved": "off",
"import/no-extraneous-dependencies": "off", "import/no-extraneous-dependencies": "off",
@ -66,8 +67,6 @@
"@typescript-eslint/ban-ts-comment": "off", "@typescript-eslint/ban-ts-comment": "off",
"@typescript-eslint/ban-types": "off", "@typescript-eslint/ban-types": "off",
"class-methods-use-this": "off", // 因为AxiosCancel必须实例化而能静态化所以加的规则如果有办法解决可以取消 "class-methods-use-this": "off", // 因为AxiosCancel必须实例化而能静态化所以加的规则如果有办法解决可以取消
"simple-import-sort/imports": "error",
"simple-import-sort/exports": "error"
}, },
"overrides": [ "overrides": [
{ {

View File

@ -53,9 +53,8 @@
"eslint": "^8.45.0", "eslint": "^8.45.0",
"eslint-config-airbnb-base": "^15.0.0", "eslint-config-airbnb-base": "^15.0.0",
"eslint-config-prettier": "^8.9.0", "eslint-config-prettier": "^8.9.0",
"eslint-plugin-import": "^2.27.5", "eslint-plugin-import": "^2.28.0",
"eslint-plugin-prettier": "^4.2.1", "eslint-plugin-prettier": "^4.2.1",
"eslint-plugin-simple-import-sort": "^10.0.0",
"eslint-plugin-vue": "^9.15.1", "eslint-plugin-vue": "^9.15.1",
"eslint-plugin-vue-scoped-css": "^2.5.0", "eslint-plugin-vue-scoped-css": "^2.5.0",
"husky": "^8.0.3", "husky": "^8.0.3",

View File

@ -1,4 +1,3 @@
/* eslint-disable simple-import-sort/imports */
import TDesign from 'tdesign-vue-next'; import TDesign from 'tdesign-vue-next';
import { createApp } from 'vue'; import { createApp } from 'vue';

View File

@ -1,6 +1,8 @@
import uniq from 'lodash/uniq'; import uniq from 'lodash/uniq';
import { createRouter, createWebHistory, RouteRecordRaw, useRoute } from 'vue-router'; import { createRouter, createWebHistory, RouteRecordRaw, useRoute } from 'vue-router';
import { useSettingStore } from '@/store';
const env = import.meta.env.MODE || 'development'; const env = import.meta.env.MODE || 'development';
// 导入homepage相关固定路由 // 导入homepage相关固定路由
@ -60,9 +62,16 @@ export const getRoutesExpanded = () => {
export const getActive = (maxLevel = 3): string => { export const getActive = (maxLevel = 3): string => {
const route = useRoute(); const route = useRoute();
const settingStore = useSettingStore();
if (!route.path) { if (!route.path) {
return ''; return '';
} }
if (settingStore.layout === 'top') {
return route.path.split('/').slice(0, 2).join('/');
}
return route.path return route.path
.split('/') .split('/')
.filter((_item: string, index: number) => index <= maxLevel && index > 0) .filter((_item: string, index: number) => index <= maxLevel && index > 0)

View File

@ -1,6 +1,6 @@
import path from 'path';
import vue from '@vitejs/plugin-vue'; import vue from '@vitejs/plugin-vue';
import vueJsx from '@vitejs/plugin-vue-jsx'; import vueJsx from '@vitejs/plugin-vue-jsx';
import path from 'path';
import { ConfigEnv, loadEnv, UserConfig } from 'vite'; import { ConfigEnv, loadEnv, UserConfig } from 'vite';
import { viteMockServe } from 'vite-plugin-mock'; import { viteMockServe } from 'vite-plugin-mock';
import svgLoader from 'vite-svg-loader'; import svgLoader from 'vite-svg-loader';