index.ts 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. // https://vitepress.dev/guide/custom-theme
  2. import type { EnhanceAppContext, Theme } from 'vitepress';
  3. import { h } from 'vue';
  4. import { useVbenForm } from '@vben/common-ui';
  5. import { NolebaseGitChangelogPlugin } from '@nolebase/vitepress-plugin-git-changelog/client';
  6. import { Button, Image } from 'ant-design-vue';
  7. import DefaultTheme from 'vitepress/theme';
  8. import { DemoPreview } from '../components';
  9. import SiteLayout from './components/site-layout.vue';
  10. import VbenContributors from './components/vben-contributors.vue';
  11. import { initHmPlugin } from './plugins/hm';
  12. import './styles';
  13. import 'virtual:group-icons.css';
  14. import '@nolebase/vitepress-plugin-git-changelog/client/style.css';
  15. export default {
  16. async enhanceApp(ctx: EnhanceAppContext) {
  17. const { app } = ctx;
  18. app.component('VbenContributors', VbenContributors);
  19. app.component('DemoPreview', DemoPreview);
  20. app.use(NolebaseGitChangelogPlugin);
  21. if (!import.meta.env.SSR) {
  22. const plugin = await import('@vben/plugins/vxe-table');
  23. plugin.setupVbenVxeTable({
  24. configVxeTable: (vxeUI) => {
  25. vxeUI.setConfig({
  26. grid: {
  27. align: 'center',
  28. border: false,
  29. columnConfig: {
  30. resizable: true,
  31. },
  32. minHeight: 180,
  33. proxyConfig: {
  34. autoLoad: true,
  35. response: {
  36. result: 'items',
  37. total: 'total',
  38. list: 'items',
  39. },
  40. showActiveMsg: true,
  41. showResponseMsg: false,
  42. },
  43. round: true,
  44. showOverflow: true,
  45. size: 'small',
  46. },
  47. });
  48. // 表格配置项可以用 cellRender: { name: 'CellImage' },
  49. vxeUI.renderer.add('CellImage', {
  50. renderDefault(_renderOpts, params) {
  51. const { column, row } = params;
  52. return h(Image, { src: row[column.field] } as any);
  53. },
  54. });
  55. // 表格配置项可以用 cellRender: { name: 'CellLink' },
  56. vxeUI.renderer.add('CellLink', {
  57. renderDefault(renderOpts) {
  58. const { props } = renderOpts;
  59. return h(
  60. Button,
  61. { size: 'small', type: 'link' },
  62. { default: () => props?.text },
  63. );
  64. },
  65. });
  66. // 这里可以自行扩展 vxe-table 的全局配置,比如自定义格式化
  67. // vxeUI.formats.add
  68. },
  69. useVbenForm,
  70. });
  71. app.component('VbenVxeGrid', plugin.VbenVxeGrid);
  72. app.provide('useVbenVxeGrid', plugin.useVbenVxeGrid);
  73. }
  74. // 百度统计
  75. initHmPlugin();
  76. },
  77. extends: DefaultTheme,
  78. Layout: SiteLayout,
  79. } satisfies Theme;