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

@ -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

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

View File

@ -12,8 +12,8 @@ export function getTabRouteByVueRoute(route: RouteRecordNormalized | RouteLocati
meta: route.meta,
scrollPosition: {
left: 0,
top: 0
}
top: 0,
},
};
return tabRoute;
}
@ -24,7 +24,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

@ -22,21 +22,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: {
/**
@ -53,7 +53,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);
}
@ -75,7 +75,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;
@ -93,7 +93,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;
@ -108,7 +108,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);
}
},
@ -119,7 +119,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);
}
},
@ -154,7 +154,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) {
@ -178,6 +178,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

@ -5,7 +5,7 @@ import type {
ThemeLayoutMode,
ThemeTabMode,
ThemeHorizontalMenuPosition,
ThemeAnimateMode
ThemeAnimateMode,
} from '@/interface';
import { getThemeSettings, getNaiveThemeOverrides, addThemeCssVarsToHtml } from './helpers';
@ -17,13 +17,15 @@ export const useThemeStore = defineStore('theme-store', {
/** naiveUI的主题配置 */
naiveThemeOverrides(state) {
const overrides = getNaiveThemeOverrides({ primary: state.themeColor, ...state.otherColor });
addThemeCssVarsToHtml(overrides.common!);
if (overrides.common) {
addThemeCssVarsToHtml(overrides.common);
}
return overrides;
},
/** naive-ui暗黑主题 */
naiveTheme(state) {
return state.darkMode ? darkTheme : undefined;
}
},
},
actions: {
/** 重置theme状态 */
@ -133,6 +135,6 @@ export const useThemeStore = defineStore('theme-store', {
/** 设置页面过渡动画类型 */
setPageAnimateMode(mode: 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 {
@ -34,7 +34,7 @@ export default function subscribeThemeStore() {
// 监听操作系统主题模式
const stopOsTheme = watch(
osTheme,
newValue => {
(newValue) => {
const isDark = newValue === 'dark';
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) {
document.documentElement.style.overflowX = 'auto';
} else {
@ -69,6 +69,6 @@ function handleWindicssDarkMode() {
}
return {
addDarkClass,
removeDarkClass
removeDarkClass,
};
}