Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions apps/web-tdesign/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"repository": {
"type": "git",
"url": "git+https://github.com/vbenjs/vue-vben-admin.git",
"directory": "apps/web-naive"
"directory": "apps/web-tdesign"
},
"license": "MIT",
"author": {
Expand Down Expand Up @@ -46,5 +46,5 @@
"tdesign-vue-next": "^1.17.1",
"vue": "catalog:",
"vue-router": "catalog:"
},
}
}
8 changes: 4 additions & 4 deletions apps/web-tdesign/src/adapter/component/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { defineAsyncComponent, defineComponent, h, ref } from 'vue';
import { ApiComponent, globalShareState, IconPicker } from '@vben/common-ui';
import { $t } from '@vben/locales';

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

/**
* 通用组件共同的使用的基础组件,原先放在 adapter/form 内部,限制了使用范围,这里提取出来,方便其他地方使用
Expand Down Expand Up @@ -218,9 +218,9 @@ async function initComponentAdapter() {
// 复制成功消息提示
copyPreferencesSuccess: (title, content) => {
notification.success({
description: content,
message: title,
placement: 'bottomRight',
title,
content,
placement: 'bottom-right',
});
},
});
Expand Down
9 changes: 9 additions & 0 deletions apps/web-tdesign/src/adapter/tdesign.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import {
DialogPlugin,
MessagePlugin,
NotificationPlugin,
} from 'tdesign-vue-next';

export const message = MessagePlugin;
export const notification = NotificationPlugin;
export const dialog = DialogPlugin;
4 changes: 2 additions & 2 deletions apps/web-tdesign/src/adapter/vxe-table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { h } from 'vue';

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

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

import { useVbenForm } from './form';

Expand Down Expand Up @@ -52,7 +52,7 @@ setupVbenVxeTable({
const { props } = renderOpts;
return h(
Button,
{ size: 'small', type: 'link' },
{ size: 'small', theme: 'primary', variant: 'text' },
{ default: () => props?.text },
);
},
Expand Down
2 changes: 1 addition & 1 deletion apps/web-tdesign/src/api/request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
} from '@vben/request';
import { useAccessStore } from '@vben/stores';

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

import { useAuthStore } from '#/store';

Expand Down
27 changes: 2 additions & 25 deletions apps/web-tdesign/src/locales/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import type { Locale } from 'ant-design-vue/es/locale';

import type { App } from 'vue';

import type { LocaleSetupOptions, SupportedLanguagesType } from '@vben/locales';
Expand All @@ -13,12 +11,8 @@ import {
} from '@vben/locales';
import { preferences } from '@vben/preferences';

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

const antdLocale = ref<Locale>(antdDefaultLocale);

const modules = import.meta.glob('./langs/**/*.json');

const localesMap = loadLocalesMapFromDir(
Expand All @@ -43,7 +37,7 @@ async function loadMessages(lang: SupportedLanguagesType) {
* @param lang
*/
async function loadThirdPartyMessage(lang: SupportedLanguagesType) {
await Promise.all([loadAntdLocale(lang), loadDayjsLocale(lang)]);
await loadDayjsLocale(lang);
}

/**
Expand Down Expand Up @@ -73,23 +67,6 @@ async function loadDayjsLocale(lang: SupportedLanguagesType) {
}
}

/**
* 加载antd的语言包
* @param lang
*/
async function loadAntdLocale(lang: SupportedLanguagesType) {
switch (lang) {
case 'en-US': {
antdLocale.value = antdEnLocale;
break;
}
case 'zh-CN': {
antdLocale.value = antdDefaultLocale;
break;
}
}
}

async function setupI18n(app: App, options: LocaleSetupOptions = {}) {
await coreSetup(app, {
defaultLocale: preferences.app.locale,
Expand All @@ -99,4 +76,4 @@ async function setupI18n(app: App, options: LocaleSetupOptions = {}) {
});
}

export { $t, antdLocale, setupI18n };
export { $t, setupI18n };
4 changes: 2 additions & 2 deletions apps/web-tdesign/src/router/access.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import type {
import { generateAccessible } from '@vben/access';
import { preferences } from '@vben/preferences';

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

import { getAllMenusApi } from '#/api';
import { BasicLayout, IFrameView } from '#/layouts';
Expand All @@ -27,7 +27,7 @@ async function generateAccess(options: GenerateMenuAndRoutesOptions) {
fetchMenuListAsync: async () => {
message.loading({
content: `${$t('common.loadingMenu')}...`,
duration: 1.5,
duration: 1500,
});
return await getAllMenusApi();
},
Expand Down
8 changes: 4 additions & 4 deletions apps/web-tdesign/src/store/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { LOGIN_PATH } from '@vben/constants';
import { preferences } from '@vben/preferences';
import { resetAllStores, useAccessStore, useUserStore } from '@vben/stores';

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

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

if (userInfo?.realName) {
notification.success({
description: `${$t('authentication.loginSuccessDesc')}:${userInfo?.realName}`,
duration: 3,
message: $t('authentication.loginSuccess'),
title: $t('authentication.loginSuccess'),
content: `${$t('authentication.loginSuccessDesc')}:${userInfo?.realName}`,
duration: 3000,
});
}
}
Expand Down
19 changes: 10 additions & 9 deletions apps/web-tdesign/src/views/demos/antd/index.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
<script lang="ts" setup>
import { Page } from '@vben/common-ui';
import { Button, Card, message, notification, Space } from 'ant-design-vue';
import { Button, Card, Space } from 'tdesign-vue-next';
import { message, notification } from '#/adapter/tdesign';
type NotificationType = 'error' | 'info' | 'success' | 'warning';
Expand All @@ -26,29 +28,28 @@ function success() {
function notify(type: NotificationType) {
notification[type]({
duration: 2500,
message: '说点啥呢',
type,
title: '说点啥呢',
});
}
</script>

<template>
<Page
description="支持多语言,主题功能集成切换等"
title="Ant Design Vue组件使用演示"
title="TDesign Vue组件使用演示"
>
<Card class="mb-5" title="按钮">
<Space>
<Button>Default</Button>
<Button type="primary"> Primary </Button>
<Button> Info </Button>
<Button danger> Error </Button>
<Button theme="primary"> Primary </Button>
<Button theme="default"> Info </Button>
<Button theme="danger"> Error </Button>
</Space>
</Card>
<Card class="mb-5" title="Message">
<Space>
<Button @click="info"> 信息 </Button>
<Button danger @click="error"> 错误 </Button>
<Button theme="danger" @click="error"> 错误 </Button>
<Button @click="warning"> 警告 </Button>
<Button @click="success"> 成功 </Button>
</Space>
Expand All @@ -57,7 +58,7 @@ function notify(type: NotificationType) {
<Card class="mb-5" title="Notification">
<Space>
<Button @click="notify('info')"> 信息 </Button>
<Button danger @click="notify('error')"> 错误 </Button>
<Button theme="danger" @click="notify('error')"> 错误 </Button>
<Button @click="notify('warning')"> 警告 </Button>
<Button @click="notify('success')"> 成功 </Button>
</Space>
Expand Down
Loading