config.mts 9.1 KB

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