yh-i18n 2.1.6 → 2.2.7
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 +40 -8
- package/index.js +1 -1
- package/lang/baseEnUS.js +1 -1
- package/lang/baseTh.js +1 -1
- package/lang/baseTr.js +1 -1
- package/lang/baseVi.js +1 -1
- package/lang/baseZhCn.js +1 -1
- package/list.vue +59 -59
- package/package.json +1 -1
package/excelTool.ts
CHANGED
|
@@ -2,14 +2,48 @@ import ExcelJS from "exceljs";
|
|
|
2
2
|
import Config from "@/config";
|
|
3
3
|
import { ElMessage, ElLoading } from "element-plus";
|
|
4
4
|
import http from "@/libs/api.request";
|
|
5
|
+
import { useI18nStore } from "./index";
|
|
5
6
|
|
|
6
7
|
const verificationCode = "lkyhtranslateexcel";
|
|
7
|
-
export async function exportExcel(
|
|
8
|
+
export async function exportExcel(total) {
|
|
8
9
|
const loading = ElLoading.service({
|
|
9
10
|
lock: true,
|
|
10
|
-
text: "
|
|
11
|
+
text: "正在获取所有翻译字段……",
|
|
11
12
|
background: "rgba(255, 255, 255, 0.2)",
|
|
12
13
|
});
|
|
14
|
+
const i18nStore = useI18nStore();
|
|
15
|
+
let records = await http
|
|
16
|
+
.request({
|
|
17
|
+
url: "/translate/select",
|
|
18
|
+
method: "post",
|
|
19
|
+
data: {
|
|
20
|
+
pageNum: 1,
|
|
21
|
+
pageSize: total,
|
|
22
|
+
},
|
|
23
|
+
})
|
|
24
|
+
.then((res) => {
|
|
25
|
+
let localKeys = i18nStore.localList.map((item) => item.value);
|
|
26
|
+
let { records } = res.data.data;
|
|
27
|
+
records = records.map((item) => {
|
|
28
|
+
try {
|
|
29
|
+
let content = JSON.parse(item.content);
|
|
30
|
+
let keys = Object.keys(content);
|
|
31
|
+
|
|
32
|
+
keys.forEach((key) => {
|
|
33
|
+
let val = content[key];
|
|
34
|
+
item[key] = val;
|
|
35
|
+
});
|
|
36
|
+
localKeys.forEach((k) => {
|
|
37
|
+
if (!keys.includes(k)) {
|
|
38
|
+
item[k] = "";
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
} catch (error) {}
|
|
42
|
+
return item;
|
|
43
|
+
});
|
|
44
|
+
return records;
|
|
45
|
+
});
|
|
46
|
+
loading.setText("正在序列化表格数据……");
|
|
13
47
|
const workbook = new ExcelJS.Workbook();
|
|
14
48
|
workbook.creator = "力控远海";
|
|
15
49
|
workbook.lastModifiedBy = "力控远海技术中心前端";
|
|
@@ -42,7 +76,7 @@ export async function exportExcel(dataList) {
|
|
|
42
76
|
sheet.columns = columns;
|
|
43
77
|
sheet.addRow(title);
|
|
44
78
|
sheet.addRows(
|
|
45
|
-
|
|
79
|
+
records.map((item) => {
|
|
46
80
|
let { adTranslateId, key } = item;
|
|
47
81
|
let row = [adTranslateId, key];
|
|
48
82
|
Config.i18nList.forEach((valKey) => {
|
|
@@ -68,7 +102,7 @@ export async function exportExcel(dataList) {
|
|
|
68
102
|
};
|
|
69
103
|
});
|
|
70
104
|
});
|
|
71
|
-
sheet.getRows(2,
|
|
105
|
+
sheet.getRows(2, records.length)?.forEach((row, index) => {
|
|
72
106
|
row.height = 25;
|
|
73
107
|
row.eachCell({ includeEmpty: true }, (cell, cellIndex) => {
|
|
74
108
|
cell.alignment = {
|
|
@@ -85,6 +119,7 @@ export async function exportExcel(dataList) {
|
|
|
85
119
|
});
|
|
86
120
|
});
|
|
87
121
|
sheet.views = [{ state: "frozen", xSplit: 0, ySplit: 1, activeCell: "C2" }];
|
|
122
|
+
loading.setText("正在生成表格文件……");
|
|
88
123
|
workbook.xlsx.writeBuffer().then((data) => {
|
|
89
124
|
const blob = new Blob([data], {
|
|
90
125
|
type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=UTF-8",
|
|
@@ -106,10 +141,7 @@ async function getFile() {
|
|
|
106
141
|
{
|
|
107
142
|
description: "请选择之前导出并已经翻译好了的Excel文件",
|
|
108
143
|
accept: {
|
|
109
|
-
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet": [
|
|
110
|
-
".xlsx",
|
|
111
|
-
".xls",
|
|
112
|
-
],
|
|
144
|
+
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet": [".xlsx", ".xls"],
|
|
113
145
|
},
|
|
114
146
|
},
|
|
115
147
|
],
|
package/index.js
CHANGED
|
@@ -71,7 +71,7 @@ function recursionAddTranslate() {
|
|
|
71
71
|
}
|
|
72
72
|
// 通过延时降低任务密度,避免挤兑正常逻辑的运算资源
|
|
73
73
|
recursionAddTimer = setTimeout(() => {
|
|
74
|
-
cLog(`${unHandle.length} ${key}`);
|
|
74
|
+
// cLog(`${unHandle.length} ${key}`);
|
|
75
75
|
recursionAddTimer = null;
|
|
76
76
|
recursionAddTranslate();
|
|
77
77
|
}, 150);
|
package/lang/baseEnUS.js
CHANGED
package/lang/baseTh.js
CHANGED
package/lang/baseTr.js
CHANGED
package/lang/baseVi.js
CHANGED
package/lang/baseZhCn.js
CHANGED
package/list.vue
CHANGED
|
@@ -7,29 +7,38 @@
|
|
|
7
7
|
<el-input
|
|
8
8
|
v-model="listForm.key"
|
|
9
9
|
@keyup.enter.stop.prevent="getDataList(true)"
|
|
10
|
-
:placeholder="ct('键入以筛选键名')"
|
|
11
|
-
></el-input>
|
|
10
|
+
:placeholder="ct('键入以筛选键名')"></el-input>
|
|
12
11
|
</el-form-item>
|
|
13
12
|
</el-form>
|
|
14
13
|
</div>
|
|
15
|
-
<el-button
|
|
16
|
-
|
|
17
|
-
|
|
14
|
+
<el-button
|
|
15
|
+
type="primary"
|
|
16
|
+
@click="getDataList">
|
|
17
|
+
{{ ct("搜索") }}
|
|
18
|
+
</el-button>
|
|
18
19
|
<el-button @click="resetList">{{ ct("重置") }}</el-button>
|
|
19
20
|
</div>
|
|
20
21
|
<div class="yh-i18n-list-actions">
|
|
21
|
-
<el-button
|
|
22
|
+
<el-button
|
|
23
|
+
type="primary"
|
|
24
|
+
@click="addOne">
|
|
22
25
|
<i class="iconfont icon-add"></i>
|
|
23
26
|
{{ ct("新增") }}
|
|
24
27
|
</el-button>
|
|
25
|
-
<el-button
|
|
28
|
+
<el-button
|
|
29
|
+
type="danger"
|
|
30
|
+
@click="delMore">
|
|
26
31
|
<i class="iconfont icon-delete"></i>
|
|
27
32
|
{{ ct("批量删除") }}
|
|
28
33
|
</el-button>
|
|
29
|
-
<el-button
|
|
30
|
-
|
|
34
|
+
<el-button
|
|
35
|
+
text
|
|
36
|
+
@click="exportExcel(listForm.total)">
|
|
37
|
+
{{ ct("导出") }}
|
|
31
38
|
</el-button>
|
|
32
|
-
<el-button
|
|
39
|
+
<el-button
|
|
40
|
+
text
|
|
41
|
+
@click="importExcel(getDataList)">
|
|
33
42
|
{{ ct("导入") }}
|
|
34
43
|
</el-button>
|
|
35
44
|
</div>
|
|
@@ -38,66 +47,64 @@
|
|
|
38
47
|
stripe
|
|
39
48
|
:data="dataList"
|
|
40
49
|
row-key="adTranslateId"
|
|
41
|
-
@row-click="rowClickHandler"
|
|
42
|
-
>
|
|
50
|
+
@row-click="rowClickHandler">
|
|
43
51
|
<el-table-column
|
|
44
52
|
type="selection"
|
|
45
53
|
width="50"
|
|
46
54
|
align="center"
|
|
47
|
-
fixed="left"
|
|
48
|
-
></el-table-column>
|
|
55
|
+
fixed="left"></el-table-column>
|
|
49
56
|
<el-table-column
|
|
50
57
|
type="index"
|
|
51
58
|
label="#"
|
|
52
59
|
width="60"
|
|
53
60
|
align="center"
|
|
54
|
-
fixed="left"
|
|
55
|
-
></el-table-column>
|
|
61
|
+
fixed="left"></el-table-column>
|
|
56
62
|
<el-table-column
|
|
57
63
|
:label="ct('操作')"
|
|
58
64
|
width="140"
|
|
59
65
|
align="center"
|
|
60
|
-
fixed="left"
|
|
61
|
-
>
|
|
66
|
+
fixed="left">
|
|
62
67
|
<template #default="{ row, $index }">
|
|
63
|
-
<el-button
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
ct("
|
|
68
|
-
|
|
68
|
+
<el-button
|
|
69
|
+
link
|
|
70
|
+
type="primary"
|
|
71
|
+
@click="editOne(row, $index)">
|
|
72
|
+
{{ ct("编辑") }}
|
|
73
|
+
</el-button>
|
|
74
|
+
<el-button
|
|
75
|
+
link
|
|
76
|
+
type="danger"
|
|
77
|
+
@click="delOne(row.adTranslateId)">
|
|
78
|
+
{{ ct("删除") }}
|
|
79
|
+
</el-button>
|
|
69
80
|
</template>
|
|
70
81
|
</el-table-column>
|
|
71
82
|
<el-table-column
|
|
72
83
|
prop="key"
|
|
73
84
|
min-width="140"
|
|
74
85
|
fixed="left"
|
|
75
|
-
:label="ct('翻译键名')"
|
|
76
|
-
></el-table-column>
|
|
86
|
+
:label="ct('翻译键名')"></el-table-column>
|
|
77
87
|
<el-table-column
|
|
78
88
|
v-for="column in listColumns"
|
|
79
89
|
:prop="column.field"
|
|
80
90
|
:label="ct(column.title)"
|
|
81
91
|
:minWidth="column.minWidth"
|
|
82
|
-
show-overflow-tooltip
|
|
83
|
-
></el-table-column>
|
|
92
|
+
show-overflow-tooltip></el-table-column>
|
|
84
93
|
</el-table>
|
|
85
94
|
<el-pagination
|
|
86
95
|
background
|
|
87
|
-
:page-sizes="[100, 200,
|
|
96
|
+
:page-sizes="[10, 100, 200, 500, 1000]"
|
|
88
97
|
v-model:page-size="listForm.pageSize"
|
|
89
98
|
:total="listForm.total"
|
|
90
99
|
v-model:current-page="listForm.pageNum"
|
|
91
|
-
layout="sizes,prev,pager,next,total"
|
|
92
|
-
></el-pagination>
|
|
100
|
+
layout="sizes,prev,pager,next,total"></el-pagination>
|
|
93
101
|
</div>
|
|
94
102
|
<el-dialog
|
|
95
103
|
class="form-drawer"
|
|
96
104
|
v-model="formShow"
|
|
97
105
|
@close="cancelForm"
|
|
98
106
|
draggable
|
|
99
|
-
:title="formData.adTranslateId ? ct('编辑翻译') : ct('新增翻译')"
|
|
100
|
-
>
|
|
107
|
+
:title="formData.adTranslateId ? ct('编辑翻译') : ct('新增翻译')">
|
|
101
108
|
<vxe-form
|
|
102
109
|
title-align="right"
|
|
103
110
|
title-width="100px"
|
|
@@ -105,30 +112,32 @@
|
|
|
105
112
|
title-colon
|
|
106
113
|
:data="formData"
|
|
107
114
|
:items="formItems"
|
|
108
|
-
:rules="fromRules"
|
|
109
|
-
></vxe-form>
|
|
115
|
+
:rules="fromRules"></vxe-form>
|
|
110
116
|
<template #footer>
|
|
111
117
|
<div class="yh-i18n-form-actions">
|
|
112
118
|
<el-button
|
|
113
119
|
@click="prevOne"
|
|
114
120
|
text
|
|
115
|
-
:disabled="!isNaN(formDataIndex) && formDataIndex <= 0"
|
|
116
|
-
|
|
117
|
-
>
|
|
118
|
-
<el-button
|
|
121
|
+
:disabled="!isNaN(formDataIndex) && formDataIndex <= 0">
|
|
122
|
+
{{ ct("上一个") }}(←)
|
|
123
|
+
</el-button>
|
|
124
|
+
<el-button
|
|
125
|
+
type="primary"
|
|
126
|
+
plain
|
|
127
|
+
@click="cancelForm">
|
|
119
128
|
{{ ct("取消") }}
|
|
120
129
|
</el-button>
|
|
121
|
-
<el-button
|
|
130
|
+
<el-button
|
|
131
|
+
type="primary"
|
|
132
|
+
@click="saveOne">
|
|
122
133
|
{{ ct("保存") }}
|
|
123
134
|
</el-button>
|
|
124
135
|
<el-button
|
|
125
136
|
@click="nextOne"
|
|
126
137
|
text
|
|
127
|
-
:disabled="
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
>{{ ct("下一个") }}(→)</el-button
|
|
131
|
-
>
|
|
138
|
+
:disabled="!isNaN(formDataIndex) && formDataIndex >= dataList.leng - 1">
|
|
139
|
+
{{ ct("下一个") }}(→)
|
|
140
|
+
</el-button>
|
|
132
141
|
</div>
|
|
133
142
|
</template>
|
|
134
143
|
</el-dialog>
|
|
@@ -151,7 +160,7 @@ const i18nList = ref();
|
|
|
151
160
|
const listForm = reactive({
|
|
152
161
|
key: "",
|
|
153
162
|
pageNum: 1,
|
|
154
|
-
pageSize:
|
|
163
|
+
pageSize: 10,
|
|
155
164
|
total: 0,
|
|
156
165
|
});
|
|
157
166
|
const listColumns = reactive<any>([]);
|
|
@@ -255,9 +264,7 @@ function editOne(item, index) {
|
|
|
255
264
|
}
|
|
256
265
|
formShow.value = true;
|
|
257
266
|
setTimeout(() => {
|
|
258
|
-
(
|
|
259
|
-
document.querySelector("#i18nFormItem1 input") as HTMLInputElement
|
|
260
|
-
)?.focus();
|
|
267
|
+
(document.querySelector("#i18nFormItem1 input") as HTMLInputElement)?.focus();
|
|
261
268
|
inputs = Array.from(document.querySelectorAll(".i18n-form-item input"));
|
|
262
269
|
}, 500);
|
|
263
270
|
}
|
|
@@ -339,9 +346,7 @@ function delOne(id) {
|
|
|
339
346
|
|
|
340
347
|
function delMore() {
|
|
341
348
|
ElMessageBox.confirm("确认删除选中的翻译记录吗?").then(async () => {
|
|
342
|
-
let ids = i18nList.value
|
|
343
|
-
?.getSelectionRows()
|
|
344
|
-
.map((row) => row.adTranslateId);
|
|
349
|
+
let ids = i18nList.value?.getSelectionRows().map((row) => row.adTranslateId);
|
|
345
350
|
if (ids && ids.length) {
|
|
346
351
|
let len = ids.length;
|
|
347
352
|
let loading = ElLoadingService({
|
|
@@ -448,13 +453,8 @@ onMounted(() => {
|
|
|
448
453
|
inputs[index].focus();
|
|
449
454
|
} else {
|
|
450
455
|
setTimeout(() => {
|
|
451
|
-
if (
|
|
452
|
-
|
|
453
|
-
!inputs.includes(document.activeElement as HTMLInputElement)
|
|
454
|
-
) {
|
|
455
|
-
(
|
|
456
|
-
document.querySelector("#i18nFormItem1 input") as HTMLInputElement
|
|
457
|
-
)?.focus();
|
|
456
|
+
if (!document.activeElement || !inputs.includes(document.activeElement as HTMLInputElement)) {
|
|
457
|
+
(document.querySelector("#i18nFormItem1 input") as HTMLInputElement)?.focus();
|
|
458
458
|
}
|
|
459
459
|
}, 100);
|
|
460
460
|
}
|