docs: annotate all shared frontend modules in Chinese

This commit is contained in:
cieanyau committed 2026-11-06 00:30:15 +08:00
1 parent 2be21c1c62
commit 408f8e5c98
55 files changed
+349

No files matched your search

+2
View File
@@ -1,3 +1,4 @@
/** 最早安装 Pinia 和 PrimeVue 服务,确保后续启动插件能使用 store、弹窗和提示。 */
import { defineNuxtPlugin } from "#app";
import { createPinia } from "pinia";
import PrimeVue from "primevue/config";
@@ -10,6 +11,7 @@ import options from "~/config/primevue.js";
export default defineNuxtPlugin({
name: "console-ui",
order: -20,
// 客户端插件只注册一次;具体主题/中文文案集中在 config/primevue.js。
setup({ vueApp }) {
vueApp.use(createPinia());
vueApp.use(PrimeVue, options);
+2
View File
@@ -1,3 +1,4 @@
/** 应用启动加载公共配置;已有登录态时并行预取菜单和账户概览,单项失败不阻断启动。 */
import { defineNuxtPlugin } from "#app";
import { useAuth, useApi } from "~/lib/auth.js";
import { t as useSiteConfig } from "~/lib/useSiteConfig.js";
@@ -9,6 +10,7 @@ export default defineNuxtPlugin({
async setup() {
const auth = useAuth();
const tasks = [useSiteConfig().load()];
// 旧平台入口的 JWT 尚待专页核验,不能在此提前当成可信会话加载私有资料。
if (auth.isLoggedIn && window.location.pathname !== "/home.htm") {
tasks.push(useNavigation(auth, useApi()).load(), auth.fetchOverview());
}
+3
View File
@@ -1,3 +1,4 @@
/** 同源多标签页会话同步:监听 jwt/clear 变更,退出时将当前受保护页面替换为登录页。 */
import { defineNuxtPlugin } from "#app";
import { useAuth, isValidJwt } from "~/lib/auth.js";
import { r as safeRedirect } from "~/lib/auth-redirect.js";
@@ -9,6 +10,7 @@ export default defineNuxtPlugin({
setup(app) {
const auth = useAuth();
const router = app.$router;
// 只处理 localStorage 会话事件;读取最新值而非 event.newValue,避免积压事件倒退状态。
function reconcileSession(event) {
if (
event.storageArea !== localStorage ||
@@ -30,6 +32,7 @@ export default defineNuxtPlugin({
}
}
window.addEventListener("storage", reconcileSession);
// 应用销毁时解绑,避免热重载或重新挂载后叠加处理同一 storage 事件。
app.vueApp.onUnmount(() =>
window.removeEventListener("storage", reconcileSession),
);