chore: 一些调整和兼容性更新

This commit is contained in:
Jin Mao 2025-10-22 18:14:42 +08:00
parent 2264eaae18
commit 33b7a605c0
4 changed files with 43 additions and 37 deletions

View File

@ -1,8 +1,8 @@
# 应用标题
VITE_APP_TITLE=Vben Admin Antd
VITE_APP_TITLE=Vben Admin Tdesign
# 应用命名空间用于缓存、store等功能的前缀确保隔离
VITE_APP_NAMESPACE=vben-web-antd
VITE_APP_NAMESPACE=vben-web-tdesign
# 对store进行加密的密钥在将store持久化到localStorage时会使用该密钥进行加密
VITE_APP_STORE_SECURE_KEY=please-replace-me-with-your-own-key

View File

@ -9,6 +9,7 @@ import { ApiComponent, globalShareState, IconPicker } from '@vben/common-ui';
import { $t } from '@vben/locales';
import { notification } from 'ant-design-vue';
/**
* 使 adapter/form 使便使
* vben-formvben-modalvben-drawer 使,
@ -178,11 +179,27 @@ async function initComponentAdapter() {
// Mentions: withDefaultPlaceholder(Mentions, 'input'),
// 自定义主要按钮
PrimaryButton: (props, { attrs, slots }) => {
return h(Button, { ...props, attrs, theme: 'primary' }, slots);
let ghost = false;
let variant = props.variant;
if (props.variant === 'ghost') {
ghost = true;
variant = 'base';
}
return h(
Button,
{ ...props, ghost, variant, attrs, theme: 'default' },
slots,
);
},
Radio,
RadioGroup,
RangePicker,
RangePicker: (props, { attrs, slots }) => {
return h(
RangePicker,
{ ...props, modelValue: props.modelValue ?? [], attrs },
slots,
);
},
Rate,
Select: withDefaultPlaceholder(Select, 'select'),
Space,

View File

@ -1,17 +1,13 @@
import type {
VbenFormSchema as FormSchema,
VbenFormProps,
} from '@vben/common-ui';
import type { VbenFormProps, VbenFormSchema as FormSchema } from "@vben/common-ui";
import { setupVbenForm, useVbenForm as useForm, z } from "@vben/common-ui";
import type { ComponentType } from './component';
import { setupVbenForm, useVbenForm as useForm, z } from '@vben/common-ui';
import { $t } from '@vben/locales';
import type { ComponentType } from "./component";
import { $t } from "@vben/locales";
async function initSetupVbenForm() {
setupVbenForm<ComponentType>({
config: {
// ant design vue组件库默认都是 v-model:value
// tdesign组件库默认都是 v-model:value
baseModelPropName: 'value',
// 一些组件是 v-model:checked 或者 v-model:fileList

View File

@ -1,39 +1,32 @@
<script lang="ts" setup>
import { computed } from 'vue';
import { onMounted } from "vue";
import { useAntdDesignTokens } from '@vben/hooks';
import { preferences, usePreferences } from '@vben/preferences';
import { usePreferences } from "@vben/preferences";
import { merge } from "@vben/utils";
import { App, ConfigProvider, theme } from 'ant-design-vue';
import { antdLocale } from '#/locales';
import { ConfigProvider } from "tdesign-vue-next";
import zhConfig from "tdesign-vue-next/es/locale/zh_CN";
defineOptions({ name: 'App' });
const { isDark } = usePreferences();
const { tokens } = useAntdDesignTokens();
const tokenTheme = computed(() => {
const algorithm = isDark.value
? [theme.darkAlgorithm]
: [theme.defaultAlgorithm];
onMounted(() => {
document.documentElement.setAttribute(
'theme-mode',
isDark.value ? 'dark' : '',
);
});
// antd
if (preferences.app.compact) {
algorithm.push(theme.compactAlgorithm);
}
return {
algorithm,
token: tokens,
};
const globalConfig = merge(zhConfig, {
// API
calendar: {},
table: {},
pagination: {},
});
</script>
<template>
<ConfigProvider :locale="antdLocale" :theme="tokenTheme">
<App>
<ConfigProvider :global-config="globalConfig">
<RouterView />
</App>
</ConfigProvider>
</template>