update prettier 替换为 oxfmt 格式化整个项目的代码结构

This commit is contained in:
疯狂的狮子Li
2026-04-01 17:03:20 +08:00
parent 199771997d
commit 16d9e1e7fe
131 changed files with 3750 additions and 1571 deletions
+6 -6
View File
@@ -21,7 +21,7 @@ export const useNoticeStore = defineStore('notice', () => {
notices: [] as NoticeItem[]
});
const unreadCount = computed(() => state.notices.filter((item) => !item.read).length);
const unreadCount = computed(() => state.notices.filter(item => !item.read).length);
const buildNoticeKey = (notice: NoticeItem) => {
if (notice.messageId !== undefined && notice.messageId !== null) {
@@ -41,7 +41,7 @@ export const useNoticeStore = defineStore('notice', () => {
const addNotice = (notice: NoticeItem) => {
const key = buildNoticeKey(notice);
const index = state.notices.findIndex((item) => buildNoticeKey(item) === key);
const index = state.notices.findIndex(item => buildNoticeKey(item) === key);
if (index > -1) {
state.notices[index] = {
...state.notices[index],
@@ -57,15 +57,15 @@ export const useNoticeStore = defineStore('notice', () => {
if (messageId === undefined || messageId === null) {
return;
}
const target = state.notices.find((item) => String(item.messageId) === String(messageId));
const target = state.notices.find(item => String(item.messageId) === String(messageId));
if (target) {
target.read = true;
}
};
const markReadBatch = (messageIds: Array<string | number>) => {
const idSet = new Set(messageIds.map((item) => String(item)));
state.notices.forEach((item) => {
const idSet = new Set(messageIds.map(item => String(item)));
state.notices.forEach(item => {
if (item.messageId !== undefined && item.messageId !== null && idSet.has(String(item.messageId))) {
item.read = true;
}
@@ -75,7 +75,7 @@ export const useNoticeStore = defineStore('notice', () => {
const readAll = () => {
markReadBatch(
state.notices
.map((item) => item.messageId)
.map(item => item.messageId)
.filter((item): item is string | number => item !== undefined && item !== null)
);
};
+12 -8
View File
@@ -56,7 +56,7 @@ export const usePermissionStore = defineStore('permission', () => {
const rewriteRoutes = filterAsyncRouter(rdata, undefined, true);
const defaultRoutes = filterAsyncRouter(defaultData);
const asyncRoutes = filterDynamicRoutes(dynamicRoutes);
asyncRoutes.forEach((route) => {
asyncRoutes.forEach(route => {
router.addRoute(route);
});
setRoutes(rewriteRoutes);
@@ -65,7 +65,7 @@ export const usePermissionStore = defineStore('permission', () => {
setTopbarRoutes(defaultRoutes);
// 路由name重复检查
duplicateRouteChecker(asyncRoutes, sidebarRoutes);
return new Promise<RouteRecordRaw[]>((resolve) => resolve(rewriteRoutes));
return new Promise<RouteRecordRaw[]>(resolve => resolve(rewriteRoutes));
};
/**
@@ -74,8 +74,12 @@ export const usePermissionStore = defineStore('permission', () => {
* @param lastRouter 上一级路由
* @param type 是否是重写路由
*/
const filterAsyncRouter = (asyncRouterMap: RouteRecordRaw[], lastRouter?: RouteRecordRaw, type = false): RouteRecordRaw[] => {
return asyncRouterMap.filter((route) => {
const filterAsyncRouter = (
asyncRouterMap: RouteRecordRaw[],
lastRouter?: RouteRecordRaw,
type = false
): RouteRecordRaw[] => {
return asyncRouterMap.filter(route => {
if (type && route.children) {
route.children = filterChildren(route.children, undefined);
}
@@ -100,7 +104,7 @@ export const usePermissionStore = defineStore('permission', () => {
};
const filterChildren = (childrenMap: RouteRecordRaw[], lastRouter?: RouteRecordRaw): RouteRecordRaw[] => {
let children: RouteRecordRaw[] = [];
childrenMap.forEach((el) => {
childrenMap.forEach(el => {
el.path = lastRouter ? lastRouter.path + '/' + el.path : el.path;
if (el.children && el.children.length && el.component?.toString() === 'ParentView') {
children = children.concat(filterChildren(el.children, el));
@@ -130,7 +134,7 @@ export const usePermissionStore = defineStore('permission', () => {
// 动态路由遍历,验证是否具备权限
export const filterDynamicRoutes = (routes: RouteRecordRaw[]) => {
const res: RouteRecordRaw[] = [];
routes.forEach((route) => {
routes.forEach(route => {
if (route.permissions) {
if (auth.hasPermiOr(route.permissions)) {
res.push(route);
@@ -178,7 +182,7 @@ function duplicateRouteChecker(localRoutes: Route[], routes: Route[]) {
// 展平
function flatRoutes(routes: Route[]) {
const res: Route[] = [];
routes.forEach((route) => {
routes.forEach(route => {
if (route.children) {
res.push(...flatRoutes(route.children));
} else {
@@ -191,7 +195,7 @@ function duplicateRouteChecker(localRoutes: Route[], routes: Route[]) {
const allRoutes = flatRoutes([...localRoutes, ...routes]);
const nameList: string[] = [];
allRoutes.forEach((route) => {
allRoutes.forEach(route => {
const name = route.name?.toString() ?? '';
if (name && nameList.includes(name)) {
const message = `路由名称: [${name}] 重复, 会造成 404`;
+24 -21
View File
@@ -34,8 +34,8 @@ const saveVisitedViews = (views: any[]) => {
}
const payload: PersistedTagView[] = (views as TagView[])
.filter((view) => !view.meta?.affix)
.map((view) => ({
.filter(view => !view.meta?.affix)
.map(view => ({
path: view.path,
fullPath: view.fullPath,
name: view.name,
@@ -91,7 +91,7 @@ export const useTagsViewStore = defineStore('tagsView', () => {
};
const delIframeView = (view: RouteLocationNormalized): Promise<RouteLocationNormalized[]> => {
return new Promise((resolve) => {
return new Promise(resolve => {
iframeViews.value = iframeViews.value.filter((item: RouteLocationNormalized) => item.path !== view.path);
resolve(iframeViews.value.slice() as RouteLocationNormalized[]);
});
@@ -105,7 +105,7 @@ export const useTagsViewStore = defineStore('tagsView', () => {
const addAffixView = (view: RouteLocationNormalized): void => {
if (visitedViews.value.some((v: RouteLocationNormalized) => v.path === view.path)) return;
const insertIndex = visitedViews.value.findIndex((item) => !item.meta?.affix);
const insertIndex = visitedViews.value.findIndex(item => !item.meta?.affix);
const normalizedView = normalizeVisitedView(view);
if (insertIndex === -1) {
visitedViews.value.push(normalizedView);
@@ -115,8 +115,8 @@ export const useTagsViewStore = defineStore('tagsView', () => {
};
const loadPersistedViews = (): void => {
loadVisitedViews().forEach((view) => {
if (visitedViews.value.some((item) => item.path === view.path)) {
loadVisitedViews().forEach(view => {
if (visitedViews.value.some(item => item.path === view.path)) {
return;
}
@@ -141,7 +141,7 @@ export const useTagsViewStore = defineStore('tagsView', () => {
visitedViews: RouteLocationNormalized[];
cachedViews: string[];
}> => {
return new Promise((resolve) => {
return new Promise(resolve => {
delVisitedView(view);
if (!isDynamicRoute(view)) {
delCachedView(view);
@@ -154,7 +154,7 @@ export const useTagsViewStore = defineStore('tagsView', () => {
};
const delVisitedView = (view: RouteLocationNormalized): Promise<RouteLocationNormalized[]> => {
return new Promise((resolve) => {
return new Promise(resolve => {
for (const [i, v] of visitedViews.value.entries()) {
if (v.path === view.path) {
visitedViews.value.splice(i, 1);
@@ -171,7 +171,7 @@ export const useTagsViewStore = defineStore('tagsView', () => {
if (view) {
viewName = view.name as string;
}
return new Promise((resolve) => {
return new Promise(resolve => {
const index = cachedViews.value.indexOf(viewName);
index > -1 && cachedViews.value.splice(index, 1);
resolve([...cachedViews.value]);
@@ -184,7 +184,7 @@ export const useTagsViewStore = defineStore('tagsView', () => {
visitedViews: RouteLocationNormalized[];
cachedViews: string[];
}> => {
return new Promise((resolve) => {
return new Promise(resolve => {
delOthersVisitedViews(view);
delOthersCachedViews(view);
resolve({
@@ -195,7 +195,7 @@ export const useTagsViewStore = defineStore('tagsView', () => {
};
const delOthersVisitedViews = (view: RouteLocationNormalized): Promise<RouteLocationNormalized[]> => {
return new Promise((resolve) => {
return new Promise(resolve => {
visitedViews.value = visitedViews.value.filter((v: RouteLocationNormalized) => {
return v.meta?.affix || v.path === view.path;
});
@@ -206,7 +206,7 @@ export const useTagsViewStore = defineStore('tagsView', () => {
const delOthersCachedViews = (view: RouteLocationNormalized): Promise<string[]> => {
const viewName = view.name as string;
return new Promise((resolve) => {
return new Promise(resolve => {
const index = cachedViews.value.indexOf(viewName);
if (index > -1) {
cachedViews.value = cachedViews.value.slice(index, index + 1);
@@ -217,8 +217,11 @@ export const useTagsViewStore = defineStore('tagsView', () => {
});
};
const delAllViews = (): Promise<{ visitedViews: RouteLocationNormalized[]; cachedViews: string[] }> => {
return new Promise((resolve) => {
const delAllViews = (): Promise<{
visitedViews: RouteLocationNormalized[];
cachedViews: string[];
}> => {
return new Promise(resolve => {
delAllVisitedViews();
delAllCachedViews();
resolve({
@@ -229,7 +232,7 @@ export const useTagsViewStore = defineStore('tagsView', () => {
};
const delAllVisitedViews = (): Promise<RouteLocationNormalized[]> => {
return new Promise((resolve) => {
return new Promise(resolve => {
visitedViews.value = visitedViews.value.filter((tag: RouteLocationNormalized) => tag.meta?.affix);
clearVisitedViews();
resolve(visitedViews.value.slice() as RouteLocationNormalized[]);
@@ -237,7 +240,7 @@ export const useTagsViewStore = defineStore('tagsView', () => {
};
const delAllCachedViews = (): Promise<string[]> => {
return new Promise((resolve) => {
return new Promise(resolve => {
cachedViews.value = [];
resolve([...cachedViews.value]);
});
@@ -254,10 +257,10 @@ export const useTagsViewStore = defineStore('tagsView', () => {
};
const delRightTags = (view: RouteLocationNormalized): Promise<RouteLocationNormalized[]> => {
return new Promise((resolve) => {
return new Promise(resolve => {
const index = visitedViews.value.findIndex((v: RouteLocationNormalized) => v.path === view.path);
if (index === -1) {
resolve(visitedViews.value.slice() as RouteLocationNormalized[]);
resolve(visitedViews.value.slice() as RouteLocationNormalized[]);
return;
}
visitedViews.value = visitedViews.value.filter((item: RouteLocationNormalized, idx: number) => {
@@ -276,10 +279,10 @@ export const useTagsViewStore = defineStore('tagsView', () => {
};
const delLeftTags = (view: RouteLocationNormalized): Promise<RouteLocationNormalized[]> => {
return new Promise((resolve) => {
return new Promise(resolve => {
const index = visitedViews.value.findIndex((v: RouteLocationNormalized) => v.path === view.path);
if (index === -1) {
resolve(visitedViews.value.slice() as RouteLocationNormalized[]);
resolve(visitedViews.value.slice() as RouteLocationNormalized[]);
return;
}
visitedViews.value = visitedViews.value.filter((item: RouteLocationNormalized, idx: number) => {
@@ -307,7 +310,7 @@ export const useTagsViewStore = defineStore('tagsView', () => {
};
const isDynamicRoute = (view: RouteLocationNormalized): boolean => {
return view.matched.some((m) => m.path.includes(':'));
return view.matched.some(m => m.path.includes(':'));
};
return {