Files

116 lines
5.0 KiB
Markdown
Raw Permalink Normal View History

# 15. 代码段地图Snippet Map
> 目的:给后续 AI coding 的“最常用代码段”提供**稳定来源与检索方式**,直接指向文件/关键词。
## 初始化与自动加载
- `setupVab(app)``library/index.ts`
- 背景 SCSS 自动加载:`require.context('./styles/background', false, /\\.scss$/)`
- 插件自动加载:`require.context('./plugins', true, /\\.ts$/)` + `app.use(Plugins(key).default)`
## Theme主题
- 打开抽屉事件:`$pub('theme')``library/components/VabTheme/*`
- 随机换肤事件:`$pub('random-theme')`
- 主题变量注入:`useSettingsStore().updateTheme()``src/store/modules/settings.ts`
- scss module 来源:`@vab/styles/variables/vab-*-variables.module.scss`
## Plugins全局注入/事件总线/指令)
- 事件总线注入:`$pub/$sub/$unsub``library/plugins/vab.ts`
- 权限指令:`v-permissions``library/plugins/directive.ts`
- 权限判断:`hasPermission()``src/utils/permission.ts`
## IconsSVG
- SVG 自动加载:`require.context('.', true, /\\.svg$/)``src/icon/index.ts`
## Router/Routes
- 后端路由转换:`convertRouter()``src/utils/routes.ts`
- 路由模式切换:`authentication === 'all'``src/store/modules/routes.ts`
- 过滤可访问路由:`filterRoutes([...constantRoutes, ...routes], control)``src/store/modules/routes.ts`
- 重置路由:`resetRouter(accessRoutes)``src/store/modules/routes.ts` / `src/router`
## Router Permissions
- 路由守卫入口:`setupPermissions(router)``src/router/permissions.ts`
- 白名单/登录拦截开关:`routesWhiteList` / `loginInterception` / `authentication``src/router/permissions.ts` / `src/config`
- 更新标题:`document.title = getPageTitle(to.meta.title)``src/router/permissions.ts`
## Config
- 配置聚合入口:`module.exports = { ...cli, ...setting, ...theme, ...network }``src/config/index.js`
- 路由/登录关键开关:`authentication/loginInterception/routesWhiteList/supportVisit``src/config/setting.config.js`
- 菜单关键开关:`defaultOpeneds/uniqueOpened/openFirstMenu``src/config/setting.config.js`
- 网络请求关键开关:`baseURL/successCode/statusName/messageName/requestTimeout``src/config/net.config.js`
## Router View
- 刷新当前视图缓存:`$sub('reload-router-view', ...)``library/components/VabRouterView/index.vue`
## Menu
- 点击当前菜单刷新:`$pub('reload-router-view')``library/components/VabMenu/components/VabMenuItem.vue`
## Refresh
- 刷新按钮触发:`$pub('reload-router-view')``library/components/VabRefresh/index.vue`
## Search
- 打开搜索快捷键:`ctrlKey/metaKey + 'k'``library/components/VabSearch/index.vue`
- 历史记录 key`vab_search_history``library/components/VabSearch/index.vue`
## Lock
- 锁屏开关:`handleLock()` / `handleUnLock()``library/components/VabLock/index.vue`
- 直接操作侧边栏:`document.querySelector('.vab-side-bar')``library/components/VabLock/index.vue`
## Notice
- 拉取通知:`getList()``library/components/VabNotice/index.vue` / `src/api/notice.ts`
## Language
- 语言切换:`useI18n().locale` / `changeLanguage(``library/components/VabLanguage/index.vue` / `src/store/modules/settings.ts`
- 切换后更新标题:`getPageTitle(``library/components/VabLanguage/index.vue` / `src/utils/pageTitle.ts`
## FullScreen
- 全屏切换:`useFullscreen().toggle``library/components/VabFullScreen/index.vue`
## Footer
- 页脚标题来源:`settings.title``library/components/VabFooter/index.vue` / `src/store/modules/settings.ts`
## Nav/Breadcrumb
- 顶部导航聚合:`<vab-nav />``library/components/VabNav/index.vue`
- 面包屑生成:`handleMatched(``library/components/VabBreadcrumb/index.vue` / `src/utils/routes.ts`
## Column Bar
- Column 二级菜单:`partialRoutes` + `defaultOpeneds``library/components/VabColumnBar/index.vue` / `src/store/modules/routes.ts` / `src/config`
## Avatar/Logo
- 用户下拉退出:`case 'logout'` + `toLoginRoute(route.fullPath)``library/components/VabAvatar/index.vue` / `src/utils/routes.ts`
- Logo/Title 来源:`logo/title``library/components/VabLogo/index.vue` / `src/store/modules/settings.ts`
## Link/Fold/Card
- 外链/内链切换:`isExternal(props.to)``library/components/VabLink/index.vue` / `src/utils/validate.ts`
- 折叠按钮:`toggleCollapse``library/components/VabFold/index.vue` / `src/store/modules/settings.ts`
- Skeleton 卡片:`el-skeleton``library/components/VabCard/index.vue`
## User/Auth
- 登出重置闭包:`resetAll()``src/store/modules/user.ts`,联动 acl/routes/tabs/resetRouter/removeToken
## API/Request
- axios 实例与拦截器:`axios.create` / `instance.interceptors``src/utils/request.ts`
- 401/402/403 分支:`case 401` / `case 402` / `case 403``src/utils/request.ts`
- token 注入:`Authorization: Bearer``src/utils/request.ts`