yh-i18n 2.3.1 → 2.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/excelTool.ts +4 -4
- package/index.js +4 -4
- package/language.vue +15 -14
- package/list.vue +41 -27
- package/package.json +1 -1
package/excelTool.ts
CHANGED
|
@@ -78,8 +78,8 @@ export async function exportExcel(total) {
|
|
|
78
78
|
sheet.addRow(title);
|
|
79
79
|
sheet.addRows(
|
|
80
80
|
records.map((item) => {
|
|
81
|
-
let {
|
|
82
|
-
let row = [
|
|
81
|
+
let {id, name} = item;
|
|
82
|
+
let row = [id, name];
|
|
83
83
|
Config.i18nList.forEach((valKey) => {
|
|
84
84
|
row.push(item[valKey]);
|
|
85
85
|
});
|
|
@@ -216,14 +216,14 @@ export async function importExcel(e, getDataList) {
|
|
|
216
216
|
let dataList: any[] = [];
|
|
217
217
|
sheet.getRows(2, len)?.forEach((row) => {
|
|
218
218
|
let id = row.getCell(1).value;
|
|
219
|
-
let
|
|
219
|
+
let name = row.getCell(2).value;
|
|
220
220
|
let content: any = {};
|
|
221
221
|
Config.i18nList.forEach((item, index) => {
|
|
222
222
|
content[item] = row.getCell(index + 3).value;
|
|
223
223
|
});
|
|
224
224
|
dataList.push({
|
|
225
225
|
id,
|
|
226
|
-
|
|
226
|
+
name,
|
|
227
227
|
content: JSON.stringify(content),
|
|
228
228
|
});
|
|
229
229
|
});
|
package/index.js
CHANGED
|
@@ -50,15 +50,15 @@ Object.keys(zhCNBase).forEach((key) => {
|
|
|
50
50
|
|
|
51
51
|
const unHandle = [];
|
|
52
52
|
|
|
53
|
-
function addTranslate (
|
|
54
|
-
if (
|
|
53
|
+
function addTranslate (name) {
|
|
54
|
+
if (name && name.indexOf("vxe") === -1) {
|
|
55
55
|
try {
|
|
56
56
|
axios.request({
|
|
57
57
|
url: "/translate/insert",
|
|
58
58
|
method: "POST",
|
|
59
59
|
data: {
|
|
60
|
-
|
|
61
|
-
content: `{"zh_CN":"${
|
|
60
|
+
name,
|
|
61
|
+
content: `{"zh_CN":"${name}"}`,
|
|
62
62
|
},
|
|
63
63
|
});
|
|
64
64
|
} catch (error) {
|
package/language.vue
CHANGED
|
@@ -12,23 +12,24 @@
|
|
|
12
12
|
:command="lo.value">
|
|
13
13
|
{{ lo.label }}
|
|
14
14
|
</el-dropdown-item>
|
|
15
|
+
<el-dropdown-item divided disabled v-if="isDev">
|
|
16
|
+
开发工具
|
|
17
|
+
</el-dropdown-item>
|
|
18
|
+
<el-dropdown-item v-if="isDev">
|
|
19
|
+
<el-link type="warning" href="/#/translate">
|
|
20
|
+
{{ ct("翻译") }}
|
|
21
|
+
</el-link>
|
|
22
|
+
</el-dropdown-item>
|
|
23
|
+
<el-dropdown-item v-if="isDev" @click.prevent>
|
|
24
|
+
<el-switch
|
|
25
|
+
:active-text="ct('收集')"
|
|
26
|
+
:inactive-text="ct('不收集')"
|
|
27
|
+
inline-prompt
|
|
28
|
+
v-model="isCollect" />
|
|
29
|
+
</el-dropdown-item>
|
|
15
30
|
</el-dropdown-menu>
|
|
16
31
|
</template>
|
|
17
32
|
</el-dropdown>
|
|
18
|
-
|
|
19
|
-
<el-link
|
|
20
|
-
v-if="isDev"
|
|
21
|
-
type="warning"
|
|
22
|
-
href="/#/translate">
|
|
23
|
-
{{ ct("翻译管理") }}
|
|
24
|
-
</el-link>
|
|
25
|
-
|
|
26
|
-
<el-switch
|
|
27
|
-
active-text="收集"
|
|
28
|
-
inactive-text="不收集"
|
|
29
|
-
inline-prompt
|
|
30
|
-
v-if="isDev"
|
|
31
|
-
v-model="isCollect"></el-switch>
|
|
32
33
|
</template>
|
|
33
34
|
|
|
34
35
|
<script setup>
|
package/list.vue
CHANGED
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
<div class="yh-i18n-list-container">
|
|
3
3
|
<div class="yh-i18n-list-actions">
|
|
4
4
|
<div class="yh-i18n-list-conditions">
|
|
5
|
-
<el-form inline>
|
|
5
|
+
<el-form inline @submit.prevent>
|
|
6
6
|
<el-form-item :label="ct('翻译键名')">
|
|
7
7
|
<el-input
|
|
8
|
-
v-model="listForm.
|
|
8
|
+
v-model="listForm.name"
|
|
9
9
|
@keyup.enter.stop.prevent="getDataList(true)"
|
|
10
10
|
:placeholder="ct('键入以筛选键名')"></el-input>
|
|
11
11
|
</el-form-item>
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
ref="i18nList"
|
|
49
49
|
stripe
|
|
50
50
|
:data="dataList"
|
|
51
|
-
row-key="
|
|
51
|
+
row-key="id"
|
|
52
52
|
@row-click="rowClickHandler">
|
|
53
53
|
<el-table-column
|
|
54
54
|
type="selection"
|
|
@@ -76,13 +76,13 @@
|
|
|
76
76
|
<el-button
|
|
77
77
|
link
|
|
78
78
|
type="danger"
|
|
79
|
-
@click="delOne(row.
|
|
79
|
+
@click="delOne(row.id)">
|
|
80
80
|
{{ ct('删除') }}
|
|
81
81
|
</el-button>
|
|
82
82
|
</template>
|
|
83
83
|
</el-table-column>
|
|
84
84
|
<el-table-column
|
|
85
|
-
prop="
|
|
85
|
+
prop="name"
|
|
86
86
|
min-width="140"
|
|
87
87
|
fixed="left"
|
|
88
88
|
:label="ct('翻译键名')"></el-table-column>
|
|
@@ -106,7 +106,7 @@
|
|
|
106
106
|
v-model="formShow"
|
|
107
107
|
@close="cancelForm"
|
|
108
108
|
draggable
|
|
109
|
-
:title="formData.
|
|
109
|
+
:title="formData.id ? ct('编辑翻译') : ct('新增翻译')">
|
|
110
110
|
<vxe-form
|
|
111
111
|
title-align="right"
|
|
112
112
|
title-width="100px"
|
|
@@ -114,7 +114,7 @@
|
|
|
114
114
|
title-colon
|
|
115
115
|
:data="formData"
|
|
116
116
|
:items="formItems"
|
|
117
|
-
:rules="
|
|
117
|
+
:rules="formRules"></vxe-form>
|
|
118
118
|
<template #footer>
|
|
119
119
|
<div class="yh-i18n-form-actions">
|
|
120
120
|
<el-button
|
|
@@ -160,7 +160,7 @@ const deleteUrl = '/translate/deleteTranslate';
|
|
|
160
160
|
|
|
161
161
|
const i18nList = ref();
|
|
162
162
|
const listForm = reactive({
|
|
163
|
-
|
|
163
|
+
name: '',
|
|
164
164
|
pageNum: 1,
|
|
165
165
|
pageSize: 10,
|
|
166
166
|
total: 0,
|
|
@@ -168,7 +168,7 @@ const listForm = reactive({
|
|
|
168
168
|
const listColumns = reactive<any>([]);
|
|
169
169
|
const dataList = ref<any>([]);
|
|
170
170
|
function getDataList(isReset = false) {
|
|
171
|
-
let {
|
|
171
|
+
let {name, pageNum, pageSize} = listForm;
|
|
172
172
|
if (isReset) {
|
|
173
173
|
pageNum = 1;
|
|
174
174
|
}
|
|
@@ -180,7 +180,7 @@ function getDataList(isReset = false) {
|
|
|
180
180
|
url: '/translate/select',
|
|
181
181
|
method: 'post',
|
|
182
182
|
data: {
|
|
183
|
-
|
|
183
|
+
name,
|
|
184
184
|
pageNum,
|
|
185
185
|
pageSize,
|
|
186
186
|
},
|
|
@@ -231,7 +231,7 @@ function rowClickHandler(row) {
|
|
|
231
231
|
}
|
|
232
232
|
|
|
233
233
|
function resetList() {
|
|
234
|
-
listForm.
|
|
234
|
+
listForm.name = '';
|
|
235
235
|
listForm.pageNum = 1;
|
|
236
236
|
listForm.total = 0;
|
|
237
237
|
getDataList();
|
|
@@ -286,21 +286,21 @@ function nextOne() {
|
|
|
286
286
|
}
|
|
287
287
|
|
|
288
288
|
function saveOne() {
|
|
289
|
-
let isAdd = !!formData.
|
|
289
|
+
let isAdd = !!formData.id;
|
|
290
290
|
let url = updateUrl;
|
|
291
291
|
vxeFormRef?.value?.validate().then((errMap) => {
|
|
292
292
|
if (!errMap) {
|
|
293
293
|
let data: any = {
|
|
294
|
-
|
|
294
|
+
name: formData.name,
|
|
295
295
|
content: {},
|
|
296
296
|
};
|
|
297
297
|
if (isAdd) {
|
|
298
298
|
url = insertUrl;
|
|
299
299
|
} else {
|
|
300
|
-
data.id = formData.
|
|
300
|
+
data.id = formData.id;
|
|
301
301
|
}
|
|
302
302
|
for (const key in formData) {
|
|
303
|
-
if (key !== '
|
|
303
|
+
if (key !== 'name' && langList.includes(key)) {
|
|
304
304
|
const val = formData[key];
|
|
305
305
|
data.content[key] = val;
|
|
306
306
|
}
|
|
@@ -315,13 +315,14 @@ function saveOne() {
|
|
|
315
315
|
.then((res) => {
|
|
316
316
|
if (res?.data?.status === 200) {
|
|
317
317
|
ElMessage.success(res.data.msg);
|
|
318
|
-
if (
|
|
318
|
+
if (isAdd) {
|
|
319
319
|
dataList.value[formDataIndex.value] = {
|
|
320
320
|
...formData,
|
|
321
321
|
};
|
|
322
322
|
nextOne();
|
|
323
323
|
} else {
|
|
324
324
|
cancelForm();
|
|
325
|
+
getDataList();
|
|
325
326
|
}
|
|
326
327
|
} else {
|
|
327
328
|
ElMessage.error(res.data.msg);
|
|
@@ -354,24 +355,37 @@ function delOne(id) {
|
|
|
354
355
|
|
|
355
356
|
function delMore() {
|
|
356
357
|
ElMessageBox.confirm('确认删除选中的翻译记录吗?').then(async () => {
|
|
357
|
-
let ids = i18nList.value?.getSelectionRows().map((row) => row.
|
|
358
|
+
let ids = i18nList.value?.getSelectionRows().map((row) => row.id);
|
|
358
359
|
if (ids && ids.length) {
|
|
359
360
|
let len = ids.length;
|
|
360
361
|
let loading = ElLoadingService({
|
|
361
362
|
text: '正在删除选中的翻译……',
|
|
362
363
|
});
|
|
364
|
+
let failCount = 0;
|
|
363
365
|
for (let i = 0; i < ids.length; i++) {
|
|
364
366
|
const id = ids[i];
|
|
365
367
|
loading.setText(`正在删除... ${i + 1}/${len}`);
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
368
|
+
try {
|
|
369
|
+
let res = await http.request({
|
|
370
|
+
url: deleteUrl,
|
|
371
|
+
method: 'POST',
|
|
372
|
+
data: {
|
|
373
|
+
id,
|
|
374
|
+
},
|
|
375
|
+
});
|
|
376
|
+
if (res?.data?.status !== 200) {
|
|
377
|
+
failCount++;
|
|
378
|
+
}
|
|
379
|
+
} catch {
|
|
380
|
+
failCount++;
|
|
381
|
+
}
|
|
373
382
|
}
|
|
374
383
|
loading.close();
|
|
384
|
+
if (failCount === 0) {
|
|
385
|
+
ElMessage.success(`成功删除 ${len} 条`);
|
|
386
|
+
} else {
|
|
387
|
+
ElMessage.warning(`删除 ${len - failCount}/${len} 条,失败 ${failCount} 条`);
|
|
388
|
+
}
|
|
375
389
|
getDataList();
|
|
376
390
|
}
|
|
377
391
|
});
|
|
@@ -379,7 +393,7 @@ function delMore() {
|
|
|
379
393
|
|
|
380
394
|
const formItems = reactive<VxeFormPropTypes.Items>([
|
|
381
395
|
{
|
|
382
|
-
field: '
|
|
396
|
+
field: 'name',
|
|
383
397
|
span: 24,
|
|
384
398
|
title: '翻译键值',
|
|
385
399
|
itemRender: {
|
|
@@ -389,8 +403,8 @@ const formItems = reactive<VxeFormPropTypes.Items>([
|
|
|
389
403
|
},
|
|
390
404
|
]);
|
|
391
405
|
|
|
392
|
-
const
|
|
393
|
-
|
|
406
|
+
const formRules = reactive<VxeFormPropTypes.Rules>({
|
|
407
|
+
name: [{required: true, type: 'string', message: '请输入翻译键值'}],
|
|
394
408
|
});
|
|
395
409
|
|
|
396
410
|
let needInit = true;
|