1
0

config.mts 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379
  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. link: '/commercial/community',
  210. text: '👨‍👦‍👦 社区交流',
  211. // items: [
  212. // {
  213. // 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',
  214. // text: 'QQ频道',
  215. // },
  216. // {
  217. // link: 'https://qm.qq.com/cgi-bin/qm/qr?_wv=1027&k=mjZmlhgVzzUxvdxllB6C1vHpX8O8QRL0&authKey=DBdFbBwERmfaKY95JvRWqLCJIRGJAmKyZbrpzZ41EKDMZ5SR6MfbjOBaaNRN73fr&noverify=0&group_code=4286109',
  218. // text: 'QQ群',
  219. // },
  220. // {
  221. // link: 'https://discord.gg/VU62jTecad',
  222. // text: 'Discord',
  223. // },
  224. // ],
  225. },
  226. {
  227. link: '/friend-links/',
  228. text: '🤝 友情链接',
  229. },
  230. ];
  231. }
  232. function sidebarGuide(): DefaultTheme.SidebarItem[] {
  233. return [
  234. {
  235. collapsed: false,
  236. text: '简介',
  237. items: [
  238. {
  239. link: 'introduction/vben',
  240. text: '关于 Vben Admin',
  241. },
  242. {
  243. link: 'introduction/why',
  244. text: '为什么选择我们?',
  245. },
  246. { link: 'introduction/quick-start', text: '快速开始' },
  247. ],
  248. },
  249. {
  250. text: '基础',
  251. items: [
  252. { link: 'essentials/concept', text: '基础概念' },
  253. { link: 'essentials/development', text: '本地开发' },
  254. { link: 'essentials/route', text: '路由和菜单' },
  255. { link: 'essentials/settings', text: '配置' },
  256. { link: 'essentials/icons', text: '图标' },
  257. { link: 'essentials/styles', text: '样式' },
  258. { link: 'essentials/external-module', text: '外部模块' },
  259. { link: 'essentials/build', text: '构建与部署' },
  260. { link: 'essentials/server', text: '服务端交互与数据Mock' },
  261. ],
  262. },
  263. {
  264. text: '深入',
  265. items: [
  266. // { link: 'in-depth/layout', text: '布局' },
  267. { link: 'in-depth/theme', text: '主题' },
  268. { link: 'in-depth/access', text: '权限' },
  269. { link: 'in-depth/locale', text: '国际化' },
  270. { link: 'in-depth/features', text: '常用功能' },
  271. { link: 'in-depth/check-updates', text: '检查更新' },
  272. { link: 'in-depth/loading', text: '全局loading' },
  273. { link: 'in-depth/ui-framework', text: '组件库切换' },
  274. ],
  275. },
  276. {
  277. text: '工程',
  278. items: [
  279. { link: 'project/standard', text: '规范' },
  280. { link: 'project/cli', text: 'CLI' },
  281. { link: 'project/test', text: '单元测试' },
  282. { link: 'project/tailwindcss', text: 'Tailwind CSS' },
  283. { link: 'project/changeset', text: 'Changeset' },
  284. { link: 'project/vite', text: 'Vite Config' },
  285. ],
  286. },
  287. {
  288. text: '其他',
  289. items: [
  290. { link: 'other/project-update', text: '项目更新' },
  291. { link: 'other/remove-code', text: '移除代码' },
  292. { link: 'other/faq', text: '常见问题' },
  293. ],
  294. },
  295. ];
  296. }
  297. function sidebarCommercial(): DefaultTheme.SidebarItem[] {
  298. return [
  299. {
  300. link: 'community',
  301. text: '社区交流',
  302. },
  303. {
  304. link: 'technical-support',
  305. text: '技术支持',
  306. },
  307. {
  308. link: 'customized',
  309. text: '定制开发',
  310. },
  311. ];
  312. }
  313. function head(): HeadConfig[] {
  314. return [
  315. ['meta', { content: 'Vbenjs Team', name: 'author' }],
  316. [
  317. 'meta',
  318. {
  319. content: 'vben, vitejs, vite, shacdn-ui, vue',
  320. name: 'keywords',
  321. },
  322. ],
  323. ['link', { href: '/favicon.ico', rel: 'icon', type: 'image/svg+xml' }],
  324. [
  325. 'meta',
  326. {
  327. content:
  328. 'width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no',
  329. name: 'viewport',
  330. },
  331. ],
  332. ['meta', { content: 'vben admin docs', name: 'keywords' }],
  333. ['link', { href: '/favicon.ico', rel: 'icon' }],
  334. // [
  335. // 'script',
  336. // {
  337. // src: 'https://cdn.tailwindcss.com',
  338. // },
  339. // ],
  340. ];
  341. }
  342. function pwa(): PwaOptions {
  343. return {
  344. includeManifestIcons: false,
  345. manifest: {
  346. description:
  347. 'Vben Admin is a modern admin dashboard template based on Vue 3. ',
  348. icons: [
  349. {
  350. sizes: '192x192',
  351. src: 'https://unpkg.com/@vbenjs/static-source@0.1.5/source/pwa-icon-192.png',
  352. type: 'image/png',
  353. },
  354. {
  355. sizes: '512x512',
  356. src: 'https://unpkg.com/@vbenjs/static-source@0.1.5/source/pwa-icon-512.png',
  357. type: 'image/png',
  358. },
  359. ],
  360. id: '/',
  361. name: 'Vben Admin Doc',
  362. short_name: 'vben_admin_doc',
  363. theme_color: '#ffffff',
  364. },
  365. outDir: resolve(process.cwd(), '.vitepress/dist'),
  366. registerType: 'autoUpdate',
  367. workbox: {
  368. globPatterns: ['**/*.{css,js,html,svg,png,ico,txt,woff2}'],
  369. },
  370. };
  371. }