Files
Web_Template_Vue3_Dev/AI-Coding/16-Config-Keys.md

77 lines
3.4 KiB
Markdown
Raw Permalink 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.
# 16. Config Key Mapsrc/config
> 目的:让 AI 在迁移/新项目开发时,明确“哪些行为由哪些 config key 控制”,并能快速定位 key 的定义与使用点。
## 聚合入口
- `src/config/index.js` 会把 4 份配置聚合导出:
- `cli.config.js`(构建/CLI 相关)
- `setting.config.js`(通用/登录/路由/菜单/缓存等)
- `theme.config.js`(主题与 UI 开关默认值)
- `net.config.js`(网络请求相关)
注意:`src/config/*` 可能会被 `vue.config.js` 在 Node 环境 `require()` 读取,因此配置文件应避免使用 `window/document`
## 高影响 keys按子系统分组
### 路由/权限/登录
- `authentication`:路由模式(`intelligence` 前端路由 / `all` 后端路由)
- `loginInterception`:是否开启登录拦截(影响 `setupPermissions` 行为)
- `routesWhiteList`:白名单路由(不校验 token
- `supportVisit`:游客模式
- `rolesControl`:是否按 `roles` 字段进行角色控制
- `isHashRouterMode`hash/history 模式相关逻辑(菜单里对 `_blank` 打开内部路由有分支)
- `publicPath`:路由/跳转时可能需要的 publicPath
### Token/存储
- `tokenName`token 字段名
- `tokenTableName`:存储 key 名
- `storage``localStorage/sessionStorage/cookie`
- `recordRoute`token 失效回到登录页时是否记录本次路由
### 页面标题
- `title`:系统标题(影响 `getPageTitle`/浏览器标题/雪花屏标题等)
- `titleSeparator`:标题分隔符
- `titleReverse`:标题是否反转
### 菜单/导航体验
- `uniqueOpened`:是否只保持一个子菜单展开
- `defaultOpeneds`:默认展开菜单 path 列表
- `openFirstMenu`:是否点击一级菜单默认开启二级菜单
- `debounce`:需要加 loading 层防重复提交的请求标识列表
- `keepAliveMaxNum`keep-alive 最大缓存数量
### Theme 默认值与开关theme.config.js
- 默认值:`layout/themeName/background/menuWidth/columnStyle/...`
- UI 开关:`showProgressBar/showTabs/showLanguage/showRefresh/showSearch/showTheme/showNotice/showFullScreen/showThemeSetting/showLock/...`
### 网络请求net.config.js
- `baseURL` / `contentType` / `requestTimeout`
- `successCode` / `statusName` / `messageName`
### 构建/CLIcli.config.js
- `devPort/outputDir/assetsDir/publicPath`
- `pwa/buildOptimize/noDebugger/lintOnSave`
## 常见使用点(快速定位)
- 路由守卫:`src/router/permissions.ts``authentication/loginInterception/routesWhiteList/supportVisit` + `showProgressBar`
- Router 定义:`src/router/index.ts``authentication/isHashRouterMode/publicPath`
- 菜单:`library/components/VabMenu/components/VabMenuItem.vue``isHashRouterMode`
- 路由 store`src/store/modules/routes.ts``authentication/rolesControl`
- 标题工具:`src/utils/pageTitle.ts``titleSeparator/titleReverse`
- token 工具:`src/utils/token.ts``storage/tokenTableName`
- request`src/utils/request.ts``baseURL/successCode/statusName/messageName/requestTimeout/contentType` 等)
## 迁移/复用提示(最小闭包)
-`router`/`request`/`menu` 等模块时,**优先把 `src/config/*` 一并带走**,避免 key 缺失导致行为变化。
- 如果目标项目要改 key 名或改配置来源(例如改成 `.env` 或远端配置),建议先在规格里写清“映射关系”和“验收点”。