config.mts 8.0 KB

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