Files
zMainPage/vite.config.js
zikai 25dbceee2d refactor: 清理死代码/提前失败/高内聚低耦合,重写文档
死代码清理:
- 删除未使用的 UI 组件 Card.vue / Tag.vue
- 移除 app.config.js 死字段 healthTimeoutMs(×2)与 isDev()
- 移除 PageShell.vue 死 prop padded(恒为默认值)
- 移除 useLocale.js 死导出 isZh/pick/locale
- 移除 router/index.js 不可达 try/catch,简化为直接 .map()
- 移除 package.json 重复依赖 ical.js(子模块自带)
- 移除 i18n 死键 common.notAvailable / common.serviceUnavailable
- 移除 vite.config.js 陈旧的 /448 /449 dev proxy(z449 为构建期组件,不走该 URL)

提前失败/日志:
- useI18nLazy.js switchLocale 加载语言包失败时 console.error 记录(原静默吞错)
- modules/index.js 字段不全的模块跳过时 console.warn 告警(原与文档承诺不符、静默跳过)
- deploy.sh 补齐 zWhiteBoard / zPDF_package 的 npm install 与子模块初始化
  (均为构建期组件 import,全新检出时缺少依赖会构建失败)

文档对齐现状(无 iframe、无外部域名):
- README 改写为简洁版,修正 iframe/ical.js/子模块数量过时描述
- architecture.md 修正 requiresAlive 示例(同源 /api/health,非外部域名)
  与「仅白板使用」断言(PDF 也用);移除已删 padded prop
- add-module.md 同步移除 padded、修正 requiresAlive 示例
- submodule-timeTableFix.md 修正 ical.js 归属(子模块自带,非父项目共享)
- submodule-zPDF_package.md 子项目数量 3 -> 4
- 新增 submodule-zWhiteBoard.md
- readme-fixes.md 记录本次勘误
2026-07-28 11:57:32 +08:00

67 lines
2.1 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import { minify } from 'html-minifier-terser'
// 构建到项目本地 dist/(每次清空,避免旧产物残留),
// 再由 `npm run deploy` 或 `deploy.sh` 用 rsync 同步到 Apache 站点根 /var/www/html。
// 文件名去掉内容 hash保持稳定JS 由 esbuild 压缩HTML 由下方插件压缩。
// 用 mainPage/ 命名空间子目录避免与 /var/www/html/js、/var/www/html/css 既有旧文件冲突。
function minifyHtml() {
return {
name: 'minify-html',
apply: 'build',
transformIndexHtml: {
order: 'post',
handler(html) {
return minify(html, {
collapseWhitespace: true,
removeComments: true,
removeRedundantAttributes: true,
removeScriptTypeAttributes: true,
removeStyleLinkTypeAttributes: true,
collapseBooleanAttributes: true,
minifyCSS: true,
minifyJS: true,
})
},
},
}
}
export default defineConfig({
plugins: [vue(), minifyHtml()],
base: '/',
build: {
outDir: 'dist',
// ★ dist 在项目内,安全清空,杜绝旧 hash 文件堆积
emptyOutDir: true,
rollupOptions: {
output: {
// 稳定文件名:去掉 [hash],便于部署与长效缓存策略
entryFileNames: 'js/mainPage/[name].js',
chunkFileNames: 'js/mainPage/[name].js',
assetFileNames: (assetInfo) => {
const name = assetInfo.name || ''
if (name.endsWith('.css')) {
return 'css/mainPage/[name][extname]'
}
return 'assets/mainPage/[name][extname]'
},
},
},
},
server: {
port: 5173,
proxy: {
// zTools2 后端同源代理所有入口API/静态/探针/WS统一在 /api/ 下,一条规则即可。
// ws:true 让 /api/ws/wb/{id} 的 WebSocket 也走此代理。
// 同源相对路径与环境无关dev 命中本地 zTools2生产由反代命中当前环境 zTools2。
'/api': {
target: 'http://127.0.0.1:6867',
changeOrigin: true,
ws: true,
},
},
},
})