-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
link gh-3
- Loading branch information
Showing
9 changed files
with
744 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import httpClient from '@/utils/axios' | ||
import type { I18nData, I18nDataDTO, I18nDataQO } from './types' | ||
|
||
export function pageI18nData(query: I18nDataQO) { | ||
return httpClient.get('/i18n/i18n-data/page', { | ||
params: query | ||
}) | ||
} | ||
|
||
export function createI18nData(data: I18nDataDTO) { | ||
return httpClient.post('/i18n/i18n-data', data) | ||
} | ||
|
||
export function removeI18nData(code: string, languageTag: string) { | ||
return httpClient.delete('/i18n/i18n-data', { | ||
params: { | ||
code: code, | ||
languageTag: languageTag | ||
} | ||
}) | ||
} | ||
|
||
export function updateI18nData(data: I18nData) { | ||
return httpClient.put('/i18n/i18n-data', data) | ||
} | ||
|
||
export function exportExcel(params: I18nDataQO) { | ||
return httpClient.get('/i18n/i18n-data/export', { params, responseType: 'blob' }) | ||
} | ||
|
||
export function importExcel() { | ||
return httpClient.postForm('i18n/i18n-data/import', null, {}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
export interface I18nDataQO { | ||
// 国际化标识 | ||
code?: string | ||
// 文本值 | ||
message?: string | ||
// 语言标签 | ||
languageTag?: string | ||
} | ||
|
||
export interface LanguageText { | ||
// 语言标签 | ||
languageTag: string | ||
// 文本值 | ||
message: string | ||
} | ||
|
||
export interface I18nBaseData { | ||
// 唯一标识 | ||
code: string | ||
// 备注 | ||
remarks?: string | ||
} | ||
|
||
export interface I18nData extends LanguageText, I18nBaseData {} | ||
|
||
/** | ||
* i18nData新建修改的传输对象 | ||
*/ | ||
export interface I18nDataDTO extends I18nBaseData { | ||
languageTexts: LanguageText[] | ||
} | ||
|
||
/** | ||
* 角色分页视图对象 | ||
*/ | ||
export interface I18nDataPageVO extends I18nBaseData, LanguageText { | ||
id: number | ||
// 创建时间 | ||
createTime?: string | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,77 @@ | ||
{ | ||
"locale.ballcat": "BallCat en-US", | ||
|
||
"user.login.submit": "Login", | ||
"user.login.submit.retry": "Login again", | ||
"user.login.expired": "Login status expired!", | ||
|
||
"user.pemission.reject": "No Permission!", | ||
|
||
"system.tip.title": "System Tip", | ||
"system.tip.request.error": "Abnormal network request!", | ||
"system.tip.request.error.message": "request error status code: {code}", | ||
"system.tip.network.error": "The network is abnormal, and the server cannot be accessed!", | ||
"system.tip.network.error.message": | ||
"The network is abnormal, please check whether your network is smooth!", | ||
"system.tip.operate.error": "Operate Error! {message}" | ||
"system.tip.network.error.message": "The network is abnormal, please check whether your network is smooth!", | ||
"system.tip.operate.error": "Operate Error! {message}", | ||
|
||
"lov": { | ||
"selectedData": "The selected data" | ||
}, | ||
|
||
"action": { | ||
"query": "Query", | ||
"reset": "Reset", | ||
"expand": "Expand", | ||
"collapse": "Collapse", | ||
"more": "More", | ||
"create": "New", | ||
"delete": "Delete", | ||
"edit": "Edit", | ||
"export": "Export", | ||
"import": "Import", | ||
"details": "Details", | ||
"selectFile": "Select File", | ||
"choose": "Choose", | ||
"cancel": "Cancel" | ||
}, | ||
|
||
"common": { | ||
"operation": "Operation", | ||
"createTime": "Create Time", | ||
"updateTime": "Update Time", | ||
"remarks": "Remarks" | ||
}, | ||
|
||
"message": { | ||
"confirmDelete": "Are you sure delete?", | ||
"pleaseEnter": "Please enter", | ||
"pleaseSelectFile": "Please Select File" | ||
}, | ||
|
||
"import": { | ||
"batchImport": "Batch Import", | ||
"downloadTemplate": "Download Template", | ||
"whenDataExisting": "When the data already exists", | ||
"skipExisting": "Skip Existing", | ||
"overwriteExisting": "Overwrite Existing", | ||
"importSuccess": "Import Success" | ||
}, | ||
|
||
"i18n": { | ||
"i18nData": { | ||
"text": "I18N Data", | ||
"languageTag": { | ||
"text": "Language Tag", | ||
"tips": "LanguageTag,eg. zh-CN en-Us", | ||
"required": "Please enter i18n data language-tag!" | ||
}, | ||
"code": { | ||
"text": "Code", | ||
"tips": "A unique code for i18n data", | ||
"required": "Please enter i18n data code!" | ||
}, | ||
"message": { | ||
"text": "Message", | ||
"tips": "The text of the i18n data", | ||
"required": "Please enter i18n data message!!" | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
<template> | ||
<a-space direction="vertical"> | ||
<div v-for="language in languageList" :key="language.languageTag"> | ||
<a-input | ||
v-model:value="language.languageTag" | ||
placeholder="语言标签" | ||
style="width: 25%; margin-right: 8px" | ||
:disabled="true" | ||
/> | ||
<a-input | ||
v-model:value="language.message" | ||
placeholder="文本值" | ||
style="width: 60%; margin-right: 8px" | ||
/> | ||
<minus-circle-outlined | ||
v-if="languageList.length > 1" | ||
class="dynamic-delete-button" | ||
:disabled="languageList.length === 1" | ||
@click="() => remove(language)" | ||
/> | ||
</div> | ||
<a-popover trigger="click"> | ||
<template #content> | ||
<a-transfer | ||
:row-key="transferKey" | ||
:data-source="allLanguageList" | ||
:render="transferKey" | ||
:titles="['Source', 'Target']" | ||
:target-keys="langTags" | ||
:lazy="false" | ||
@change="langTagChange" | ||
/> | ||
</template> | ||
<a-button type="dashed" style="width: 60%"> | ||
<PlusOutlined /> | ||
Add field | ||
</a-button> | ||
</a-popover> | ||
</a-space> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
import type { LanguageText } from '@/api/i18n/types' | ||
import { supportLanguage } from '@/config' | ||
const supportLanguageTags = Object.keys(supportLanguage) | ||
const langTags = ref<string[]>([]) | ||
const allLanguageList = ref<LanguageText[]>([]) | ||
const languageList = ref<LanguageText[]>([]) | ||
watch(langTags.value, () => { | ||
languageList.value = allLanguageList.value.filter( | ||
x => langTags.value.findIndex(key => key === x.languageTag) !== -1 | ||
) | ||
}) | ||
onMounted(() => { | ||
allLanguageList.value = supportLanguageTags.map(languageTag => { | ||
return { | ||
languageTag, | ||
message: '' | ||
} | ||
}) | ||
langTags.value = [...supportLanguageTags] | ||
}) | ||
const langTagChange = (nextTargetKeys: string[]) => { | ||
langTags.value = nextTargetKeys | ||
} | ||
const transferKey = (item: LanguageText) => item.languageTag | ||
const remove = (language: LanguageText) => { | ||
const index = langTags.value.findIndex(key => key === language.languageTag) | ||
langTags.value.splice(index, 1) | ||
} | ||
defineExpose({ | ||
data: languageList, | ||
resetData() { | ||
allLanguageList.value = supportLanguageTags.map(languageTag => { | ||
return { | ||
languageTag, | ||
message: '' | ||
} | ||
}) | ||
langTags.value = [...supportLanguageTags] | ||
} | ||
}) | ||
</script> | ||
|
||
<style scoped lang="less"> | ||
.dynamic-delete-button { | ||
cursor: pointer; | ||
position: relative; | ||
top: 4px; | ||
font-size: 24px; | ||
color: #999; | ||
transition: all 0.3s; | ||
} | ||
.dynamic-delete-button:hover { | ||
color: #777; | ||
} | ||
.dynamic-delete-button[disabled] { | ||
cursor: not-allowed; | ||
opacity: 0.5; | ||
} | ||
</style> |
Oops, something went wrong.