解决中英文问题
This commit is contained in:
1 parent
8a13dfb836
commit
42435acf7e
8 files changed
+75
-32
No files matched your search
@@ -26,4 +26,24 @@ FROM base AS final
|
||||
WORKDIR /app
|
||||
COPY --from=publish /app/publish .
|
||||
COPY ./dist ./dist
|
||||
ENTRYPOINT ["dotnet", "CloudBuilder.Web.Entry.dll"]
|
||||
ENTRYPOINT ["dotnet", "CloudBuilder.Web.Entry.dll"]
|
||||
|
||||
#version: "3"
|
||||
#services:
|
||||
#cb:
|
||||
#image: mcr.microsoft.com/dotnet/runtime-deps:8.0
|
||||
#container_name: CloudBuilder.Web.Entry
|
||||
#restart: always
|
||||
#ports:
|
||||
#- "5200:8080"
|
||||
#volumes:
|
||||
#- ./:/app
|
||||
#- /vol1/1000/Docker/NET8/publish/data:/app/data
|
||||
#working_dir: /app
|
||||
#environment:
|
||||
#- ASPNETCORE_URLS=http://+:8080
|
||||
#- ASPNETCORE_ENVIRONMENT=Production
|
||||
#- TZ=Asia/Shanghai # 新增时区环境变量
|
||||
#command: >
|
||||
#sh -c "chmod +x ./CloudBuilder.Web.Entry && ./CloudBuilder.Web.Entry"
|
||||
#
|
||||
+1
-1
@@ -3,7 +3,7 @@
|
||||
<Project>
|
||||
<PropertyGroup>
|
||||
<_PublishTargetUrl>C:\inetpub\wwwroot\dockwebapi2</_PublishTargetUrl>
|
||||
<History>True|2026-09-02T02:58:16.8081797Z||;True|2026-08-26T13:34:12.3805892+08:00||;True|2026-08-25T08:31:30.7787234+08:00||;True|2026-08-20T13:10:46.4725468+08:00||;True|2026-08-20T13:10:28.3142576+08:00||;True|2026-08-19T16:10:27.3362887+08:00||;True|2026-08-19T16:01:12.6234971+08:00||;True|2026-08-19T15:42:46.6576265+08:00||;True|2026-08-19T13:39:59.9363522+08:00||;True|2026-08-19T13:36:53.0379313+08:00||;True|2026-08-19T13:31:36.0841398+08:00||;True|2026-08-19T11:44:37.5319626+08:00||;True|2026-08-19T09:36:45.6000047+08:00||;True|2026-08-19T09:34:36.8468631+08:00||;True|2026-08-19T08:35:41.2202300+08:00||;True|2026-08-18T16:20:59.0170916+08:00||;</History>
|
||||
<History>True|2026-09-02T03:08:23.8720038Z||;True|2026-09-02T10:58:16.8081797+08:00||;True|2026-08-26T13:34:12.3805892+08:00||;True|2026-08-25T08:31:30.7787234+08:00||;True|2026-08-20T13:10:46.4725468+08:00||;True|2026-08-20T13:10:28.3142576+08:00||;True|2026-08-19T16:10:27.3362887+08:00||;True|2026-08-19T16:01:12.6234971+08:00||;True|2026-08-19T15:42:46.6576265+08:00||;True|2026-08-19T13:39:59.9363522+08:00||;True|2026-08-19T13:36:53.0379313+08:00||;True|2026-08-19T13:31:36.0841398+08:00||;True|2026-08-19T11:44:37.5319626+08:00||;True|2026-08-19T09:36:45.6000047+08:00||;True|2026-08-19T09:34:36.8468631+08:00||;True|2026-08-19T08:35:41.2202300+08:00||;True|2026-08-18T16:20:59.0170916+08:00||;</History>
|
||||
<LastFailureDetails />
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
@@ -10,16 +10,17 @@
|
||||
"DbContexts": {
|
||||
"MasterDbContext": {
|
||||
"DbContextTypeName": "MasterDbContext",
|
||||
"ConnectionString": "Server=localhost\\SQLEXPRESS;Database=Furion;User=sa;Password=owen123456;MultipleActiveResultSets=True;TrustServerCertificate=true",
|
||||
"DatabaseType": "SqlServer",
|
||||
"ConnectionString": "server=nas.youjiala.com;port=3307;database=Furion;uid=root;pwd=Root@1237890;CharSet=utf8mb4;",
|
||||
"DatabaseType": "MySql",
|
||||
|
||||
"LazyLoadingProxiesEnabled": true,
|
||||
"AuditEntityEnabled": true,
|
||||
"AutoMigrationEnabled": true
|
||||
},
|
||||
"SecondaryDbContext": {
|
||||
"DbContextTypeName": "SecondaryDbContext",
|
||||
"ConnectionString": "server=nas.youjiala.com;port=3307;database=Furion;uid=root;pwd=Root@1237890;CharSet=utf8mb4;",
|
||||
"DatabaseType": "MySql",
|
||||
"ConnectionString": "Server=localhost\\SQLEXPRESS;Database=Furion;User=sa;Password=owen123456;MultipleActiveResultSets=True;TrustServerCertificate=true",
|
||||
"DatabaseType": "SqlServer",
|
||||
"LazyLoadingProxiesEnabled": true,
|
||||
"AuditEntityEnabled": true,
|
||||
"AutoMigrationEnabled": true
|
||||
|
||||
@@ -2,7 +2,11 @@ import { createI18n } from 'vue-i18n'
|
||||
import type { I18nOptions } from 'vue-i18n';
|
||||
import type { App } from 'vue';
|
||||
import { set } from 'lodash-es';
|
||||
import axios from 'axios';
|
||||
import type { LocaleEntity } from '@/data/auto/localeEntity';
|
||||
import { WebSitePolicy } from '@/policy/custom/webSitePolicy';
|
||||
import en from './lang/en.ts';
|
||||
import cn from './lang/zh-cn.ts';
|
||||
|
||||
//这儿使用await,需要如下两步处理
|
||||
//npm install vite-plugin-top-level-await -D
|
||||
@@ -15,16 +19,14 @@ const i18n:any =createI18n( options)
|
||||
|
||||
async function createI18nOptions(): Promise<I18nOptions> {
|
||||
const locale:string='zh-cn';
|
||||
const en = await import(`./lang/en.ts`);
|
||||
const cn = await import(`./lang/zh-cn.ts`);
|
||||
|
||||
return {
|
||||
legacy: false,
|
||||
globalInjection: true, //全局生效$t
|
||||
locale: locale, // 默认cn翻译
|
||||
messages: {
|
||||
['zh-cn']: cn.default?.message,
|
||||
['en']: en.default?.message,
|
||||
['zh-cn']: cn?.message,
|
||||
['en']: en?.message,
|
||||
},
|
||||
sync: true, //If you don’t want to inherit locale from global scope, you need to set sync of i18n component option to false.
|
||||
silentTranslationWarn: true, // true - warning off
|
||||
@@ -36,6 +38,10 @@ async function createI18nOptions(): Promise<I18nOptions> {
|
||||
// setup i18n instance with global
|
||||
export async function setupI18n(app: App) {
|
||||
app.use(i18n);
|
||||
// 初始化 i18n 后拉取数据库翻译并合并。
|
||||
// 注意:不能 await,否则接口慢/挂起会阻塞 app.mount 导致白屏;
|
||||
// mergeLocaleMessage 是响应式的,合并完成界面文案会自动更新,失败只 warn。
|
||||
mergeDbLocaleMessages();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -46,12 +52,24 @@ export async function setupI18n(app: App) {
|
||||
* GroupName -> 顶层分组(对应 json 文件名的 key,如 layout / login / request)
|
||||
* Name -> 点分隔的翻译 key(如 header.logout)
|
||||
* Value -> 翻译文本
|
||||
* 需在应用启动后调用;内部使用动态 import,避免与 utils/request 形成循环依赖。
|
||||
* 需在应用启动后调用;参考 router/insideLayout.ts,直接使用 axios 裸调接口,
|
||||
* 不经过 utils/request 封装,避免与其形成循环依赖。
|
||||
*/
|
||||
export async function mergeDbLocaleMessages() {
|
||||
try {
|
||||
const { default: localeService } = await import('@/service/security/localeService');
|
||||
const list = await localeService.FindAll();
|
||||
// 参考 router/insideLayout.ts 的 axios 调用方式
|
||||
if (process.env.NODE_ENV === "development") {
|
||||
axios.defaults.baseURL = WebSitePolicy.WebApiRootDev;
|
||||
axios.defaults.withCredentials = true;
|
||||
} else {
|
||||
axios.defaults.baseURL = WebSitePolicy.WebApiRoot;
|
||||
}
|
||||
const response = await axios.create().request({
|
||||
url: "/Locale/FindAll",
|
||||
method: "get",
|
||||
});
|
||||
|
||||
const list: LocaleEntity[] = response.status == 200 ? response.data : [];
|
||||
if (!list || list.length === 0) return;
|
||||
|
||||
// 按语言分组,并将 GroupName.Name 铺平成嵌套对象
|
||||
|
||||
@@ -1,15 +1,17 @@
|
||||
{
|
||||
"login": {
|
||||
"login": "Login"
|
||||
},
|
||||
"register": {
|
||||
"twoDifferentPasswords": "Two different passwords",
|
||||
"pleaseEnterYourConfirmationPassword": "Please enter your confirmation password"
|
||||
},
|
||||
"changePassword": {
|
||||
"changePassword": "Change Password",
|
||||
"oldPassword":"Old Password",
|
||||
"newPassword":"New Password",
|
||||
"confirmPassword":"Confirm Password",
|
||||
"pleaseInputOldPassword":"Please input old password",
|
||||
"pleaseInputNewPassword":"Please input new password"
|
||||
|
||||
"oldPassword": "Old Password",
|
||||
"newPassword": "New Password",
|
||||
"confirmPassword": "Confirm Password",
|
||||
"pleaseInputOldPassword": "Please input old password",
|
||||
"pleaseInputNewPassword": "Please input new password"
|
||||
}
|
||||
}
|
||||
@@ -1,14 +1,17 @@
|
||||
{
|
||||
"login": {
|
||||
"login": "登录"
|
||||
},
|
||||
"register": {
|
||||
"pleaseEnterYourConfirmationPassword": "请输入确认密码",
|
||||
"twoDifferentPasswords": "两次密码不一样"
|
||||
},
|
||||
"changePassword": {
|
||||
"changePassword": "修改密码",
|
||||
"oldPassword":"旧密码",
|
||||
"newPassword":"新密码",
|
||||
"confirmPassword":"确认密码",
|
||||
"pleaseInputOldPassword":"请输入旧密码",
|
||||
"pleaseInputNewPassword":"请输入新密码"
|
||||
}
|
||||
}
|
||||
"oldPassword": "旧密码",
|
||||
"newPassword": "新密码",
|
||||
"confirmPassword": "确认密码",
|
||||
"pleaseInputOldPassword": "请输入旧密码",
|
||||
"pleaseInputNewPassword": "请输入新密码"
|
||||
}
|
||||
}
|
||||
+3
-4
@@ -5,7 +5,7 @@ import App from "./App.vue";
|
||||
import { setupStore } from "./store";
|
||||
//使用了Top await
|
||||
import { setupRouter } from "./router";
|
||||
import { mergeDbLocaleMessages } from "./locales";
|
||||
import { setupI18n } from "./locales";
|
||||
|
||||
import {
|
||||
setupAntd,
|
||||
@@ -33,11 +33,10 @@ function setupPlugins() {
|
||||
async function setupApp() {
|
||||
// 挂载pinia状态管理
|
||||
setupStore(app);
|
||||
// 并行加载数据库 locale 表内容作为中英文翻译补充
|
||||
const dbLocale = mergeDbLocaleMessages();
|
||||
// 挂载路由
|
||||
await setupRouter(app);
|
||||
await dbLocale;
|
||||
// 初始化 i18n(内部会异步拉取数据库翻译补充,不阻塞挂载)
|
||||
await setupI18n(app);
|
||||
|
||||
app.mount("#app");
|
||||
}
|
||||
|
||||
@@ -17,10 +17,10 @@
|
||||
</a-input>
|
||||
</a-form-item>
|
||||
<a-form-item>
|
||||
<a-button type="primary" html-type="submit" size="large" block> 登录 </a-button>
|
||||
<a-button type="primary" html-type="submit" size="large" block> {{ t('login.login.login')}} </a-button>
|
||||
</a-form-item>
|
||||
<!-- 技术上已实现,暂时不加入中文系统 -->
|
||||
<div class="culture-switch" v-if="false">
|
||||
<div class="culture-switch" v-if="true">
|
||||
<a-button
|
||||
type="text"
|
||||
size="large"
|
||||
|
||||
Reference in new issue
Block a user