From 7b6bb822fa5f813e6ce01c5de25895ab094d43fd Mon Sep 17 00:00:00 2001 From: zhiyun Date: Wed, 4 Feb 2026 19:10:34 +0800 Subject: [PATCH] chore: normalize eol and cleanup --- .gitattributes | 23 ++++++++++++++ app.js | 10 +++--- pages/agreement/agreement.js | 2 +- pages/chat-detail/chat-detail.js | 54 ++++++++++++++++---------------- pages/chat/chat.js | 10 +++--- pages/gift-shop/gift-shop.js | 8 ++--- 6 files changed, 65 insertions(+), 42 deletions(-) create mode 100644 .gitattributes diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..91cf313 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,23 @@ +* text=auto + +*.js text eol=lf +*.json text eol=lf +*.wxml text eol=lf +*.wxss text eol=lf +*.wxs text eol=lf +*.md text eol=lf +*.sh text eol=lf +*.yml text eol=lf +*.yaml text eol=lf +*.xml text eol=lf +*.svg text eol=lf + +*.bat text eol=crlf +*.cmd text eol=crlf + +*.png binary +*.jpg binary +*.jpeg binary +*.gif binary +*.webp binary +*.ico binary diff --git a/app.js b/app.js index 1f57cd8..2c5c3b4 100644 --- a/app.js +++ b/app.js @@ -439,18 +439,18 @@ App({ async loadAuditStatus() { const localAppVersion = config.APP_VERSION || '' - + try { const res = await api.common.getAuditStatus() if (res.code === 0 && res.data) { const serverAppVersion = res.data.app_version || res.data.appVersion || '' - + if (localAppVersion !== serverAppVersion) { this.globalData.auditStatus = 0 wx.setStorageSync('auditStatus', 0) return } - + const auditStatus = Number(res.data.auditStatus || 0) this.globalData.auditStatus = auditStatus wx.setStorageSync('auditStatus', auditStatus) @@ -459,13 +459,13 @@ App({ } catch (err) { console.error('获取审核状态失败', err) } - + const cachedStatus = wx.getStorageSync('auditStatus') if (cachedStatus !== undefined) { this.globalData.auditStatus = cachedStatus return } - + this.globalData.auditStatus = 0 wx.setStorageSync('auditStatus', 0) }, diff --git a/pages/agreement/agreement.js b/pages/agreement/agreement.js index 85b26c7..38790c2 100644 --- a/pages/agreement/agreement.js +++ b/pages/agreement/agreement.js @@ -43,7 +43,7 @@ Page({ // 从配置文件获取API域名 const baseUrl = String(config.API_BASE_URL || '').replace(/\/api$/, '') - + // 网络请求 wx.request({ url: `${baseUrl}/api/agreements?code=${code}`, diff --git a/pages/chat-detail/chat-detail.js b/pages/chat-detail/chat-detail.js index f30638e..2e0b317 100644 --- a/pages/chat-detail/chat-detail.js +++ b/pages/chat-detail/chat-detail.js @@ -22,10 +22,10 @@ Page({ data: { statusBarHeight: 44, navHeight: 96, - + // 审核状态 auditStatus: 0, - + // 角色信息 characterId: '', conversationId: '', @@ -134,21 +134,21 @@ Page({ // 从本地存储读取审核状态 const auditStatus = wx.getStorageSync('auditStatus') || 0 const { statusBarHeight, navHeight } = app.globalData - + // 初始化消息处理相关变量 this.pendingMessages = [] this.messageTimer = null this.isProcessing = false - + // 获取参数 const characterId = options.id || '' const conversationId = options.conversationId || '' const characterName = decodeURIComponent(options.name || '') - + // 设置用户头像 const userInfo = app.globalData.userInfo const myAvatar = imageUrl.getAvatarUrl(userInfo?.avatar) - + this.setData({ statusBarHeight, navHeight, @@ -172,7 +172,7 @@ Page({ // 从本地存储读取审核状态 const auditStatus = wx.getStorageSync('auditStatus') || 0 this.setData({ auditStatus }) - + // 每次显示页面时,刷新一次配额状态,确保免费畅聊时间等状态是最新的 if (!this.data.loading) { this.loadQuotaStatus() @@ -1937,31 +1937,31 @@ Page({ onVoiceTouchEnd() { clearInterval(this.recordingTimer) - + const { voiceCancelHint, recordingDuration, characterId, character, isUnlocked, remainingCount } = this.data - + this.setData({ isRecording: false }) - + if (this.recorderManager) { this.recorderManager.stop() } - + // 取消发送 if (voiceCancelHint) { util.showToast('已取消') return } - + // 录音时间太短 if (recordingDuration < 1) { util.showError('录音时间太短') return } - + // 等待录音停止后再处理 this.recorderManager.onStop(async (res) => { console.log('[chat-detail] 录音完成:', res.tempFilePath, '时长:', recordingDuration) - + // 先显示语音消息(带识别中状态) const newId = util.generateId() const voiceMessage = { @@ -1974,32 +1974,32 @@ Page({ recognizing: true, recognizedText: '' } - + this.setData({ messages: [...this.data.messages, voiceMessage] }, () => { this.scrollToBottom() }) - + // 进行语音识别 try { wx.showLoading({ title: '语音识别中...' }) - + const fs = wx.getFileSystemManager() const audioData = fs.readFileSync(res.tempFilePath) const audioBase64 = wx.arrayBufferToBase64(audioData) console.log('[chat-detail] 音频文件大小:', audioData.byteLength, 'bytes') console.log('[chat-detail] Base64长度:', audioBase64.length, 'chars') - + console.log('[chat-detail] 开始调用语音识别API...') const recognizeRes = await api.speech.recognize({ audio: audioBase64, format: 'mp3' }) console.log('[chat-detail] 语音识别响应:', JSON.stringify(recognizeRes).substring(0, 200)) - + wx.hideLoading() - + let recognizedText = '' if (recognizeRes.success && recognizeRes.data && recognizeRes.data.text) { recognizedText = recognizeRes.data.text @@ -2020,24 +2020,24 @@ Page({ if (recognizedText && recognizedText !== '[语音消息]') { const canChatByFreeTime = !!(this.data.freeTime && this.data.freeTime.isActive) const canChatByVip = !!this.data.isVip - + if (!isUnlocked && !canChatByVip && !canChatByFreeTime) { console.log('[chat-detail] 语音消息无聊天权限', { isUnlocked, isVip, canChatByFreeTime }) this.setData({ showUnlockPopup: true }) return } - + this.pendingMessages.push(recognizedText) - + if (!this.messageTimer) { this.startMessageTimer(characterId, this.data.conversationId, character, isUnlocked, remainingCount) } } - + } catch (err) { wx.hideLoading() console.error('[chat-detail] 语音识别失败:', err) - + const messages = this.data.messages.map(msg => { if (msg.id === newId) { return { ...msg, recognizing: false, recognizedText: '[语音消息]' } @@ -2053,7 +2053,7 @@ Page({ onVoiceTouchCancel() { clearInterval(this.recordingTimer) this.setData({ isRecording: false }) - + if (this.recorderManager) { this.recorderManager.stop() } @@ -2064,7 +2064,7 @@ Page({ */ onMessageLongPress(e) { const item = e.currentTarget.dataset.item - + wx.showActionSheet({ itemList: ['复制', '删除'], success: (res) => { diff --git a/pages/chat/chat.js b/pages/chat/chat.js index a548cf5..5b2e261 100644 --- a/pages/chat/chat.js +++ b/pages/chat/chat.js @@ -37,12 +37,12 @@ Page({ // 总未读消息数 totalUnread: 0, - + // 加载状态 loading: true, error: null, auditStatus: 0, - + // 免费畅聊相关 freeTime: null, countdownText: '' @@ -57,14 +57,14 @@ Page({ onShow() { wx.hideTabBar({ animation: false }) - + // 从本地存储读取审核状态 const auditStatus = wx.getStorageSync('auditStatus') || 0 this.setData({ auditStatus }) - + // 检查免费畅聊时间 this.checkFreeTime() - + // 每次显示时刷新列表 // 增加延迟,确保标记已读API有时间完成(从聊天详情页返回时) if (!this.data.loading) { diff --git a/pages/gift-shop/gift-shop.js b/pages/gift-shop/gift-shop.js index 1ad32ff..b35cb37 100644 --- a/pages/gift-shop/gift-shop.js +++ b/pages/gift-shop/gift-shop.js @@ -32,7 +32,7 @@ Page({ const menuButton = wx.getMenuButtonBoundingClientRect() const navBarHeight = menuButton.height + (menuButton.top - statusBarHeight) * 2 const totalNavHeight = statusBarHeight + navBarHeight - + this.setData({ statusBarHeight, navBarHeight, @@ -41,12 +41,12 @@ Page({ // 礼物商城无需登录即可访问 this.loadGifts() - + // 检查登录状态并加载爱心值 const app = getApp() const isLoggedIn = app.globalData.isLoggedIn this.setData({ isLoggedIn }) - + if (isLoggedIn) { this.loadLovePoints() } @@ -55,7 +55,7 @@ Page({ onShow() { const app = getApp() this.setData({ isLoggedIn: app.globalData.isLoggedIn }) - + // 仅在登录状态下刷新爱心值 if (app.globalData.isLoggedIn) { this.loadLovePoints()