@ganwei-web/ganwei-pc-cli 6.2.9 → 6.3.2

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.
Files changed (71) hide show
  1. package/ganwei-iotcenter-index-6.2.3/configuration/moduleConfiguration.json +2 -0
  2. package/ganwei-iotcenter-index-6.2.3/packages/ganwei-iotcenter-index/env.d.ts +8 -5
  3. package/ganwei-iotcenter-index-6.2.3/packages/ganwei-iotcenter-index/index.html +1 -1
  4. package/ganwei-iotcenter-index-6.2.3/packages/ganwei-iotcenter-index/public/static/css/ElementPlusAdapter.css +437 -68
  5. package/ganwei-iotcenter-index-6.2.3/packages/ganwei-iotcenter-index/public/static/css/reset-6-1.css +1 -0
  6. package/ganwei-iotcenter-index-6.2.3/packages/ganwei-iotcenter-index/public/static/css/reset-plus.css +396 -0
  7. package/ganwei-iotcenter-index-6.2.3/packages/ganwei-iotcenter-index/public/static/http/createAxios.js +38 -13
  8. package/ganwei-iotcenter-index-6.2.3/packages/ganwei-iotcenter-index/public/static/js/getLanguage.js +19 -12
  9. package/ganwei-iotcenter-index-6.2.3/packages/ganwei-iotcenter-index/public/static/themes/dark-6-1.css +3 -3
  10. package/ganwei-iotcenter-index-6.2.3/packages/ganwei-iotcenter-index/public/static/themes/green-6-1.css +12 -11
  11. package/ganwei-iotcenter-index-6.2.3/packages/ganwei-iotcenter-index/src/App.vue +11 -6
  12. package/ganwei-iotcenter-index-6.2.3/packages/ganwei-iotcenter-index/src/components/indexRightContent/headerRight/equipAlarmDialog/index.vue +6 -0
  13. package/ganwei-iotcenter-index-6.2.3/packages/ganwei-iotcenter-index/src/components/indexRightContent/headerRight/expirationReminder/index.vue +7 -3
  14. package/ganwei-iotcenter-index-6.2.3/packages/ganwei-iotcenter-index/src/components/indexRightContent/headerRight/index.scss +4 -0
  15. package/ganwei-iotcenter-index-6.2.3/packages/ganwei-iotcenter-index/src/components/indexRightContent/headerRight/userInfo/index.js +35 -3
  16. package/ganwei-iotcenter-index-6.2.3/packages/ganwei-iotcenter-index/src/components/indexRightContent/headerRight/userInfo/index.scss +7 -1
  17. package/ganwei-iotcenter-index-6.2.3/packages/ganwei-iotcenter-index/src/components/indexRightContent/headerRight/userInfo/index.vue +2 -2
  18. package/ganwei-iotcenter-index-6.2.3/packages/ganwei-iotcenter-index/src/components/layouts/Navigation/ContractMenu.vue +11 -37
  19. package/ganwei-iotcenter-index-6.2.3/packages/ganwei-iotcenter-index/src/components/layouts/Navigation/TopNav.vue +3 -2
  20. package/ganwei-iotcenter-index-6.2.3/packages/ganwei-iotcenter-index/src/components/layouts/Sidebar/LeftContent/index.vue +7 -1
  21. package/ganwei-iotcenter-index-6.2.3/packages/ganwei-iotcenter-index/src/router.js +120 -18
  22. package/ganwei-iotcenter-index-6.2.3/packages/ganwei-iotcenter-index/src/utils/date.ts +80 -0
  23. package/ganwei-iotcenter-index-6.2.3/packages/ganwei-iotcenter-index/src/utils/dom.ts +99 -0
  24. package/ganwei-iotcenter-index-6.2.3/packages/ganwei-iotcenter-index/src/utils/env.ts +20 -0
  25. package/ganwei-iotcenter-index-6.2.3/packages/ganwei-iotcenter-index/src/utils/file.ts +74 -0
  26. package/ganwei-iotcenter-index-6.2.3/packages/ganwei-iotcenter-index/src/utils/index.ts +26 -0
  27. package/ganwei-iotcenter-index-6.2.3/packages/ganwei-iotcenter-index/src/utils/number.ts +83 -0
  28. package/ganwei-iotcenter-index-6.2.3/packages/ganwei-iotcenter-index/src/utils/performance.ts +69 -0
  29. package/ganwei-iotcenter-index-6.2.3/packages/ganwei-iotcenter-index/src/utils/storage.ts +80 -0
  30. package/ganwei-iotcenter-index-6.2.3/packages/ganwei-iotcenter-index/src/utils/string.ts +116 -0
  31. package/ganwei-iotcenter-index-6.2.3/packages/ganwei-iotcenter-index/src/utils/xss-filter.ts +260 -0
  32. package/ganwei-iotcenter-index-6.2.3/packages/ganwei-iotcenter-index/src/views/jumpIframe/index.vue +45 -28
  33. package/ganwei-iotcenter-index-6.2.3/packages/ganwei-iotcenter-index/tsconfig.json +1 -0
  34. package/ganwei-iotcenter-index-6.2.3/packages/ganwei-iotcenter-index/vite.config.ts +10 -1
  35. package/ganwei-iotcenter-index-6.2.3/packages/ganwei-iotcenter-login/public/static/http/createAxios.js +40 -15
  36. package/ganwei-iotcenter-index-6.2.3/packages/ganwei-iotcenter-login/public/static/js/getLanguage.js +10 -2
  37. package/ganwei-iotcenter-index-6.2.3/packages/ganwei-iotcenter-login/src/views/login.vue +55 -53
  38. package/ganwei-iotcenter-index-6.2.3/packages/ganwei-iotcenter-login/src/views/ssoLogin.vue +10 -9
  39. package/ganwei-iotcenter-index-6.2.3/packages/ganwei-iotcenter-template/.env.development +0 -3
  40. package/ganwei-iotcenter-index-6.2.3/packages/ganwei-iotcenter-template/.env.production +1 -4
  41. package/ganwei-iotcenter-index-6.2.3/packages/ganwei-iotcenter-template/.env.test +0 -3
  42. package/ganwei-iotcenter-index-6.2.3/packages/ganwei-iotcenter-template/.eslintrc.cjs +2 -2
  43. package/ganwei-iotcenter-index-6.2.3/packages/ganwei-iotcenter-template/env.d.ts +9 -5
  44. package/ganwei-iotcenter-index-6.2.3/packages/ganwei-iotcenter-template/index.html +1 -0
  45. package/ganwei-iotcenter-index-6.2.3/packages/ganwei-iotcenter-template/package.json +3 -2
  46. package/ganwei-iotcenter-index-6.2.3/packages/ganwei-iotcenter-template/public/static/http/createAxios.js +38 -13
  47. package/ganwei-iotcenter-index-6.2.3/packages/ganwei-iotcenter-template/public/static/js/getLanguage.js +10 -2
  48. package/ganwei-iotcenter-index-6.2.3/packages/ganwei-iotcenter-template/src/App.vue +1 -1
  49. package/ganwei-iotcenter-index-6.2.3/packages/ganwei-iotcenter-template/src/request/api.ts +0 -1
  50. package/ganwei-iotcenter-index-6.2.3/packages/ganwei-iotcenter-template/src/request/models/response/template.ts +0 -0
  51. package/ganwei-iotcenter-index-6.2.3/packages/ganwei-iotcenter-template/src/utils/date.ts +79 -0
  52. package/ganwei-iotcenter-index-6.2.3/packages/ganwei-iotcenter-template/src/utils/dom.ts +99 -0
  53. package/ganwei-iotcenter-index-6.2.3/packages/ganwei-iotcenter-template/src/utils/env.ts +20 -0
  54. package/ganwei-iotcenter-index-6.2.3/packages/ganwei-iotcenter-template/src/utils/file.ts +74 -0
  55. package/ganwei-iotcenter-index-6.2.3/packages/ganwei-iotcenter-template/src/utils/index.ts +29 -0
  56. package/ganwei-iotcenter-index-6.2.3/packages/ganwei-iotcenter-template/src/utils/number.ts +83 -0
  57. package/ganwei-iotcenter-index-6.2.3/packages/ganwei-iotcenter-template/src/utils/performance.ts +69 -0
  58. package/ganwei-iotcenter-index-6.2.3/packages/ganwei-iotcenter-template/src/utils/signalr.ts +564 -0
  59. package/ganwei-iotcenter-index-6.2.3/packages/ganwei-iotcenter-template/src/utils/storage.ts +80 -0
  60. package/ganwei-iotcenter-index-6.2.3/packages/ganwei-iotcenter-template/src/utils/string.ts +116 -0
  61. package/ganwei-iotcenter-index-6.2.3/packages/ganwei-iotcenter-template/src/utils/xss-filter.ts +260 -0
  62. package/ganwei-iotcenter-index-6.2.3/packages/ganwei-iotcenter-template/src/views/template.vue +0 -1
  63. package/ganwei-iotcenter-index-6.2.3/packages/ganwei-iotcenter-template/tsconfig.json +7 -0
  64. package/ganwei-iotcenter-index-6.2.3/pnpm-lock.yaml +489 -155
  65. package/package.json +1 -1
  66. package/ganwei-iotcenter-index-6.2.3/packages/ganwei-iotcenter-index/src/mixins/judgePermission.js +0 -60
  67. package/ganwei-iotcenter-index-6.2.3/packages/ganwei-iotcenter-index/src/utils/setStorage.js +0 -5
  68. package/ganwei-iotcenter-index-6.2.3/packages/ganwei-iotcenter-template/src/utils/setStorage.js +0 -5
  69. /package/ganwei-iotcenter-index-6.2.3/packages/ganwei-iotcenter-index/build/{enteryJson.js → entryJson.js} +0 -0
  70. /package/ganwei-iotcenter-index-6.2.3/packages/ganwei-iotcenter-template/src/{request/models/request/index.ts → enum/template.ts} +0 -0
  71. /package/ganwei-iotcenter-index-6.2.3/packages/ganwei-iotcenter-template/src/request/models/{response/index.ts → request/template.ts} +0 -0
@@ -0,0 +1,260 @@
1
+ /**
2
+ * XSS 过滤工具
3
+ * 用于过滤和清理用户输入,防止 XSS 攻击
4
+ */
5
+
6
+ /**
7
+ * HTML 实体编码映射
8
+ */
9
+ const HTML_ENTITIES: Record<string, string> = {
10
+ '&': '&amp;',
11
+ '<': '&lt;',
12
+ '>': '&gt;',
13
+ '"': '&quot;',
14
+ "'": '&#x27;',
15
+ '/': '&#x2F;',
16
+ '`': '&#x60;',
17
+ '=': '&#x3D;'
18
+ }
19
+
20
+ /**
21
+ * 危险 HTML 标签正则
22
+ */
23
+ const DANGEROUS_TAGS_REGEX =
24
+ /<(script|iframe|object|embed|form|input|button|textarea|select|style|link|meta|base)[^>]*>.*?<\/\1>|<(script|iframe|object|embed|form|input|button|textarea|select|style|link|meta|base)[^>]*\/?>/gi
25
+
26
+ /**
27
+ * 危险属性正则
28
+ */
29
+ const DANGEROUS_ATTRS_REGEX = /\s(on\w+|href|src|action|formaction|data|dynsrc|lowsrc)\s*=\s*(['"]?)[^'">\s]*\2/gi
30
+
31
+ /**
32
+ * javascript: 协议正则
33
+ */
34
+ const JAVASCRIPT_PROTOCOL_REGEX = /javascript\s*:/gi
35
+
36
+ /**
37
+ * 转义 HTML 特殊字符
38
+ * @param str - 要转义的字符串
39
+ * @returns 转义后的字符串
40
+ * @example
41
+ * escapeHtml('<script>alert("xss")</script>')
42
+ * // '&lt;script&gt;alert(&quot;xss&quot;)&lt;/script&gt;'
43
+ */
44
+ export function escapeHtml(str: string): string {
45
+ if (!str) return ''
46
+ return str.replace(/[&<>"'`=/]/g, char => HTML_ENTITIES[char])
47
+ }
48
+
49
+ /**
50
+ * 反转义 HTML 特殊字符
51
+ * @param str - 要反转义的字符串
52
+ * @returns 反转义后的字符串
53
+ */
54
+ export function unescapeHtml(str: string): string {
55
+ if (!str) return ''
56
+ const entities: Record<string, string> = {
57
+ '&amp;': '&',
58
+ '&lt;': '<',
59
+ '&gt;': '>',
60
+ '&quot;': '"',
61
+ '&#x27;': "'",
62
+ '&#x2F;': '/',
63
+ '&#x60;': '`',
64
+ '&#x3D;': '='
65
+ }
66
+ return str.replace(/&(amp|lt|gt|quot|#x27|#x2F|#x60|#x3D);/g, entity => entities[entity] || entity)
67
+ }
68
+
69
+ /**
70
+ * 移除危险 HTML 标签
71
+ * @param html - HTML 字符串
72
+ * @returns 清理后的 HTML
73
+ * @example
74
+ * stripDangerousTags('<script>alert(1)</script><p>安全</p>')
75
+ * // '<p>安全</p>'
76
+ */
77
+ export function stripDangerousTags(html: string): string {
78
+ if (!html) return ''
79
+ return html.replace(DANGEROUS_TAGS_REGEX, '')
80
+ }
81
+
82
+ /**
83
+ * 移除危险属性
84
+ * @param html - HTML 字符串
85
+ * @returns 清理后的 HTML
86
+ * @example
87
+ * stripDangerousAttrs('<div onclick="alert(1)">内容</div>')
88
+ * // '<div>内容</div>'
89
+ */
90
+ export function stripDangerousAttrs(html: string): string {
91
+ if (!html) return ''
92
+ return html.replace(DANGEROUS_ATTRS_REGEX, '')
93
+ }
94
+
95
+ /**
96
+ * 移除 javascript: 协议
97
+ * @param str - 字符串
98
+ * @returns 清理后的字符串
99
+ */
100
+ export function stripJavascriptProtocol(str: string): string {
101
+ if (!str) return ''
102
+ return str.replace(JAVASCRIPT_PROTOCOL_REGEX, '')
103
+ }
104
+
105
+ /**
106
+ * XSS 过滤(完整版)
107
+ * @param input - 用户输入
108
+ * @param options - 过滤选项
109
+ * @returns 过滤后的安全字符串
110
+ */
111
+ export interface XssFilterOptions {
112
+
113
+ /** 是否转义 HTML,默认 true */
114
+ escapeHtml?: boolean
115
+
116
+ /** 是否移除危险标签,默认 true */
117
+ stripDangerousTags?: boolean
118
+
119
+ /** 是否移除危险属性,默认 true */
120
+ stripDangerousAttrs?: boolean
121
+
122
+ /** 是否移除 javascript 协议,默认 true */
123
+ stripJavascriptProtocol?: boolean
124
+ }
125
+
126
+ export function xssFilter(input: string, options: XssFilterOptions = {}): string {
127
+ if (!input) return ''
128
+
129
+ const {
130
+ escapeHtml: shouldEscape = true,
131
+ stripDangerousTags: shouldStripTags = true,
132
+ stripDangerousAttrs: shouldStripAttrs = true,
133
+ stripJavascriptProtocol: shouldStripJsProtocol = true
134
+ } = options
135
+
136
+ let result = input
137
+
138
+ // 移除危险标签
139
+ if (shouldStripTags) {
140
+ result = stripDangerousTags(result)
141
+ }
142
+
143
+ // 移除危险属性
144
+ if (shouldStripAttrs) {
145
+ result = stripDangerousAttrs(result)
146
+ }
147
+
148
+ // 移除 javascript 协议
149
+ if (shouldStripJsProtocol) {
150
+ result = stripJavascriptProtocol(result)
151
+ }
152
+
153
+ // 转义 HTML
154
+ if (shouldEscape) {
155
+ result = escapeHtml(result)
156
+ }
157
+
158
+ return result
159
+ }
160
+
161
+ /**
162
+ * 过滤 URL,只允许安全协议
163
+ * @param url - URL 字符串
164
+ * @param allowedProtocols - 允许的协议列表
165
+ * @returns 安全的 URL 或空字符串
166
+ * @example
167
+ * filterUrl('javascript:alert(1)') // ''
168
+ * filterUrl('https://example.com') // 'https://example.com'
169
+ */
170
+ export function filterUrl(
171
+ url: string,
172
+ allowedProtocols: string[] = ['http', 'https', 'mailto', 'tel', 'ftp']
173
+ ): string {
174
+ if (!url) return ''
175
+
176
+ // 移除空白字符
177
+ const trimmedUrl = url.trim()
178
+
179
+ // 检查是否为相对路径或锚点
180
+ if (trimmedUrl.startsWith('/') || trimmedUrl.startsWith('#') || trimmedUrl.startsWith('?')) {
181
+ return trimmedUrl
182
+ }
183
+
184
+ // 提取协议
185
+ const protocolMatch = trimmedUrl.match(/^([a-zA-Z][a-zA-Z0-9+.-]*):/)
186
+ if (!protocolMatch) {
187
+ return trimmedUrl // 无协议,视为相对路径
188
+ }
189
+
190
+ const protocol = protocolMatch[1].toLowerCase()
191
+
192
+ // 检查协议是否在允许列表中
193
+ if (allowedProtocols.includes(protocol)) {
194
+ return trimmedUrl
195
+ }
196
+
197
+ return ''
198
+ }
199
+
200
+ /**
201
+ * 过滤对象中的 XSS
202
+ * @param obj - 要过滤的对象
203
+ * @param options - 过滤选项
204
+ * @returns 过滤后的对象
205
+ */
206
+ export function filterObject<T extends Record<string, any>>(
207
+ obj: T,
208
+ options: XssFilterOptions = {}
209
+ ): T {
210
+ if (!obj || typeof obj !== 'object') return obj
211
+
212
+ const result: Record<string, any> = {}
213
+
214
+ for (const [key, value] of Object.entries(obj)) {
215
+ if (typeof value === 'string') {
216
+ result[key] = xssFilter(value, options)
217
+ } else if (typeof value === 'object' && value !== null) {
218
+ result[key] = filterObject(value, options)
219
+ } else {
220
+ result[key] = value
221
+ }
222
+ }
223
+
224
+ return result as T
225
+ }
226
+
227
+ /**
228
+ * 白名单标签过滤
229
+ * 只保留允许的 HTML 标签
230
+ * @param html - HTML 字符串
231
+ * @param allowedTags - 允许的标签列表
232
+ * @returns 过滤后的 HTML
233
+ * @example
234
+ * filterHtmlTags('<p><script>alert(1)</script>内容</p>', ['p'])
235
+ * // '<p>内容</p>'
236
+ */
237
+ export function filterHtmlTags(html: string, allowedTags: string[] = []): string {
238
+ if (!html) return ''
239
+ if (allowedTags.length === 0) return escapeHtml(html)
240
+
241
+ // 构建白名单正则
242
+ const allowedTagsPattern = allowedTags.join('|')
243
+ const openTagRegex = new RegExp(`<(${allowedTagsPattern})([^>]*)>`, 'gi')
244
+ const closeTagRegex = new RegExp(`</(${allowedTagsPattern})>`, 'gi')
245
+
246
+ // 先转义所有 HTML
247
+ let result = escapeHtml(html)
248
+
249
+ // 恢复允许的标签
250
+ result = result.replace(
251
+ new RegExp(`&lt;(${allowedTagsPattern})([^&]*)&gt;`, 'gi'),
252
+ (_, tag, attrs) => `<${tag}${unescapeHtml(attrs)}>`
253
+ )
254
+ result = result.replace(
255
+ new RegExp(`&lt;/(${allowedTagsPattern})&gt;`, 'gi'),
256
+ (_, tag) => `</${tag}>`
257
+ )
258
+
259
+ return result
260
+ }
@@ -2,8 +2,8 @@
2
2
  <div class="jumpPage">
3
3
  <loading v-show="loading"></loading>
4
4
  <!-- 菜单至少不为空时,才开始加载页面,避免单点登录时,菜单为空,导致页面异常 -->
5
- <iframe v-if="name != 'noPage' && isHasPage" :id="name" :src="path" width="100%" height="100%"
6
- allowfullscreen></iframe>
5
+ <iframe v-if="name != 'noPage' && isHasPage" :id="name" :src="path" width="100%" height="100%" allowfullscreen
6
+ allow="microphone"></iframe>
7
7
  <noPage v-if="name == 'noPage'"></noPage>
8
8
  </div>
9
9
  </template>
@@ -101,6 +101,8 @@ export default {
101
101
  menuName,
102
102
  languageType: localStorage.languageType,
103
103
  userName: sessionStorage.userName,
104
+ aesUserName: sessionStorage.aesUserName,
105
+ // photograph: sessionStorage.photograph,
104
106
  auth: this.auth,
105
107
  customName: this.customName,
106
108
  // 会自动 encodeURIComponent,所以需要先decodeURIComponent
@@ -158,37 +160,52 @@ export default {
158
160
  }
159
161
  },
160
162
 
163
+ // checkFrameLoad 方法重写
161
164
  checkFrameLoad(packageName, packageId, menuName) {
162
165
  let iframe = document.getElementById(this.name)
163
- if (iframe) {
164
- iframe.onload = () => {
165
- try {
166
- iframe.contentWindow.document.documentElement.setAttribute('data-theme', sessionStorage.theme)
167
- } catch (error) {
168
- console.log(error)
169
- }
170
- try {
171
- iframe.contentWindow.postMessage({
172
- theme: sessionStorage.theme,
173
- languagePackage: sessionStorage.languagePackage,
174
- packageId: packageId,
175
- packageName: packageName,
176
- menuName: menuName
177
- }, "*")
178
- } catch (error) {
179
- console.log(error)
180
- }
181
- this.loading = false;
182
- this.checkPageLoad()
166
+ if (!iframe) {
167
+ this.isNoPage()
168
+ return
169
+ }
170
+
171
+ // 用于防止重复发送
172
+ let hasSent = false
173
+
174
+ // 发送消息的统一方法
175
+ const sendPostMessage = () => {
176
+ if (hasSent) return
177
+ hasSent = true
178
+
179
+ try {
180
+ iframe.contentWindow.document.documentElement.setAttribute('data-theme', sessionStorage.theme)
181
+ } catch (error) {
182
+ console.log(error)
183
183
  }
184
184
 
185
- // 防止onload不执行,兜底
186
- setTimeout(() => {
187
- this.loading = false;
188
- }, LOADING_TIME);
189
- } else {
190
- this.isNoPage()
185
+ try {
186
+ iframe.contentWindow.postMessage({
187
+ theme: sessionStorage.theme,
188
+ languagePackage: sessionStorage.languagePackage,
189
+ packageId: packageId,
190
+ packageName: packageName,
191
+ menuName: menuName,
192
+ photograph: sessionStorage.photograph // 完整参数
193
+ }, "*")
194
+ } catch (error) {
195
+ console.log(error)
196
+ }
197
+
198
+ this.loading = false
199
+ this.checkPageLoad()
191
200
  }
201
+
202
+ // 绑定 onload
203
+ iframe.onload = sendPostMessage
204
+
205
+ // 兜底定时器(确保完整参数)
206
+ setTimeout(() => {
207
+ sendPostMessage()
208
+ }, LOADING_TIME)
192
209
  },
193
210
 
194
211
  checkPageLoad() {
@@ -43,6 +43,7 @@
43
43
  }
44
44
  },
45
45
  "include": [
46
+ "env.d.ts",
46
47
  "src/**/*.ts",
47
48
  "src/**/*.d.ts",
48
49
  "src/**/*.tsx",
@@ -12,7 +12,7 @@ import { createHtmlPlugin } from 'vite-plugin-html'
12
12
  import viteAddInfoHtml from './build/vite-addInfo-html'
13
13
  import { name } from "./package.json"
14
14
  import stats from "./build/vite-plugin-stats-html"
15
- import getEntryPath from "./build/enteryJson.js";
15
+ import getEntryPath from "./build/entryJson.js";
16
16
  const htmlParams = {
17
17
  minify: false, // 开发环境不压缩
18
18
  pages: getEntryPath
@@ -118,6 +118,15 @@ export default ({ mode }) => {
118
118
  https: false, // 启用 TLS + HTTP/2
119
119
  open: false,
120
120
  proxy: {
121
+ '/file': {
122
+ target: VITE_APP_TARGET_URL,
123
+ changeOrigin: true,
124
+ secure: false,
125
+ rewrite: (path) => path.replace(/^\/file/, '/file'),
126
+ headers: {
127
+ Referer: VITE_APP_TARGET_URL
128
+ }
129
+ },
121
130
  '/api': {
122
131
  target: VITE_APP_TARGET_URL,
123
132
  changeOrigin: true,
@@ -4,7 +4,6 @@
4
4
  function generateSign(params) {
5
5
  const { appId, timestamp, nonce, body } = params;
6
6
  const raw = appId + timestamp + nonce + body;
7
- console.log(raw)
8
7
  return window.smEncrypt.sm3(raw);
9
8
  }
10
9
 
@@ -26,9 +25,8 @@ function urlEncode(val) {
26
25
  } else if (typeof val != 'string') {
27
26
  val = JSON.stringify(val)
28
27
  }
29
- console.log(val)
30
28
  return encodeURIComponent(val).replace(/[!*'()]/g, c =>
31
- '%' + c.charCodeAt(0).toString(16).toUpperCase()
29
+ '%' + c.charCodeAt(0).toString(16).toUpperCase()
32
30
  );
33
31
  }
34
32
 
@@ -58,6 +56,22 @@ const overTimeList = [
58
56
  { api: "/IoT/api/v3/GWAssembly/BatchInstallAppStorePlugin", timeout: 1800000 }
59
57
  ];
60
58
 
59
+ const languageValue = {
60
+ 'zh-CN': [
61
+ '登录超时,请重新登录',
62
+ '提示',
63
+ '确定',
64
+ '取消'
65
+ ],
66
+ 'en-US': [
67
+ 'Login Timeout, Please Login Again',
68
+ 'Tips',
69
+ 'Confirm',
70
+ 'Cancel'
71
+ ]
72
+ };
73
+
74
+
61
75
  /**
62
76
  * axios封装
63
77
  * 请求拦截、响应拦截、错误统一处理
@@ -103,14 +117,21 @@ const overTimeList = [
103
117
  }
104
118
  async function getLoginLanuage(pluginName, menuName, packageId, msg, duration) {
105
119
  await _this.requestLanguage(pluginName, menuName, packageId, '').then(res => {
106
- if (!sessionStorage.languageType) { sessionStorage.languageType = localStorage.languageType }
107
- if (currentAxiosBuilder.i18n && currentAxiosBuilder.i18n.global && currentAxiosBuilder.i18n.global.messages) {
108
- currentAxiosBuilder.i18n.global.messages.value[sessionStorage.languageType][menuName] = res
120
+ const langType = sessionStorage.languageType || localStorage.languageType || 'zh-CN';
121
+ const i18nGlobal = currentAxiosBuilder.i18n?.global;
122
+
123
+ if (i18nGlobal && i18nGlobal.messages) {
124
+ if (!i18nGlobal.messages.value[langType]) {
125
+ i18nGlobal.messages.value[langType] = {};
126
+ }
127
+ i18nGlobal.messages.value[langType][menuName] = res;
109
128
  }
110
129
  }).catch(err => {
111
130
  console.log(err)
112
131
  }).finally(o => {
113
- messageTips(msg, duration)
132
+ if (msg && duration) {
133
+ messageTips(msg, duration)
134
+ }
114
135
  })
115
136
  }
116
137
  function messageTips(msg, duration) {
@@ -148,15 +169,18 @@ const overTimeList = [
148
169
  } catch (error) {
149
170
  console.log(error)
150
171
  }
151
- if (!languagePackage || !languagePackage[localStorage.languageType] || !languagePackage[localStorage.languageType].login) {
152
- await getLoginLanuage('ganwei-iotcenter-login', 'login', 'Ganweisoft.IoTCenter.Module.Login', msg, duration)
153
- }
172
+ // TODO 如果此时有操作清空了浏览器缓存,正好服务断开,则会出现键值/重启服务直接访问登录后页面,此时会出现登录页面无法获取语言包,导致提示语不对,需要重新梳理语言包挂载
173
+ // if (!languagePackage || !languagePackage[localStorage.languageType] || !languagePackage[localStorage.languageType].login) {
174
+ // await getLoginLanuage('ganwei-iotcenter-login', 'login', 'Ganweisoft.IoTCenter.Module.Login', '', '')
175
+ // }
176
+ sessionStorage.setItem('isLgStatus', false)
177
+ let lType = sessionStorage.languageType || localStorage.languageType || 'zh-CN';
154
178
  currentAxiosBuilder.elmessageBox && currentAxiosBuilder.elmessageBox.confirm(
155
- currentAxiosBuilder.i18n.global.t('login.noAccess.noAccess[7]'),
156
- currentAxiosBuilder.i18n.global.t('login.mainInfoDialog.tips.tip'),
179
+ languageValue[lType][0],
180
+ languageValue[lType][1],
157
181
  {
158
- confirmButtonText: currentAxiosBuilder.i18n.global.t('login.publics.button.confirm'),
159
- cancelButtonText: currentAxiosBuilder.i18n.global.t('login.publics.button.cancel'),
182
+ confirmButtonText: languageValue[lType][2],
183
+ cancelButtonText: languageValue[lType][3],
160
184
  type: 'warning',
161
185
  showClose: false,
162
186
  closeOnClickModal: false,
@@ -329,6 +353,7 @@ const overTimeList = [
329
353
  _this.i18n = this.i18n = i18n
330
354
  _this.notification = this.notification = notification
331
355
  _this.elmessageBox = this.elmessageBox = elmessageBox
356
+
332
357
  try {
333
358
  if (_this.top.AxiosBuilder.i18n) { this.i18n = _this.top.AxiosBuilder.i18n }
334
359
  if (_this.top.AxiosBuilder.notification) { this.notification = _this.top.AxiosBuilder.notification }
@@ -365,7 +390,6 @@ const overTimeList = [
365
390
  config => {
366
391
  config.headers['Accept-Language'] = window.localStorage.languageType || 'zh-CN'
367
392
  config.headers['Xsrf-Token'] = window.sessionStorage.CSRF_TOKEN || ''
368
-
369
393
  if (config.method === 'post') {
370
394
  const signParams = {
371
395
  appId: sessionStorage.getItem("userName"),
@@ -425,6 +449,7 @@ const overTimeList = [
425
449
  this.axios.defaults['overTimeList'] = _this.mergeApi(res.httpConfig.overTimeList || [], overTimeList)
426
450
  }
427
451
  })
452
+ _this.AxiosBuilder.axios = this.axios
428
453
  return this
429
454
  }
430
455
  _this['AxiosBuilder'].prototype.getInstance = function getInstance() {
@@ -131,8 +131,16 @@ window.updateLanguage = (pluginName, menuName,vm, i18n) => {
131
131
 
132
132
  // Vue3 基座
133
133
  if (vm && vm.i18nInstance) {
134
- vm.i18nInstance.locale = langType;
135
- vm.i18nInstance.mergeLocaleMessage(langType, JSON.parse(JSON.stringify(merged)));
134
+ // composition API 模式下,locale mergeLocaleMessage 在 i18n.global 上
135
+ const i18nInstance = vm.i18nInstance.global || vm.i18nInstance;
136
+ if (i18nInstance.locale && typeof i18nInstance.locale === 'object' && 'value' in i18nInstance.locale) {
137
+ // composition API 模式
138
+ i18nInstance.locale.value = langType;
139
+ } else {
140
+ // legacy 模式
141
+ i18nInstance.locale = langType;
142
+ }
143
+ i18nInstance.mergeLocaleMessage(langType, JSON.parse(JSON.stringify(merged)));
136
144
  }
137
145
  // Vue2 基座
138
146
  else if (i18n && i18n._vm) {