AI模块联调
This commit is contained in:
@@ -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);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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',
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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,
|
||||||
|
|||||||
@@ -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'
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import {
|
|||||||
} 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)
|
||||||
@@ -25,18 +25,11 @@ export function useTTSPlayer(wsUrl) {
|
|||||||
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
|
|
||||||
let isHeaderDecoded = false
|
|
||||||
let pendingText = null
|
|
||||||
|
|
||||||
let currentPlayId = 0
|
const speak = async (text) => {
|
||||||
let activePlayId = 0
|
|
||||||
|
|
||||||
const speak = (text) => {
|
|
||||||
if (!audioContext) {
|
if (!audioContext) {
|
||||||
console.warn('⚠️ TTS not supported in current environment');
|
console.warn('⚠️ TTS not supported in current environment');
|
||||||
return;
|
return;
|
||||||
@@ -44,65 +37,102 @@ export function useTTSPlayer(wsUrl) {
|
|||||||
|
|
||||||
console.log('🎤 TTS speak function called');
|
console.log('🎤 TTS speak function called');
|
||||||
console.log('📝 Text to synthesize:', text ? text.substring(0, 100) + '...' : 'No text');
|
console.log('📝 Text to synthesize:', text ? text.substring(0, 100) + '...' : 'No text');
|
||||||
console.log('🔗 WebSocket URL:', wsUrl);
|
console.log('🔗 HTTP URL:', httpUrl);
|
||||||
|
|
||||||
currentPlayId++
|
// 停止当前播放
|
||||||
const myPlayId = currentPlayId
|
stop()
|
||||||
console.log('🆔 Play ID:', myPlayId);
|
|
||||||
|
|
||||||
reset()
|
try {
|
||||||
pendingText = text
|
// 提取要合成的文本
|
||||||
activePlayId = myPlayId
|
const speechText = extractSpeechText(text)
|
||||||
|
console.log('📤 Sending text to TTS server via GET:', speechText.substring(0, 100) + '...');
|
||||||
|
|
||||||
console.log('✅ Speak function setup complete');
|
// 构建GET请求URL
|
||||||
|
const url = `${httpUrl}?text=${encodeURIComponent(speechText)}`
|
||||||
|
console.log('🔗 Final GET URL:', url);
|
||||||
|
|
||||||
|
// 发送GET请求获取语音数据
|
||||||
|
const response = await fetch(url)
|
||||||
|
if (!response.ok) {
|
||||||
|
throw new Error(`HTTP error! status: ${response.status}`)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取二进制数据
|
||||||
|
const arrayBuffer = await response.arrayBuffer()
|
||||||
|
console.log('✅ Received audio data, size:', arrayBuffer.byteLength + ' bytes');
|
||||||
|
|
||||||
|
// 解码音频数据
|
||||||
|
const decoded = await WavDecoder.decode(arrayBuffer)
|
||||||
|
console.log('✅ Audio decoded, sampleRate:', decoded.sampleRate, 'channels:', decoded.channelData.length);
|
||||||
|
|
||||||
|
// 播放音频
|
||||||
|
playDecodedAudio(decoded)
|
||||||
|
} catch (error) {
|
||||||
|
console.error('❌ TTS synthesis failed:', error);
|
||||||
|
isSpeaking.value = false
|
||||||
|
isComplete.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const playDecodedAudio = (decoded) => {
|
||||||
|
if (!audioContext) return;
|
||||||
|
|
||||||
|
// 使用第一个声道的数据
|
||||||
|
const audioBuffer = audioContext.createBuffer(1, decoded.channelData[0].length, decoded.sampleRate)
|
||||||
|
audioBuffer.copyToChannel(decoded.channelData[0], 0)
|
||||||
|
|
||||||
|
currentAudioBuffer = audioBuffer
|
||||||
|
|
||||||
|
// 创建音频源
|
||||||
|
currentSource = audioContext.createBufferSource()
|
||||||
|
currentSource.buffer = audioBuffer
|
||||||
|
currentSource.connect(audioContext.destination)
|
||||||
|
|
||||||
|
// 监听播放结束
|
||||||
|
currentSource.onended = () => {
|
||||||
|
console.log('🎵 Audio playback completed');
|
||||||
|
isSpeaking.value = false
|
||||||
|
isComplete.value = true
|
||||||
|
}
|
||||||
|
|
||||||
|
// 开始播放
|
||||||
|
currentSource.start()
|
||||||
|
isSpeaking.value = true
|
||||||
|
isPaused.value = false
|
||||||
|
isComplete.value = false
|
||||||
|
console.log('<27> Audio playback started');
|
||||||
}
|
}
|
||||||
|
|
||||||
const pause = () => {
|
const pause = () => {
|
||||||
if (!audioContext) {
|
if (!audioContext || !isSpeaking.value || isPaused.value) {
|
||||||
console.warn('⚠️ TTS not supported in current environment');
|
console.warn('⚠️ Cannot pause TTS playback');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log('⏸️ TTS pause called');
|
console.log('⏸️ TTS pause called');
|
||||||
console.log('🔊 AudioContext state:', audioContext.state);
|
|
||||||
console.log('🔊 Is speaking before pause:', isSpeaking.value);
|
|
||||||
console.log('⏸️ Is paused before pause:', isPaused.value);
|
|
||||||
|
|
||||||
if (audioContext.state === 'running') {
|
if (audioContext.state === 'running') {
|
||||||
audioContext.suspend()
|
audioContext.suspend()
|
||||||
isPaused.value = true
|
isPaused.value = true
|
||||||
// 不要设置 isSpeaking.value = false,保持当前状态
|
// 保存当前播放位置
|
||||||
|
playTimeOffset = audioContext.currentTime
|
||||||
console.log('✅ Audio paused successfully');
|
console.log('✅ Audio paused successfully');
|
||||||
} else {
|
|
||||||
console.log('⚠️ AudioContext is not running, cannot pause');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log('🔊 Is speaking after pause:', isSpeaking.value);
|
|
||||||
console.log('⏸️ Is paused after pause:', isPaused.value);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const resume = () => {
|
const resume = () => {
|
||||||
if (!audioContext) {
|
if (!audioContext || !isSpeaking.value || !isPaused.value) {
|
||||||
console.warn('⚠️ TTS not supported in current environment');
|
console.warn('⚠️ Cannot resume TTS playback');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log('▶️ TTS resume called');
|
console.log('▶️ TTS resume called');
|
||||||
console.log('🔊 AudioContext state:', audioContext.state);
|
|
||||||
console.log('🔊 Is speaking before resume:', isSpeaking.value);
|
|
||||||
console.log('⏸️ Is paused before resume:', isPaused.value);
|
|
||||||
|
|
||||||
if (audioContext.state === 'suspended') {
|
if (audioContext.state === 'suspended') {
|
||||||
audioContext.resume()
|
audioContext.resume()
|
||||||
isPaused.value = false
|
isPaused.value = false
|
||||||
isSpeaking.value = true
|
|
||||||
console.log('✅ Audio resumed successfully');
|
console.log('✅ Audio resumed successfully');
|
||||||
} else {
|
|
||||||
console.log('⚠️ AudioContext is not suspended, cannot resume');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log('🔊 Is speaking after resume:', isSpeaking.value);
|
|
||||||
console.log('⏸️ Is paused after resume:', isPaused.value);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const cancelAudio = () => {
|
const cancelAudio = () => {
|
||||||
@@ -110,165 +140,33 @@ export function useTTSPlayer(wsUrl) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const stop = () => {
|
const stop = () => {
|
||||||
isSpeaking.value = false
|
console.log('⏹️ TTS stop called');
|
||||||
isPaused.value = false
|
|
||||||
isComplete.value = false
|
|
||||||
playTime = audioContext ? audioContext.currentTime : 0
|
|
||||||
|
|
||||||
sourceNodes.forEach(node => {
|
if (currentSource) {
|
||||||
try {
|
try {
|
||||||
node.stop()
|
currentSource.stop()
|
||||||
node.disconnect()
|
currentSource.disconnect()
|
||||||
} catch (e) {}
|
} catch (e) {
|
||||||
})
|
console.error('❌ Error stopping audio source:', e);
|
||||||
sourceNodes = []
|
}
|
||||||
|
currentSource = null
|
||||||
if (socket) {
|
|
||||||
socket.close()
|
|
||||||
socket = null
|
|
||||||
}
|
}
|
||||||
|
|
||||||
isHeaderDecoded = false
|
if (audioContext && audioContext.state === 'running') {
|
||||||
pendingText = null
|
try {
|
||||||
}
|
audioContext.suspend()
|
||||||
|
} catch (e) {
|
||||||
|
console.error('❌ Error suspending audio context:', e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const reset = () => {
|
|
||||||
stop()
|
|
||||||
isSpeaking.value = false
|
isSpeaking.value = false
|
||||||
isPaused.value = false
|
isPaused.value = false
|
||||||
isComplete.value = false
|
isComplete.value = false
|
||||||
playTime = audioContext ? audioContext.currentTime : 0
|
currentAudioBuffer = null
|
||||||
initWebSocket()
|
playTimeOffset = 0
|
||||||
}
|
|
||||||
|
|
||||||
const initWebSocket = () => {
|
console.log('✅ TTS playback stopped');
|
||||||
if (!audioContext) {
|
|
||||||
console.warn('⚠️ WebSocket TTS not supported in current environment');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const thisPlayId = currentPlayId
|
|
||||||
console.log('🔌 Initializing WebSocket connection');
|
|
||||||
console.log('🔗 WebSocket URL:', wsUrl);
|
|
||||||
console.log('🆔 This play ID:', thisPlayId);
|
|
||||||
|
|
||||||
socket = new WebSocket(wsUrl)
|
|
||||||
socket.binaryType = 'arraybuffer'
|
|
||||||
|
|
||||||
// 设置心跳检测,避免超时
|
|
||||||
const heartbeatInterval = setInterval(() => {
|
|
||||||
if (socket && socket.readyState === WebSocket.OPEN) {
|
|
||||||
socket.send(JSON.stringify({ type: 'ping' }));
|
|
||||||
}
|
|
||||||
}, 30000); // 每30秒发送一次心跳
|
|
||||||
|
|
||||||
socket.onopen = () => {
|
|
||||||
console.log('✅ WebSocket connection opened');
|
|
||||||
if (pendingText && thisPlayId === activePlayId) {
|
|
||||||
const seepdText = extractSpeechText(pendingText)
|
|
||||||
console.log('📤 Sending text to TTS server:', seepdText.substring(0, 100) + '...');
|
|
||||||
socket.send(seepdText)
|
|
||||||
pendingText = null
|
|
||||||
} else {
|
|
||||||
console.log('❌ No pending text or play ID mismatch');
|
|
||||||
console.log('📝 Pending text exists:', !!pendingText);
|
|
||||||
console.log('🆔 Play ID match:', thisPlayId === activePlayId);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
socket.onerror = (error) => {
|
|
||||||
console.error('❌ WebSocket error:', error);
|
|
||||||
}
|
|
||||||
|
|
||||||
socket.onclose = (event) => {
|
|
||||||
console.log('🔌 WebSocket connection closed:', event.code, event.reason);
|
|
||||||
clearInterval(heartbeatInterval);
|
|
||||||
}
|
|
||||||
|
|
||||||
socket.onmessage = async (e) => {
|
|
||||||
if (thisPlayId !== activePlayId) return // 忽略旧播放的消息
|
|
||||||
|
|
||||||
if (typeof e.data === 'string') {
|
|
||||||
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(() => {
|
onUnmounted(() => {
|
||||||
|
|||||||
16
main.js
16
main.js
@@ -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;
|
||||||
|
|||||||
@@ -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([]))}`
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -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))}`
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
98
pages.json
98
pages.json
@@ -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": {
|
||||||
|
|||||||
@@ -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
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -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(){
|
||||||
|
|||||||
@@ -51,11 +51,100 @@ function StreamRequestMiniProgram(url, data = {}, onDataReceived, onError, onCom
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// UTF-8解码函数,用于微信小程序真机环境
|
||||||
|
function utf8Decode(uint8Array) {
|
||||||
|
let result = '';
|
||||||
|
let i = 0;
|
||||||
|
const len = uint8Array.length;
|
||||||
|
|
||||||
|
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) => {
|
requestTask.onChunkReceived((res) => {
|
||||||
try {
|
try {
|
||||||
const decoder = new TextDecoder('utf-8');
|
// 微信小程序兼容处理:微信小程序不支持TextDecoder,使用自定义UTF-8解码
|
||||||
const chunk = decoder.decode(new Uint8Array(res.data));
|
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);
|
console.log('📦 收到分块数据:', chunk);
|
||||||
buffer += chunk;
|
buffer += chunk;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user