diff --git a/common/globalFunction.js b/common/globalFunction.js index caca696..e2ff269 100644 --- a/common/globalFunction.js +++ b/common/globalFunction.js @@ -1,4 +1,12 @@ +// #ifdef H5 import '@/lib/encryption/sm4.min.js' +// #endif + +// #ifndef H5 +import { sm4 } from 'sm-crypto'; +// #endif + + import useUserStore from "../stores/useUserStore"; import { createRequestWithCache, @@ -601,7 +609,6 @@ export function sm4Decrypt(key, value, mode = "hex") { cipherType: mode === 'hex' ? 'hex' : 'base64', padding: 'pkcs#5' }); - return decrypted } catch (e) { @@ -638,9 +645,13 @@ export function reloadBrowser() { export function isY9MachineType() { try { - const ua = navigator.userAgent; - const isY9Machine = /Y9-ZYYH/i.test(ua); // 匹配机器型号 - return isY9Machine; + const ua = navigator.userAgent; + const isY9Machine = /Y9-ZYYH/i.test(ua); // 匹配机器型号 + return isY9Machine; + } catch (error) { + return false + } + } // 一体机环境判断 @@ -648,10 +659,16 @@ export function isAsdMachineType() { // const ua = navigator.userAgent; // const isY9Machine = /asd_hanweb/i.test(ua); // 匹配机器型号 // return isY9Machine; - return !!lightAppJssdk.user + try { + return !!lightAppJssdk.user + } catch (error) { + false + } + } + export const $api = { msg, prePage, diff --git a/pages/index/components/AIMatch.vue b/pages/index/components/AIMatch.vue index 8e33153..cb06425 100644 --- a/pages/index/components/AIMatch.vue +++ b/pages/index/components/AIMatch.vue @@ -1,46 +1,39 @@ - +]); - diff --git a/stores/useLocationStore.js b/stores/useLocationStore.js index f6e035f..13cfa2b 100644 --- a/stores/useLocationStore.js +++ b/stores/useLocationStore.js @@ -22,6 +22,9 @@ const useLocationStore = defineStore("location", () => { const count = ref(0) function getLocation() { // 获取经纬度两个平台 + // #ifndef H5 + const lightAppJssdk = {} + // #endif return new Promise((resole, reject) => { try { if (lightAppJssdk.map) { diff --git a/stores/useScreenStore.js b/stores/useScreenStore.js index d90f90f..bee858f 100644 --- a/stores/useScreenStore.js +++ b/stores/useScreenStore.js @@ -52,17 +52,25 @@ class ScreenDetectionManager { // 检测折叠屏 checkVisualViewport() { - if (window.visualViewport?.segments?.length > 1) { - return { - foldable: true, - count: window.visualViewport.segments.length - 1 + try { + if (window.visualViewport?.segments?.length > 1) { + return { + foldable: true, + count: window.visualViewport.segments.length - 1 + } + } else { + return { + foldable: false, + count: 1 + } } - } else { + } catch (error) { return { foldable: false, count: 1 } } + } // 动态加载 CSS diff --git a/utils/db.js b/utils/db.js index 450436e..c0648f4 100644 --- a/utils/db.js +++ b/utils/db.js @@ -1,4 +1,5 @@ import IndexedDBHelper from '@/common/IndexedDBHelper.js' +import UniStorageHelper from '@/common/UniStorageHelper.js' import useChatGroupDBStore from '@/stores/userChatGroupStore' import config from '@/config' @@ -66,7 +67,14 @@ class BaseStore { } initDB() { + // #ifdef H5 this.db = new IndexedDBHelper(this.dbName, config.DBversion); + // #endif + + // #ifndef H5 + this.db = new UniStorageHelper(this.dbName, config.DBversion); + // #endif + return this.db.openDB([{ name: 'record', keyPath: "id", @@ -103,8 +111,15 @@ class BaseStore { } async clearDB() { - // 修正拼写错误并优化 Promise 写法 - return new IndexedDBHelper().deleteDB(this.dbName); + + + // #ifdef H5 + return new IndexedDBHelper().deleteDB(this.dbName); + // #endif + + // #ifndef H5 + return new UniStorageHelper().deleteDB(this.dbName); + // #endif } /**