fix: 登入页面国际化

This commit is contained in:
chenjianxing 2021-12-17 17:15:38 +08:00 committed by BugKing
parent df432e3593
commit 04f10bf9fb
6 changed files with 271 additions and 252 deletions

View File

@ -15,6 +15,7 @@ export const TEST_PLAN_SCENARIO_CASE = 'test_plan_scenario_case'
export const TokenKey = 'Admin-Token';
export const LicenseKey = 'License';
export const DEFAULT_LANGUAGE = 'default_language';
export const CURRENT_LANGUAGE = 'current_language';
export const ROLE_ADMIN = 'admin';
export const ROLE_ORG_ADMIN = 'org_admin';

View File

@ -388,6 +388,9 @@ export default {
version:'Version',
is_new:"Is new"
},
login: {
normal_Login: "Normal Login",
},
license: {
title: 'Authorization management',
corporation: 'corporation',

View File

@ -7,6 +7,7 @@ import zh_TWLocale from "element-ui/lib/locale/lang/zh-TW";
import zh_CN from "./zh-CN";
import en_US from "./en-US";
import zh_TW from "./zh-TW";
import {CURRENT_LANGUAGE} from "@/common/js/constants";
Vue.use(VueI18n);
@ -37,6 +38,7 @@ function setI18nLanguage(lang) {
i18n.locale = lang;
axios.defaults.headers.common['Accept-Language'] = lang.replace("_", "-");
document.querySelector('html').setAttribute('lang', lang);
localStorage.setItem(CURRENT_LANGUAGE, lang);
return lang;
}

View File

@ -390,6 +390,9 @@ export default {
version: '版本',
is_new: "是否新建"
},
login: {
normal_Login: "普通登录",
},
license: {
title: '授权管理',
corporation: '客户名称',

View File

@ -57,7 +57,7 @@ export default {
confirm: '確定',
cancel: '取消',
scenario: '場景',
scenario_warning: '當前場景沒有環境,需要先設自身環境',
scenario_warning: '當前場景沒有環境,需要先設自身環境',
confirm_info: '未保存,是否確認關閉?',
track: '用例',
actuator: '執行器',
@ -100,8 +100,8 @@ export default {
test_resource_pool: '測試資源池',
system_setting: '系統設置',
api: '接口測試',
encode: '编码',
follow_api: '跟隨API定義',
encode: '編碼',
response_time_delay: '響應延遲時間',
performance: '性能測試',
enable_settings: '啟用設置',
@ -189,7 +189,7 @@ export default {
mock: "Mock 設置",
encrypted: "不加密",
no_corresponding: "無對應的",
code_template: "代模版",
code_template: "代模版",
api_case: "接口用例",
scenario_case: "場景用例",
task_center: "任務中心",
@ -204,17 +204,17 @@ export default {
create_user_id: '創建人ID',
run_message: "任務執行中,請到任務中心查看詳情",
executor: "執行人",
edit_info: "編輯詳情",
enable_scene: "啟用場景環境",
enable_scene_info: "啟用場景環境:當前步驟使用場景原始環境配寘運行",
execute_history: "執行歷史",
debug_history: "調試歷史",
testing: "測試中",
edit_info: "編輯詳情",
enable_scene: "啟用場景環境",
enable_scene_info: "啟用場景環境:當前步驟使用場景原始環境配置運行",
environment: "運行環境",
run_success: "執行成功",
run_completed: "執行完成",
run_warning: "正在運行中,請稍後查看",
run_stop: "當前任務已停止,無法查看報告",
run_stop: "The current task has been stopped and the report cannot be viewed",
run_fail: "執行失敗",
follow_success: "關註成功",
cancel_follow_success: "取消關註成功",
@ -390,6 +390,9 @@ export default {
version: '版本',
is_new: "是否新建"
},
login: {
normal_Login: "普通登錄",
},
license: {
title: '授權管理',
corporation: '客戶名稱',
@ -670,9 +673,10 @@ export default {
no_data: '無數據',
select: '選擇項目',
repeatable: '接口定義URL可重復',
repeatable_info: '接口定義URL可重復 \n 啟用後接口定義重復性校驗將不校驗URL',
repeatable_info: '啟用後接口定義重復性校驗將不校驗URL',
case_public: '公共用例庫',
public_info: '啟動公共用例庫 \n 可以使用公共用例庫數據,也可以自行添加用例至公共用例庫',
public: '啟動公共用例庫',
public_info: '可以使用公共用例庫數據,也可以自行添加用例至公共用例庫',
upload_file_again: '重新上傳',
code_segment: {
code_segment: "自定義代碼片段",
@ -717,9 +721,9 @@ export default {
log_desc: '項目全部操作過程',
code_segment_desc: '自定義代碼片段',
test_case_custom_id: '測試用例自定義ID',
test_case_custom_id_info: '測試用例自定義ID \n 用例ID默認為系統自增ID',
test_case_custom_id_info: '用例ID默認為系統自增ID',
scenario_custom_id: '場景自定義ID',
scenario_custom_id_info: '場景自定義ID \n 場景用例ID默認為系統自增ID',
scenario_custom_id_info: '場景用例ID默認為系統自增ID',
},
member: {
create: '添加成員',
@ -1059,9 +1063,9 @@ export default {
},
definition: {
api_quick_button: '接口定義快捷添加按鈕',
id: '接口定義ID',
api_all: '全部接口',
unplanned_api: '未規劃接口',
id: '接口定義ID',
api_title: "接口列表",
case_title: "用例列表",
doc_title: "文檔",
@ -1387,28 +1391,28 @@ export default {
wait: "等待",
all_name: "名字",
all_url:"網址",
boolean:"布林值",
all_url: "url",
boolean: "布爾值",
capitalize: "大寫字母開頭",
cfirst: "姓(中文)",
character:"字元",
city:"都市",
character: "字符",
city: "城市",
clast: "名(中文)",
cname: "中文名",
color: "顏色",
county: "縣",
ctitle: "中文標題",
dataImage:"數據影像",
dataImage: "數據圖像",
date: "日期",
datetime: "日期時間",
domain: "域",
email: "電子郵件",
first: "姓",
float: "浮點數",
guid:"指南",
hex:"十六進位",
guid: "guid",
hex: "十六進製",
hsl: "hsl",
id:"身份證件",
id: "id",
img: "圖片地址",
increment: "增量",
integer: "整數",
@ -1419,7 +1423,7 @@ export default {
now: "當前時間",
paragraph: "段",
pick: "選擇",
protocol:"協定",
protocol: "協議",
province: "省",
range: "範圍",
region: "地區",
@ -1427,13 +1431,13 @@ export default {
rgba: "rgba",
sentence: "句子",
shuffle: "洗牌",
string:"字串",
string: "字串",
time: "時間",
title: "標題",
tld: "tld",
upper: "大寫字母",
word: "詞",
zip:"郵遞區號",
zip: "郵政編碼",
assertions: {
label: "斷言",
@ -1466,19 +1470,19 @@ export default {
set_failure_status: "設置失敗狀態",
set_failure_msg: "設置失敗消息",
suggest_tip: "點擊便簽添加JSONPath斷言",
regex_info: '特殊字元“$* + . [ ] \\ ^ { } |”需轉義為“\\”+“特殊字元”,如“\\$”',
regex_info: '特殊字符"$ ( ) * + . [ ] \\ ^ { } |"需轉義為"\\ "+"特殊字符",如"\\$"',
regular_match: '正則匹配',
none: '不校驗[]',
value_eq: '值-等於[value=]',
value_not_eq: '值-不等於[value=]',
value_not_eq: '值-不等於[value!=]',
value_in: '值-包含[include=]',
length_eq: '長度-等於[length=]',
length_not_eq: '長度-不等於[length=]',
length_not_eq: '長度-不等於[length!=]',
length_gt: '長度-大於[length>]',
length_lt: '長度-小於[length<]',
must_contain: '必含',
type_verification: '類型校驗',
content_verification: '容校驗',
content_verification: '容校驗',
expected_results: '預期結果',
check: '校驗組內元素',
add_check: '添加校驗',
@ -1566,10 +1570,10 @@ export default {
title: "接口測試導入",
data_format: "數據格式",
file_size_limit: "文件大小不超過 50 M",
support_format: "支持p12,jks,pfx格式",
tip: "說明",
export_tip: "導出方法",
ms_tip: "支持 MeterSphere json 格式",
support_format: "支持p12,jks,pfx格式",
ms_export_tip: "通過 MeterSphere 接口測試頁面或者瀏覽器插件導出 json 格式文件",
har_export_tip: "通過 瀏覽器的開發者工具 導出 HAR 格式文件",
esb_export_tip: "暫時不支持ESB文件的導出",
@ -2497,8 +2501,8 @@ export default {
'PERFORMANCE_TEST_TASK': '性能測試',
'PERFORMANCE_REPORT_TASK': '性能測試報告',
'TRACK_TEST_CASE_TASK': '測試用例',
'TRACK_HOME_TASK': '測試跟首頁',
'TRACK_REPORT_TASK': '測試跟報告',
'TRACK_HOME_TASK': '測試跟首頁',
'TRACK_REPORT_TASK': '測試跟報告',
},
result: {
'EXECUTE_SUCCESSFUL': '成功',
@ -2518,18 +2522,18 @@ export default {
edit_password: "修改密碼"
},
system_workspace: {
name: "工作空",
read: "查詢工作空",
create: "創建工作空",
edit: "編輯工作空",
delete: "刪除工作空",
name: "工作空",
read: "查詢工作空",
create: "創建工作空",
edit: "編輯工作空",
delete: "刪除工作空",
},
system_group: {
name: "用戶组与权限",
read: "查詢用戶组与权限",
create: "創建用戶",
edit: "編輯用戶",
setting_permission: "设置权限",
name: "用戶組與權限",
read: "查詢用戶組與權限",
create: "創建用戶",
edit: "編輯用戶",
setting_permission: "設置權限",
delete: "刪除"
},
system_test_pool: {
@ -2556,7 +2560,7 @@ export default {
},
system_operation_log: {
name: "操作日誌",
read: "查詢操作日"
read: "查詢操作日"
},
workspace_user: {
name: "成員",
@ -2583,30 +2587,30 @@ export default {
custom: "自定義字段"
},
workspace_project_manager: {
name: "目管理",
read: "查詢目",
create: "創建目",
edit: "編輯目",
delete: "刪除目",
upload_jar: "上jar包",
name: "目管理",
read: "查詢目",
create: "創建目",
edit: "編輯目",
delete: "刪除目",
upload_jar: "上jar包",
},
workspace_project_environment: {
name: "环境设置",
name: "環境設置",
read: "查詢",
create: "創建境",
edit: "編輯境",
delete: "刪除境",
copy: "複製环境",
import: "導入境",
export: "導出境",
create_group: "創建环境组",
edit_group: "編輯环境组",
copy_group: "複製环境组",
delete_group: "刪除环境组",
create: "創建境",
edit: "編輯境",
delete: "刪除境",
copy: "復製環境",
import: "導入境",
export: "導出境",
create_group: "創建環境組",
edit_group: "編輯環境組",
copy_group: "復製環境組",
delete_group: "刪除環境組",
},
workspace_operation_log: {
name: "操作日",
read: "查詢操作日"
name: "操作日",
read: "查詢操作日"
},
project_user: {
name: "成員",
@ -2616,47 +2620,47 @@ export default {
delete: "移除成員",
},
project_manager: {
name: "目管理",
read: "查詢目",
edit: "編輯目"
name: "目管理",
read: "查詢目",
edit: "編輯目"
},
project_group: {
name: "用戶组与权限",
read: "查詢用戶组与权限",
create: "創建用戶组与权限",
edit: "編輯用戶组与权限",
delete: "刪除用戶组与权限",
setting_permission: "设置权限",
name: "用戶組與權限",
read: "查詢用戶組與權限",
create: "創建用戶組與權限",
edit: "編輯用戶組與權限",
delete: "刪除用戶組與權限",
setting_permission: "設置權限",
},
project_environment: {
name: "环境设置",
read: "查詢境",
create: "創建境",
edit: "編輯境",
delete: "刪除境",
copy: "複製环境",
import: "導入境",
export: "導出境",
name: "環境設置",
read: "查詢境",
create: "創建境",
edit: "編輯境",
delete: "刪除境",
copy: "復製環境",
import: "導入境",
export: "導出境",
},
project_operation_log: {
name: "操作日",
read: "查詢操作日"
name: "操作日",
read: "查詢操作日"
},
project_custom_code: {
name: "自定義代片段",
name: "自定義代片段",
read: "查詢",
create: "創建",
edit: "編輯",
delete: "刪除",
copy: "製",
copy: "製",
},
project_file: {
name: "文件管理",
jar: "查詢jar包",
upload_jar: "上jar包",
upload_jar: "上jar包",
delete_jar: "刪除jar包",
read: "查詢文件",
upload_file: "上文件",
upload_file: "上文件",
delete_file: "刪除文件",
},
project_track_case: {
@ -2665,10 +2669,10 @@ export default {
create: "創建用例",
edit: "編輯用例",
delete: "刪除用例",
copy: "製用例",
copy: "製用例",
import: "導入用例",
export: "導出用例",
recover: "恢用例",
recover: "恢用例",
},
project_track_review: {
name: "測試評審",
@ -2687,13 +2691,13 @@ export default {
create: "創建測試計劃",
edit: "編輯測試計劃",
delete: "刪除測試計劃",
copy: "製測試計劃",
run: "行測試計劃",
batch_run: "批量行用例",
copy: "製測試計劃",
run: "行測試計劃",
batch_run: "批量行用例",
batch_edit: "批量編輯用例",
schedule: "定时任务",
schedule: "定時任務",
relevance_or_cancel: "關聯/取消關聯用例",
batch_delete: "批量取消关联用例",
batch_delete: "批量取消關聯用例",
},
project_track_issue: {
name: "缺陷",
@ -2709,40 +2713,40 @@ export default {
export: "導出報告",
},
project_api_definition: {
name: "接口定",
name: "接口定",
read: "查詢接口",
create_api: "創建接口",
edit_api: "編輯接口",
delete_api: "刪除接口",
copy_api: "製接口",
copy_api: "製接口",
create_case: "添加用例",
edit_case: "編輯用例",
delete_case: "刪除用例",
copy_case: "製用例",
copy_case: "製用例",
import_api: "導入接口",
export_api: "導出接口",
timing_sync: "定同步",
timing_sync: "定同步",
create_performance: "創建性能測試",
run: "行",
debug: "调试",
mock: "MOCK置",
run: "行",
debug: "調試",
mock: "MOCK置",
},
project_api_scenario: {
name: "接口自化",
name: "接口自化",
read: "查詢場景",
create: "創建場景",
edit: "編輯場景",
delete: "刪除場景",
copy: "製場景",
run: "行場景",
debug: "调试場景",
schedule: "定时任务",
copy: "製場景",
run: "行場景",
debug: "調試場景",
schedule: "定時任務",
import: "導入場景",
export: "導出場景",
move_batch: "批量移",
move_batch: "批量移",
create_performance: "創建性能測試",
create_performance_batch: "批量創建性能測試",
batch_copy: "批量製",
batch_copy: "批量製",
},
project_api_report: {
name: "測試報告",
@ -2756,31 +2760,31 @@ export default {
create: "創建測試",
edit: "編輯測試",
delete: "刪除測試",
copy: "製測試",
run: "行",
schedule: "定时任务",
copy: "製測試",
run: "行",
schedule: "定時任務",
},
project_performance_report: {
name: "報告",
read: "查詢報告",
delete: "刪除報告",
export: "導出報告",
compare: "比報告",
compare: "比報告",
},
project_report_analysis: {
name: "報表",
read: "查看",
export: "導出",
update: "保存",
create: "另存",
create: "另存",
},
project_enterprise_report: {
name: "目報告",
export: "发送邮件",
name: "目報告",
export: "發送郵件",
create: "創建報告",
delete: "刪除報告",
copy: "製報告",
schedule: "定时发送",
copy: "製報告",
schedule: "定時發送",
edit: "修改報告",
},
@ -2791,12 +2795,11 @@ export default {
read: "查看腳本",
},
other: {
track: "測試跟",
track: "測試跟",
api: "接口測試",
performance: "性能測試",
project: "項目設置",
report: "報表統計"
}
}
};

View File

@ -8,7 +8,7 @@
<img :src="'/display/file/loginLogo'" alt="">
</div>
<div class="welcome">
<span>{{ loginTitle }}</span>
<span>{{ $t("commons.welcome") }}</span>
</div>
</div>
<div class="form">
@ -16,7 +16,7 @@
<el-form-item v-slot:default>
<el-radio-group v-model="form.authenticate" @change="redirectAuth(form.authenticate)">
<el-radio label="LDAP" size="mini" v-if="openLdap">LDAP</el-radio>
<el-radio label="LOCAL" size="mini" v-if="openLdap">普通登录</el-radio>
<el-radio label="LOCAL" size="mini" v-if="openLdap">{{ $t('login.normal_Login') }}</el-radio>
<el-radio :label="auth.id" size="mini" v-for="auth in authSources" :key="auth.id">{{ auth.type }}
{{ auth.name }}
</el-radio>
@ -59,7 +59,7 @@
<script>
import {publicKeyEncrypt, saveLocalStorage} from '@/common/js/utils';
import {DEFAULT_LANGUAGE, PRIMARY_COLOR} from "@/common/js/constants";
import {CURRENT_LANGUAGE, DEFAULT_LANGUAGE, PRIMARY_COLOR} from "@/common/js/constants";
const requireComponent = require.context('@/business/components/xpack/', true, /\.vue$/);
const display = requireComponent.keys().length > 0 ? requireComponent("./display/Display.vue") : {};
@ -76,19 +76,10 @@ export default {
password: '',
authenticate: 'LOCAL'
},
rules: {
username: [
{required: true, message: this.$t('commons.input_login_username'), trigger: 'blur'},
],
password: [
{required: true, message: this.$t('commons.input_password'), trigger: 'blur'},
{min: 6, max: 30, message: this.$t('commons.input_limit', [6, 30]), trigger: 'blur'}
]
},
rules: this.getDefaultRules(),
msg: '',
ready: false,
openLdap: false,
loginTitle: this.$t("commons.welcome"),
authSources: [],
loginUrl: 'signin',
};
@ -119,6 +110,11 @@ export default {
this.ready = true;
//
localStorage.setItem("publicKey", response.data.message);
let lang = localStorage.getItem(CURRENT_LANGUAGE);
if (lang) {
this.$setLang(lang);
this.rules = this.getDefaultRules();
}
} else {
let user = response.data.data;
saveLocalStorage(response.data);
@ -207,6 +203,17 @@ export default {
if (auth.default) {
auth.default.redirectAuth(this, authId);
}
},
getDefaultRules() { //
return {
username: [
{required: true, message: this.$t('commons.input_login_username'), trigger: 'blur'},
],
password: [
{required: true, message: this.$t('commons.input_password'), trigger: 'blur'},
{min: 6, max: 30, message: this.$t('commons.input_limit', [6, 30]), trigger: 'blur'}
]
};
}
}
};