AI模块联调

This commit is contained in:
francis_fh
2026-01-22 18:58:19 +08:00
parent 4dce6d3e39
commit b92e3b8adb
23 changed files with 424 additions and 453 deletions

View File

@@ -72,18 +72,18 @@ export const navTo = function(url, {
const pages = getCurrentPages(); const pages = getCurrentPages();
if (pages.length >= 10) { if (pages.length >= 10) {
uni.redirectTo({ uni.redirectTo({
url: '/pages/complete-info/complete-info', url: '/packageA/pages/complete-info/complete-info',
fail: (err) => { fail: (err) => {
console.error('页面跳转失败:', err); console.error('页面跳转失败:', err);
} }
}); });
} else { } else {
uni.navigateTo({ uni.navigateTo({
url: '/pages/complete-info/complete-info', url: '/packageA/pages/complete-info/complete-info',
fail: (err) => { fail: (err) => {
console.error('页面跳转失败:', err); console.error('页面跳转失败:', err);
uni.redirectTo({ uni.redirectTo({
url: '/pages/complete-info/complete-info', url: '/packageA/pages/complete-info/complete-info',
fail: (err2) => { fail: (err2) => {
console.error('redirectTo也失败:', err2); console.error('redirectTo也失败:', err2);
} }

View File

@@ -104,7 +104,7 @@ const generateTabbarList = () => {
baseItems.splice(1, 0, { baseItems.splice(1, 0, {
id: 1, id: 1,
text: '发布岗位', text: '发布岗位',
path: '/pages/job/publishJob', path: '/packageA/pages/job/publishJob',
iconPath: '/static/tabbar/post.png', iconPath: '/static/tabbar/post.png',
selectedIconPath: '/static/tabbar/posted.png', selectedIconPath: '/static/tabbar/posted.png',
centerItem: false, centerItem: false,
@@ -173,7 +173,7 @@ const switchTab = (item, index) => {
// 检查是否为需要登录的页面 // 检查是否为需要登录的页面
const loginRequiredPages = [ const loginRequiredPages = [
'/pages/job/publishJob', '/packageA/pages/job/publishJob',
'/pages/mine/mine', '/pages/mine/mine',
'/pages/mine/company-mine' '/pages/mine/company-mine'
]; ];
@@ -190,7 +190,7 @@ const switchTab = (item, index) => {
} }
// 已登录,处理特定页面的逻辑 // 已登录,处理特定页面的逻辑
if (item.path === '/pages/job/publishJob') { if (item.path === '/packageA/pages/job/publishJob') {
// 检查企业信息是否完整 // 检查企业信息是否完整
const cachedUserInfo = uni.getStorageSync('userInfo') || {}; const cachedUserInfo = uni.getStorageSync('userInfo') || {};
const storeUserInfo = userInfo.value || {}; const storeUserInfo = userInfo.value || {};
@@ -200,12 +200,12 @@ const switchTab = (item, index) => {
if (!currentUserInfo.company || currentUserInfo.company === null) { if (!currentUserInfo.company || currentUserInfo.company === null) {
// 企业信息为空,跳转到企业信息补全页面 // 企业信息为空,跳转到企业信息补全页面
uni.navigateTo({ uni.navigateTo({
url: '/pages/complete-info/company-info', url: '/packageA/pages/complete-info/company-info',
}); });
} else { } else {
// 企业信息完整,跳转到发布岗位页面 // 企业信息完整,跳转到发布岗位页面
uni.navigateTo({ uni.navigateTo({
url: '/pages/job/publishJob', url: '/packageA/pages/job/publishJob',
}); });
} }

View File

@@ -110,7 +110,7 @@ const generateTabbarList = () => {
baseItems.splice(1, 0, { baseItems.splice(1, 0, {
id: 1, id: 1,
text: '发布岗位', text: '发布岗位',
path: '/pages/job/publishJob', path: '/packageA/pages/job/publishJob',
iconPath: '../../static/tabbar/post.png', iconPath: '../../static/tabbar/post.png',
selectedIconPath: '../../static/tabbar/posted.png', selectedIconPath: '../../static/tabbar/posted.png',
centerItem: false, centerItem: false,

View File

@@ -188,12 +188,12 @@ const getPhoneNumber = (e) => {
if (userType.value === 1 && !resData.idCard) { if (userType.value === 1 && !resData.idCard) {
// 求职者跳转到个人信息补全页面 // 求职者跳转到个人信息补全页面
uni.navigateTo({ uni.navigateTo({
url: '/pages/complete-info/complete-info?step=1' url: '/packageA/pages/complete-info/complete-info?step=1'
}); });
} else if (userType.value === 0 && !resData.idCard) { } else if (userType.value === 0 && !resData.idCard) {
// 招聘者跳转到企业信息补全页面 // 招聘者跳转到企业信息补全页面
uni.navigateTo({ uni.navigateTo({
url: '/pages/complete-info/company-info' url: '/packageA/pages/complete-info/company-info'
}); });
} }
} }
@@ -271,12 +271,12 @@ const wxLogin = () => {
if (userType.value === 1) { if (userType.value === 1) {
// 求职者跳转到个人信息补全页面 // 求职者跳转到个人信息补全页面
uni.navigateTo({ uni.navigateTo({
url: '/pages/complete-info/complete-info?step=1' url: '/packageA/pages/complete-info/complete-info?step=1'
}); });
} else if (userType.value === 0) { } else if (userType.value === 0) {
// 招聘者跳转到企业信息补全页面 // 招聘者跳转到企业信息补全页面
uni.navigateTo({ uni.navigateTo({
url: '/pages/complete-info/company-info' url: '/packageA/pages/complete-info/company-info'
}); });
} }
} }
@@ -325,12 +325,12 @@ const testLogin = () => {
if (userType.value === 1) { if (userType.value === 1) {
// 求职者跳转到个人信息补全页面 // 求职者跳转到个人信息补全页面
uni.navigateTo({ uni.navigateTo({
url: '/pages/complete-info/complete-info?step=1' url: '/packageA/pages/complete-info/complete-info?step=1'
}); });
} else if (userType.value === 0) { } else if (userType.value === 0) {
// 招聘者跳转到企业信息补全页面 // 招聘者跳转到企业信息补全页面
uni.navigateTo({ uni.navigateTo({
url: '/pages/complete-info/company-info' url: '/packageA/pages/complete-info/company-info'
}); });
} }
} }

View File

@@ -1,297 +1,195 @@
import { import {
ref, ref,
onUnmounted, onUnmounted,
onBeforeUnmount, onBeforeUnmount,
onMounted onMounted
} from 'vue' } from 'vue'
import { import {
onHide, onHide,
onUnload onUnload
} from '@dcloudio/uni-app' } from '@dcloudio/uni-app'
import WavDecoder from '@/lib/wav-decoder@1.3.0.js' import WavDecoder from '@/lib/wav-decoder@1.3.0.js'
export function useTTSPlayer(wsUrl) { export function useTTSPlayer(httpUrl) {
const isSpeaking = ref(false) const isSpeaking = ref(false)
const isPaused = ref(false) const isPaused = ref(false)
const isComplete = ref(false) const isComplete = ref(false)
// #ifdef H5 // #ifdef H5
const audioContext = typeof window !== 'undefined' && (window.AudioContext || window.webkitAudioContext) const audioContext = typeof window !== 'undefined' && (window.AudioContext || window.webkitAudioContext)
? new(window.AudioContext || window.webkitAudioContext)() ? new(window.AudioContext || window.webkitAudioContext)()
: null : null
// #endif // #endif
// #ifdef MP-WEIXIN // #ifdef MP-WEIXIN
const audioContext = null // 微信小程序不支持 AudioContext const audioContext = null // 微信小程序不支持 AudioContext
// #endif // #endif
let playTime = audioContext ? audioContext.currentTime : 0 let currentAudioBuffer = null
let sourceNodes = [] let currentSource = null
let socket = null let playTimeOffset = 0
let sampleRate = 16000
let numChannels = 1 const speak = async (text) => {
let isHeaderDecoded = false if (!audioContext) {
let pendingText = null console.warn('⚠️ TTS not supported in current environment');
return;
let currentPlayId = 0 }
let activePlayId = 0
console.log('🎤 TTS speak function called');
const speak = (text) => { console.log('📝 Text to synthesize:', text ? text.substring(0, 100) + '...' : 'No text');
if (!audioContext) { console.log('🔗 HTTP URL:', httpUrl);
console.warn('⚠️ TTS not supported in current environment');
return; // 停止当前播放
} stop()
console.log('🎤 TTS speak function called'); try {
console.log('📝 Text to synthesize:', text ? text.substring(0, 100) + '...' : 'No text'); // 提取要合成的文本
console.log('🔗 WebSocket URL:', wsUrl); const speechText = extractSpeechText(text)
console.log('📤 Sending text to TTS server via GET:', speechText.substring(0, 100) + '...');
currentPlayId++
const myPlayId = currentPlayId // 构建GET请求URL
console.log('🆔 Play ID:', myPlayId); const url = `${httpUrl}?text=${encodeURIComponent(speechText)}`
console.log('🔗 Final GET URL:', url);
reset()
pendingText = text // 发送GET请求获取语音数据
activePlayId = myPlayId const response = await fetch(url)
if (!response.ok) {
console.log('✅ Speak function setup complete'); throw new Error(`HTTP error! status: ${response.status}`)
} }
const pause = () => { // 获取二进制数据
if (!audioContext) { const arrayBuffer = await response.arrayBuffer()
console.warn('⚠️ TTS not supported in current environment'); console.log('✅ Received audio data, size:', arrayBuffer.byteLength + ' bytes');
return;
} // 解码音频数据
const decoded = await WavDecoder.decode(arrayBuffer)
console.log('⏸️ TTS pause called'); console.log('✅ Audio decoded, sampleRate:', decoded.sampleRate, 'channels:', decoded.channelData.length);
console.log('🔊 AudioContext state:', audioContext.state);
console.log('🔊 Is speaking before pause:', isSpeaking.value); // 播放音频
console.log('⏸️ Is paused before pause:', isPaused.value); playDecodedAudio(decoded)
} catch (error) {
if (audioContext.state === 'running') { console.error('❌ TTS synthesis failed:', error);
audioContext.suspend() isSpeaking.value = false
isPaused.value = true isComplete.value = false
// 不要设置 isSpeaking.value = false保持当前状态 }
console.log('✅ Audio paused successfully'); }
} else {
console.log('⚠️ AudioContext is not running, cannot pause'); const playDecodedAudio = (decoded) => {
} if (!audioContext) return;
console.log('🔊 Is speaking after pause:', isSpeaking.value); // 使用第一个声道的数据
console.log('⏸️ Is paused after pause:', isPaused.value); const audioBuffer = audioContext.createBuffer(1, decoded.channelData[0].length, decoded.sampleRate)
} audioBuffer.copyToChannel(decoded.channelData[0], 0)
const resume = () => { currentAudioBuffer = audioBuffer
if (!audioContext) {
console.warn('⚠️ TTS not supported in current environment'); // 创建音频源
return; currentSource = audioContext.createBufferSource()
} currentSource.buffer = audioBuffer
currentSource.connect(audioContext.destination)
console.log('▶️ TTS resume called');
console.log('🔊 AudioContext state:', audioContext.state); // 监听播放结束
console.log('🔊 Is speaking before resume:', isSpeaking.value); currentSource.onended = () => {
console.log('⏸️ Is paused before resume:', isPaused.value); console.log('🎵 Audio playback completed');
isSpeaking.value = false
if (audioContext.state === 'suspended') { isComplete.value = true
audioContext.resume() }
isPaused.value = false
isSpeaking.value = true // 开始播放
console.log('✅ Audio resumed successfully'); currentSource.start()
} else { isSpeaking.value = true
console.log('⚠️ AudioContext is not suspended, cannot resume'); isPaused.value = false
} isComplete.value = false
console.log('<27> Audio playback started');
console.log('🔊 Is speaking after resume:', isSpeaking.value); }
console.log('⏸️ Is paused after resume:', isPaused.value);
} const pause = () => {
if (!audioContext || !isSpeaking.value || isPaused.value) {
const cancelAudio = () => { console.warn('⚠️ Cannot pause TTS playback');
stop() return;
} }
const stop = () => { console.log('⏸️ TTS pause called');
isSpeaking.value = false
isPaused.value = false if (audioContext.state === 'running') {
isComplete.value = false audioContext.suspend()
playTime = audioContext ? audioContext.currentTime : 0 isPaused.value = true
// 保存当前播放位置
sourceNodes.forEach(node => { playTimeOffset = audioContext.currentTime
try { console.log('✅ Audio paused successfully');
node.stop() }
node.disconnect() }
} catch (e) {}
}) const resume = () => {
sourceNodes = [] if (!audioContext || !isSpeaking.value || !isPaused.value) {
console.warn('⚠️ Cannot resume TTS playback');
if (socket) { return;
socket.close() }
socket = null
} console.log('▶️ TTS resume called');
isHeaderDecoded = false if (audioContext.state === 'suspended') {
pendingText = null audioContext.resume()
} isPaused.value = false
console.log('✅ Audio resumed successfully');
const reset = () => { }
stop() }
isSpeaking.value = false
isPaused.value = false const cancelAudio = () => {
isComplete.value = false stop()
playTime = audioContext ? audioContext.currentTime : 0 }
initWebSocket()
} const stop = () => {
console.log('⏹️ TTS stop called');
const initWebSocket = () => {
if (!audioContext) { if (currentSource) {
console.warn('⚠️ WebSocket TTS not supported in current environment'); try {
return; currentSource.stop()
} currentSource.disconnect()
} catch (e) {
const thisPlayId = currentPlayId console.error('❌ Error stopping audio source:', e);
console.log('🔌 Initializing WebSocket connection'); }
console.log('🔗 WebSocket URL:', wsUrl); currentSource = null
console.log('🆔 This play ID:', thisPlayId); }
socket = new WebSocket(wsUrl) if (audioContext && audioContext.state === 'running') {
socket.binaryType = 'arraybuffer' try {
audioContext.suspend()
// 设置心跳检测,避免超时 } catch (e) {
const heartbeatInterval = setInterval(() => { console.error('❌ Error suspending audio context:', e);
if (socket && socket.readyState === WebSocket.OPEN) { }
socket.send(JSON.stringify({ type: 'ping' })); }
}
}, 30000); // 每30秒发送一次心跳 isSpeaking.value = false
isPaused.value = false
socket.onopen = () => { isComplete.value = false
console.log('✅ WebSocket connection opened'); currentAudioBuffer = null
if (pendingText && thisPlayId === activePlayId) { playTimeOffset = 0
const seepdText = extractSpeechText(pendingText)
console.log('📤 Sending text to TTS server:', seepdText.substring(0, 100) + '...'); console.log('✅ TTS playback stopped');
socket.send(seepdText) }
pendingText = null
} else { onUnmounted(() => {
console.log('❌ No pending text or play ID mismatch'); stop()
console.log('📝 Pending text exists:', !!pendingText); })
console.log('🆔 Play ID match:', thisPlayId === activePlayId);
} // 页面刷新/关闭时
} onMounted(() => {
if (typeof window !== 'undefined') {
socket.onerror = (error) => { window.addEventListener('beforeunload', cancelAudio)
console.error('❌ WebSocket error:', error); }
} })
socket.onclose = (event) => { onBeforeUnmount(() => {
console.log('🔌 WebSocket connection closed:', event.code, event.reason); cancelAudio()
clearInterval(heartbeatInterval); if (typeof window !== 'undefined') {
} window.removeEventListener('beforeunload', cancelAudio)
}
socket.onmessage = async (e) => { })
if (thisPlayId !== activePlayId) return // 忽略旧播放的消息
onHide(cancelAudio)
if (typeof e.data === 'string') { onUnload(cancelAudio)
try {
const msg = JSON.parse(e.data)
console.log('📨 TTS server message:', msg);
if (msg.status === 'complete') {
console.log('✅ TTS synthesis completed');
isComplete.value = true
// 计算剩余播放时间,确保播放完整
const remainingTime = audioContext ? Math.max(0, (playTime - audioContext.currentTime) * 1000) : 0;
console.log('⏱️ Remaining play time:', remainingTime + 'ms');
setTimeout(() => {
if (thisPlayId === activePlayId) {
console.log('🔇 TTS playback finished, setting isSpeaking to false');
isSpeaking.value = false
}
}, remainingTime + 500) // 额外500ms缓冲时间
}
} catch (e) {
console.log('[TTSPlayer] 文本消息:', e.data)
}
} else if (e.data instanceof ArrayBuffer) {
if (!isHeaderDecoded) {
try {
const decoded = await WavDecoder.decode(e.data)
sampleRate = decoded.sampleRate
numChannels = decoded.channelData.length
decoded.channelData.forEach((channel, i) => {
const audioBuffer = audioContext.createBuffer(1, channel.length,
sampleRate)
audioBuffer.copyToChannel(channel, 0)
playBuffer(audioBuffer)
})
isHeaderDecoded = true
} catch (err) {
console.error('WAV 解码失败:', err)
}
} else {
const pcm = new Int16Array(e.data)
const audioBuffer = pcmToAudioBuffer(pcm, sampleRate, numChannels)
playBuffer(audioBuffer)
}
}
}
}
const pcmToAudioBuffer = (pcm, sampleRate, numChannels) => {
if (!audioContext) return null;
const length = pcm.length / numChannels
const audioBuffer = audioContext.createBuffer(numChannels, length, sampleRate)
for (let ch = 0; ch < numChannels; ch++) {
const channelData = audioBuffer.getChannelData(ch)
for (let i = 0; i < length; i++) {
const sample = pcm[i * numChannels + ch]
channelData[i] = sample / 32768
}
}
return audioBuffer
}
const playBuffer = (audioBuffer) => {
if (!audioContext || !audioBuffer) return;
console.log('🎵 playBuffer called, duration:', audioBuffer.duration + 's');
if (!isSpeaking.value) {
playTime = audioContext.currentTime
console.log('🎵 Starting new audio playback at time:', playTime);
}
const source = audioContext.createBufferSource()
source.buffer = audioBuffer
source.connect(audioContext.destination)
source.start(playTime)
sourceNodes.push(source)
playTime += audioBuffer.duration
isSpeaking.value = true
console.log('🎵 Audio scheduled, new playTime:', playTime);
// 添加音频播放结束监听
source.onended = () => {
console.log('🎵 Audio buffer finished playing');
}
}
onUnmounted(() => {
stop()
})
// 页面刷新/关闭时
onMounted(() => {
if (typeof window !== 'undefined') {
window.addEventListener('beforeunload', cancelAudio)
}
})
onBeforeUnmount(() => {
cancelAudio()
if (typeof window !== 'undefined') {
window.removeEventListener('beforeunload', cancelAudio)
}
})
onHide(cancelAudio)
onUnload(cancelAudio)
return { return {
speak, speak,
pause, pause,
@@ -300,68 +198,68 @@ export function useTTSPlayer(wsUrl) {
isSpeaking, isSpeaking,
isPaused, isPaused,
isComplete isComplete
} }
} }
function extractSpeechText(markdown) { function extractSpeechText(markdown) {
console.log('🔍 extractSpeechText called'); console.log('🔍 extractSpeechText called');
console.log('📝 Input markdown length:', markdown ? markdown.length : 0); console.log('📝 Input markdown length:', markdown ? markdown.length : 0);
console.log('📝 Input markdown preview:', markdown ? markdown.substring(0, 200) + '...' : 'No markdown'); console.log('📝 Input markdown preview:', markdown ? markdown.substring(0, 200) + '...' : 'No markdown');
const jobRegex = /``` job-json\s*({[\s\S]*?})\s*```/g; const jobRegex = /``` job-json\s*({[\s\S]*?})\s*```/g;
const jobs = []; const jobs = [];
let match; let match;
let lastJobEndIndex = 0; let lastJobEndIndex = 0;
let firstJobStartIndex = -1; let firstJobStartIndex = -1;
// 提取岗位 json 数据及前后位置 // 提取岗位 json 数据及前后位置
while ((match = jobRegex.exec(markdown)) !== null) { while ((match = jobRegex.exec(markdown)) !== null) {
const jobStr = match[1]; const jobStr = match[1];
try { try {
const job = JSON.parse(jobStr); const job = JSON.parse(jobStr);
jobs.push(job); jobs.push(job);
if (firstJobStartIndex === -1) { if (firstJobStartIndex === -1) {
firstJobStartIndex = match.index; firstJobStartIndex = match.index;
} }
lastJobEndIndex = jobRegex.lastIndex; lastJobEndIndex = jobRegex.lastIndex;
console.log('✅ Found job:', job.jobTitle); console.log('✅ Found job:', job.jobTitle);
} catch (e) { } catch (e) {
console.warn('JSON 解析失败', e); console.warn('JSON 解析失败', e);
} }
} }
console.log('📊 Jobs found:', jobs.length); console.log('📊 Jobs found:', jobs.length);
console.log('📍 First job start index:', firstJobStartIndex); console.log('📍 First job start index:', firstJobStartIndex);
console.log('📍 Last job end index:', lastJobEndIndex); console.log('📍 Last job end index:', lastJobEndIndex);
// 提取引导语(第一个 job-json 之前的文字) // 提取引导语(第一个 job-json 之前的文字)
const guideText = firstJobStartIndex > 0 ? const guideText = firstJobStartIndex > 0 ?
markdown.slice(0, firstJobStartIndex).trim() : markdown.slice(0, firstJobStartIndex).trim() :
''; '';
// 提取结束语(最后一个 job-json 之后的文字) // 提取结束语(最后一个 job-json 之后的文字)
const endingText = lastJobEndIndex < markdown.length ? const endingText = lastJobEndIndex < markdown.length ?
markdown.slice(lastJobEndIndex).trim() : markdown.slice(lastJobEndIndex).trim() :
''; '';
console.log('📝 Guide text:', guideText); console.log('📝 Guide text:', guideText);
console.log('📝 Ending text:', endingText); console.log('📝 Ending text:', endingText);
// 岗位信息格式化为语音文本 // 岗位信息格式化为语音文本
const jobTexts = jobs.map((job, index) => { const jobTexts = jobs.map((job, index) => {
return `${index + 1} 个岗位,岗位名称是:${job.jobTitle},公司是:${job.companyName},薪资:${job.salary},地点:${job.location},学历要求:${job.education},经验要求:${job.experience}`; return `${index + 1} 个岗位,岗位名称是:${job.jobTitle},公司是:${job.companyName},薪资:${job.salary},地点:${job.location},学历要求:${job.education},经验要求:${job.experience}`;
}); });
// 拼接总语音内容 // 拼接总语音内容
const finalTextParts = []; const finalTextParts = [];
if (guideText) finalTextParts.push(guideText); if (guideText) finalTextParts.push(guideText);
finalTextParts.push(...jobTexts); finalTextParts.push(...jobTexts);
if (endingText) finalTextParts.push(endingText); if (endingText) finalTextParts.push(endingText);
const finalText = finalTextParts.join('\n'); const finalText = finalTextParts.join('\n');
console.log('🎤 Final TTS text length:', finalText.length); console.log('🎤 Final TTS text length:', finalText.length);
console.log('🎤 Final TTS text preview:', finalText.substring(0, 200) + '...'); console.log('🎤 Final TTS text preview:', finalText.substring(0, 200) + '...');
console.log('🎤 Final TTS text parts count:', finalTextParts.length); console.log('🎤 Final TTS text parts count:', finalTextParts.length);
return finalText; return finalText;
} }

16
main.js
View File

@@ -14,15 +14,7 @@ import AppLayout from './components/AppLayout/AppLayout.vue';
import Empty from './components/empty/empty.vue'; import Empty from './components/empty/empty.vue';
import NoBouncePage from '@/components/NoBouncePage/NoBouncePage.vue' import NoBouncePage from '@/components/NoBouncePage/NoBouncePage.vue'
import MsgTips from '@/components/MsgTips/MsgTips.vue' import MsgTips from '@/components/MsgTips/MsgTips.vue'
import SelectPopup from '@/components/selectPopup/selectPopup.vue'
import SelectPopupPlugin from '@/components/selectPopup/selectPopupPlugin'; import SelectPopupPlugin from '@/components/selectPopup/selectPopupPlugin';
import RenderJobs from '@/components/renderJobs/renderJobs.vue';
import RenderCompanys from '@/components/renderCompanys/renderCompanys.vue';
import uniIcons from './uni_modules/uni-icons/components/uni-icons/uni-icons.vue'
import uniPopup from './uni_modules/uni-popup/components/uni-popup/uni-popup.vue'
import uniDataSelect from './uni_modules/uni-data-select/components/uni-data-select/uni-data-select.vue'
import uniSwipeAction from './uni_modules/uni-swipe-action/components/uni-swipe-action/uni-swipe-action.vue'
import uniSwipeActionItem from './uni_modules/uni-swipe-action/components/uni-swipe-action-item/uni-swipe-action-item.vue'
import storeRc from './utilsRc/store/index.js' import storeRc from './utilsRc/store/index.js'
import {processFileUrl,} from '@/utilsRc/common.js' import {processFileUrl,} from '@/utilsRc/common.js'
// iconfont.css 已在 App.vue 中通过 @import 引入,无需在此处重复引入 // iconfont.css 已在 App.vue 中通过 @import 引入,无需在此处重复引入
@@ -48,14 +40,6 @@ export function createApp() {
app.component('Empty', Empty) app.component('Empty', Empty)
app.component('NoBouncePage', NoBouncePage) app.component('NoBouncePage', NoBouncePage)
app.component('MsgTips', MsgTips) app.component('MsgTips', MsgTips)
app.component('SelectPopup', SelectPopup)
app.component('RenderJobs', RenderJobs)
app.component('RenderCompanys', RenderCompanys)
app.component('uni-icons', uniIcons)
app.component('uni-popup', uniPopup)
app.component('uni-data-select', uniDataSelect)
app.component('uni-swipe-action', uniSwipeAction)
app.component('uni-swipe-action-item', uniSwipeActionItem)
app.config.globalProperties.$processFileUrl = processFileUrl; app.config.globalProperties.$processFileUrl = processFileUrl;

View File

@@ -364,7 +364,7 @@ const changeSkillName = (index) => {
state.currentEditingSkillIndex = index; state.currentEditingSkillIndex = index;
// //
uni.navigateTo({ uni.navigateTo({
url: `/pages/complete-info/skill-search?selected=${encodeURIComponent(JSON.stringify([]))}` url: `/packageA/pages/complete-info/skill-search?selected=${encodeURIComponent(JSON.stringify([]))}`
}); });
}; };

View File

@@ -472,7 +472,7 @@ function changeSkillName(index) {
// 将当前已选中的技能名称传递给查询页面 // 将当前已选中的技能名称传递给查询页面
const selectedSkills = state.skills.map(skill => skill.name).filter(name => name); const selectedSkills = state.skills.map(skill => skill.name).filter(name => name);
uni.navigateTo({ uni.navigateTo({
url: `/pages/complete-info/skill-search?selected=${encodeURIComponent(JSON.stringify(selectedSkills))}` url: `/packageA/pages/complete-info/skill-search?selected=${encodeURIComponent(JSON.stringify(selectedSkills))}`
}); });
} }

View File

@@ -70,7 +70,7 @@
</view> </view>
<view class="company-grid"> <view class="company-grid">
<view class="company-item press-button" @click="navTo('/pages/job/publishJob')"> <view class="company-item press-button" @click="navTo('/packageA/pages/job/publishJob')">
<view class="company-icon company-icon-1"> <view class="company-icon company-icon-1">
<uni-icons type="plus-filled" size="32" color="#FFFFFF"></uni-icons> <uni-icons type="plus-filled" size="32" color="#FFFFFF"></uni-icons>
</view> </view>
@@ -731,7 +731,7 @@ const handleLoginSuccess = () => {
// 处理附近工作点击 // 处理附近工作点击
const handleNearbyClick = () => { const handleNearbyClick = () => {
if (checkLogin()) { if (checkLogin()) {
navTo("/pages/nearby/nearby"); navTo("/packageA/pages/nearby/nearby");
} }
}; };

View File

@@ -31,50 +31,9 @@
} }
}, },
{ {
"path": "pages/complete-info/complete-info", "path": "pages/search/search",
"style": { "style": {
"navigationBarTitleText": "补全信息" "navigationBarTitleText": "搜索职位"
}
},
{
"path": "pages/complete-info/company-info",
"style": {
"navigationBarTitleText": "企业信息"
}
},
{
"path": "pages/complete-info/components/map-location-picker",
"style": {
"navigationBarTitleText": "选择地址"
}
},
{
"path": "pages/complete-info/skill-search",
"style": {
"navigationBarTitleText": "技能查询"
}
},
{
"path": "pages/nearby/nearby",
"style": {
"navigationBarTitleText": "附近",
"navigationBarBackgroundColor": "#4778EC",
"navigationBarTextStyle": "white"
}
},
{
"path": "pages/job/publishJob",
"style": {
"navigationBarTitleText": "发布岗位"
}
},
{
"path": "pages/job/companySearch",
"style": {
"navigationBarTitleText": "选择企业",
"disableScroll": false,
"enablePullDownRefresh": false,
"backgroundColor": "#f5f5f5"
} }
}, },
{ {
@@ -86,12 +45,6 @@
"enablePullDownRefresh": false "enablePullDownRefresh": false
} }
}, },
{
"path": "pages/search/search",
"style": {
"navigationBarTitleText": "搜索职位"
}
},
{ {
"path": "pages/service/career-planning", "path": "pages/service/career-planning",
"style": { "style": {
@@ -161,6 +114,53 @@
{ {
"root": "packageA", "root": "packageA",
"pages": [ "pages": [
{
"path": "pages/complete-info/complete-info",
"style": {
"navigationBarTitleText": "补全信息"
}
},
{
"path": "pages/complete-info/company-info",
"style": {
"navigationBarTitleText": "企业信息"
}
},
{
"path": "pages/complete-info/components/map-location-picker",
"style": {
"navigationBarTitleText": "选择地址"
}
},
{
"path": "pages/complete-info/skill-search",
"style": {
"navigationBarTitleText": "技能查询"
}
},
{
"path": "pages/nearby/nearby",
"style": {
"navigationBarTitleText": "附近",
"navigationBarBackgroundColor": "#4778EC",
"navigationBarTextStyle": "white"
}
},
{
"path": "pages/job/publishJob",
"style": {
"navigationBarTitleText": "发布岗位"
}
},
{
"path": "pages/job/companySearch",
"style": {
"navigationBarTitleText": "选择企业",
"disableScroll": false,
"enablePullDownRefresh": false,
"backgroundColor": "#f5f5f5"
}
},
{ {
"path": "pages/addWorkExperience/addWorkExperience", "path": "pages/addWorkExperience/addWorkExperience",
"style": { "style": {

View File

@@ -197,7 +197,7 @@
</view> </view>
<view class="company-grid"> <view class="company-grid">
<view class="company-item press-button" @click="navTo('/pages/job/publishJob')"> <view class="company-item press-button" @click="navTo('/packageA/pages/job/publishJob')">
<view class="company-icon company-icon-1"> <view class="company-icon company-icon-1">
<uni-icons type="plus-filled" size="32" color="#FFFFFF"></uni-icons> <uni-icons type="plus-filled" size="32" color="#FFFFFF"></uni-icons>
</view> </view>
@@ -744,7 +744,7 @@ onMounted(() => {
console.log('收到citySelected事件选择的城市:', city); console.log('收到citySelected事件选择的城市:', city);
selectedCity.value = city; selectedCity.value = city;
// 可以在这里添加根据城市筛选职位的逻辑 // 可以在这里添加根据城市筛选职位的逻辑
conditionSearch.value.jobLocationAreaCode = city.code; conditionSearch.value.regionCode = city.code;
getJobRecommend('refresh'); getJobRecommend('refresh');
}); });
@@ -807,13 +807,13 @@ onLoad(() => {
const handleNearbyClick = (options ) => { const handleNearbyClick = (options ) => {
// #ifdef MP-WEIXIN // #ifdef MP-WEIXIN
if (checkLogin()) { if (checkLogin()) {
navTo('/pages/nearby/nearby'); navTo('/packageA/pages/nearby/nearby');
} }
// #endif // #endif
// #ifdef H5 // #ifdef H5
const token = options.token || uni.getStorageSync('zkr-token'); const token = options.token || uni.getStorageSync('zkr-token');
if (token) { if (token) {
navTo('/pages/nearby/nearby'); navTo('/packageA/pages/nearby/nearby');
} }
// #endif // #endif
}; };

View File

@@ -201,7 +201,7 @@ function seeDetail() {
function goToJobHelper() { function goToJobHelper() {
// 跳转到求职者信息补全页面 // 跳转到求职者信息补全页面
navTo('/pages/complete-info/complete-info'); navTo('/packageA/pages/complete-info/complete-info');
} }
// 跳转到素质测评 // 跳转到素质测评
function goCa(){ function goCa(){

View File

@@ -51,12 +51,101 @@ function StreamRequestMiniProgram(url, data = {}, onDataReceived, onError, onCom
} }
}); });
// 监听分块数据 // UTF-8解码函数用于微信小程序真机环境
requestTask.onChunkReceived((res) => { function utf8Decode(uint8Array) {
try { let result = '';
const decoder = new TextDecoder('utf-8'); let i = 0;
const chunk = decoder.decode(new Uint8Array(res.data)); const len = uint8Array.length;
console.log('📦 收到分块数据:', chunk);
while (i < len) {
const byte1 = uint8Array[i];
// 1字节字符 (0xxxxxxx)
if (byte1 < 0x80) {
result += String.fromCharCode(byte1);
i++;
}
// 2字节字符 (110xxxxx 10xxxxxx)
else if (byte1 >= 0xC0 && byte1 < 0xE0) {
if (i + 1 < len) {
const byte2 = uint8Array[i + 1];
if (byte2 >= 0x80 && byte2 < 0xC0) {
const codePoint = ((byte1 & 0x1F) << 6) | (byte2 & 0x3F);
result += String.fromCharCode(codePoint);
i += 2;
continue;
}
}
// 无效的UTF-8序列跳过
result += '<27>';
i++;
}
// 3字节字符 (1110xxxx 10xxxxxx 10xxxxxx)
else if (byte1 >= 0xE0 && byte1 < 0xF0) {
if (i + 2 < len) {
const byte2 = uint8Array[i + 1];
const byte3 = uint8Array[i + 2];
if ((byte2 >= 0x80 && byte2 < 0xC0) && (byte3 >= 0x80 && byte3 < 0xC0)) {
const codePoint = ((byte1 & 0x0F) << 12) | ((byte2 & 0x3F) << 6) | (byte3 & 0x3F);
result += String.fromCharCode(codePoint);
i += 3;
continue;
}
}
// 无效的UTF-8序列跳过
result += '<27>';
i++;
}
// 4字节字符 (11110xxx 10xxxxxx 10xxxxxx 10xxxxxx)
else if (byte1 >= 0xF0 && byte1 < 0xF8) {
if (i + 3 < len) {
const byte2 = uint8Array[i + 1];
const byte3 = uint8Array[i + 2];
const byte4 = uint8Array[i + 3];
if ((byte2 >= 0x80 && byte2 < 0xC0) && (byte3 >= 0x80 && byte3 < 0xC0) && (byte4 >= 0x80 && byte4 < 0xC0)) {
let codePoint = ((byte1 & 0x07) << 18) | ((byte2 & 0x3F) << 12) | ((byte3 & 0x3F) << 6) | (byte4 & 0x3F);
// 处理UTF-16代理对
if (codePoint >= 0x10000) {
codePoint -= 0x10000;
const highSurrogate = (codePoint >> 10) + 0xD800;
const lowSurrogate = (codePoint & 0x3FF) + 0xDC00;
result += String.fromCharCode(highSurrogate, lowSurrogate);
} else {
result += String.fromCharCode(codePoint);
}
i += 4;
continue;
}
}
// 无效的UTF-8序列跳过
result += '<27>';
i++;
}
// 无效的UTF-8序列跳过
else {
result += '<27>';
i++;
}
}
return result;
}
// 监听分块数据
requestTask.onChunkReceived((res) => {
try {
// 微信小程序兼容处理微信小程序不支持TextDecoder使用自定义UTF-8解码
let chunk = '';
if (typeof TextDecoder !== 'undefined') {
// 支持TextDecoder的环境如开发者工具
const decoder = new TextDecoder('utf-8');
chunk = decoder.decode(new Uint8Array(res.data));
} else {
// 微信小程序真机环境使用自定义UTF-8解码函数
const uint8Array = new Uint8Array(res.data);
chunk = utf8Decode(uint8Array);
}
console.log('📦 收到分块数据:', chunk);
buffer += chunk; buffer += chunk;
let lines = buffer.split("\n"); let lines = buffer.split("\n");