From f511c392b0ee495502e7a107e4d8de081af6f2d2 Mon Sep 17 00:00:00 2001
From: wtt <1985833171@qq.com>
Date: 星期日, 04 一月 2026 10:18:28 +0800
Subject: [PATCH] Merge branch 'Dev' of http://101.37.171.70:10101/r/~jhz/STUWMS into Dev
---
utils/i18n.js | 72 ++++++++++++++++++++++++++++++-----
1 files changed, 61 insertions(+), 11 deletions(-)
diff --git a/utils/i18n.js b/utils/i18n.js
index b097a7e..04133e2 100644
--- a/utils/i18n.js
+++ b/utils/i18n.js
@@ -3,10 +3,14 @@
import {
CommonUtils
} from "./common.js"
-const MissingKeysMap = new Map()
+let MissingKeysMap = {}
+let enableCollectMissingKey = false
+let clockID = null
// 杩滅▼鑾峰彇璇█鍖�
export async function getLanguagePackJson(language, forceUpdate = false) {
+ // TODO 鑾峰彇璇█鍖呮椂锛屾坊鍔犱竴涓増鏈瓧娈碉紝瀵规瘮娴忚鍣ㄧ紦瀛樹腑鐨勭増鏈瓧娈靛拰鍚庣鏂囦欢鐨勬槸鍚﹀搴�
+ // 濡傛灉瀵瑰簲锛屽垯涓嶈繑鍥炰换浣曟枃浠讹紝浣跨敤缂撳瓨鏂囦欢鍗冲彲銆�
try {
const res = await CommonUtils.doRequest2Async({
url: '/Xt_grdAlignment_WMES/SelectMESLanguage_JSON',
@@ -15,17 +19,24 @@
forceUpdate: forceUpdate
}
})
- let {data, Message, count} = res.data
- if(count == 1) {
+ let {
+ data,
+ Message,
+ count
+ } = res.data
+ if (count == 1) {
+ enableCollectMissingKey = true
return data
- }else {
+ } else {
+ enableCollectMissingKey = false
CommonUtils.showTips({
title: "娓╅Θ鎻愮ず",
message: "[i18n]鑾峰彇璇█鍖呭け璐�: " + Message
})
return
}
- }catch(err) {
+ } catch (err) {
+ enableCollectMissingKey = false
CommonUtils.showTips({
title: "娓╅Θ鎻愮ず",
message: "[i18n]鑾峰彇璇█鍖呭け璐�: " + err.message
@@ -34,13 +45,52 @@
}
}
-export function addMissingKeyToMap(key) {
- MissingKeysMap.set(key, key)
+export function addMissingKeyToMap(key, HFieldCode) {
+ if (enableCollectMissingKey) {
+ if (!MissingKeysMap[key]) {
+ MissingKeysMap[key] = new Set()
+ }
+ // 闃叉椤甸潰鍒濇鍔犺浇鏃讹紝浣跨敤鏈湴缈昏瘧妯″潡瀵艰嚧鐨� 鍋囩己澶辩幇璞�
+ MissingKeysMap[key].add(HFieldCode)
+ console.log('MissingKeysMap: ', MissingKeysMap);
+ if (!clockID) {
+ clockID = setTimeout(() => {
+ syncMissingKeyToDB()
+ }, 1000)
+ } else {
+ clearTimeout(clockID)
+ clockID = setTimeout(() => {
+ syncMissingKeyToDB()
+ }, 1000)
+ }
+ }
}
// 娣诲姞缂哄け瀛楁鍒拌繙绋嬫暟鎹簱
-export async function syncMissingKeyToDB(){
-
+export async function syncMissingKeyToDB() {
+ console.log('MissingKeysMap: ', MissingKeysMap);
+ for (let key in MissingKeysMap) {
+ if (MissingKeysMap.hasOwnProperty(key)) {
+ MissingKeysMap[key] = Array.from(MissingKeysMap[key])
+ }
+ }
+ CommonUtils.doRequest2Sync({
+ url: "/Xt_grdAlignment_WMES/syncMissingKeyToDB",
+ data: {
+ missingObj: JSON.stringify(MissingKeysMap)
+ }
+ })
// 娓呴櫎缂哄け瀛楁缂撳瓨
- MissingKeysMap.clear()
-}
+ MissingKeysMap = {}
+ // 閲嶅惎搴旂敤
+ const systemInfo = uni.getSystemInfoSync();
+ const platform = systemInfo.platform;
+
+ if (platform === 'ios' || platform === 'android') {
+ // App 绔細瀹屽叏閲嶅惎
+ plus.runtime.restart();
+ } else if (platform === 'h5') {
+ // H5 绔細鍒锋柊椤甸潰
+ window.location.reload();
+ }
+}
\ No newline at end of file
--
Gitblit v1.9.1