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'
import { showToast, showLoading, hideLoading, showModal, openDocument, downloadFile, previewImage } from '@tarojs/taro'
import { isVideoFile } from '@/utils/tools'
import { extractExtensionFromFile } from '@/utils/documentIcons'
import { features } from '@/config/features'
/**
* 文件操作 Hook
......@@ -112,7 +113,9 @@ export function useFileOperation() {
showCopyButton = true
} else if (['pdf'].includes(fileExt)) {
message = 'PDF 文件打开失败'
suggestion = '\n\n您可以复制链接在其他应用中打开,或前往"意见反馈"告诉我们'
// 根据功能配置决定是否提示反馈
suggestion = '\n\n您可以复制链接在其他应用中打开' +
(features.feedback ? ',或前往"意见反馈"告诉我们' : '')
showCopyButton = !!item.downloadUrl
} else {
message = `暂不支持预览 ${fileExt.toUpperCase()} 格式文件`
......@@ -125,14 +128,18 @@ export function useFileOperation() {
title: '提示',
content: message + suggestion,
confirmText: showCopyButton ? '复制链接' : '我知道了',
cancelText: '去反馈',
showCancel: true
showCancel: features.feedback
}
// 只有启用反馈功能时才添加 cancelText
if (features.feedback) {
modalParams.cancelText = '去反馈'
}
showModal({
...modalParams,
success: (modalRes) => {
console.log('[文件操作] 用户选择:', modalRes.confirm ? '复制链接' : '去反馈')
console.log('[文件操作] 用户选择:', modalRes.confirm ? '复制链接' : (features.feedback ? '去反馈' : '取消'))
if (modalRes.confirm) {
// 点击主按钮:复制链接(如果有 downloadUrl)
......@@ -161,12 +168,15 @@ export function useFileOperation() {
})
}
// 如果没有 downloadUrl,点击"我知道了"不做任何事
} else {
} else if (features.feedback) {
// 点击取消按钮:跳转到意见反馈页面
console.log('[文件操作] 跳转到意见反馈页面')
Taro.navigateTo({
url: '/pages/feedback/index'
})
} else {
// 反馈功能已关闭,点击取消不做任何事
console.log('[文件操作] 反馈功能已关闭,取消操作')
}
}
})
......