Commit 208d4188 by vben

refactor: refactor locales, separate locales within apps,fixed #12

1 parent 35715113
Showing 76 changed files with 247 additions and 186 deletions
......@@ -169,7 +169,10 @@
"packages/@vben-core/shared/design-tokens/src/**/*.css"
],
"i18n-ally.localesPaths": ["packages/locales/src/langs"],
"i18n-ally.localesPaths": [
"packages/@core/locales/src/langs",
"apps/*/src/locales/langs"
],
"i18n-ally.enabledParsers": ["json", "ts", "js", "yaml"],
"i18n-ally.sourceLanguage": "en",
"i18n-ally.displayLanguage": "zh-CN",
......
......@@ -16,7 +16,7 @@
- @vben/constants@5.0.1
- @vben/hooks@5.0.1
- @vben/icons@5.0.1
- @vben/locales@5.0.1
- #/locales@5.0.1
- @vben/styles@5.0.1
- @vben/types@5.0.1
- @vben/utils@5.0.1
......@@ -26,6 +26,7 @@
},
"dependencies": {
"@vben-core/helpers": "workspace:*",
"@vben-core/locales": "workspace:*",
"@vben-core/preferences": "workspace:*",
"@vben-core/request": "workspace:*",
"@vben-core/stores": "workspace:*",
......@@ -34,7 +35,6 @@
"@vben/constants": "workspace:*",
"@vben/icons": "workspace:*",
"@vben/layouts": "workspace:*",
"@vben/locales": "workspace:*",
"@vben/styles": "workspace:*",
"@vben/types": "workspace:*",
"@vben/universal-ui": "workspace:*",
......
......@@ -6,7 +6,7 @@ import { preferences, usePreferences } from '@vben-core/preferences';
import { App, ConfigProvider, theme } from 'ant-design-vue';
import { antdLocale } from '#/forward';
import { antdLocale } from '#/locales';
defineOptions({ name: 'App' });
......
import { createApp } from 'vue';
import { setupI18n } from '@vben/locales';
import '@vben/styles';
import { preferences } from '@vben-core/preferences';
import { loadThirdPartyMessage } from '#/forward';
import { loadMessages, setupI18n } from '#/locales';
import { setupStore } from '#/store';
import App from './app.vue';
......@@ -16,7 +15,7 @@ async function bootstrap(namespace: string) {
// 国际化 i18n 配置
await setupI18n(app, {
defaultLocale: preferences.app.locale,
loadThirdPartyMessage,
loadMessages,
});
// 配置 pinia-store
......
......@@ -2,13 +2,13 @@ import type { GeneratorMenuAndRoutesOptions } from '@vben/access';
import type { ComponentRecordType } from '@vben/types';
import { generateMenusAndRoutes } from '@vben/access';
import { $t } from '@vben/locales';
import { preferences } from '@vben-core/preferences';
import { message } from 'ant-design-vue';
import { getAllMenus } from '#/apis';
import { BasicLayout, IFrameView } from '#/layouts';
import { $t } from '#/locales';
const forbiddenPage = () => import('#/views/_essential/fallback/forbidden.vue');
......
export * from './locale';
export * from './access';
export * from './request';
......@@ -7,11 +7,11 @@ import { useRouter } from 'vue-router';
import { LOGIN_PATH } from '@vben/constants';
import { IcRoundCreditScore, MdiDriveDocument, MdiGithub } from '@vben/icons';
import { BasicLayout } from '@vben/layouts';
import { $t } from '@vben/locales';
import { openWindow } from '@vben/utils';
import { Notification, UserDropdown } from '@vben/widgets';
import { preferences } from '@vben-core/preferences';
import { $t } from '#/locales';
import { resetRoutes } from '#/router';
import { useAppStore } from '#/store';
......
......@@ -3,11 +3,41 @@ import type { Locale } from 'ant-design-vue/es/locale';
import { ref } from 'vue';
import { $t, loadLocalesMap, setupI18n } from '@vben-core/locales';
import defaultLocale from 'ant-design-vue/es/locale/zh_CN';
import dayjs from 'dayjs';
const antdLocale = ref<Locale>(defaultLocale);
const modules = import.meta.glob('./langs/*.y(a)?ml');
const localesMap = loadLocalesMap(modules);
/**
* 加载应用特有的语言包
* @param lang
*/
async function loadMessages(lang: SupportedLanguagesType) {
const [appLocaleMessages] = await Promise.all([
localesMap[lang](),
loadThirdPartyMessage(lang),
]);
return appLocaleMessages.default;
}
/**
* 加载第三方组件库的语言包
* @param lang
*/
async function loadThirdPartyMessage(lang: SupportedLanguagesType) {
await Promise.all([loadAntdLocale(lang), loadDayjsLocale(lang)]);
}
/**
* 加载dayjs的语言包
* @param lang
*/
async function loadDayjsLocale(lang: SupportedLanguagesType) {
let locale;
switch (lang) {
......@@ -19,13 +49,18 @@ async function loadDayjsLocale(lang: SupportedLanguagesType) {
locale = await import('dayjs/locale/en');
break;
}
// 默认使用英语
default: {
locale = await import('dayjs/locale/en');
} // 默认使用英语
}
}
dayjs.locale(locale);
}
/**
* 加载antd的语言包
* @param lang
*/
async function loadAntdLocale(lang: SupportedLanguagesType) {
switch (lang) {
case 'zh-CN': {
......@@ -41,8 +76,4 @@ async function loadAntdLocale(lang: SupportedLanguagesType) {
}
}
async function loadThirdPartyMessage(land: SupportedLanguagesType) {
await Promise.all([loadAntdLocale(land), loadDayjsLocale(land)]);
}
export { antdLocale, loadThirdPartyMessage };
export { $t, antdLocale, loadMessages, setupI18n };
page:
demos:
title: Demos
access:
title: Access Control
frontend-control: Front-end Control
backend-control: Backend Control
page: Page visit
button: Button control
loading-menu: In the loading menu
access-test-1: Super visit
access-test-2: Admin visit
access-test-3: User visit
nested:
title: Nested Menu
menu1: Menu 1
menu2: Menu 2
menu21: Menu 2-1
menu3: Menu 3
menu31: Menu 3-1
menu32: Menu 3-2
menu321: Menu 3-2-1
outside:
title: External Page
embedded: embedded Page
external-link: External Link
fallback:
title: Fallback Page
page:
demos:
title: 演示
access:
title: 访问控制
frontend-control: 前端控制
backend-control: 后端控制
page: 页面访问
button: 按钮控制
access-test-1: Super 可见
access-test-2: Admin 可见
access-test-3: User 可见
nested:
title: 嵌套菜单
menu1: 菜单 1
menu2: 菜单 2
menu21: 菜单 2-1
menu3: 菜单 3
menu31: 菜单 3-1
menu32: 菜单 3-2
menu321: 菜单 3-2-1
outside:
title: 外部页面
embedded: 内嵌
external-link: 外链
fallback:
title: 缺省页
import type { Router } from 'vue-router';
import { LOGIN_PATH } from '@vben/constants';
import { $t } from '@vben/locales';
import { startProgress, stopProgress } from '@vben/utils';
import { preferences } from '@vben-core/preferences';
import { useTitle } from '@vueuse/core';
import { generateAccess } from '#/forward/access';
import { generateAccess } from '#/forward';
import { $t } from '#/locales';
import { dynamicRoutes, essentialsRouteNames } from '#/router/routes';
import { useAccessStore } from '#/store';
......
import type { RouteRecordRaw } from 'vue-router';
import { DEFAULT_HOME_PATH } from '@vben/constants';
import { $t } from '@vben/locales';
import { AuthPageLayout } from '#/layouts';
import { $t } from '#/locales';
import Login from '#/views/_essential/authentication/login.vue';
/** 全局404页面 */
......
import type { RouteRecordRaw } from 'vue-router';
import { $t } from '@vben/locales/helper';
import { BasicLayout } from '#/layouts';
import { $t } from '#/locales';
const routes: RouteRecordRaw[] = [
{
......
import type { RouteRecordRaw } from 'vue-router';
import { $t } from '@vben/locales/helper';
import { BasicLayout, IFrameView } from '#/layouts';
import { $t } from '#/locales';
const routes: RouteRecordRaw[] = [
{
......
......@@ -2,9 +2,8 @@ import type { RouteRecordRaw } from 'vue-router';
import { VBEN_GITHUB_URL, VBEN_LOGO } from '@vben/constants';
import { $t } from '@vben/locales/helper';
import { BasicLayout, IFrameView } from '#/layouts';
import { $t } from '#/locales';
const routes: RouteRecordRaw[] = [
{
......
<script lang="ts" setup>
import type { LoginAndRegisterParams } from '@vben/universal-ui';
import { $t } from '@vben/locales';
import { AuthenticationLogin } from '@vben/universal-ui';
import { App } from 'ant-design-vue';
import { $t } from '#/locales';
import { useAccessStore } from '#/store';
defineOptions({ name: 'Login' });
......
......@@ -55,7 +55,7 @@
"postcss": "^8.4.39",
"postcss-antd-fixes": "^0.2.0",
"postcss-import": "^16.1.0",
"postcss-preset-env": "^9.5.15",
"postcss-preset-env": "^9.5.16",
"tailwindcss": "^3.4.4",
"tailwindcss-animate": "^1.0.7"
},
......
......@@ -4,7 +4,7 @@ import type { DefineApplicationOptions } from '../typing';
import { defineConfig, loadEnv, mergeConfig } from 'vite';
import { getApplicationConditionPlugins } from '../plugins';
import { loadApplicationPlugins } from '../plugins';
import { getCommonConfig } from './common';
function defineApplicationConfig(options: DefineApplicationOptions = {}) {
......@@ -15,7 +15,7 @@ function defineApplicationConfig(options: DefineApplicationOptions = {}) {
const isBuild = command === 'build';
const env = loadEnv(mode, root);
const plugins = await getApplicationConditionPlugins({
const plugins = await loadApplicationPlugins({
compress: false,
compressTypes: ['brotli', 'gzip'],
devtools: true,
......
......@@ -6,7 +6,7 @@ import { readPackageJSON } from '@vben/node-utils';
import { defineConfig, mergeConfig } from 'vite';
import { getLibraryConditionPlugins } from '../plugins';
import { loadLibraryPlugins } from '../plugins';
import { getCommonConfig } from './common';
function defineLibraryConfig(options: DefineLibraryOptions = {}) {
......@@ -16,7 +16,7 @@ function defineLibraryConfig(options: DefineLibraryOptions = {}) {
const { library = {}, vite = {} } = options;
const isBuild = command === 'build';
const plugins = await getLibraryConditionPlugins({
const plugins = await loadLibraryPlugins({
dts: false,
injectLibCss: true,
injectMetadata: true,
......
......@@ -9,7 +9,7 @@ import type {
import { join } from 'node:path';
import { getPackage } from '@vben/node-utils';
import { getPackage, getPackages } from '@vben/node-utils';
import viteVueI18nPlugin from '@intlify/unplugin-vue-i18n/vite';
import viteVue from '@vitejs/plugin-vue';
......@@ -33,9 +33,7 @@ import { viteLicensePlugin } from './license';
* 获取条件成立的 vite 插件
* @param conditionPlugins
*/
async function getConditionEstablishedPlugins(
conditionPlugins: ConditionPlugin[],
) {
async function loadConditionPlugins(conditionPlugins: ConditionPlugin[]) {
const plugins: PluginOption[] = [];
for (const conditionPlugin of conditionPlugins) {
if (conditionPlugin.condition) {
......@@ -49,7 +47,7 @@ async function getConditionEstablishedPlugins(
/**
* 根据条件获取通用的vite插件
*/
async function getCommonConditionPlugins(
async function loadCommonPlugins(
options: CommonPluginOptions,
): Promise<ConditionPlugin[]> {
const { devtools, injectMetadata, isBuild, visualizer } = options;
......@@ -89,7 +87,7 @@ async function getCommonConditionPlugins(
/**
* 根据条件获取应用类型的vite插件
*/
async function getApplicationConditionPlugins(
async function loadApplicationPlugins(
options: ApplicationPluginOptions,
): Promise<PluginOption[]> {
// 单独取,否则commonOptions拿不到
......@@ -112,15 +110,33 @@ async function getApplicationConditionPlugins(
...commonOptions
} = options;
const commonPlugins = await getCommonConditionPlugins(commonOptions);
const commonPlugins = await loadCommonPlugins(commonOptions);
return await getConditionEstablishedPlugins([
return await loadConditionPlugins([
...commonPlugins,
{
condition: i18n,
plugins: async () => {
const pkg = await getPackage('@vben/locales');
const include = `${join(pkg?.dir ?? '', isBuild ? 'dist' : 'src', 'langs')}/*.yaml`;
const { packages } = await getPackages();
const pkg = await getPackage('@vben-core/locales');
const include: string[] = [
`${join(pkg?.dir ?? '', isBuild ? 'dist' : 'src', 'langs')}/*.yaml`,
];
// 加载所有应用的国际化文件
for (const { dir, relativeDir } of packages) {
if (
// 排除非应用目录
!relativeDir.startsWith('apps') ||
// 排除mock目录
relativeDir.includes('backend-mock')
) {
continue;
}
include.push(`${join(dir, 'src', 'locales', 'langs')}/*.yaml`);
}
return [
viteVueI18nPlugin({
compositionOnly: true,
......@@ -204,14 +220,14 @@ async function getApplicationConditionPlugins(
/**
* 根据条件获取库类型的vite插件
*/
async function getLibraryConditionPlugins(
async function loadLibraryPlugins(
options: LibraryPluginOptions,
): Promise<PluginOption[]> {
// 单独取,否则commonOptions拿不到
const isBuild = options.isBuild;
const { dts, injectLibCss, ...commonOptions } = options;
const commonPlugins = await getCommonConditionPlugins(commonOptions);
return await getConditionEstablishedPlugins([
const commonPlugins = await loadCommonPlugins(commonOptions);
return await loadConditionPlugins([
...commonPlugins,
{
condition: isBuild && !!dts,
......@@ -225,8 +241,8 @@ async function getLibraryConditionPlugins(
}
export {
getApplicationConditionPlugins,
getLibraryConditionPlugins,
loadApplicationPlugins,
loadLibraryPlugins,
viteCompressPlugin,
viteDtsPlugin,
viteHtmlPlugin,
......
......@@ -5,7 +5,6 @@ export default defineBuildConfig({
declaration: true,
entries: [
'src/index',
'src/helper',
{
builder: 'mkdist',
input: './src/langs',
......
{
"name": "@vben/locales",
"name": "@vben-core/locales",
"version": "5.0.0",
"homepage": "https://github.com/vbenjs/vue-vben-admin",
"bugs": "https://github.com/vbenjs/vue-vben-admin/issues",
"repository": {
"type": "git",
"url": "git+https://github.com/vbenjs/vue-vben-admin.git",
"directory": "packages/locales"
"directory": "packages/@vben-core/forward/locales"
},
"license": "MIT",
"type": "module",
......@@ -30,11 +30,6 @@
},
"./langs/*": {
"default": "./dist/langs/*"
},
"./helper": {
"types": "./src/helper.ts",
"development": "./src/helper.ts",
"default": "./dist/helper.mjs"
}
},
"publishConfig": {
......@@ -45,6 +40,9 @@
}
}
},
"peerDependencies": {
"vite": "latest"
},
"dependencies": {
"@intlify/core-base": "^9.13.1",
"@vben-core/typings": "workspace:*",
......
......@@ -8,6 +8,7 @@ import { createI18n } from 'vue-i18n';
const loadedLanguages = new Set<string>();
// TODO:import.meta.env 和 import.meta.glob 是源码依赖,会导致该包依赖外部项目必须是vite才可以
const i18n = createI18n({
globalInjection: true,
legacy: false,
......@@ -20,13 +21,22 @@ const i18n = createI18n({
const modules = import.meta.glob('./langs/*.y(a)?ml');
const localesMap: Record<Locale, ImportLocaleFn> = {};
const localesMap = loadLocalesMap(modules);
for (const [path, loadLocale] of Object.entries(modules)) {
const key = path.match(/([\w-]*)\.y(a)?ml/)?.[1];
if (key) {
localesMap[key] = loadLocale as ImportLocaleFn;
/**
* Load locale modules
* @param modules
*/
function loadLocalesMap(modules: Record<string, () => Promise<unknown>>) {
const localesMap: Record<Locale, ImportLocaleFn> = {};
for (const [path, loadLocale] of Object.entries(modules)) {
const key = path.match(/([\w-]*)\.y(a)?ml/)?.[1];
if (key) {
localesMap[key] = loadLocale as ImportLocaleFn;
}
}
return localesMap;
}
/**
......@@ -52,11 +62,11 @@ async function loadI18nMessages(lang: SupportedLanguagesType) {
return setI18nLanguage(lang);
}
const messages = await localesMap[lang]();
const message = await localesMap[lang]();
i18n.global.setLocaleMessage(lang, messages.default);
i18n.global.setLocaleMessage(lang, message.default);
loadedLanguages.add(lang);
return setI18nLanguage(lang);
}
export { i18n, loadI18nMessages, setI18nLanguage };
export { i18n, loadI18nMessages, loadLocalesMap, setI18nLanguage };
import type { LocaleSetupOptions, SupportedLanguagesType } from './typing';
import type {
ImportLocaleFn,
LoadMessageFn,
LocaleSetupOptions,
SupportedLanguagesType,
} from './typing';
import type { App } from 'vue';
import { i18n, loadI18nMessages } from './i18n';
import { i18n, loadI18nMessages, loadLocalesMap } from './i18n';
const $t = i18n.global.t;
let loadThirdPartyMessage: (lang: SupportedLanguagesType) => Promise<void>;
let loadMessages: LoadMessageFn;
async function loadLocaleMessages(lang: SupportedLanguagesType) {
const mergeMessage = await loadMessages(lang);
await loadI18nMessages(lang);
await loadThirdPartyMessage(lang);
i18n.global.mergeLocaleMessage(lang, mergeMessage);
}
async function setupI18n(app: App, options: LocaleSetupOptions = {}) {
const { defaultLocale = 'zh-CN' } = options;
// app可以自行扩展一些第三方库和组件库的国际化
loadThirdPartyMessage = options.loadThirdPartyMessage || (async () => {});
loadMessages = options.loadMessages || (async () => ({}));
app.use(i18n);
await loadLocaleMessages(defaultLocale);
}
export { $t, loadLocaleMessages, setupI18n };
export type { CompileError } from '@intlify/core-base';
export { $t, loadLocaleMessages, loadLocalesMap, setupI18n };
export { useI18n } from 'vue-i18n';
export type { Locale } from 'vue-i18n';
export type { ImportLocaleFn };
page:
demos:
title: Demos
access:
title: Access Control
frontend-control: Front-end Control
# menuVisibleWithForbidden: Menu is visible
backend-control: Backend Control
page: Page visit
button: Button control
loading-menu: In the loading menu
access-test-1: Super visit
access-test-2: Admin visit
access-test-3: User visit
nested:
title: Nested Menu
menu1: Menu 1
menu2: Menu 2
menu21: Menu 2-1
menu3: Menu 3
menu31: Menu 3-1
menu32: Menu 3-2
menu321: Menu 3-2-1
outside:
title: External Page
embedded: embedded Page
external-link: External Link
fallback:
title: Fallback Page
essentials:
login: Login
register: Register
......
page:
demos:
title: 演示
access:
title: 访问控制
frontend-control: 前端控制
# menuVisibleWithForbidden: 菜单可见
backend-control: 后端控制
page: 页面访问
button: 按钮控制
access-test-1: Super 可见
access-test-2: Admin 可见
access-test-3: User 可见
nested:
title: 嵌套菜单
menu1: 菜单 1
menu2: 菜单 2
menu21: 菜单 2-1
menu3: 菜单 3
menu31: 菜单 3-1
menu32: 菜单 3-2
menu321: 菜单 3-2-1
outside:
title: 外部页面
embedded: 内嵌
external-link: 外链
fallback:
title: 缺省页
essentials:
login: 登陆
register: 注册
......
......@@ -2,6 +2,10 @@ import type { SupportedLanguagesType } from '@vben-core/typings';
type ImportLocaleFn = () => Promise<{ default: Record<string, string> }>;
type LoadMessageFn = (
lang: SupportedLanguagesType,
) => Promise<Record<string, string>>;
interface LocaleSetupOptions {
/**
* Default language
......@@ -9,11 +13,16 @@ interface LocaleSetupOptions {
*/
defaultLocale?: SupportedLanguagesType;
/**
* Load third-party library messages
* Load message function
* @param lang
* @returns
*/
loadThirdPartyMessage?: (lang: SupportedLanguagesType) => Promise<void>;
loadMessages?: LoadMessageFn;
}
export type { ImportLocaleFn, LocaleSetupOptions, SupportedLanguagesType };
export type {
ImportLocaleFn,
LoadMessageFn,
LocaleSetupOptions,
SupportedLanguagesType,
};
......@@ -37,10 +37,10 @@
}
},
"dependencies": {
"@vben-core/locales": "workspace:*",
"@vben-core/preferences": "workspace:*",
"@vben-core/stores": "workspace:*",
"@vben-core/toolkit": "workspace:*",
"@vben/locales": "workspace:*",
"vue": "^3.4.31",
"vue-router": "^4.4.0"
},
......
......@@ -6,7 +6,7 @@ import type { RouteRecordRaw } from 'vue-router';
import type { GeneratorMenuAndRoutesOptions } from '../types';
import { $t } from '@vben/locales';
import { $t } from '@vben-core/locales';
import { mapTree } from '@vben-core/toolkit';
/**
......
......@@ -40,13 +40,13 @@
"@vben-core/helpers": "workspace:*",
"@vben-core/iconify": "workspace:*",
"@vben-core/layout-ui": "workspace:*",
"@vben-core/locales": "workspace:*",
"@vben-core/menu-ui": "workspace:*",
"@vben-core/preferences": "workspace:*",
"@vben-core/shadcn-ui": "workspace:*",
"@vben-core/stores": "workspace:*",
"@vben-core/tabs-ui": "workspace:*",
"@vben-core/toolkit": "workspace:*",
"@vben/locales": "workspace:*",
"@vben/widgets": "workspace:*",
"vue": "^3.4.31",
"vue-router": "^4.4.0"
......
<script setup lang="ts">
import { computed } from 'vue';
import { $t } from '@vben/locales';
import { $t } from '@vben-core/locales';
import { preferences, usePreferences } from '@vben-core/preferences';
import AuthenticationFromView from './from-view.vue';
......
......@@ -4,8 +4,8 @@ import type { VbenDropdownMenuItem } from '@vben-core/shadcn-ui';
import { computed } from 'vue';
import { $t } from '@vben/locales';
import { MdiDockBottom, MdiDockLeft, MdiDockRight } from '@vben-core/iconify';
import { $t } from '@vben-core/locales';
import {
preferences,
updatePreferences,
......
<script lang="ts" setup>
import { computed } from 'vue';
import { $t } from '@vben/locales';
import { PreferencesWidget } from '@vben/widgets';
import { VbenAdminLayout } from '@vben-core/layout-ui';
import { $t } from '@vben-core/locales';
import {
preferences,
updatePreferences,
......
......@@ -8,7 +8,6 @@ import type {
import { computed, ref, watch } from 'vue';
import { useRoute, useRouter } from 'vue-router';
import { $t, useI18n } from '@vben/locales';
import {
IcRoundClose,
IcRoundMultipleStop,
......@@ -19,6 +18,7 @@ import {
MdiPin,
MdiPinOff,
} from '@vben-core/iconify';
import { $t, useI18n } from '@vben-core/locales';
import {
storeToRefs,
useCoreAccessStore,
......
......@@ -5,7 +5,7 @@ import type { IBreadcrumb } from '@vben-core/shadcn-ui';
import { computed } from 'vue';
import { useRoute, useRouter } from 'vue-router';
import { $t } from '@vben/locales';
import { $t } from '@vben-core/locales';
import { VbenBackgroundBreadcrumb, VbenBreadcrumb } from '@vben-core/shadcn-ui';
interface Props {
......
......@@ -42,9 +42,9 @@
"dependencies": {
"@vben-core/design": "workspace:*",
"@vben-core/iconify": "workspace:*",
"@vben-core/locales": "workspace:*",
"@vben-core/shadcn-ui": "workspace:*",
"@vben/constants": "workspace:*",
"@vben/locales": "workspace:*",
"@vben/types": "workspace:*",
"@vueuse/integrations": "^10.11.0",
"qrcode": "^1.5.3",
......
......@@ -5,7 +5,7 @@ import { computed, onBeforeUnmount, reactive, ref } from 'vue';
import { useRouter } from 'vue-router';
import { LOGIN_PATH } from '@vben/constants';
import { $t } from '@vben/locales';
import { $t } from '@vben-core/locales';
import { VbenButton, VbenInput, VbenPinInput } from '@vben-core/shadcn-ui';
import Title from './auth-title.vue';
......
......@@ -3,7 +3,7 @@ import { computed, reactive } from 'vue';
import { useRouter } from 'vue-router';
import { LOGIN_PATH } from '@vben/constants';
import { $t } from '@vben/locales';
import { $t } from '@vben-core/locales';
import { VbenButton, VbenInput } from '@vben-core/shadcn-ui';
import Title from './auth-title.vue';
......
......@@ -4,7 +4,7 @@ import type { LoginEmits } from './typings';
import { computed, reactive } from 'vue';
import { useRouter } from 'vue-router';
import { $t } from '@vben/locales';
import { $t } from '@vben-core/locales';
import {
VbenButton,
VbenCheckbox,
......
......@@ -3,7 +3,7 @@ import { ref } from 'vue';
import { useRouter } from 'vue-router';
import { LOGIN_PATH } from '@vben/constants';
import { $t } from '@vben/locales';
import { $t } from '@vben-core/locales';
import { VbenButton } from '@vben-core/shadcn-ui';
import { useQRCode } from '@vueuse/integrations/useQRCode';
......
......@@ -5,7 +5,7 @@ import { computed, reactive } from 'vue';
import { useRouter } from 'vue-router';
import { LOGIN_PATH } from '@vben/constants';
import { $t } from '@vben/locales';
import { $t } from '@vben-core/locales';
import {
VbenButton,
VbenCheckbox,
......
<script setup lang="ts">
import { $t } from '@vben/locales';
import { MdiGithub, MdiGoogle, MdiQqchat, MdiWechat } from '@vben-core/iconify';
import { $t } from '@vben-core/locales';
import { VbenIconButton } from '@vben-core/shadcn-ui';
defineOptions({
......
......@@ -4,8 +4,8 @@ import type { FallbackProps } from './fallback';
import { computed, defineAsyncComponent } from 'vue';
import { useRouter } from 'vue-router';
import { $t } from '@vben/locales';
import { IcRoundArrowBackIosNew, IcRoundRefresh } from '@vben-core/iconify';
import { $t } from '@vben-core/locales';
import { VbenButton } from '@vben-core/shadcn-ui';
interface Props extends FallbackProps {}
......
......@@ -43,10 +43,10 @@
"@vben-core/colorful": "workspace:*",
"@vben-core/design": "workspace:*",
"@vben-core/iconify": "workspace:*",
"@vben-core/locales": "workspace:*",
"@vben-core/preferences": "workspace:*",
"@vben-core/shadcn-ui": "workspace:*",
"@vben-core/toolkit": "workspace:*",
"@vben/locales": "workspace:*",
"@vueuse/core": "^10.11.0",
"vue": "^3.4.31",
"vue-router": "^4.4.0"
......
......@@ -51,19 +51,19 @@ onUnmounted(() => {
});
</script>
<template>
<div ref="wrapperEl" class="coze-assistant"></div>
<div ref="wrapperEl" class="coze-vben-admin-assistant"></div>
</template>
<style>
.coze-assistant {
.coze-vben-admin-assistant {
position: fixed;
right: 30px;
bottom: 60px;
z-index: 1000;
img {
width: 42px !important;
height: 42px !important;
width: 50px !important;
height: 50px !important;
border-radius: 50%;
}
}
......
......@@ -3,7 +3,6 @@ import type { MenuRecordRaw } from '@vben/types';
import { onMounted, onUnmounted, ref, watch } from 'vue';
import { $t } from '@vben/locales';
import {
IcRoundArrowDownward,
IcRoundArrowUpward,
......@@ -11,6 +10,7 @@ import {
IcRoundSubdirectoryArrowLeft,
MdiKeyboardEsc,
} from '@vben-core/iconify';
import { $t } from '@vben-core/locales';
import {
Dialog,
DialogContent,
......
......@@ -4,8 +4,8 @@ import type { MenuRecordRaw } from '@vben/types';
import { nextTick, onMounted, ref, shallowRef, watch } from 'vue';
import { useRouter } from 'vue-router';
import { $t } from '@vben/locales';
import { IcRoundClose, IcRoundSearchOff } from '@vben-core/iconify';
import { $t } from '@vben-core/locales';
import { VbenIcon, VbenScrollbar } from '@vben-core/shadcn-ui';
import { mapTree, traverseTreeValues, uniqueByField } from '@vben-core/toolkit';
......
<script setup lang="ts">
import type { SupportedLanguagesType } from '@vben/types';
import { loadLocaleMessages } from '@vben/locales';
import { IcBaselineLanguage } from '@vben-core/iconify';
import { loadLocaleMessages } from '@vben-core/locales';
import {
SUPPORT_LANGUAGES,
preferences,
......
<script lang="ts" setup>
import type { NotificationItem } from './interface';
import { $t } from '@vben/locales';
import {
IcRoundMarkEmailRead,
IcRoundNotificationsNone,
} from '@vben-core/iconify';
import { $t } from '@vben-core/locales';
import {
VbenButton,
VbenIconButton,
......
<script setup lang="ts">
import { $t } from '@vben/locales';
import { $t } from '@vben-core/locales';
import SwitchItem from '../switch-item.vue';
......
<script setup lang="ts">
import type { SelectListItem } from '@vben/types';
import { $t } from '@vben/locales';
import { $t } from '@vben-core/locales';
import { SUPPORT_LANGUAGES } from '@vben-core/preferences';
import SelectItem from '../select-item.vue';
......
......@@ -3,7 +3,7 @@ import type { SelectListItem } from '@vben/types';
import { computed } from 'vue';
import { $t } from '@vben/locales';
import { $t } from '@vben-core/locales';
import SwitchItem from '../switch-item.vue';
import ToggleItem from '../toggle-item.vue';
......
<script setup lang="ts">
import { type Component, computed } from 'vue';
import { $t } from '@vben/locales';
import { $t } from '@vben-core/locales';
import { ContentCompact, ContentWide } from '../../icons';
......
<script setup lang="ts">
import { $t } from '@vben/locales';
import { $t } from '@vben-core/locales';
import InputItem from '../input-item.vue';
import SwitchItem from '../switch-item.vue';
......
<script setup lang="ts">
import { $t } from '@vben/locales';
import { $t } from '@vben-core/locales';
import SwitchItem from '../switch-item.vue';
......
<script setup lang="ts">
import type { LayoutHeaderModeType, SelectListItem } from '@vben/types';
import { $t } from '@vben/locales';
import { $t } from '@vben-core/locales';
import SelectItem from '../select-item.vue';
import SwitchItem from '../switch-item.vue';
......
<script setup lang="ts">
import { $t } from '@vben/locales';
import { $t } from '@vben-core/locales';
import SwitchItem from '../switch-item.vue';
......
......@@ -3,8 +3,8 @@ import type { LayoutType } from '@vben/types';
import { type Component, computed } from 'vue';
import { $t } from '@vben/locales';
import { MdiQuestionMarkCircleOutline } from '@vben-core/iconify';
import { $t } from '@vben-core/locales';
import { VbenTooltip } from '@vben-core/shadcn-ui';
import {
......
<script setup lang="ts">
import type { SelectListItem } from '@vben/types';
import { $t } from '@vben/locales';
import { $t } from '@vben-core/locales';
import SwitchItem from '../switch-item.vue';
import ToggleItem from '../toggle-item.vue';
......
<script setup lang="ts">
import { $t } from '@vben/locales';
import { $t } from '@vben-core/locales';
import NumberFieldItem from '../number-field-item.vue';
import SwitchItem from '../switch-item.vue';
......
<script setup lang="ts">
import { $t } from '@vben/locales';
import { $t } from '@vben-core/locales';
import SwitchItem from '../switch-item.vue';
......
<script setup lang="ts">
import { computed } from 'vue';
import { $t } from '@vben/locales';
import { $t } from '@vben-core/locales';
import { isWindowsOs } from '@vben-core/toolkit';
import SwitchItem from '../switch-item.vue';
......
......@@ -3,9 +3,9 @@ import type { BuiltinThemeType } from '@vben/types';
import { computed, ref } from 'vue';
import { $t } from '@vben/locales';
import { TinyColor, convertToHsl } from '@vben-core/colorful';
import { MdiEditBoxOutline } from '@vben-core/iconify';
import { $t } from '@vben-core/locales';
import {
BUILT_IN_THEME_PRESETS,
type BuiltinThemePreset,
......
<script setup lang="ts">
import { $t } from '@vben/locales';
import { $t } from '@vben-core/locales';
import SwitchItem from '../switch-item.vue';
......
......@@ -3,12 +3,12 @@ import type { ThemeModeType } from '@vben-core/preferences';
import type { Component } from 'vue';
import { $t } from '@vben/locales';
import {
IcRoundMotionPhotosAuto,
IcRoundWbSunny,
MdiMoonAndStars,
} from '@vben-core/iconify';
import { $t } from '@vben-core/locales';
import SwitchItem from '../switch-item.vue';
......
<script lang="ts" setup>
import { loadLocaleMessages } from '@vben/locales';
import { loadLocaleMessages } from '@vben-core/locales';
import { preferences, updatePreferences } from '@vben-core/preferences';
import Preferences from './preferences.vue';
......
......@@ -15,8 +15,8 @@ import type { SegmentedItem } from '@vben-core/shadcn-ui';
import { computed, ref } from 'vue';
import { $t, loadLocaleMessages } from '@vben/locales';
import { IcRoundFolderCopy, IcRoundRestartAlt } from '@vben-core/iconify';
import { $t, loadLocaleMessages } from '@vben-core/locales';
import {
clearPreferencesCache,
preferences,
......
<script setup lang="ts">
import { $t } from '@vben/locales';
import { $t } from '@vben-core/locales';
import { VbenButton } from '@vben-core/shadcn-ui';
import IconSetting from './icons/setting.vue';
......
<script lang="ts" setup>
import { $t } from '@vben/locales';
import {
IcRoundMotionPhotosAuto,
IcRoundWbSunny,
MdiMoonAndStars,
} from '@vben-core/iconify';
import { $t } from '@vben-core/locales';
import {
type ThemeModeType,
preferences,
......
......@@ -4,8 +4,8 @@ import type { AnyFunction } from '@vben/types';
import type { Component } from 'vue';
import { computed, ref } from 'vue';
import { $t } from '@vben/locales';
import { IcRoundLogout, IcRoundSettingsSuggest } from '@vben-core/iconify';
import { $t } from '@vben-core/locales';
import { preferences, usePreferences } from '@vben-core/preferences';
import {
Badge,
......
/**
* 没有任何实际作用,只用于 IDE 对I18的提示
*/
function $t(key: string) {
return key;
}
export { $t };
......@@ -6,6 +6,7 @@ packages:
- "packages/@core/ui-kit/*"
- "packages/@core/forward/*"
- "packages/@core/helpers"
- "packages/@core/locales"
- "packages/business/*"
- "apps/*"
- "scripts/*"
......
......@@ -61,6 +61,10 @@
"path": "packages/@core/forward/stores",
},
{
"name": "@vben-core/locales",
"path": "packages/@core/locales",
},
{
"name": "@vben-core/cache",
"path": "packages/@core/shared/cache",
},
......@@ -133,10 +137,6 @@
"path": "packages/icons",
},
{
"name": "@vben/locales",
"path": "packages/locales",
},
{
"name": "@vben/styles",
"path": "packages/styles",
},
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!