Merge remote-tracking branch 'origin/main' into bin

This commit is contained in:
2025-11-20 13:50:49 +08:00
15 changed files with 416 additions and 367 deletions

12
App.vue
View File

@@ -9,8 +9,7 @@ import config from '@/config.js';
onLaunch((options) => {
useUserStore().initSeesionId(); //更新
useDictStore().getDictData();
// uni.hideTabBar();
uni.hideTabBar();
// 登录
let token = uni.getStorageSync('token') || ''; // 同步获取 缓存信息
if (token) {
@@ -26,14 +25,7 @@ onLaunch((options) => {
}
});
onMounted(() => {
// #ifndef MP-WEIXIN
appendScriptTagElement('https://qd.zhaopinzao8dian.com/file/csn/jweixin-1.4.0.js').then(() => {
console.log('✅ 微信 JSSDK 加载完成');
// signatureFn();
});
// #endif
});
onMounted(() => {});
onShow(() => {
console.log('App Show');

View File

@@ -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,
}

View File

@@ -32,7 +32,7 @@
</template>
<script setup>
import { ref, reactive, computed, inject, nextTick, defineExpose, onMounted } from 'vue';
import { ref, reactive, computed, inject, nextTick, onMounted } from 'vue';
const { $api, navTo, setCheckedNodes, cloneDeep } = inject('globalFunction');
import useUserStore from '@/stores/useUserStore';
import { storeToRefs } from 'pinia';

View File

@@ -19,7 +19,7 @@
</template>
<script setup>
import { ref, defineProps, onMounted, computed } from 'vue';
import { ref, onMounted, computed } from 'vue';
import { useReadMsg } from '@/stores/useReadMsg';
const props = defineProps({
currentpage: {

View File

@@ -1,6 +1,9 @@
export default {
// baseUrl: 'http://39.98.44.136:8080', // 测试
baseUrl: 'https://qd.zhaopinzao8dian.com/api', // 测试
// baseUrl: 'http://10.133.17.161:8080/api', // 测试
// baseUrl: 'http://192.168.3.19:8080', // 测试
// baseUrl: 'http://39.98.44.136:6009', // 测试
// sseAI+
// StreamBaseURl: 'http://39.98.44.136:8000',
StreamBaseURl: 'https://qd.zhaopinzao8dian.com/ai',
@@ -13,7 +16,7 @@ export default {
// indexedDB
DBversion: 2,
// 只使用本地缓寸的数据
OnlyUseCachedDB: true,
OnlyUseCachedDB: false,
// 使用模拟定位
UsingSimulatedPositioning: true,
// 应用信息
@@ -69,5 +72,11 @@ export default {
title: '找工作,用 AI 更高效|青岛市智能求职平台',
desc: '融合海量岗位、智能简历匹配、竞争力分析,助你精准锁定理想职位!',
imgUrl: 'https://qd.zhaopinzao8dian.com/file/csn/qd_shareLogo.jpg',
},
sm4Config: {
key: '86C63180C1306ABC4D8F989E0A0BC9F3',
mode: 'ECB', // default
iv: 'UISwD9fW6cFh9SNS', // default is null
cipherType: 'base64' // default is base64
}
}

View File

@@ -24,7 +24,9 @@
vConsole.destroy();
</script> -->
<!-- 爱山东jssdk -->
<script type="text/javascript" src="https://isdapp.shandong.gov.cn/jmopen/jssdk/index.js"></script>
<!-- <script type="text/javascript" src="https://isdapp.shandong.gov.cn/jmopen/jssdk/index.js"></script> -->
<script type="module" src="./static/js/sm4.min.js"></script>
</head>
<!-- <body> -->
<div id="app"><!--app-html--></div>

View File

@@ -1,288 +1,284 @@
{
"pages": [
//pages数组中第一项表示应用启动页参考https://uniapp.dcloud.io/collocation/pages
{
"path": "pages/index/index",
"style": {
"navigationBarTitleText": "青岛智慧就业平台",
// #ifdef H5
"navigationStyle": "custom"
// #endif
}
},
{
"path": "pages/mine/mine",
"style": {
"navigationBarTitleText": "我的",
"navigationStyle": "custom"
}
},
{
"path": "pages/msglog/msglog",
"style": {
"navigationBarTitleText": "消息",
"navigationStyle": "custom",
"enablePullDownRefresh": false
}
},
{
"path": "pages/careerfair/careerfair",
"style": {
"navigationBarTitleText": "招聘会",
"navigationStyle": "custom"
}
},
{
"path": "pages/login/login",
"style": {
"navigationBarTitleText": "AI+就业服务程序",
"navigationStyle": "custom"
}
},
{
"path": "pages/nearby/nearby",
"style": {
"navigationBarTitleText": "附近",
"navigationBarBackgroundColor": "#4778EC",
"navigationBarTextStyle": "white",
"navigationStyle": "custom"
}
},
{
"path": "pages/chat/chat",
"style": {
"navigationBarTitleText": "AI+",
"navigationBarBackgroundColor": "#4778EC",
"navigationBarTextStyle": "white",
"enablePullDownRefresh": false,
// #ifdef H5
"navigationStyle": "custom"
//#endif
}
},
{
"path": "pages/search/search",
"style": {
"navigationBarTitleText": "",
"navigationStyle": "custom"
}
}
],
"subpackages": [
{
"root": "packageA",
"pages": [
"pages": [
//pages数组中第一项表示应用启动页参考https://uniapp.dcloud.io/collocation/pages
{
"path": "pages/choiceness/choiceness",
"style": {
"navigationBarTitleText": "精选",
"navigationBarBackgroundColor": "#4778EC",
"navigationBarTextStyle": "white",
"navigationStyle": "custom"
}
"path": "pages/index/index",
"style": {
"navigationBarTitleText": "青岛智慧就业平台",
// #ifdef H5
"navigationStyle": "custom"
// #endif
}
},
{
"path": "pages/post/post",
"style": {
"navigationBarTitleText": "职位详情",
"navigationBarBackgroundColor": "#4778EC",
"navigationBarTextStyle": "white",
"navigationStyle": "custom"
}
"path": "pages/mine/mine",
"style": {
"navigationBarTitleText": "我的",
"navigationStyle": "custom"
}
},
{
"path": "pages/UnitDetails/UnitDetails",
"style": {
"navigationBarTitleText": "单位详情",
"navigationBarBackgroundColor": "#4778EC",
"navigationBarTextStyle": "white",
"navigationStyle": "custom"
}
"path": "pages/msglog/msglog",
"style": {
"navigationBarTitleText": "消息",
"navigationStyle": "custom",
"enablePullDownRefresh": false
}
},
{
"path": "pages/exhibitors/exhibitors",
"style": {
"navigationBarTitleText": "参展单位",
"navigationBarBackgroundColor": "#4778EC",
"navigationBarTextStyle": "white",
"navigationStyle": "custom"
}
"path": "pages/careerfair/careerfair",
"style": {
"navigationBarTitleText": "招聘会",
"navigationStyle": "custom"
}
},
{
"path": "pages/myResume/myResume",
"style": {
"navigationBarTitleText": "我的简历",
"navigationBarBackgroundColor": "#FFFFFF",
"navigationStyle": "custom"
}
"path": "pages/login/login",
"style": {
"navigationBarTitleText": "AI+就业服务程序",
"navigationStyle": "custom"
}
},
{
"path": "pages/vCard/vCard",
"style": {
"navigationBarTitleText": "点子名片",
"navigationBarBackgroundColor": "#FFFFFF",
"navigationStyle": "custom"
}
"path": "pages/nearby/nearby",
"style": {
"navigationBarTitleText": "附近",
"navigationBarBackgroundColor": "#4778EC",
"navigationBarTextStyle": "white",
"navigationStyle": "custom"
}
},
{
"path": "pages/Intendedposition/Intendedposition",
"style": {
"navigationBarTitleText": "投递记录",
"navigationBarBackgroundColor": "#FFFFFF"
}
"path": "pages/chat/chat",
"style": {
"navigationBarTitleText": "AI+",
"navigationBarBackgroundColor": "#4778EC",
"navigationBarTextStyle": "white",
"enablePullDownRefresh": false,
// #ifdef H5
"navigationStyle": "custom"
//#endif
}
},
{
"path": "pages/collection/collection",
"style": {
"navigationBarTitleText": "我的收藏",
"navigationBarBackgroundColor": "#FFFFFF",
"navigationStyle": "custom"
}
},
{
"path": "pages/browseJob/browseJob",
"style": {
"navigationBarTitleText": "我的浏览",
"navigationBarBackgroundColor": "#FFFFFF",
"navigationStyle": "custom"
}
},
{
"path": "pages/addPosition/addPosition",
"style": {
"navigationBarTitleText": "添加岗位",
"navigationStyle": "custom"
}
},
{
"path": "pages/selectDate/selectDate",
"style": {
"navigationBarTitleText": "",
"navigationStyle": "custom"
}
},
{
"path": "pages/personalInfo/personalInfo",
"style": {
"navigationBarTitleText": "个人信息",
"navigationStyle": "custom"
}
},
{
"path": "pages/jobExpect/jobExpect",
"style": {
"navigationBarTitleText": "求职期望",
"navigationStyle": "custom"
}
},
{
"path": "pages/workExp/workExp",
"style": {
"navigationBarTitleText": "工作经历",
"navigationStyle": "custom"
}
},
{
"path": "pages/reservation/reservation",
"style": {
"navigationBarTitleText": "我的预约",
"navigationBarBackgroundColor": "#FFFFFF"
}
},
{
"path": "pages/choicenessList/choicenessList",
"style": {
"navigationBarTitleText": "精选企业",
"navigationBarBackgroundColor": "#FFFFFF",
"navigationStyle": "custom"
}
},
{
"path": "pages/newJobPosition/newJobPosition",
"style": {
"navigationBarTitleText": "新职位推荐",
"navigationBarBackgroundColor": "#FFFFFF"
}
},
{
"path": "pages/systemNotification/systemNotification",
"style": {
"navigationBarTitleText": "系统通知",
"navigationBarBackgroundColor": "#FFFFFF"
}
},
{
"path": "pages/tiktok/tiktok",
"style": {
"navigationBarTitleText": "",
"navigationBarBackgroundColor": "#FFFFFF",
"navigationStyle": "custom"
}
},
{
"path": "pages/moreJobs/moreJobs",
"style": {
"navigationBarTitleText": "更多岗位",
"navigationBarBackgroundColor": "#FFFFFF"
}
"path": "pages/search/search",
"style": {
"navigationBarTitleText": "",
"navigationStyle": "custom"
}
}
]
}
],
"tabBar": {
"custom": true,
"display": "none",
"color": "#5E5F60",
"selectedColor": "#256BFA",
"borderStyle": "black",
"backgroundColor": "#ffffff",
"midButton": {
"width": "50px",
"height": "50px",
"backgroundImage": "static/tabbar/logo2copy.png"
],
"subpackages": [{
"root": "packageA",
"pages": [{
"path": "pages/choiceness/choiceness",
"style": {
"navigationBarTitleText": "精选",
"navigationBarBackgroundColor": "#4778EC",
"navigationBarTextStyle": "white",
"navigationStyle": "custom"
}
},
{
"path": "pages/post/post",
"style": {
"navigationBarTitleText": "职位详情",
"navigationBarBackgroundColor": "#4778EC",
"navigationBarTextStyle": "white",
"navigationStyle": "custom"
}
},
{
"path": "pages/UnitDetails/UnitDetails",
"style": {
"navigationBarTitleText": "单位详情",
"navigationBarBackgroundColor": "#4778EC",
"navigationBarTextStyle": "white",
"navigationStyle": "custom"
}
},
{
"path": "pages/exhibitors/exhibitors",
"style": {
"navigationBarTitleText": "参展单位",
"navigationBarBackgroundColor": "#4778EC",
"navigationBarTextStyle": "white",
"navigationStyle": "custom"
}
},
{
"path": "pages/myResume/myResume",
"style": {
"navigationBarTitleText": "我的简历",
"navigationBarBackgroundColor": "#FFFFFF",
"navigationStyle": "custom"
}
},
{
"path": "pages/vCard/vCard",
"style": {
"navigationBarTitleText": "点子名片",
"navigationBarBackgroundColor": "#FFFFFF",
"navigationStyle": "custom"
}
},
{
"path": "pages/Intendedposition/Intendedposition",
"style": {
"navigationBarTitleText": "投递记录",
"navigationBarBackgroundColor": "#FFFFFF"
}
},
{
"path": "pages/collection/collection",
"style": {
"navigationBarTitleText": "我的收藏",
"navigationBarBackgroundColor": "#FFFFFF",
"navigationStyle": "custom"
}
},
{
"path": "pages/browseJob/browseJob",
"style": {
"navigationBarTitleText": "我的浏览",
"navigationBarBackgroundColor": "#FFFFFF",
"navigationStyle": "custom"
}
},
{
"path": "pages/addPosition/addPosition",
"style": {
"navigationBarTitleText": "添加岗位",
"navigationStyle": "custom"
}
},
{
"path": "pages/selectDate/selectDate",
"style": {
"navigationBarTitleText": "",
"navigationStyle": "custom"
}
},
{
"path": "pages/personalInfo/personalInfo",
"style": {
"navigationBarTitleText": "个人信息",
"navigationStyle": "custom"
}
},
{
"path": "pages/jobExpect/jobExpect",
"style": {
"navigationBarTitleText": "求职期望",
"navigationStyle": "custom"
}
},
{
"path": "pages/workExp/workExp",
"style": {
"navigationBarTitleText": "工作经历",
"navigationStyle": "custom"
}
},
{
"path": "pages/reservation/reservation",
"style": {
"navigationBarTitleText": "我的预约",
"navigationBarBackgroundColor": "#FFFFFF"
}
},
{
"path": "pages/choicenessList/choicenessList",
"style": {
"navigationBarTitleText": "精选企业",
"navigationBarBackgroundColor": "#FFFFFF",
"navigationStyle": "custom"
}
},
{
"path": "pages/newJobPosition/newJobPosition",
"style": {
"navigationBarTitleText": "新职位推荐",
"navigationBarBackgroundColor": "#FFFFFF"
}
},
{
"path": "pages/systemNotification/systemNotification",
"style": {
"navigationBarTitleText": "系统通知",
"navigationBarBackgroundColor": "#FFFFFF"
}
},
{
"path": "pages/tiktok/tiktok",
"style": {
"navigationBarTitleText": "",
"navigationBarBackgroundColor": "#FFFFFF",
"navigationStyle": "custom"
}
},
{
"path": "pages/moreJobs/moreJobs",
"style": {
"navigationBarTitleText": "更多岗位",
"navigationBarBackgroundColor": "#FFFFFF"
}
}
]
}],
"tabBar": {
"custom": true,
"display": "none",
"color": "#5E5F60",
"selectedColor": "#256BFA",
"borderStyle": "black",
"backgroundColor": "#ffffff",
"midButton": {
"width": "50px",
"height": "50px",
"backgroundImage": "static/tabbar/logo2copy.png"
},
"list": [{
"pagePath": "pages/index/index",
"iconPath": "static/tabbar/calendar.png",
"selectedIconPath": "static/tabbar/calendared.png",
"text": "职位"
},
{
"pagePath": "pages/careerfair/careerfair",
"iconPath": "static/tabbar/post.png",
"selectedIconPath": "static/tabbar/posted.png",
"text": "招聘会"
},
{
"pagePath": "pages/chat/chat",
"iconPath": "static/tabbar/logo3.png",
"selectedIconPath": "static/tabbar/logo3.png"
},
{
"pagePath": "pages/msglog/msglog",
"iconPath": "static/tabbar/chat4.png",
"selectedIconPath": "static/tabbar/chat4ed.png",
"text": "消息"
},
{
"pagePath": "pages/mine/mine",
"iconPath": "static/tabbar/mine.png",
"selectedIconPath": "static/tabbar/mined.png",
"text": "我的"
}
]
},
"list": [
{
"pagePath": "pages/index/index",
"iconPath": "static/tabbar/calendar.png",
"selectedIconPath": "static/tabbar/calendared.png",
"text": "职位"
},
{
"pagePath": "pages/careerfair/careerfair",
"iconPath": "static/tabbar/post.png",
"selectedIconPath": "static/tabbar/posted.png",
"text": "招聘会"
},
{
"pagePath": "pages/chat/chat",
"iconPath": "static/tabbar/logo3.png",
"selectedIconPath": "static/tabbar/logo3.png"
},
{
"pagePath": "pages/msglog/msglog",
"iconPath": "static/tabbar/chat4.png",
"selectedIconPath": "static/tabbar/chat4ed.png",
"text": "消息"
},
{
"pagePath": "pages/mine/mine",
"iconPath": "static/tabbar/mine.png",
"selectedIconPath": "static/tabbar/mined.png",
"text": "我的"
}
]
},
"globalStyle": {
"navigationBarTextStyle": "black",
"navigationBarTitleText": "uni-app",
"navigationBarBackgroundColor": "#F8F8F8",
"backgroundColor": "#F8F8F8",
// "enablePullDownRefresh": false,
// "navigationStyle": "custom",
"rpxCalcBaseDeviceWidth": 375,
"rpxCalcMaxDeviceWidth": 750,
"rpxCalcIncludeWidth": 750
},
"uniIdRouter": {}
"globalStyle": {
"navigationBarTextStyle": "black",
"navigationBarTitleText": "uni-app",
"navigationBarBackgroundColor": "#F8F8F8",
"backgroundColor": "#F8F8F8",
// "enablePullDownRefresh": false,
// "navigationStyle": "custom",
"rpxCalcBaseDeviceWidth": 375,
"rpxCalcMaxDeviceWidth": 750,
"rpxCalcIncludeWidth": 750
},
"uniIdRouter": {}
}

View File

@@ -250,8 +250,6 @@ import {
ref,
inject,
nextTick,
defineProps,
defineEmits,
onMounted,
onUnmounted,
toRaw,
@@ -448,7 +446,7 @@ const scrollToBottom = throttle(function () {
}, 500);
function getGuess() {
$api.chatRequest('/guest', { sessionId: chatSessionID.value }, 'POST').then((res) => {
$api.chatRequest('/app/chat/guest', { sessionId: chatSessionID.value }, 'POST').then((res) => {
guessList.value = res.data;
showGuess.value = true;
nextTick(() => {

View File

@@ -37,7 +37,7 @@
</template>
<script setup>
import { ref, inject, defineEmits } from 'vue';
import { ref, inject } from 'vue';
const emit = defineEmits(['onSend']);
const { $api } = inject('globalFunction');
const popup = ref(null);

View File

@@ -109,6 +109,7 @@
</template>
</tabcontrolVue>
<SelectJobs ref="selectJobsModel"></SelectJobs>
<view class="backdoor" @click="loginbackdoor">后门</view>
</AppLayout>
</template>
@@ -149,7 +150,7 @@ const fromValue = reactive({
});
onLoad((parmas) => {
getTreeselect();
// getTreeselect();
});
onMounted(() => {});
@@ -243,6 +244,23 @@ function getTreeselect() {
});
}
function loginbackdoor() {
$api.createRequest('/app/mock/login', {}, 'post').then((resData) => {
$api.msg('模拟帐号密码测试登录成功');
loginSetToken(resData.token).then((resume) => {
if (resume.data.jobTitleId) {
// 设置推荐列表,每次退出登录都需要更新
useUserStore().initSeesionId();
uni.reLaunch({
url: '/pages/index/index',
});
} else {
nextStep();
}
});
});
}
// 登录
function loginTest() {
// uni.share({
@@ -289,6 +307,12 @@ function complete() {
</script>
<style lang="stylus" scoped>
.backdoor{
position: fixed;
left: 0;
top: 500rpx;
background: red
}
.input-nx
position: relative
border-bottom: 2rpx solid #EBEBEB

View File

@@ -45,9 +45,7 @@
<text v-if="userInfo.jobTitle.length - 1 !== index">|</text>
</text>
</view>
<view class="top-btn button-click" >
电子名片
</view>
<view class="top-btn button-click">电子名片</view>
</view>
<view class="card-main">
<view class="main-title">服务专区</view>
@@ -132,7 +130,6 @@ const isAbove90 = (percent) => parseFloat(percent) < 90;
function getUserstatistics() {
$api.createRequest('/app/user/statistics').then((resData) => {
console.log(resData);
counts.value = resData.data;
});
}

7
static/js/sm4.min.js vendored Normal file

File diff suppressed because one or more lines are too long

View File

@@ -180,7 +180,7 @@ const useChatGroupDBStore = defineStore("messageGroup", () => {
resolve();
}
$api.streamRequest('/chat', params, onDataReceived, onError, onComplete);
$api.streamRequest('/app/chat/chat', params, onDataReceived, onError, onComplete);
} catch (err) {
console.log(err);
reject(err);
@@ -230,7 +230,7 @@ const useChatGroupDBStore = defineStore("messageGroup", () => {
// 云端数据
function getHistory() {
$api.chatRequest('/getHistory').then((res) => {
$api.chatRequest('/app/chat/getHistory').then((res) => {
if (!res.data.list.length) return
let tabel = parseHistory(res.data.list)
if (tabel && tabel.length) {
@@ -250,7 +250,7 @@ const useChatGroupDBStore = defineStore("messageGroup", () => {
const params = {
sessionId: chatSessionID.value
}
$api.chatRequest('/detail', params, 'GET', loading).then((res) => {
$api.chatRequest('/app/chat/detail', params, 'GET', loading).then((res) => {
let list = parseHistoryDetail(res.data.list, chatSessionID.value)
if (list.length) {
baseDB.db.add(massageName.value, list).then((ids) => {

View File

@@ -1,69 +1,20 @@
import config from "@/config.js"
import useUserStore from '@/stores/useUserStore';
export function request({
url,
method = 'GET',
data = {},
load = false,
header = {}
} = {}) {
import {
sm4Decrypt,
sm4Encrypt
} from '../common/globalFunction';
return new Promise((resolve, reject) => {
if (load) {
uni.showLoading({
title: '请稍候',
mask: true
});
}
let Authorization = ''
if (useUserStore().token) {
Authorization = `${useUserStore().userInfo.token}${useUserStore().token}`
}
uni.request({
url: config.baseUrl + url,
method,
data: data,
header: {
'Authorization': Authorization || '',
},
success: resData => {
// 响应拦截
if (resData.statusCode === 200) {
const {
code,
msg
} = resData.data
if (code === 200) {
resolve(resData.data)
return
}
uni.showToast({
title: msg,
icon: 'none'
})
}
if (resData.data?.code === 401 || resData.data?.code === 402) {
useUserStore().logOut()
uni.showToast({
title: '登录过期,请重新登录',
icon: 'none'
})
return
}
const err = new Error('请求出现异常,请联系工作人员')
err.error = resData
reject(err)
},
fail: err => reject(err),
complete() {
if (load) {
uni.hideLoading();
}
}
})
})
}
const needToEncrypt = [
["post", "/app/login"],
["get", "/app/user/resume"],
["post", "/app/user/resume"],
["post", "/app/user/experience/edit"],
["post", "/app/user/experience/delete"],
["get", "/app/user/experience/getSingle/{value}"],
["get", "/app/user/experience/list"]
]
/**
* @param url String请求的地址默认none
@@ -87,15 +38,44 @@ export function createRequest(url, data = {}, method = 'GET', loading = false, h
const header = headers || {};
header["Authorization"] = encodeURIComponent(Authorization);
// ------------------------------------------------------------------
// 检查当前请求是否需要加密
const isEncrypt = needToEncrypt.some(item => {
const matchMethod = item[0].toLowerCase() === method.toLowerCase();
const matchUrl = item[1].includes('{') ?
url.startsWith(item[1].split('/{')[0]) // 检查动态路径的前缀
:
item[1] === url; // 检查静态路径
return matchMethod && matchUrl;
});
let requestData = data;
if (isEncrypt) {
const jsonData = JSON.stringify(data);
const encryptedBody = sm4Encrypt(config.sm4Config.key, jsonData);
requestData = {
encrypted: true,
encryptedData: encryptedBody,
timestamp: Date.now()
};
}
// ------------------------------------------------------------------
return new Promise((resolve, reject) => {
uni.request({
url: config.baseUrl + url,
method: method,
data: data,
data: requestData,
header,
success: resData => {
// 响应拦截
if (resData.statusCode === 200) {
if (resData.data.encrypted) {
const decryptedData = sm4Decrypt(config
.sm4Config.key, resData.data.encryptedData)
resData.data = JSON.parse(decryptedData)
}
const {
code,
msg

View File

@@ -17,7 +17,7 @@ export default function StreamRequest(url, data = {}, onDataReceived, onError, o
};
return new Promise(async (resolve, reject) => {
try {
const response = await fetch(config.StreamBaseURl + url, {
const response = await fetch(config.baseUrl + url, {
method: "POST",
headers,
body: JSON.stringify(data)
@@ -46,6 +46,7 @@ export default function StreamRequest(url, data = {}, onDataReceived, onError, o
let lines = buffer.split("\n");
buffer = lines.pop(); // 可能是不完整的 JSON 片段,留待下次解析
for (let line of lines) {
line = line.slice(5).trim()
if (line.startsWith("data: ")) {
const jsonData = line.slice(6).trim();
if (jsonData === "[DONE]") {
@@ -104,7 +105,7 @@ export function chatRequest(url, data = {}, method = 'GET', loading = false, hea
header["Authorization"] = encodeURIComponent(Authorization);
return new Promise((resolve, reject) => {
uni.request({
url: config.StreamBaseURl + url,
url: config.baseUrl + url,
method: method,
data: data,
header,