config.mts 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374
  1. import type { DefaultTheme, HeadConfig } from 'vitepress';
  2. import { resolve } from 'node:path';
  3. import { type PwaOptions, withPwa } from '@vite-pwa/vitepress';
  4. import { defineConfigWithTheme } from 'vitepress';
  5. import { version } from '../../package.json';
  6. export default withPwa(
  7. defineConfigWithTheme({
  8. description: 'Vben Admin& 企业级管理系统框架',
  9. head: head(),
  10. lang: 'zh',
  11. pwa: pwa(),
  12. // locales: {
  13. // en: {
  14. // label: 'English',
  15. // lang: 'en',
  16. // link: '/en/',
  17. // },
  18. // root: {
  19. // label: '简体中文',
  20. // lang: 'zh-CN',
  21. srcDir: 'src',
  22. // },
  23. themeConfig: {
  24. darkModeSwitchLabel: '主题',
  25. darkModeSwitchTitle: '切换到深色模式',
  26. docFooter: {
  27. next: '下一页',
  28. prev: '上一页',
  29. },
  30. editLink: {
  31. pattern:
  32. 'https://github.com/vbenjs/vue-vben-admin/edit/main/docs/:path',
  33. text: '在 GitHub 上编辑此页面',
  34. },
  35. footer: {
  36. copyright: `Copyright © 2020-${new Date().getFullYear()} Vben`,
  37. message: '基于 MIT 许可发布.',
  38. },
  39. i18nRouting: true,
  40. langMenuLabel: '多语言',
  41. lastUpdated: {
  42. formatOptions: {
  43. dateStyle: 'short',
  44. timeStyle: 'medium',
  45. },
  46. text: '最后更新于',
  47. },
  48. lightModeSwitchTitle: '切换到浅色模式',
  49. logo: 'https://unpkg.com/@vbenjs/static-source@0.1.5/source/logo-v1.webp',
  50. nav: nav(),
  51. outline: {
  52. label: '页面导航',
  53. },
  54. returnToTopLabel: '回到顶部',
  55. search: {
  56. options: {
  57. locales: {
  58. zh: {
  59. translations: {
  60. button: {
  61. buttonAriaLabel: '搜索文档',
  62. buttonText: '搜索文档',
  63. },
  64. modal: {
  65. footer: {
  66. navigateText: '切换',
  67. selectText: '选择',
  68. },
  69. noResultsText: '无法找到相关结果',
  70. resetButtonTitle: '清除查询条件',
  71. },
  72. },
  73. },
  74. },
  75. },
  76. provider: 'local',
  77. },
  78. sidebar: {
  79. '/commercial/': { base: '/commercial/', items: sidebarCommercial() },
  80. '/guide/': { base: '/guide/', items: sidebarGuide() },
  81. },
  82. sidebarMenuLabel: '菜单',
  83. siteTitle: 'Vben Admin',
  84. socialLinks: [
  85. { icon: 'github', link: 'https://github.com/vbenjs/vue-vben-admin' },
  86. ],
  87. },
  88. title: 'Vben Admin',
  89. vite: {
  90. build: {
  91. chunkSizeWarningLimit: Infinity,
  92. minify: 'terser',
  93. },
  94. json: {
  95. stringify: true,
  96. },
  97. server: {
  98. fs: {
  99. allow: ['../..'],
  100. },
  101. host: true,
  102. port: 6173,
  103. },
  104. ssr: {
  105. external: ['@vue/repl'],
  106. },
  107. },
  108. }),
  109. );
  110. function nav(): DefaultTheme.NavItem[] {
  111. return [
  112. {
  113. text: '文档',
  114. items: [
  115. {
  116. link: '/guide/introduction/vben',
  117. text: '指南',
  118. // items: [
  119. // {
  120. // link: '/guide/introduction/vben',
  121. // text: '简介',
  122. // },
  123. // {
  124. // link: '/guide/essentials/concept',
  125. // text: '基础',
  126. // },
  127. // {
  128. // link: '/guide/in-depth/layout',
  129. // text: '深入',
  130. // },
  131. // {
  132. // link: '/guide/project/standard',
  133. // text: '工程',
  134. // },
  135. // {
  136. // link: '/guide/other/project-update',
  137. // text: '其他',
  138. // },
  139. // ],
  140. },
  141. {
  142. text: '历史版本',
  143. items: [
  144. {
  145. link: 'https://doc.vvbin.cn',
  146. text: '2.x版本文档',
  147. },
  148. ],
  149. },
  150. ],
  151. },
  152. {
  153. text: '演示',
  154. items: [
  155. {
  156. text: 'Vben Admin',
  157. items: [
  158. {
  159. link: 'https://www.vben.pro',
  160. text: 'Ant Design Vue 版本(默认)',
  161. },
  162. {
  163. link: 'https://naive.vben.pro',
  164. text: 'Naive 版本',
  165. },
  166. {
  167. link: 'https://ele.vben.pro',
  168. text: 'Element Plus版本',
  169. },
  170. ],
  171. },
  172. {
  173. text: '其他',
  174. items: [
  175. {
  176. link: 'https://vben.vvbin.cn',
  177. text: 'Vben Admin 2.x',
  178. },
  179. ],
  180. },
  181. ],
  182. },
  183. {
  184. text: version,
  185. items: [
  186. {
  187. link: 'https://github.com/vbenjs/vue-vben-admin/releases',
  188. text: '更新日志',
  189. },
  190. {
  191. link: 'https://github.com/orgs/vbenjs/projects/5',
  192. text: '路线图',
  193. },
  194. {
  195. link: 'https://github.com/vbenjs/vue-vben-admin/blob/main/.github/contributing.md',
  196. text: '贡献',
  197. },
  198. ],
  199. },
  200. {
  201. link: '/commercial/technical-support',
  202. text: '🦄 技术支持',
  203. },
  204. {
  205. link: '/sponsor/personal',
  206. text: '✨ 赞助',
  207. },
  208. {
  209. text: '👨‍👦‍👦 社区',
  210. items: [
  211. {
  212. link: 'https://qun.qq.com/qqweb/qunpro/share?_wv=3&_wwv=128&appChannel=share&inviteCode=22ySzj7pKiw&businessType=9&from=246610&biz=ka&mainSourceId=share&subSourceId=others&jumpsource=shorturl#/pc',
  213. text: 'QQ频道',
  214. },
  215. {
  216. link: 'https://qm.qq.com/cgi-bin/qm/qr?_wv=1027&k=mjZmlhgVzzUxvdxllB6C1vHpX8O8QRL0&authKey=DBdFbBwERmfaKY95JvRWqLCJIRGJAmKyZbrpzZ41EKDMZ5SR6MfbjOBaaNRN73fr&noverify=0&group_code=4286109',
  217. text: 'QQ群',
  218. },
  219. {
  220. link: 'https://discord.gg/VU62jTecad',
  221. text: 'Discord',
  222. },
  223. ],
  224. },
  225. {
  226. link: '/friend-links/',
  227. text: '🤝 友情链接',
  228. },
  229. ];
  230. }
  231. function sidebarGuide(): DefaultTheme.SidebarItem[] {
  232. return [
  233. {
  234. collapsed: false,
  235. text: '简介',
  236. items: [
  237. {
  238. link: 'introduction/vben',
  239. text: '关于 Vben Admin',
  240. },
  241. {
  242. link: 'introduction/why',
  243. text: '为什么选择我们?',
  244. },
  245. { link: 'introduction/quick-start', text: '快速开始' },
  246. ],
  247. },
  248. {
  249. text: '基础',
  250. items: [
  251. { link: 'essentials/concept', text: '基础概念' },
  252. { link: 'essentials/development', text: '本地开发' },
  253. { link: 'essentials/route', text: '路由和菜单' },
  254. { link: 'essentials/settings', text: '配置' },
  255. { link: 'essentials/icons', text: '图标' },
  256. { link: 'essentials/styles', text: '样式' },
  257. { link: 'essentials/external-module', text: '外部模块' },
  258. { link: 'essentials/build', text: '构建与部署' },
  259. { link: 'essentials/server', text: '服务端交互与数据Mock' },
  260. ],
  261. },
  262. {
  263. text: '深入',
  264. items: [
  265. // { link: 'in-depth/layout', text: '布局' },
  266. { link: 'in-depth/theme', text: '主题' },
  267. { link: 'in-depth/access', text: '权限' },
  268. { link: 'in-depth/locale', text: '国际化' },
  269. { link: 'in-depth/features', text: '常用功能' },
  270. { link: 'in-depth/check-updates', text: '检查更新' },
  271. { link: 'in-depth/loading', text: '全局loading' },
  272. { link: 'in-depth/ui-framework', text: '组件库切换' },
  273. ],
  274. },
  275. {
  276. text: '工程',
  277. items: [
  278. { link: 'project/standard', text: '规范' },
  279. { link: 'project/cli', text: 'CLI' },
  280. { link: 'project/test', text: '单元测试' },
  281. { link: 'project/tailwindcss', text: 'Tailwind CSS' },
  282. { link: 'project/changeset', text: 'Changeset' },
  283. { link: 'project/vite', text: 'Vite Config' },
  284. ],
  285. },
  286. {
  287. text: '其他',
  288. items: [
  289. { link: 'other/project-update', text: '项目更新' },
  290. { link: 'other/remove-code', text: '移除代码' },
  291. { link: 'other/faq', text: '常见问题' },
  292. ],
  293. },
  294. ];
  295. }
  296. function sidebarCommercial(): DefaultTheme.SidebarItem[] {
  297. return [
  298. {
  299. link: 'technical-support',
  300. text: '技术支持',
  301. },
  302. {
  303. link: 'customized',
  304. text: '定制开发',
  305. },
  306. ];
  307. }
  308. function head(): HeadConfig[] {
  309. return [
  310. ['meta', { content: 'Vbenjs Team', name: 'author' }],
  311. [
  312. 'meta',
  313. {
  314. content: 'vben, vitejs, vite, shacdn-ui, vue',
  315. name: 'keywords',
  316. },
  317. ],
  318. ['link', { href: '/favicon.ico', rel: 'icon', type: 'image/svg+xml' }],
  319. [
  320. 'meta',
  321. {
  322. content:
  323. 'width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no',
  324. name: 'viewport',
  325. },
  326. ],
  327. ['meta', { content: 'vben admin docs', name: 'keywords' }],
  328. ['link', { href: '/favicon.ico', rel: 'icon' }],
  329. // [
  330. // 'script',
  331. // {
  332. // src: 'https://cdn.tailwindcss.com',
  333. // },
  334. // ],
  335. ];
  336. }
  337. function pwa(): PwaOptions {
  338. return {
  339. includeManifestIcons: false,
  340. manifest: {
  341. description:
  342. 'Vben Admin is a modern admin dashboard template based on Vue 3. ',
  343. icons: [
  344. {
  345. sizes: '192x192',
  346. src: 'https://unpkg.com/@vbenjs/static-source@0.1.5/source/pwa-icon-192.png',
  347. type: 'image/png',
  348. },
  349. {
  350. sizes: '512x512',
  351. src: 'https://unpkg.com/@vbenjs/static-source@0.1.5/source/pwa-icon-512.png',
  352. type: 'image/png',
  353. },
  354. ],
  355. id: '/',
  356. name: 'Vben Admin Doc',
  357. short_name: 'vben_admin_doc',
  358. theme_color: '#ffffff',
  359. },
  360. outDir: resolve(process.cwd(), '.vitepress/dist'),
  361. registerType: 'autoUpdate',
  362. workbox: {
  363. globPatterns: ['**/*.{css,js,html,svg,png,ico,txt,woff2}'],
  364. },
  365. };
  366. }