From b5dcf924fb7e6e44afa8543b1048cfbbabaf933a Mon Sep 17 00:00:00 2001 From: zikai <1621362626@qq.com> Date: Wed, 22 Jul 2026 02:22:59 +0000 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=96=B0=E5=A2=9E=E5=85=B1=E4=BA=AB?= =?UTF-8?q?=E8=AE=B0=E4=BA=8B=E6=9C=AC=E9=A1=B5=E7=AD=BE=EF=BC=88iframe=20?= =?UTF-8?q?=E5=B5=8C=E5=85=A5=20+=20=E5=AD=98=E6=B4=BB=E6=A0=A1=E9=AA=8C?= =?UTF-8?q?=EF=BC=89=E4=B8=8E=E9=9B=86=E4=B8=AD=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 新增 whiteboard 模块:iframe 嵌入 f.zikai.wang/wb/shared,骨架屏+降级外链 - 存活校验:模块声明 requiresAlive,启动时 no-cors 探测 /health 一次, 服务挂掉则隐藏页签(刷新页面才重探) - 集中配置 src/config/app.config.js:白板 URL/探针/默认记事本 id 统一管理 - 容错强化:注册表/路由/useProjects 单模块异常不影响其他页签,删除一个页签 仅需删其模块文件夹并重新 build - i18n:tabs.whiteboard / common.serviceUnavailable / whiteboard.openExternal - README 精简重写:仅保留项目结构、基础设施、Ubuntu 从0安装、新增页签 --- README.md | 236 ++++++++------------------ src/composables/useLiveness.js | 71 ++++++++ src/composables/useProjects.js | 29 +++- src/config/app.config.js | 30 ++++ src/i18n/locales/en.js | 9 +- src/i18n/locales/zh-CN.js | 9 +- src/modules/index.js | 13 +- src/modules/whiteboard/Whiteboard.vue | 152 +++++++++++++++++ src/modules/whiteboard/index.js | 14 ++ src/router/index.js | 25 ++- 10 files changed, 409 insertions(+), 179 deletions(-) create mode 100644 src/composables/useLiveness.js create mode 100644 src/config/app.config.js create mode 100644 src/modules/whiteboard/Whiteboard.vue create mode 100644 src/modules/whiteboard/index.js diff --git a/README.md b/README.md index b8559b6..a586bdd 100644 --- a/README.md +++ b/README.md @@ -1,209 +1,115 @@ # mainPage · 作品集主页 -Zikai 的作品集主页 -- 一个 **Vue 3 模块化**的多项目展示站点。 -采用**浅色极简**美术风格,**中英双语**并支持**懒加载**(默认中文,只看中文的访客不会下载英文资源)。 -设计目标:高内聚低耦合、可扩展 -- 后续每个新项目都是一个独立「模块」,自动生成页签与路由。 - -> 这是「主页」项目本身。它展示的第一个项目页签是 448/449 移动游戏毕设, -> 详见同级目录下的 `/root/html/448/README.md` 与 `/root/html/449/README.md`。 +Zikai 的作品集主页 -- Vue 3 模块化多项目展示站。浅色极简、中英双语(英文按需懒加载)。 +每个项目页签是一个独立「模块」,由注册表自动生成页签与路由 -- 新增/删除页签只增删一个文件夹,互不影响。 --- -## 技术栈 - -| 层 | 选型 | -|---|---| -| 框架 | Vue 3(` + + + + + {{ t('tabs.whiteboard') }} + + + + {{ t('common.serviceUnavailable') }} + + {{ t('whiteboard.openExternal') }} + + + + + + + + {{ t('common.loading') }} + + + + + + + + + diff --git a/src/modules/whiteboard/index.js b/src/modules/whiteboard/index.js new file mode 100644 index 0000000..5c50101 --- /dev/null +++ b/src/modules/whiteboard/index.js @@ -0,0 +1,14 @@ +// 模块元数据 -- 共享记事本(白板)页签 +// requiresAlive 指向存活探针 URL:启动时探测,服务不可达则隐藏该页签。 +// 删除本目录即可移除此页签,其余模块不受影响。 +import { healthUrl } from '../../config/app.config.js' + +export default { + id: 'whiteboard', + tabKey: 'tabs.whiteboard', + order: 2, + // 存活探针 URL;useProjects 启动时探测一次,挂掉则不显示页签 + requiresAlive: healthUrl('whiteboard'), + // 懒加载组件 -> 独立 chunk + component: () => import('./Whiteboard.vue') +} diff --git a/src/router/index.js b/src/router/index.js index 8a88b64..378d85e 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -2,18 +2,29 @@ import { createRouter, createWebHistory } from 'vue-router' import modules from '../modules/index.js' +const moduleRoutes = modules + .map((m) => { + try { + return { + path: `/${m.id}`, + name: m.id, + component: m.component, + meta: { moduleId: m.id } + } + } catch (e) { + console.warn(`[router] 模块 ${m?.id} 路由生成失败,已跳过:`, e) + return null + } + }) + .filter(Boolean) + const routes = [ { path: '/', - redirect: modules.length ? `/${modules[0].id}` : '/404' + redirect: moduleRoutes.length ? moduleRoutes[0].path : '/404' }, // 每个模块一条路由,组件懒加载 - ...modules.map((m) => ({ - path: `/${m.id}`, - name: m.id, - component: m.component, - meta: { moduleId: m.id } - })), + ...moduleRoutes, { path: '/:pathMatch(.*)*', name: 'not-found',
{{ t('common.serviceUnavailable') }}