Skip to content

Commit 33b7a60

Browse files
committed
chore: 一些调整和兼容性更新
1 parent 2264eaa commit 33b7a60

File tree

4 files changed

+43
-37
lines changed

4 files changed

+43
-37
lines changed

apps/web-tdesign/.env

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# 应用标题
2-
VITE_APP_TITLE=Vben Admin Antd
2+
VITE_APP_TITLE=Vben Admin Tdesign
33

44
# 应用命名空间,用于缓存、store等功能的前缀,确保隔离
5-
VITE_APP_NAMESPACE=vben-web-antd
5+
VITE_APP_NAMESPACE=vben-web-tdesign
66

77
# 对store进行加密的密钥,在将store持久化到localStorage时会使用该密钥进行加密
88
VITE_APP_STORE_SECURE_KEY=please-replace-me-with-your-own-key

apps/web-tdesign/src/adapter/component/index.ts

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { ApiComponent, globalShareState, IconPicker } from '@vben/common-ui';
99
import { $t } from '@vben/locales';
1010

1111
import { notification } from 'ant-design-vue';
12+
1213
/**
1314
* 通用组件共同的使用的基础组件,原先放在 adapter/form 内部,限制了使用范围,这里提取出来,方便其他地方使用
1415
* 可用于 vben-form、vben-modal、vben-drawer 等组件使用,
@@ -178,11 +179,27 @@ async function initComponentAdapter() {
178179
// Mentions: withDefaultPlaceholder(Mentions, 'input'),
179180
// 自定义主要按钮
180181
PrimaryButton: (props, { attrs, slots }) => {
181-
return h(Button, { ...props, attrs, theme: 'primary' }, slots);
182+
let ghost = false;
183+
let variant = props.variant;
184+
if (props.variant === 'ghost') {
185+
ghost = true;
186+
variant = 'base';
187+
}
188+
return h(
189+
Button,
190+
{ ...props, ghost, variant, attrs, theme: 'default' },
191+
slots,
192+
);
182193
},
183194
Radio,
184195
RadioGroup,
185-
RangePicker,
196+
RangePicker: (props, { attrs, slots }) => {
197+
return h(
198+
RangePicker,
199+
{ ...props, modelValue: props.modelValue ?? [], attrs },
200+
slots,
201+
);
202+
},
186203
Rate,
187204
Select: withDefaultPlaceholder(Select, 'select'),
188205
Space,

apps/web-tdesign/src/adapter/form.ts

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,13 @@
1-
import type {
2-
VbenFormSchema as FormSchema,
3-
VbenFormProps,
4-
} from '@vben/common-ui';
1+
import type { VbenFormProps, VbenFormSchema as FormSchema } from "@vben/common-ui";
2+
import { setupVbenForm, useVbenForm as useForm, z } from "@vben/common-ui";
53

6-
import type { ComponentType } from './component';
7-
8-
import { setupVbenForm, useVbenForm as useForm, z } from '@vben/common-ui';
9-
import { $t } from '@vben/locales';
4+
import type { ComponentType } from "./component";
5+
import { $t } from "@vben/locales";
106

117
async function initSetupVbenForm() {
128
setupVbenForm<ComponentType>({
139
config: {
14-
// ant design vue组件库默认都是 v-model:value
10+
// tdesign组件库默认都是 v-model:value
1511
baseModelPropName: 'value',
1612

1713
// 一些组件是 v-model:checked 或者 v-model:fileList

apps/web-tdesign/src/app.vue

Lines changed: 17 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,32 @@
11
<script lang="ts" setup>
2-
import { computed } from 'vue';
2+
import { onMounted } from "vue";
33
4-
import { useAntdDesignTokens } from '@vben/hooks';
5-
import { preferences, usePreferences } from '@vben/preferences';
4+
import { usePreferences } from "@vben/preferences";
5+
import { merge } from "@vben/utils";
66
7-
import { App, ConfigProvider, theme } from 'ant-design-vue';
8-
9-
import { antdLocale } from '#/locales';
7+
import { ConfigProvider } from "tdesign-vue-next";
8+
import zhConfig from "tdesign-vue-next/es/locale/zh_CN";
109
1110
defineOptions({ name: 'App' });
12-
1311
const { isDark } = usePreferences();
14-
const { tokens } = useAntdDesignTokens();
1512
16-
const tokenTheme = computed(() => {
17-
const algorithm = isDark.value
18-
? [theme.darkAlgorithm]
19-
: [theme.defaultAlgorithm];
20-
21-
// antd 紧凑模式算法
22-
if (preferences.app.compact) {
23-
algorithm.push(theme.compactAlgorithm);
24-
}
13+
onMounted(() => {
14+
document.documentElement.setAttribute(
15+
'theme-mode',
16+
isDark.value ? 'dark' : '',
17+
);
18+
});
2519
26-
return {
27-
algorithm,
28-
token: tokens,
29-
};
20+
const globalConfig = merge(zhConfig, {
21+
// 可以在此处定义更多自定义配置,具体可配置内容参看 API 文档
22+
calendar: {},
23+
table: {},
24+
pagination: {},
3025
});
3126
</script>
3227

3328
<template>
34-
<ConfigProvider :locale="antdLocale" :theme="tokenTheme">
35-
<App>
29+
<ConfigProvider :global-config="globalConfig">
3630
<RouterView />
37-
</App>
3831
</ConfigProvider>
3932
</template>

0 commit comments

Comments
 (0)