Files
Web_Template_Vue3_Dev/AI-Coding/15-Snippet-Map.md

5.0 KiB
Raw Permalink Blame 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/$unsublibrary/plugins/vab.ts
  • 权限指令:v-permissionslibrary/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 / authenticationsrc/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/supportVisitsrc/config/setting.config.js
  • 菜单关键开关:defaultOpeneds/uniqueOpened/openFirstMenusrc/config/setting.config.js
  • 网络请求关键开关:baseURL/successCode/statusName/messageName/requestTimeoutsrc/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
  • 打开搜索快捷键:ctrlKey/metaKey + 'k'library/components/VabSearch/index.vue
  • 历史记录 keyvab_search_historylibrary/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().togglelibrary/components/VabFullScreen/index.vue
  • 页脚标题来源:settings.titlelibrary/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 + defaultOpenedslibrary/components/VabColumnBar/index.vue / src/store/modules/routes.ts / src/config
  • 用户下拉退出:case 'logout' + toLoginRoute(route.fullPath)library/components/VabAvatar/index.vue / src/utils/routes.ts
  • Logo/Title 来源:logo/titlelibrary/components/VabLogo/index.vue / src/store/modules/settings.ts

Link/Fold/Card

  • 外链/内链切换:isExternal(props.to)library/components/VabLink/index.vue / src/utils/validate.ts
  • 折叠按钮:toggleCollapselibrary/components/VabFold/index.vue / src/store/modules/settings.ts
  • Skeleton 卡片:el-skeletonlibrary/components/VabCard/index.vue

User/Auth

  • 登出重置闭包:resetAll()src/store/modules/user.ts,联动 acl/routes/tabs/resetRouter/removeToken

API/Request

  • axios 实例与拦截器:axios.create / instance.interceptorssrc/utils/request.ts
  • 401/402/403 分支:case 401 / case 402 / case 403src/utils/request.ts
  • token 注入:Authorization: Bearersrc/utils/request.ts