cloud-web-corejs 1.0.328 → 1.0.330

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "cloud-web-corejs",
3
3
  "private": false,
4
- "version": "1.0.328",
4
+ "version": "1.0.330",
5
5
  "scripts": {
6
6
  "dev": "vue-cli-service serve",
7
7
  "check:package-resources": "node build/check-package-resources.js",
@@ -3,7 +3,7 @@ import vue from "vue";
3
3
  import excelImport from "./index.vue";
4
4
  import exportDialog from "./exportDialog.vue";
5
5
  import { getBdEnv } from "@base/api/user";
6
- import { encrypt } from "@base/utils/aes";
6
+ import { encrypt, loadAesKeys } from "@base/utils/aes";
7
7
  import {
8
8
  getExportArchiveType,
9
9
  processArchiveExport,
@@ -88,8 +88,11 @@ moudule.install = function (Vue) {
88
88
  if (options.plaintext) {
89
89
  reqData.plaintext = options.plaintext;
90
90
  }
91
+ loadAesKeys().catch(function () {});
92
+ const plain = JSON.stringify(reqData);
93
+ const cipher = encrypt(plain);
91
94
  let data = {
92
- datas: encrypt(JSON.stringify(reqData)),
95
+ datas: cipher === null ? plain : cipher,
93
96
  };
94
97
 
95
98
  that.$http({
@@ -22,9 +22,7 @@
22
22
  :clearable="field.options.clearable"
23
23
  :filterable="field.options.filterable"
24
24
  :collapse-tags="!field.options.flatCollapseTags"
25
- :placeholder="
26
- field.options.placeholder || i18nt('render.hint.selectPlaceholder')
27
- "
25
+ :placeholder="getI18nLabel(field.options.placeholder || $t1('请选择'))"
28
26
  :show-all-levels="showFullPath"
29
27
  :props="cascaderProps"
30
28
  @visible-change="hideDropDownOnClick"
@@ -99,7 +97,7 @@ export default {
99
97
  cascaderOptions() {
100
98
  return this.lazyEnabled
101
99
  ? this.lazyEmptyOptions
102
- : this.field.options.optionItems;
100
+ : this.translateOptionNodes(this.field.options.optionItems);
103
101
  },
104
102
 
105
103
  cascaderProps() {
@@ -287,7 +285,7 @@ export default {
287
285
  settled = true;
288
286
  const nodes = this.normalizeLazyNodes(list);
289
287
  this.rememberLazyNodes(node, nodes);
290
- resolve(nodes);
288
+ resolve(this.translateOptionNodes(nodes));
291
289
  };
292
290
  const abortLazyLoad = () => {
293
291
  if (settled) return;
@@ -318,7 +316,7 @@ export default {
318
316
  settled = true;
319
317
  const nodes = this.normalizeLazyNodes(list);
320
318
  this.rememberLazyNodes(node, nodes);
321
- resolve(nodes);
319
+ resolve(this.translateOptionNodes(nodes));
322
320
  };
323
321
  // 请求失败不能 resolve([]):Element 会把 node.loaded 置 true,之后不再 lazyLoad
324
322
  const abortLazyLoad = () => {
@@ -349,6 +347,48 @@ export default {
349
347
  error: abortLazyLoad,
350
348
  });
351
349
  },
350
+ // 展示用副本。原文留在不可枚举的 __rawLabel,脚本仍拿原文
351
+ translateOptionNodes(list) {
352
+ if (!Array.isArray(list) || this.designState) return list;
353
+ const labelKey = this.labelKey;
354
+ const childrenKey = this.childrenKey;
355
+ return list.map((item) => {
356
+ if (!item || typeof item !== "object") return item;
357
+ const next = { ...item };
358
+ const rawLabel = item[labelKey];
359
+ Object.defineProperty(next, "__rawLabel", {
360
+ value: rawLabel,
361
+ enumerable: false,
362
+ });
363
+ if (rawLabel != null && rawLabel !== "") {
364
+ next[labelKey] = this.getI18nLabel(rawLabel);
365
+ }
366
+ if (Array.isArray(item[childrenKey])) {
367
+ next[childrenKey] = this.translateOptionNodes(item[childrenKey]);
368
+ }
369
+ return next;
370
+ });
371
+ },
372
+ rawNodeLabel(node) {
373
+ const data = node && node.data;
374
+ if (data && Object.prototype.hasOwnProperty.call(data, "__rawLabel")) {
375
+ return data.__rawLabel;
376
+ }
377
+ return node && node.label != null ? node.label : "";
378
+ },
379
+ rawOptionData(data) {
380
+ if (!data || typeof data !== "object") return data || null;
381
+ if (!Object.prototype.hasOwnProperty.call(data, "__rawLabel")) return data;
382
+ const next = { ...data };
383
+ next[this.labelKey] = data.__rawLabel;
384
+ const childrenKey = this.childrenKey;
385
+ if (Array.isArray(data[childrenKey])) {
386
+ next[childrenKey] = data[childrenKey].map((child) =>
387
+ this.rawOptionData(child)
388
+ );
389
+ }
390
+ return next;
391
+ },
352
392
  // 展开节点时的路径上下文(与 onSelect 的 item 字段含义一致)
353
393
  buildCascaderNodePathContext(node) {
354
394
  if (!node || node.root || node.level === 0) {
@@ -366,15 +406,15 @@ export default {
366
406
  const levels = pathNodes.map((seg, index) => ({
367
407
  level: index,
368
408
  value: seg.value,
369
- label: seg.label,
370
- data: seg.data || null,
409
+ label: this.rawNodeLabel(seg),
410
+ data: this.rawOptionData(seg.data),
371
411
  }));
372
412
  return {
373
- row: node.data || null,
413
+ row: this.rawOptionData(node.data),
374
414
  level: path.length ? path.length - 1 : 0,
375
415
  path: path,
376
- pathLabels: node.pathLabels ? node.pathLabels.slice() : [],
377
- pathRows: pathNodes.map((seg) => seg.data || null),
416
+ pathLabels: pathNodes.map((seg) => this.rawNodeLabel(seg)),
417
+ pathRows: pathNodes.map((seg) => this.rawOptionData(seg.data)),
378
418
  levels: levels,
379
419
  };
380
420
  },
@@ -579,7 +619,7 @@ export default {
579
619
  const ctx = this.buildCascaderNodePathContext(node);
580
620
  return {
581
621
  value: node.value,
582
- label: node.label,
622
+ label: this.rawNodeLabel(node),
583
623
  level: ctx.level == null ? 0 : ctx.level,
584
624
  path: ctx.path,
585
625
  pathLabels: ctx.pathLabels,
@@ -12,14 +12,14 @@
12
12
  :limit="field.options.limit" :on-exceed="handleFileExceed" :before-upload="beforeFileUpload"
13
13
  :on-success="handleFileUpload" :on-error="handleUploadError">
14
14
  <div slot="tip" class="el-upload__tip"
15
- v-if="!!field.options.uploadTip">{{field.options.uploadTip}}</div>
15
+ v-if="!!field.options.uploadTip">{{getI18nLabel(field.options.uploadTip)}}</div>
16
16
  <i slot="default" class="el-icon-plus avatar-uploader-icon"></i>
17
17
  <template #file="{ file }">
18
18
  <div class="upload-file-list">
19
19
  <span class="upload-file-name" :title="file.name">{{file.name}}</span>
20
20
  <a :href="file.url" download="" target="_blank">
21
- <i class="el-icon-download file-action" :title="i18nt('render.hint.downloadFile')"></i></a>
22
- <i class="el-icon-delete file-action" :title="i18nt('render.hint.removeFile')" v-if="!field.options.disabled"
21
+ <i class="el-icon-download file-action" :title="$t1('下载')"></i></a>
22
+ <i class="el-icon-delete file-action" :title="$t1('移除')" v-if="!field.options.disabled"
23
23
  @click="removeUploadFile(file.name, file.url, file.uid)"></i>
24
24
  </div>
25
25
  </template>
@@ -30,16 +30,13 @@
30
30
  <script>
31
31
  import FormItemWrapper from './form-item-wrapper'
32
32
  import emitter from '../../../../../components/xform/utils/emitter'
33
- import i18n, {translate} from "../../../../../components/xform/utils/i18n";
34
33
  import {deepClone} from "../../../../../components/xform/utils/util";
35
34
  import fieldMixin from "../../../../../components/xform/form-designer/form-widget/field-widget/fieldMixin";
36
35
 
37
- let selectFileText = "'" + translate('render.hint.selectFile') + "'"
38
-
39
36
  export default {
40
37
  name: "file-upload-widget",
41
38
  componentName: 'FieldWidget', //必须固定为FieldWidget,用于接收父级组件的broadcast事件
42
- mixins: [emitter, fieldMixin, i18n],
39
+ mixins: [emitter, fieldMixin],
43
40
  props: {
44
41
  field: Object,
45
42
  parentWidget: Object,
@@ -86,14 +83,14 @@
86
83
  },
87
84
  fileList: [], //上传文件列表
88
85
  uploadBtnHidden: false,
89
-
90
- styleVariables: {
91
- '--select-file-action': selectFileText,
92
- },
93
86
  }
94
87
  },
95
88
  computed: {
96
-
89
+ styleVariables() {
90
+ return {
91
+ '--select-file-action': "' " + this.$t1('选择文件') + "'",
92
+ };
93
+ },
97
94
  },
98
95
  beforeCreate() {
99
96
  /* 这里不能访问方法和属性!! */
@@ -121,7 +118,7 @@
121
118
  methods: {
122
119
  handleFileExceed() {
123
120
  let uploadLimit = this.field.options.limit
124
- this.$message.warning( this.i18nt('render.hint.uploadExceed').replace('${uploadLimit}', uploadLimit) )
121
+ this.$message.warning(this.$t1('最大上传数量({p0})已超出.', { p0: uploadLimit }))
125
122
  },
126
123
 
127
124
  beforeFileUpload(file) {
@@ -136,7 +133,7 @@
136
133
  }
137
134
  }
138
135
  if (!fileTypeCheckResult) {
139
- this.$message.error(this.i18nt('render.hint.unsupportedFileType') + extFileName)
136
+ this.$message.error(this.$t1('不支持格式: {p0}', { p0: extFileName }))
140
137
  return false;
141
138
  }
142
139
 
@@ -147,7 +144,7 @@
147
144
  }
148
145
  fileSizeCheckResult = file.size / 1024 / 1024 <= uploadFileMaxSize
149
146
  if (!fileSizeCheckResult) {
150
- this.$message.error(this.i18nt('render.hint.fileSizeExceed') + uploadFileMaxSize + 'MB')
147
+ this.$message.error(this.$t1('文件大小已超出: {p0}MB', { p0: uploadFileMaxSize }))
151
148
  return false;
152
149
  }
153
150
 
@@ -250,7 +247,7 @@
250
247
  customFn.call(this, err, file, fileList)
251
248
  } else {
252
249
  this.$message({
253
- message: this.i18nt('render.hint.uploadError') + err,
250
+ message: this.$t1('上传错误: {p0}', { p0: err }),
254
251
  duration: 3000,
255
252
  type: 'error',
256
253
  })
@@ -108,7 +108,7 @@
108
108
  <template v-if="field.options.labelIconPosition === 'front'">
109
109
  <template v-if="!!field.options.labelTooltip">
110
110
  <el-tooltip
111
- :content="field.options.labelTooltip"
111
+ :content="getI18nLabel(field.options.labelTooltip)"
112
112
  effect="dark"
113
113
  popper-class="label-tooltip-pre-line"
114
114
  >
@@ -130,7 +130,7 @@
130
130
  label
131
131
  }}</span
132
132
  ><el-tooltip
133
- :content="field.options.labelTooltip"
133
+ :content="getI18nLabel(field.options.labelTooltip)"
134
134
  effect="dark"
135
135
  popper-class="label-tooltip-pre-line"
136
136
  >
@@ -127,7 +127,7 @@
127
127
  methods: {
128
128
  handlePictureExceed() {
129
129
  let uploadLimit = this.field.options.limit
130
- this.$message.warning( this.i18nt('render.hint.uploadExceed').replace('${uploadLimit}', uploadLimit) )
130
+ this.$message.warning(this.$t1('最大上传数量({p0})已超出.', { p0: uploadLimit }))
131
131
  },
132
132
 
133
133
  handlePicturePreview(file) {
@@ -146,7 +146,7 @@
146
146
  }
147
147
  }
148
148
  if (!fileTypeCheckResult) {
149
- this.$message.error(this.i18nt('render.hint.unsupportedFileType') + file.type)
149
+ this.$message.error(this.$t1('不支持格式: {p0}', { p0: file.type }))
150
150
  return false;
151
151
  }
152
152
 
@@ -157,7 +157,7 @@
157
157
  }
158
158
  fileSizeCheckResult = file.size / 1024 / 1024 <= uploadFileMaxSize
159
159
  if (!fileSizeCheckResult) {
160
- this.$message.error(this.i18nt('render.hint.fileSizeExceed') + uploadFileMaxSize + 'MB')
160
+ this.$message.error(this.$t1('文件大小已超出: {p0}MB', { p0: uploadFileMaxSize }))
161
161
  return false;
162
162
  }
163
163
 
@@ -246,7 +246,7 @@
246
246
  customFn.call(this, err, file, fileList)
247
247
  } else {
248
248
  this.$message({
249
- message: this.i18nt('render.hint.uploadError') + err,
249
+ message: this.$t1('上传错误: {p0}', { p0: err }),
250
250
  duration: 3000,
251
251
  type: 'error',
252
252
  })
@@ -3,7 +3,7 @@
3
3
  :parent-widget="parentWidget" :parent-list="parentList" :index-of-parent-list="indexOfParentList"
4
4
  :sub-form-row-index="subFormRowIndex" :sub-form-col-index="subFormColIndex" :sub-form-row-id="subFormRowId">
5
5
  <div ref="fieldEditor" :style="!!field.options.fontSize ? `font-size: ${field.options.fontSize};`: ''" :class="widgetClass">
6
- <pre :style="{'white-space': !!field.options.preWrap ? 'pre-wrap' : 'pre', 'text-align': !!field.options.textAlign ? field.options.textAlign : 'left'}">{{field.options.textContent}}</pre></div>
6
+ <pre :style="{'white-space': !!field.options.preWrap ? 'pre-wrap' : 'pre', 'text-align': !!field.options.textAlign ? field.options.textAlign : 'left'}">{{getI18nLabel(field.options.textContent)}}</pre></div>
7
7
  </static-content-wrapper>
8
8
  </template>
9
9
 
@@ -4,7 +4,7 @@
4
4
  :sub-form-row-index="subFormRowIndex" :sub-form-col-index="subFormColIndex" :sub-form-row-id="subFormRowId">
5
5
  <el-switch ref="fieldEditor" v-model="fieldModel"
6
6
  :disabled="field.options.disabled"
7
- :active-text="field.options.activeText" :inactive-text="field.options.inactiveText"
7
+ :active-text="getI18nLabel(field.options.activeText)" :inactive-text="getI18nLabel(field.options.inactiveText)"
8
8
  :active-color="field.options.activeColor" :inactive-color="field.options.inactiveColor"
9
9
  :width="field.options.switchWidth"
10
10
  @change="handleChangeEvent">
@@ -92,8 +92,8 @@
92
92
  return rawValue;
93
93
  }
94
94
  return rawValue
95
- ? this.field.options.activeText
96
- : this.field.options.inactiveText;
95
+ ? this.getI18nLabel(this.field.options.activeText)
96
+ : this.getI18nLabel(this.field.options.inactiveText);
97
97
  },
98
98
  }
99
99
  }
@@ -1,106 +1,106 @@
1
- <template>
2
- <form-item-wrapper :designer="designer" :field="field" :rules="rules" :design-state="designState"
3
- :parent-widget="parentWidget" :parent-list="parentList" :index-of-parent-list="indexOfParentList"
4
- :sub-form-row-index="subFormRowIndex" :sub-form-col-index="subFormColIndex" :sub-form-row-id="subFormRowId">
5
- <el-time-picker ref="fieldEditor" is-range v-model="fieldModel" class="full-width-input"
6
- :disabled="field.options.disabled" :readonly="field.options.readonly"
7
- :size="field.options.size"
8
- :clearable="field.options.clearable" :editable="field.options.editable"
9
- :format="field.options.format" value-format="HH:mm:ss"
10
- :start-placeholder="field.options.startPlaceholder || i18nt('render.hint.startTimePlaceholder')"
11
- :end-placeholder="field.options.endPlaceholder || i18nt('render.hint.endTimePlaceholder')"
12
- @focus="handleFocusCustomEvent" @blur="handleBlurCustomEvent"
13
- @change="handleChangeEvent">
14
- </el-time-picker>
15
- </form-item-wrapper>
16
- </template>
17
-
18
- <script>
19
- import FormItemWrapper from './form-item-wrapper'
20
- import emitter from '../../../../../components/xform/utils/emitter'
21
- import i18n from "../../../../../components/xform/utils/i18n";
22
- import fieldMixin from "../../../../../components/xform/form-designer/form-widget/field-widget/fieldMixin";
23
- import utcTransformMixin from "../../../../../components/xform/form-designer/form-widget/field-widget/mixins/utc-transform-mixin";
24
- import relativeDefaultMixin from "../../../../../components/xform/form-designer/form-widget/field-widget/mixins/relative-default-mixin";
25
-
26
- export default {
27
- name: "time-range-widget",
28
- componentName: 'FieldWidget', //必须固定为FieldWidget,用于接收父级组件的broadcast事件
29
- mixins: [emitter, fieldMixin, i18n, utcTransformMixin, relativeDefaultMixin],
30
- props: {
31
- field: Object,
32
- parentWidget: Object,
33
- parentList: Array,
34
- indexOfParentList: Number,
35
- designer: Object,
36
-
37
- designState: {
38
- type: Boolean,
39
- default: false
40
- },
41
-
42
- subFormRowIndex: { /* 子表单组件行索引,从0开始计数 */
43
- type: Number,
44
- default: -1
45
- },
46
- subFormColIndex: { /* 子表单组件列索引,从0开始计数 */
47
- type: Number,
48
- default: -1
49
- },
50
- subFormRowId: { /* 子表单组件行Id,唯一id且不可变 */
51
- type: String,
52
- default: ''
53
- },
54
-
55
- },
56
- components: {
57
- FormItemWrapper,
58
- },
59
- inject: ['refList', 'globalOptionData', 'globalModel'],
60
- data() {
61
- return {
62
- oldFieldValue: [], //field组件change之前的值
63
- fieldModel: [],
64
- rules: [],
65
- }
66
- },
67
- computed: {
68
-
69
- },
70
- beforeCreate() {
71
- /* 这里不能访问方法和属性!! */
72
- },
73
-
74
- created() {
75
- /* 注意:子组件mounted在父组件created之后、父组件mounted之前触发,故子组件mounted需要用到的prop
76
- 需要在父组件created中初始化!! */
77
- this.initRelativeFieldModel()
78
- this.registerToRefList()
79
- this.initEventHandler()
80
- this.buildFieldRules()
81
-
82
- this.handleOnCreated()
83
- },
84
-
85
- mounted() {
86
- this.handleOnMounted()
87
- },
88
-
89
- beforeDestroy() {
90
- this.unregisterFromRefList()
91
- },
92
-
93
- methods: {
94
-
95
- }
96
- }
97
- </script>
98
-
99
- <style lang="scss" scoped>
100
- @import "~@base/styles/theme-variables.scss"; //* form-item-wrapper已引入,还需要重复引入吗? *//
101
-
102
- .full-width-input {
103
- width: 100% !important;
104
- }
105
-
106
- </style>
1
+ <template>
2
+ <form-item-wrapper :designer="designer" :field="field" :rules="rules" :design-state="designState"
3
+ :parent-widget="parentWidget" :parent-list="parentList" :index-of-parent-list="indexOfParentList"
4
+ :sub-form-row-index="subFormRowIndex" :sub-form-col-index="subFormColIndex" :sub-form-row-id="subFormRowId">
5
+ <el-time-picker ref="fieldEditor" is-range v-model="fieldModel" class="full-width-input"
6
+ :disabled="field.options.disabled" :readonly="field.options.readonly"
7
+ :size="field.options.size"
8
+ :clearable="field.options.clearable" :editable="field.options.editable"
9
+ :format="field.options.format" value-format="HH:mm:ss"
10
+ :start-placeholder="getI18nLabel(field.options.startPlaceholder || $t1('起始时间'))"
11
+ :end-placeholder="getI18nLabel(field.options.endPlaceholder || $t1('截止时间'))"
12
+ @focus="handleFocusCustomEvent" @blur="handleBlurCustomEvent"
13
+ @change="handleChangeEvent">
14
+ </el-time-picker>
15
+ </form-item-wrapper>
16
+ </template>
17
+
18
+ <script>
19
+ import FormItemWrapper from './form-item-wrapper'
20
+ import emitter from '../../../../../components/xform/utils/emitter'
21
+ import i18n from "../../../../../components/xform/utils/i18n";
22
+ import fieldMixin from "../../../../../components/xform/form-designer/form-widget/field-widget/fieldMixin";
23
+ import utcTransformMixin from "../../../../../components/xform/form-designer/form-widget/field-widget/mixins/utc-transform-mixin";
24
+ import relativeDefaultMixin from "../../../../../components/xform/form-designer/form-widget/field-widget/mixins/relative-default-mixin";
25
+
26
+ export default {
27
+ name: "time-range-widget",
28
+ componentName: 'FieldWidget', //必须固定为FieldWidget,用于接收父级组件的broadcast事件
29
+ mixins: [emitter, fieldMixin, i18n, utcTransformMixin, relativeDefaultMixin],
30
+ props: {
31
+ field: Object,
32
+ parentWidget: Object,
33
+ parentList: Array,
34
+ indexOfParentList: Number,
35
+ designer: Object,
36
+
37
+ designState: {
38
+ type: Boolean,
39
+ default: false
40
+ },
41
+
42
+ subFormRowIndex: { /* 子表单组件行索引,从0开始计数 */
43
+ type: Number,
44
+ default: -1
45
+ },
46
+ subFormColIndex: { /* 子表单组件列索引,从0开始计数 */
47
+ type: Number,
48
+ default: -1
49
+ },
50
+ subFormRowId: { /* 子表单组件行Id,唯一id且不可变 */
51
+ type: String,
52
+ default: ''
53
+ },
54
+
55
+ },
56
+ components: {
57
+ FormItemWrapper,
58
+ },
59
+ inject: ['refList', 'globalOptionData', 'globalModel'],
60
+ data() {
61
+ return {
62
+ oldFieldValue: [], //field组件change之前的值
63
+ fieldModel: [],
64
+ rules: [],
65
+ }
66
+ },
67
+ computed: {
68
+
69
+ },
70
+ beforeCreate() {
71
+ /* 这里不能访问方法和属性!! */
72
+ },
73
+
74
+ created() {
75
+ /* 注意:子组件mounted在父组件created之后、父组件mounted之前触发,故子组件mounted需要用到的prop
76
+ 需要在父组件created中初始化!! */
77
+ this.initRelativeFieldModel()
78
+ this.registerToRefList()
79
+ this.initEventHandler()
80
+ this.buildFieldRules()
81
+
82
+ this.handleOnCreated()
83
+ },
84
+
85
+ mounted() {
86
+ this.handleOnMounted()
87
+ },
88
+
89
+ beforeDestroy() {
90
+ this.unregisterFromRefList()
91
+ },
92
+
93
+ methods: {
94
+
95
+ }
96
+ }
97
+ </script>
98
+
99
+ <style lang="scss" scoped>
100
+ @import "~@base/styles/theme-variables.scss"; //* form-item-wrapper已引入,还需要重复引入吗? *//
101
+
102
+ .full-width-input {
103
+ width: 100% !important;
104
+ }
105
+
106
+ </style>
@@ -2,7 +2,7 @@
2
2
  <static-content-wrapper :designer="designer" :field="field" :design-state="designState"
3
3
  :parent-widget="parentWidget" :parent-list="parentList" :index-of-parent-list="indexOfParentList"
4
4
  :sub-form-row-index="subFormRowIndex" :sub-form-col-index="subFormColIndex" :sub-form-row-id="subFormRowId">
5
- <div class="title" :class="field.options.styleTitClass"><b v-html="field.options.htmlContent"></b></div>
5
+ <div class="title" :class="field.options.styleTitClass"><b v-html="getI18nLabel(field.options.htmlContent)"></b></div>
6
6
  </static-content-wrapper>
7
7
  </template>
8
8
 
@@ -5,10 +5,10 @@
5
5
  v-show="!widget.options.hidden">
6
6
  <el-row class="header-row">
7
7
  <div class="action-header-column">
8
- <span class="action-label">{{i18nt('render.hint.subFormAction')}}</span>
8
+ <span class="action-label">{{$t1('操作')}}</span>
9
9
  <el-button :disabled="actionDisabled" round type="primary" size="mini" class="action-button" @click="addSubFormRow"
10
- :title="i18nt('render.hint.subFormAddActionHint')">
11
- {{i18nt('render.hint.subFormAddAction')}}<i class="el-icon-plus el-icon-right"></i></el-button>
10
+ :title="$t1('新增行')">
11
+ {{$t1('新增')}}<i class="el-icon-plus el-icon-right"></i></el-button>
12
12
  </div>
13
13
  <template v-for="(subWidget) in widget.widgetList">
14
14
  <div :key="subWidget.id + 'thc'" class="field-header-column"
@@ -18,28 +18,28 @@
18
18
  <template v-if="subWidget.options.labelIconPosition === 'front'">
19
19
  <template v-if="!!subWidget.options.labelTooltip">
20
20
  <el-tooltip
21
- :content="subWidget.options.labelTooltip"
21
+ :content="getI18nLabel(subWidget.options.labelTooltip)"
22
22
  effect="light"
23
23
  popper-class="label-tooltip-pre-line"
24
24
  >
25
- <i :class="subWidget.options.labelIconClass"></i></el-tooltip>{{subWidget.options.label}}</template>
25
+ <i :class="subWidget.options.labelIconClass"></i></el-tooltip>{{getI18nLabel(subWidget.options.label)}}</template>
26
26
  <template v-else>
27
- <i :class="subWidget.options.labelIconClass"></i>{{subWidget.options.label}}</template>
27
+ <i :class="subWidget.options.labelIconClass"></i>{{getI18nLabel(subWidget.options.label)}}</template>
28
28
  </template>
29
29
  <template v-else-if="subWidget.options.labelIconPosition === 'rear'">
30
30
  <template v-if="!!subWidget.options.labelTooltip">
31
- {{subWidget.options.label}}<el-tooltip
32
- :content="subWidget.options.labelTooltip"
31
+ {{getI18nLabel(subWidget.options.label)}}<el-tooltip
32
+ :content="getI18nLabel(subWidget.options.labelTooltip)"
33
33
  effect="light"
34
34
  popper-class="label-tooltip-pre-line"
35
35
  >
36
36
  <i :class="subWidget.options.labelIconClass"></i></el-tooltip></template>
37
37
  <template v-else>
38
- {{subWidget.options.label}}<i :class="subWidget.options.labelIconClass"></i></template>
38
+ {{getI18nLabel(subWidget.options.label)}}<i :class="subWidget.options.labelIconClass"></i></template>
39
39
  </template>
40
40
  </span>
41
41
  <template v-else>
42
- <span :title="subWidget.options.labelTooltip">{{subWidget.options.label}}</span></template>
42
+ <span :title="getI18nLabel(subWidget.options.labelTooltip)">{{getI18nLabel(subWidget.options.label)}}</span></template>
43
43
  </div>
44
44
  </template>
45
45
  </el-row>
@@ -47,9 +47,9 @@
47
47
  <div class="sub-form-action-column hide-label">
48
48
  <div class="action-button-column">
49
49
  <el-button :disabled="actionDisabled" circle type="" icon="el-icon-circle-plus-outline" @click="insertSubFormRow(sfrIdx)"
50
- :title="i18nt('render.hint.insertSubFormRow')"></el-button>
50
+ :title="$t1('插入行')"></el-button>
51
51
  <el-button :disabled="actionDisabled" circle type="" icon="el-icon-delete" @click="deleteSubFormRow(sfrIdx)"
52
- :title="i18nt('render.hint.deleteSubFormRow')"></el-button>
52
+ :title="$t1('删除行')"></el-button>
53
53
  <span v-if="widget.options.showRowNumber" class="row-number-span">#{{sfrIdx+1}}</span>
54
54
  </div>
55
55
  </div>
@@ -267,9 +267,9 @@
267
267
  },
268
268
 
269
269
  deleteSubFormRow(formRowIndex) {
270
- this.$confirm(this.i18nt('render.hint.deleteSubFormRow') + '?', this.i18nt('render.hint.prompt'), {
271
- confirmButtonText: this.i18nt('render.hint.confirm'),
272
- cancelButtonText: this.i18nt('render.hint.cancel')
270
+ this.$confirm(this.$t1('删除行?'), this.$t1('提示'), {
271
+ confirmButtonText: this.$t1('确定'),
272
+ cancelButtonText: this.$t1('取消')
273
273
  }).then(() => {
274
274
  let oldSubFormData = this.formModel[this.widget.options.name] || []
275
275
  let deletedDataRow = deepClone(oldSubFormData[formRowIndex])
@@ -9,6 +9,7 @@ import {
9
9
  getLogicParamValue,
10
10
  } from "../../api/user";
11
11
  import { getToken, setToken, clearToken } from "../../utils/auth";
12
+ import { loadAesKeys, clearAesKeys } from "../../utils/aes";
12
13
  import { clearBaseDictsCache } from "../../utils/baseDictsCache";
13
14
  import router, { resetRouter } from "@base/router";
14
15
  import { unmountAllMicroApps } from "@base/microRouter";
@@ -142,6 +143,7 @@ actions = {
142
143
  let token = opts.token;
143
144
  commit("SET_TOKEN", token);
144
145
  configUtil.setToken(token);
146
+ loadAesKeys(token).catch(function () {});
145
147
  sessionStorage.setItem(
146
148
  "easyweb",
147
149
  JSON.stringify({
@@ -156,6 +158,8 @@ actions = {
156
158
 
157
159
  // get user info
158
160
  getInfo2({ commit, state, dispatch }) {
161
+ // 刷新页面或主应用注入 token 时不会再走登录,这里补拉一次密钥。失败不提示、不阻塞。
162
+ loadAesKeys().catch(function () {});
159
163
  return new Promise((resolve, reject) => {
160
164
  configUtil
161
165
  .getInfo({
@@ -320,6 +324,7 @@ actions = {
320
324
  // remove token
321
325
  resetToken({ commit, state, dispatch }) {
322
326
  return new Promise((resolve) => {
327
+ clearAesKeys();
323
328
  commit("SET_TOKEN", "");
324
329
  commit("SET_ROLES", []);
325
330
  commit("SET_NICK_NAME", "");
package/src/utils/aes.js CHANGED
@@ -1,21 +1,142 @@
1
+ import request from "./request.js";
1
2
  import CryptoJS from "crypto-js";
3
+ import prefixConfig from "@base/prefixConfig.js";
4
+ import { getToken } from "./auth.js";
2
5
 
3
- const secretKey = "2025202620272028"; // 密钥必须是16个字节
4
- const ivKey = "2022202320242025"; // 向量必须是16个字节
6
+ // 密钥只存在内存里,跟当前 token 绑定。退出登录或 token 变化后作废。
7
+ // 接口 404、objx 为空、解密失败时记成「本次不加密」,请求继续发原始内容。
8
+ let keys = null;
9
+ let pending = null;
10
+ let unavailableToken = null;
11
+ let generation = 0;
12
+
13
+ function currentKeys() {
14
+ const token = getToken();
15
+ if (!keys || !token || keys.token !== token || !keys.k || !keys.iv)
16
+ return null;
17
+ return keys;
18
+ }
19
+
20
+ export function setAesKeys(k, iv, token) {
21
+ const boundToken = token == null ? getToken() : token;
22
+ if (!k || !iv || !boundToken) {
23
+ keys = null;
24
+ return;
25
+ }
26
+ keys = { k: k, iv: iv, token: boundToken };
27
+ unavailableToken = null;
28
+ }
29
+
30
+ export function clearAesKeys() {
31
+ generation += 1;
32
+ keys = null;
33
+ pending = null;
34
+ unavailableToken = null;
35
+ }
36
+
37
+ function decryptKok(objx, token) {
38
+ try {
39
+ const material = String(token || "").substring(0, 16);
40
+ if (material.length < 16) return null;
41
+ const plain = CryptoJS.AES.decrypt(
42
+ objx,
43
+ CryptoJS.enc.Utf8.parse(material),
44
+ {
45
+ iv: CryptoJS.enc.Utf8.parse(material),
46
+ }
47
+ ).toString(CryptoJS.enc.Utf8);
48
+ const sep = plain.indexOf(":");
49
+ if (sep <= 0) return null;
50
+ const k = plain.slice(0, sep);
51
+ const iv = plain.slice(sep + 1);
52
+ if (!k || !iv) return null;
53
+ return { k: k, iv: iv };
54
+ } catch (e) {
55
+ return null;
56
+ }
57
+ }
58
+
59
+ function requestKok(token) {
60
+ const prefix = String(prefixConfig.USER_PREFIX || "/user").replace(/\/$/, "");
61
+ // 走统一请求。失败不弹窗;fetchAesKey: false 避免本请求再进去取一次密钥。
62
+ return request({
63
+ url: prefix + "/common/kok",
64
+ method: "post",
65
+ timeout: 10000,
66
+ isLoading: false,
67
+ modal: false,
68
+ failMsg: false,
69
+ errorMsg: false,
70
+ fetchAesKey: false,
71
+ filterConfig: { enabled: false },
72
+ })
73
+ .then(function (data) {
74
+ if (!data || typeof data !== "object") return null;
75
+ if (data.type && data.type !== "success") return null;
76
+ if (!data.objx) return null;
77
+ return decryptKok(data.objx, token);
78
+ })
79
+ .catch(function () {
80
+ return null;
81
+ });
82
+ }
83
+
84
+ // 登录成功或刷新后调用。同一 token 只请求一次,进行中的调用共用同一个 Promise。
85
+ export function loadAesKeys(token) {
86
+ const current = token || getToken();
87
+ if (!current) return Promise.resolve(null);
88
+ if (keys && keys.token === current && keys.k && keys.iv) {
89
+ return Promise.resolve(keys);
90
+ }
91
+ if (unavailableToken === current) return Promise.resolve(null);
92
+ if (pending && pending.token === current) return pending.promise;
93
+
94
+ const gen = generation;
95
+ const promise = requestKok(current)
96
+ .then(function (result) {
97
+ if (gen !== generation || getToken() !== current) return null;
98
+ if (!result) {
99
+ unavailableToken = current;
100
+ if (keys && keys.token === current) keys = null;
101
+ return null;
102
+ }
103
+ keys = { k: result.k, iv: result.iv, token: current };
104
+ unavailableToken = null;
105
+ return keys;
106
+ })
107
+ .catch(function () {
108
+ if (gen !== generation) return null;
109
+ unavailableToken = current;
110
+ return null;
111
+ })
112
+ .finally(function () {
113
+ if (pending && pending.promise === promise) pending = null;
114
+ });
115
+ pending = { token: current, promise: promise };
116
+ return promise;
117
+ }
5
118
 
6
- // 加密函数
7
119
  export function encrypt(text) {
8
- return CryptoJS.AES.encrypt(text, CryptoJS.enc.Utf8.parse(secretKey), {
9
- iv: CryptoJS.enc.Utf8.parse(ivKey),
120
+ const key = currentKeys();
121
+ if (!key) return null;
122
+ return CryptoJS.AES.encrypt(text, CryptoJS.enc.Utf8.parse(key.k), {
123
+ iv: CryptoJS.enc.Utf8.parse(key.iv),
10
124
  }).toString();
11
125
  }
12
126
 
13
- // 解密函数
14
127
  export function decrypt(ciphertext) {
15
- const bytes = CryptoJS.AES.decrypt(
16
- ciphertext,
17
- CryptoJS.enc.Utf8.parse(secretKey),
18
- { iv: CryptoJS.enc.Utf8.parse(ivKey) }
19
- );
20
- return bytes.toString(CryptoJS.enc.Utf8);
128
+ const key = currentKeys();
129
+ if (!key || ciphertext == null || ciphertext === "") return ciphertext;
130
+ try {
131
+ const bytes = CryptoJS.AES.decrypt(
132
+ ciphertext,
133
+ CryptoJS.enc.Utf8.parse(key.k),
134
+ {
135
+ iv: CryptoJS.enc.Utf8.parse(key.iv),
136
+ }
137
+ );
138
+ return bytes.toString(CryptoJS.enc.Utf8);
139
+ } catch (e) {
140
+ return ciphertext;
141
+ }
21
142
  }
@@ -8,7 +8,7 @@ import ErroreBox from "../components/errorMsg/index.js";
8
8
  import PopupManager from "element-ui/src/utils/popup/popup-manager.js";
9
9
  import settingConfig from "@/settings.js";
10
10
  import { encode } from "js-base64";
11
- import { encrypt } from "@base/utils/aes";
11
+ import { encrypt, loadAesKeys } from "@base/utils/aes";
12
12
  import { handleRequestNetworkError } from "@base/utils/runtimeRecovery";
13
13
 
14
14
  let configUtil = {
@@ -95,14 +95,23 @@ function aesPlainText(data, useEmptyObject) {
95
95
  }
96
96
 
97
97
  function wrapAesBody(data, useEmptyObject) {
98
+ const cipher = encrypt(aesPlainText(data, useEmptyObject));
99
+ if (!cipher) return null;
98
100
  return {
99
- _aeenboda: encrypt(aesPlainText(data, useEmptyObject)),
101
+ _aeenboda: cipher,
100
102
  };
101
103
  }
102
104
 
105
+ function applyAesBody(config, useEmptyObject) {
106
+ const wrapped = wrapAesBody(config.data, useEmptyObject);
107
+ if (!wrapped) return false;
108
+ config.data = wrapped;
109
+ return true;
110
+ }
111
+
103
112
  // request interceptor
104
113
  service.interceptors.request.use(
105
- (config) => {
114
+ async (config) => {
106
115
  if (config.useToken !== false) {
107
116
  let token = getToken();
108
117
  if (token) {
@@ -123,30 +132,33 @@ service.interceptors.request.use(
123
132
  );
124
133
  }
125
134
  const canEncryptBody = !isBinaryRequestBody(config.data);
126
- if (
127
- settingConfig.requestAesEnabled === true &&
128
- canEncryptBody &&
129
- isOwnBackendRequest(config)
130
- ) {
131
- config.data = wrapAesBody(config.data, true);
135
+ // fetchAesKey: false 强制本请求不取密钥,也不加密。
136
+ const skipAesKey = config.fetchAesKey === false;
137
+ const wantGlobalAes
138
+ = !skipAesKey
139
+ && settingConfig.requestAesEnabled === true
140
+ && canEncryptBody
141
+ && isOwnBackendRequest(config);
142
+ const isFormUrlEncoded
143
+ = config.headers["Content-Type"] === "application/x-www-form-urlencoded"
144
+ || config.headers["Content-Type"]
145
+ === "application/x-www-form-urlencoded;charset=UTF-8";
146
+ const wantListedAes
147
+ = !skipAesKey
148
+ && canEncryptBody
149
+ && settingConfig.base64Urls
150
+ && settingConfig.base64Urls.includes(config.url);
151
+ const wantFlagAes = !skipAesKey && canEncryptBody && config.aes;
152
+ // 密钥在后台取。没取到或接口 404/报错时不等待、不提示,直接发原始请求体。
153
+ if (wantGlobalAes || wantListedAes || wantFlagAes) {
154
+ loadAesKeys().catch(function () {});
155
+ }
156
+ if (wantGlobalAes && applyAesBody(config, true)) {
132
157
  config.headers["Content-Type"] = "application/json;charset=UTF-8";
133
- } else if (
134
- (config.headers["Content-Type"] === "application/x-www-form-urlencoded" ||
135
- config.headers["Content-Type"] ===
136
- "application/x-www-form-urlencoded;charset=UTF-8") &&
137
- typeof config.data !== "string" &&
138
- config.data
139
- ) {
158
+ } else if (isFormUrlEncoded && typeof config.data !== "string" && config.data) {
140
159
  config.data = qs.stringify(config.data);
141
- } else if (
142
- canEncryptBody &&
143
- settingConfig.base64Urls &&
144
- settingConfig.base64Urls.includes(config.url)
145
- ) {
146
- // config.data = {"_baenboda": encode(JSON.stringify(config.data))};
147
- config.data = wrapAesBody(config.data);
148
- } else if (canEncryptBody && config.aes) {
149
- config.data = wrapAesBody(config.data);
160
+ } else if (wantListedAes || wantFlagAes) {
161
+ applyAesBody(config);
150
162
  }
151
163
 
152
164
  if (config.modal !== false && config.loadingTarget) {