Skip to content

Commit 04321b1

Browse files
Copilotlikui628
andauthored
fix: replace ant-design-vue with tdesign components in web-tdesign app (#6880)
* Initial plan * fix: replace ant-design-vue with tdesign components Co-authored-by: likui628 <[email protected]> * fix: remove trailing comma in package.json Co-authored-by: likui628 <[email protected]> --------- Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: likui628 <[email protected]>
1 parent 33b7a60 commit 04321b1

File tree

9 files changed

+36
-49
lines changed

9 files changed

+36
-49
lines changed

apps/web-tdesign/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"repository": {
77
"type": "git",
88
"url": "git+https://github.com/vbenjs/vue-vben-admin.git",
9-
"directory": "apps/web-naive"
9+
"directory": "apps/web-tdesign"
1010
},
1111
"license": "MIT",
1212
"author": {
@@ -46,5 +46,5 @@
4646
"tdesign-vue-next": "^1.17.1",
4747
"vue": "catalog:",
4848
"vue-router": "catalog:"
49-
},
49+
}
5050
}

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { defineAsyncComponent, defineComponent, h, ref } from 'vue';
88
import { ApiComponent, globalShareState, IconPicker } from '@vben/common-ui';
99
import { $t } from '@vben/locales';
1010

11-
import { notification } from 'ant-design-vue';
11+
import { notification } from '#/adapter/tdesign';
1212

1313
/**
1414
* 通用组件共同的使用的基础组件,原先放在 adapter/form 内部,限制了使用范围,这里提取出来,方便其他地方使用
@@ -218,9 +218,9 @@ async function initComponentAdapter() {
218218
// 复制成功消息提示
219219
copyPreferencesSuccess: (title, content) => {
220220
notification.success({
221-
description: content,
222-
message: title,
223-
placement: 'bottomRight',
221+
title,
222+
content,
223+
placement: 'bottom-right',
224224
});
225225
},
226226
});
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import {
2+
DialogPlugin,
3+
MessagePlugin,
4+
NotificationPlugin,
5+
} from 'tdesign-vue-next';
6+
7+
export const message = MessagePlugin;
8+
export const notification = NotificationPlugin;
9+
export const dialog = DialogPlugin;

apps/web-tdesign/src/adapter/vxe-table.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { h } from 'vue';
44

55
import { setupVbenVxeTable, useVbenVxeGrid } from '@vben/plugins/vxe-table';
66

7-
import { Button, Image } from 'ant-design-vue';
7+
import { Button, Image } from 'tdesign-vue-next';
88

99
import { useVbenForm } from './form';
1010

@@ -52,7 +52,7 @@ setupVbenVxeTable({
5252
const { props } = renderOpts;
5353
return h(
5454
Button,
55-
{ size: 'small', type: 'link' },
55+
{ size: 'small', theme: 'primary', variant: 'text' },
5656
{ default: () => props?.text },
5757
);
5858
},

apps/web-tdesign/src/api/request.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import {
1313
} from '@vben/request';
1414
import { useAccessStore } from '@vben/stores';
1515

16-
import { message } from 'ant-design-vue';
16+
import { message } from '#/adapter/tdesign';
1717

1818
import { useAuthStore } from '#/store';
1919

apps/web-tdesign/src/locales/index.ts

Lines changed: 2 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import type { Locale } from 'ant-design-vue/es/locale';
2-
31
import type { App } from 'vue';
42

53
import type { LocaleSetupOptions, SupportedLanguagesType } from '@vben/locales';
@@ -13,12 +11,8 @@ import {
1311
} from '@vben/locales';
1412
import { preferences } from '@vben/preferences';
1513

16-
import antdEnLocale from 'ant-design-vue/es/locale/en_US';
17-
import antdDefaultLocale from 'ant-design-vue/es/locale/zh_CN';
1814
import dayjs from 'dayjs';
1915

20-
const antdLocale = ref<Locale>(antdDefaultLocale);
21-
2216
const modules = import.meta.glob('./langs/**/*.json');
2317

2418
const localesMap = loadLocalesMapFromDir(
@@ -43,7 +37,7 @@ async function loadMessages(lang: SupportedLanguagesType) {
4337
* @param lang
4438
*/
4539
async function loadThirdPartyMessage(lang: SupportedLanguagesType) {
46-
await Promise.all([loadAntdLocale(lang), loadDayjsLocale(lang)]);
40+
await loadDayjsLocale(lang);
4741
}
4842

4943
/**
@@ -73,23 +67,6 @@ async function loadDayjsLocale(lang: SupportedLanguagesType) {
7367
}
7468
}
7569

76-
/**
77-
* 加载antd的语言包
78-
* @param lang
79-
*/
80-
async function loadAntdLocale(lang: SupportedLanguagesType) {
81-
switch (lang) {
82-
case 'en-US': {
83-
antdLocale.value = antdEnLocale;
84-
break;
85-
}
86-
case 'zh-CN': {
87-
antdLocale.value = antdDefaultLocale;
88-
break;
89-
}
90-
}
91-
}
92-
9370
async function setupI18n(app: App, options: LocaleSetupOptions = {}) {
9471
await coreSetup(app, {
9572
defaultLocale: preferences.app.locale,
@@ -99,4 +76,4 @@ async function setupI18n(app: App, options: LocaleSetupOptions = {}) {
9976
});
10077
}
10178

102-
export { $t, antdLocale, setupI18n };
79+
export { $t, setupI18n };

apps/web-tdesign/src/router/access.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import type {
66
import { generateAccessible } from '@vben/access';
77
import { preferences } from '@vben/preferences';
88

9-
import { message } from 'ant-design-vue';
9+
import { message } from '#/adapter/tdesign';
1010

1111
import { getAllMenusApi } from '#/api';
1212
import { BasicLayout, IFrameView } from '#/layouts';
@@ -27,7 +27,7 @@ async function generateAccess(options: GenerateMenuAndRoutesOptions) {
2727
fetchMenuListAsync: async () => {
2828
message.loading({
2929
content: `${$t('common.loadingMenu')}...`,
30-
duration: 1.5,
30+
duration: 1500,
3131
});
3232
return await getAllMenusApi();
3333
},

apps/web-tdesign/src/store/auth.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { LOGIN_PATH } from '@vben/constants';
77
import { preferences } from '@vben/preferences';
88
import { resetAllStores, useAccessStore, useUserStore } from '@vben/stores';
99

10-
import { notification } from 'ant-design-vue';
10+
import { notification } from '#/adapter/tdesign';
1111
import { defineStore } from 'pinia';
1212

1313
import { getAccessCodesApi, getUserInfoApi, loginApi, logoutApi } from '#/api';
@@ -61,9 +61,9 @@ export const useAuthStore = defineStore('auth', () => {
6161

6262
if (userInfo?.realName) {
6363
notification.success({
64-
description: `${$t('authentication.loginSuccessDesc')}:${userInfo?.realName}`,
65-
duration: 3,
66-
message: $t('authentication.loginSuccess'),
64+
title: $t('authentication.loginSuccess'),
65+
content: `${$t('authentication.loginSuccessDesc')}:${userInfo?.realName}`,
66+
duration: 3000,
6767
});
6868
}
6969
}

apps/web-tdesign/src/views/demos/antd/index.vue

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
<script lang="ts" setup>
22
import { Page } from '@vben/common-ui';
33
4-
import { Button, Card, message, notification, Space } from 'ant-design-vue';
4+
import { Button, Card, Space } from 'tdesign-vue-next';
5+
6+
import { message, notification } from '#/adapter/tdesign';
57
68
type NotificationType = 'error' | 'info' | 'success' | 'warning';
79
@@ -26,29 +28,28 @@ function success() {
2628
function notify(type: NotificationType) {
2729
notification[type]({
2830
duration: 2500,
29-
message: '说点啥呢',
30-
type,
31+
title: '说点啥呢',
3132
});
3233
}
3334
</script>
3435

3536
<template>
3637
<Page
3738
description="支持多语言,主题功能集成切换等"
38-
title="Ant Design Vue组件使用演示"
39+
title="TDesign Vue组件使用演示"
3940
>
4041
<Card class="mb-5" title="按钮">
4142
<Space>
4243
<Button>Default</Button>
43-
<Button type="primary"> Primary </Button>
44-
<Button> Info </Button>
45-
<Button danger> Error </Button>
44+
<Button theme="primary"> Primary </Button>
45+
<Button theme="default"> Info </Button>
46+
<Button theme="danger"> Error </Button>
4647
</Space>
4748
</Card>
4849
<Card class="mb-5" title="Message">
4950
<Space>
5051
<Button @click="info"> 信息 </Button>
51-
<Button danger @click="error"> 错误 </Button>
52+
<Button theme="danger" @click="error"> 错误 </Button>
5253
<Button @click="warning"> 警告 </Button>
5354
<Button @click="success"> 成功 </Button>
5455
</Space>
@@ -57,7 +58,7 @@ function notify(type: NotificationType) {
5758
<Card class="mb-5" title="Notification">
5859
<Space>
5960
<Button @click="notify('info')"> 信息 </Button>
60-
<Button danger @click="notify('error')"> 错误 </Button>
61+
<Button theme="danger" @click="notify('error')"> 错误 </Button>
6162
<Button @click="notify('warning')"> 警告 </Button>
6263
<Button @click="notify('success')"> 成功 </Button>
6364
</Space>

0 commit comments

Comments
 (0)