flat: ai对话提交
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
import useUserStore from "../stores/useUserStore";
|
||||
import {
|
||||
request,
|
||||
createRequest,
|
||||
uploadFile
|
||||
} from "../utils/request";
|
||||
@@ -8,6 +7,9 @@ import streamRequest, {
|
||||
chatRequest
|
||||
} from "../utils/streamRequest.js";
|
||||
|
||||
const sm4 = typeof window.sm4 !== 'undefined' ? window.sm4 :
|
||||
(typeof window.smCrypto !== 'undefined' ? window.smCrypto.sm4 : null);
|
||||
|
||||
export const CloneDeep = (props) => {
|
||||
if (typeof props !== 'object' || props === null) {
|
||||
return props
|
||||
@@ -67,14 +69,14 @@ export const navTo = function(url, {
|
||||
onBack = null
|
||||
} = {}) {
|
||||
const userStore = useUserStore();
|
||||
if(isJumping) return
|
||||
isJumping=true
|
||||
if (isJumping) return
|
||||
isJumping = true
|
||||
if (needLogin && !userStore.hasLogin) {
|
||||
setTimeout(() => {
|
||||
uni.navigateTo({
|
||||
url: '/pages/login/login'
|
||||
});
|
||||
isJumping=false
|
||||
isJumping = false
|
||||
}, 170);
|
||||
return;
|
||||
}
|
||||
@@ -94,7 +96,7 @@ export const navTo = function(url, {
|
||||
uni.navigateTo({
|
||||
url: finalUrl
|
||||
});
|
||||
isJumping=false
|
||||
isJumping = false
|
||||
}, 170);
|
||||
};
|
||||
|
||||
@@ -553,11 +555,51 @@ function isEmptyObject(obj) {
|
||||
}
|
||||
|
||||
|
||||
export function sm4Decrypt(key, value, mode = "hex") {
|
||||
try {
|
||||
if (key.length !== 32) {
|
||||
alert('密钥必须是32位16进制字符串(128位)');
|
||||
return;
|
||||
}
|
||||
const decrypted = sm4.decrypt(value, key, {
|
||||
mode: 'ecb',
|
||||
cipherType: mode === 'hex' ? 'hex' : 'base64',
|
||||
padding: 'pkcs#5'
|
||||
});
|
||||
|
||||
return decrypted
|
||||
|
||||
} catch (e) {
|
||||
console.log('解密失败')
|
||||
}
|
||||
}
|
||||
|
||||
export function sm4Encrypt(key, value, mode = "hex") {
|
||||
try {
|
||||
|
||||
if (key.length !== 32) {
|
||||
alert('密钥必须是32位16进制字符串(128位)');
|
||||
return;
|
||||
}
|
||||
|
||||
const encrypted = sm4.encrypt(value, key, {
|
||||
mode: 'ecb',
|
||||
cipherType: mode === 'hex' ? 'hex' : 'base64',
|
||||
padding: 'pkcs#5'
|
||||
});
|
||||
|
||||
return encrypted
|
||||
|
||||
} catch (e) {
|
||||
console.log('加密失败')
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export const $api = {
|
||||
msg,
|
||||
prePage,
|
||||
sleep,
|
||||
request,
|
||||
createRequest,
|
||||
streamRequest,
|
||||
chatRequest,
|
||||
@@ -595,4 +637,5 @@ export default {
|
||||
insertSortData,
|
||||
isInWechatMiniProgramWebview,
|
||||
isEmptyObject,
|
||||
sm4Decrypt,
|
||||
}
|
||||
Reference in New Issue
Block a user