chore(frontend): introduce prettier + eslint and prune unused code
- Add Prettier 3 with prettier-plugin-organize-imports (sorts/removes unused imports) - Add ESLint 10 flat config with typescript-eslint + eslint-plugin-vue + eslint-config-prettier - Add root scripts: format, format:check, lint, lint:fix - Reformat 257 files across admin-web, ops-web, desktop-client, packages - Remove unused locals/exports flagged by --noUnusedLocals/--noUnusedParameters - Fix duplicate localTabLabel key, surrogate-pair regex u-flag, NBSP literal in regex - Skip server/ (Go) and apps/browser-extension/ (deprecated per ADR) Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -1,91 +1,91 @@
|
||||
import { createRouter, createWebHistory } from "vue-router";
|
||||
import { createRouter, createWebHistory } from 'vue-router'
|
||||
|
||||
import { pinia } from "@/stores/pinia";
|
||||
import { useAuthStore } from "@/stores/auth";
|
||||
import { useAuthStore } from '@/stores/auth'
|
||||
import { pinia } from '@/stores/pinia'
|
||||
|
||||
export const router = createRouter({
|
||||
history: createWebHistory(),
|
||||
routes: [
|
||||
{
|
||||
path: "/login",
|
||||
name: "login",
|
||||
component: () => import("@/views/LoginView.vue"),
|
||||
meta: { title: "登录" },
|
||||
path: '/login',
|
||||
name: 'login',
|
||||
component: () => import('@/views/LoginView.vue'),
|
||||
meta: { title: '登录' },
|
||||
},
|
||||
{
|
||||
path: "/",
|
||||
component: () => import("@/layouts/AppShell.vue"),
|
||||
path: '/',
|
||||
component: () => import('@/layouts/AppShell.vue'),
|
||||
meta: { requiresAuth: true },
|
||||
children: [
|
||||
{ path: "", redirect: "/admin-users" },
|
||||
{ path: '', redirect: '/admin-users' },
|
||||
{
|
||||
path: "admin-users",
|
||||
name: "admin-users",
|
||||
component: () => import("@/views/AdminUsersView.vue"),
|
||||
meta: { title: "用户管理" },
|
||||
path: 'admin-users',
|
||||
name: 'admin-users',
|
||||
component: () => import('@/views/AdminUsersView.vue'),
|
||||
meta: { title: '用户管理' },
|
||||
},
|
||||
{
|
||||
path: "kol-subscriptions",
|
||||
name: "kol-subscriptions",
|
||||
component: () => import("@/views/KolSubscriptionsView.vue"),
|
||||
meta: { title: "订阅包审批" },
|
||||
path: 'kol-subscriptions',
|
||||
name: 'kol-subscriptions',
|
||||
component: () => import('@/views/KolSubscriptionsView.vue'),
|
||||
meta: { title: '订阅包审批' },
|
||||
},
|
||||
{
|
||||
path: "accounts",
|
||||
name: "accounts",
|
||||
component: () => import("@/views/AccountsView.vue"),
|
||||
meta: { title: "操作员管理" },
|
||||
path: 'accounts',
|
||||
name: 'accounts',
|
||||
component: () => import('@/views/AccountsView.vue'),
|
||||
meta: { title: '操作员管理' },
|
||||
},
|
||||
{
|
||||
path: "audits",
|
||||
name: "audits",
|
||||
component: () => import("@/views/AuditLogsView.vue"),
|
||||
meta: { title: "审计日志" },
|
||||
path: 'audits',
|
||||
name: 'audits',
|
||||
component: () => import('@/views/AuditLogsView.vue'),
|
||||
meta: { title: '审计日志' },
|
||||
},
|
||||
{
|
||||
path: "site-domain-mappings",
|
||||
name: "site-domain-mappings",
|
||||
component: () => import("@/views/SiteDomainMappingsView.vue"),
|
||||
meta: { title: "站点映射" },
|
||||
path: 'site-domain-mappings',
|
||||
name: 'site-domain-mappings',
|
||||
component: () => import('@/views/SiteDomainMappingsView.vue'),
|
||||
meta: { title: '站点映射' },
|
||||
},
|
||||
{
|
||||
path: "profile",
|
||||
name: "profile",
|
||||
component: () => import("@/views/ProfileView.vue"),
|
||||
meta: { title: "个人资料" },
|
||||
path: 'profile',
|
||||
name: 'profile',
|
||||
component: () => import('@/views/ProfileView.vue'),
|
||||
meta: { title: '个人资料' },
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
path: "/:pathMatch(.*)*",
|
||||
redirect: "/",
|
||||
path: '/:pathMatch(.*)*',
|
||||
redirect: '/',
|
||||
},
|
||||
],
|
||||
});
|
||||
})
|
||||
|
||||
router.beforeEach((to) => {
|
||||
const auth = useAuthStore(pinia);
|
||||
const auth = useAuthStore(pinia)
|
||||
if (!auth.initialized) {
|
||||
auth.hydrate();
|
||||
auth.hydrate()
|
||||
}
|
||||
|
||||
if (to.meta.requiresAuth && !auth.isAuthenticated) {
|
||||
return {
|
||||
name: "login",
|
||||
query: to.fullPath !== "/" ? { redirect: to.fullPath } : undefined,
|
||||
};
|
||||
name: 'login',
|
||||
query: to.fullPath !== '/' ? { redirect: to.fullPath } : undefined,
|
||||
}
|
||||
}
|
||||
|
||||
if (to.name === "login" && auth.isAuthenticated) {
|
||||
return { name: "admin-users" };
|
||||
if (to.name === 'login' && auth.isAuthenticated) {
|
||||
return { name: 'admin-users' }
|
||||
}
|
||||
|
||||
return true;
|
||||
});
|
||||
return true
|
||||
})
|
||||
|
||||
router.afterEach((to) => {
|
||||
if (typeof document !== "undefined") {
|
||||
const t = (to.meta.title as string | undefined) ?? "运营后台";
|
||||
document.title = `${t} · 省心推`;
|
||||
if (typeof document !== 'undefined') {
|
||||
const t = (to.meta.title as string | undefined) ?? '运营后台'
|
||||
document.title = `${t} · 省心推`
|
||||
}
|
||||
});
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user