hookehuyr

fix(composable): 修复文件操作反馈功能配置同步问题

- 导入 features 配置,使用命名导入
- 根据 features.feedback 动态控制"去反馈"按钮显示
- 根据配置动态调整提示文案(移除"前往意见反馈"提示)
- 根据配置决定是否跳转反馈页面
- 修复 showModal cancelText 为 undefined 导致的参数错误

修复了当 feedback: false 时文件操作失败提示出现:
"showModal:fail parameter error: parameter.cancelText should be String instead of Undefined"

影响文件:
- src/composables/useFileOperation.js

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
...@@ -12,6 +12,7 @@ import Taro from '@tarojs/taro' ...@@ -12,6 +12,7 @@ import Taro from '@tarojs/taro'
12 import { showToast, showLoading, hideLoading, showModal, openDocument, downloadFile, previewImage } from '@tarojs/taro' 12 import { showToast, showLoading, hideLoading, showModal, openDocument, downloadFile, previewImage } from '@tarojs/taro'
13 import { isVideoFile } from '@/utils/tools' 13 import { isVideoFile } from '@/utils/tools'
14 import { extractExtensionFromFile } from '@/utils/documentIcons' 14 import { extractExtensionFromFile } from '@/utils/documentIcons'
15 +import { features } from '@/config/features'
15 16
16 /** 17 /**
17 * 文件操作 Hook 18 * 文件操作 Hook
...@@ -112,7 +113,9 @@ export function useFileOperation() { ...@@ -112,7 +113,9 @@ export function useFileOperation() {
112 showCopyButton = true 113 showCopyButton = true
113 } else if (['pdf'].includes(fileExt)) { 114 } else if (['pdf'].includes(fileExt)) {
114 message = 'PDF 文件打开失败' 115 message = 'PDF 文件打开失败'
115 - suggestion = '\n\n您可以复制链接在其他应用中打开,或前往"意见反馈"告诉我们' 116 + // 根据功能配置决定是否提示反馈
117 + suggestion = '\n\n您可以复制链接在其他应用中打开' +
118 + (features.feedback ? ',或前往"意见反馈"告诉我们' : '')
116 showCopyButton = !!item.downloadUrl 119 showCopyButton = !!item.downloadUrl
117 } else { 120 } else {
118 message = `暂不支持预览 ${fileExt.toUpperCase()} 格式文件` 121 message = `暂不支持预览 ${fileExt.toUpperCase()} 格式文件`
...@@ -125,14 +128,18 @@ export function useFileOperation() { ...@@ -125,14 +128,18 @@ export function useFileOperation() {
125 title: '提示', 128 title: '提示',
126 content: message + suggestion, 129 content: message + suggestion,
127 confirmText: showCopyButton ? '复制链接' : '我知道了', 130 confirmText: showCopyButton ? '复制链接' : '我知道了',
128 - cancelText: '去反馈', 131 + showCancel: features.feedback
129 - showCancel: true 132 + }
133 +
134 + // 只有启用反馈功能时才添加 cancelText
135 + if (features.feedback) {
136 + modalParams.cancelText = '去反馈'
130 } 137 }
131 138
132 showModal({ 139 showModal({
133 ...modalParams, 140 ...modalParams,
134 success: (modalRes) => { 141 success: (modalRes) => {
135 - console.log('[文件操作] 用户选择:', modalRes.confirm ? '复制链接' : '去反馈') 142 + console.log('[文件操作] 用户选择:', modalRes.confirm ? '复制链接' : (features.feedback ? '去反馈' : '取消'))
136 143
137 if (modalRes.confirm) { 144 if (modalRes.confirm) {
138 // 点击主按钮:复制链接(如果有 downloadUrl) 145 // 点击主按钮:复制链接(如果有 downloadUrl)
...@@ -161,12 +168,15 @@ export function useFileOperation() { ...@@ -161,12 +168,15 @@ export function useFileOperation() {
161 }) 168 })
162 } 169 }
163 // 如果没有 downloadUrl,点击"我知道了"不做任何事 170 // 如果没有 downloadUrl,点击"我知道了"不做任何事
164 - } else { 171 + } else if (features.feedback) {
165 // 点击取消按钮:跳转到意见反馈页面 172 // 点击取消按钮:跳转到意见反馈页面
166 console.log('[文件操作] 跳转到意见反馈页面') 173 console.log('[文件操作] 跳转到意见反馈页面')
167 Taro.navigateTo({ 174 Taro.navigateTo({
168 url: '/pages/feedback/index' 175 url: '/pages/feedback/index'
169 }) 176 })
177 + } else {
178 + // 反馈功能已关闭,点击取消不做任何事
179 + console.log('[文件操作] 反馈功能已关闭,取消操作')
170 } 180 }
171 } 181 }
172 }) 182 })
......