config.mts 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349
  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. },
  164. {
  165. text: '其他',
  166. items: [
  167. {
  168. link: 'https://vben.vvbin.cn',
  169. text: 'Vben Admin 2.x',
  170. },
  171. ],
  172. },
  173. ],
  174. },
  175. {
  176. text: version,
  177. items: [
  178. {
  179. link: 'https://github.com/vbenjs/vue-vben-admin/releases',
  180. text: '更新日志',
  181. },
  182. {
  183. link: 'https://github.com/vbenjs/vue-vben-admin/blob/main/.github/contributing.md',
  184. text: '贡献',
  185. },
  186. ],
  187. },
  188. {
  189. link: '/commercial/technical-support',
  190. text: '🦄 技术支持',
  191. },
  192. {
  193. link: '/sponsor/personal',
  194. text: '✨ 赞助',
  195. },
  196. {
  197. link: '/friend-links/',
  198. text: '🤝 友情链接',
  199. },
  200. ];
  201. }
  202. function sidebarGuide(): DefaultTheme.SidebarItem[] {
  203. return [
  204. {
  205. collapsed: false,
  206. text: '简介',
  207. items: [
  208. {
  209. link: 'introduction/vben',
  210. text: '关于 Vben Admin',
  211. },
  212. {
  213. link: 'introduction/why',
  214. text: '为什么选择我们?',
  215. },
  216. { link: 'introduction/quick-start', text: '快速开始' },
  217. {
  218. link: 'https://github.com/vbenjs/vue-vben-admin/releases',
  219. text: '更新日志',
  220. },
  221. { link: 'https://github.com/orgs/vbenjs/projects/5', text: '路线图' },
  222. ],
  223. },
  224. {
  225. text: '基础',
  226. items: [
  227. { link: 'essentials/concept', text: '基础概念' },
  228. { link: 'essentials/development', text: '本地开发' },
  229. { link: 'essentials/route', text: '路由和菜单' },
  230. { link: 'essentials/settings', text: '配置' },
  231. { link: 'essentials/icons', text: '图标' },
  232. { link: 'essentials/styles', text: '样式' },
  233. { link: 'essentials/external-module', text: '外部模块' },
  234. { link: 'essentials/build', text: '构建与部署' },
  235. { link: 'essentials/server', text: '服务端交互与数据Mock' },
  236. ],
  237. },
  238. {
  239. text: '深入',
  240. items: [
  241. // { link: 'in-depth/layout', text: '布局' },
  242. { link: 'in-depth/theme', text: '主题' },
  243. { link: 'in-depth/access', text: '权限' },
  244. { link: 'in-depth/locale', text: '国际化' },
  245. { link: 'in-depth/features', text: '常用功能' },
  246. { link: 'in-depth/check-updates', text: '检查更新' },
  247. { link: 'in-depth/loading', text: '全局loading' },
  248. ],
  249. },
  250. {
  251. text: '工程',
  252. items: [
  253. { link: 'project/standard', text: '规范' },
  254. { link: 'project/cli', text: 'CLI' },
  255. { link: 'project/test', text: '单元测试' },
  256. { link: 'project/tailwindcss', text: 'Tailwind CSS' },
  257. { link: 'project/changeset', text: 'Changeset' },
  258. { link: 'project/vite', text: 'Vite Config' },
  259. ],
  260. },
  261. {
  262. text: '其他',
  263. items: [
  264. { link: 'other/project-update', text: '项目更新' },
  265. { link: 'other/remove-code', text: '移除代码' },
  266. { link: 'other/faq', text: '常见问题' },
  267. ],
  268. },
  269. ];
  270. }
  271. function sidebarCommercial(): DefaultTheme.SidebarItem[] {
  272. return [
  273. {
  274. link: 'technical-support',
  275. text: '技术支持',
  276. },
  277. {
  278. link: 'customized',
  279. text: '定制开发',
  280. },
  281. ];
  282. }
  283. function head(): HeadConfig[] {
  284. return [
  285. ['meta', { content: 'Vbenjs Team', name: 'author' }],
  286. [
  287. 'meta',
  288. {
  289. content: 'vben, vitejs, vite, shacdn-ui, vue',
  290. name: 'keywords',
  291. },
  292. ],
  293. ['link', { href: '/favicon.ico', rel: 'icon', type: 'image/svg+xml' }],
  294. [
  295. 'meta',
  296. {
  297. content:
  298. 'width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no',
  299. name: 'viewport',
  300. },
  301. ],
  302. ['meta', { content: 'vben admin docs', name: 'keywords' }],
  303. ['link', { href: '/favicon.ico', rel: 'icon' }],
  304. // [
  305. // 'script',
  306. // {
  307. // src: 'https://cdn.tailwindcss.com',
  308. // },
  309. // ],
  310. ];
  311. }
  312. function pwa(): PwaOptions {
  313. return {
  314. includeManifestIcons: false,
  315. manifest: {
  316. description:
  317. 'Vben Admin is a modern admin dashboard template based on Vue 3. ',
  318. icons: [
  319. {
  320. sizes: '192x192',
  321. src: 'https://unpkg.com/@vbenjs/static-source@0.1.5/source/pwa-icon-192.png',
  322. type: 'image/png',
  323. },
  324. {
  325. sizes: '512x512',
  326. src: 'https://unpkg.com/@vbenjs/static-source@0.1.5/source/pwa-icon-512.png',
  327. type: 'image/png',
  328. },
  329. ],
  330. id: '/',
  331. name: 'Vben Admin Doc',
  332. short_name: 'vben_admin_doc',
  333. theme_color: '#ffffff',
  334. },
  335. outDir: resolve(process.cwd(), '.vitepress/dist'),
  336. registerType: 'autoUpdate',
  337. workbox: {
  338. globPatterns: ['**/*.{css,js,html,svg,png,ico,txt,woff2}'],
  339. },
  340. };
  341. }