config.mts 10 KB

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