From c4a9cad1c50e89365e2a58b50e259af642ed3b8c Mon Sep 17 00:00:00 2001 From: Codex Assistant <codex@example.com> Date: 星期二, 07 十月 2025 16:12:20 +0800 Subject: [PATCH] feat(review): 调整评审详情展示顺序与样式,描述支持多行,项目信息列宽40/60 fix(auth): 登录页与首页循环跳转保护;api.ts 在登录页不再重定向;401分支在登录页不跳转 fix(router): /login 放行策略优化,避免死循环;评审列表跳转到 /project-review/:id/detail fix(frontend): 补齐 utils/appConfig.ts,避免启动白屏 fix(review): 详情页提交评分缺少stageId时回退使用项目详情的stageId feat(backend): ActivityPlayerDetailResponse.playerInfo 补充 avatarUrl/avatar,服务组装时填充用户头像 chore(dev): 启动脚本注入本地JWT密钥,重启前后端 --- web/src/utils/cos-simple.ts | 135 +++++++++++++++++++++----------------------- 1 files changed, 64 insertions(+), 71 deletions(-) diff --git a/web/src/utils/cos-simple.ts b/web/src/utils/cos-simple.ts index 9190707..6f3e835 100644 --- a/web/src/utils/cos-simple.ts +++ b/web/src/utils/cos-simple.ts @@ -1,72 +1,65 @@ -import axios from 'axios' - -// GraphQL鏌ヨ鑾峰彇涓婁紶鍑瘉 -const GET_UPLOAD_CREDENTIALS = ` - query GetUploadCredentials { - getUploadCredentials { - bucket - region - key - presignedUrl - expiration - } - } -` - -// 浠庡悗绔疓raphQL鑾峰彇涓婁紶鍑瘉 -const getUploadCredentials = async () => { - try { - const response = await axios.post('http://localhost:8080/graphql', { - query: GET_UPLOAD_CREDENTIALS - }) - - if (response.data.errors) { - throw new Error(response.data.errors[0].message) - } - - return response.data.data.getUploadCredentials - } catch (error) { - console.error('鑾峰彇涓婁紶鍑瘉澶辫触:', error) - throw error - } -} - -/** - * 浣跨敤棰勭鍚峌RL涓婁紶鏂囦欢鍒拌吘璁簯COS - * @param file 瑕佷笂浼犵殑鏂囦欢 - * @returns Promise<string> 杩斿洖鏂囦欢鐨勮闂甎RL - */ -export const uploadToCOS = async (file: File): Promise<string> => { - try { - console.log('寮�濮嬭幏鍙栦笂浼犲嚟璇�...') - - // 鑾峰彇涓婁紶鍑瘉 - const credentials = await getUploadCredentials() - console.log('鑾峰彇鍒颁笂浼犲嚟璇�:', credentials) - - // 浣跨敤棰勭鍚峌RL - const uploadUrl = credentials.presignedUrl - - console.log('寮�濮嬩笂浼犳枃浠跺埌:', uploadUrl) - - // 浣跨敤棰勭鍚峌RL涓婁紶鏂囦欢 - const uploadResponse = await axios.put(uploadUrl, file, { - headers: { - 'Content-Type': file.type, - } - }) - - if (uploadResponse.status === 200) { - console.log('鏂囦欢涓婁紶鎴愬姛!') - // 杩斿洖鏂囦欢鐨勮闂甎RL锛堝幓鎺夋煡璇㈠弬鏁帮級 - const fileUrl = `https://${credentials.bucket}.cos.${credentials.region}.myqcloud.com/${credentials.key}` - return fileUrl - } else { - throw new Error(`涓婁紶澶辫触锛岀姸鎬佺爜: ${uploadResponse.status}`) - } - - } catch (error) { - console.error('涓婁紶鏂囦欢澶辫触:', error) - throw error - } +import axios from 'axios' + +// GraphQL鏌ヨ鑾峰彇涓婁紶鍑瘉 +const GET_UPLOAD_CREDENTIALS = ` + query GetUploadCredentials { + getUploadCredentials { + bucket + region + key + presignedUrl + expiration + } + } +` + +// 浠庡悗绔疓raphQL鑾峰彇涓婁紶鍑瘉 +const getUploadCredentials = async () => { + try { + const response = await axios.post('http://localhost:8080/graphql', { + query: GET_UPLOAD_CREDENTIALS + }) + + if (response.data.errors) { + throw new Error(response.data.errors[0].message) + } + + return response.data.data.getUploadCredentials + } catch (error) { + console.error('鑾峰彇涓婁紶鍑瘉澶辫触:', error) + throw error + } +} + +/** + * 浣跨敤棰勭鍚峌RL涓婁紶鏂囦欢鍒拌吘璁簯COS + * @param file 瑕佷笂浼犵殑鏂囦欢 + * @returns Promise<string> 杩斿洖鏂囦欢鐨勮闂甎RL + */ +export const uploadToCOS = async (file: File): Promise<string> => { + try { + // 鑾峰彇涓婁紶鍑瘉 + const credentials = await getUploadCredentials() + + // 浣跨敤棰勭鍚峌RL + const uploadUrl = credentials.presignedUrl + + // 浣跨敤棰勭鍚峌RL涓婁紶鏂囦欢 + const uploadResponse = await axios.put(uploadUrl, file, { + headers: { + 'Content-Type': file.type, + } + }) + + if (uploadResponse.status === 200) { + // 杩斿洖鏂囦欢鐨勮闂甎RL锛堝幓鎺夋煡璇㈠弬鏁帮級 + const fileUrl = `https://${credentials.bucket}.cos.${credentials.region}.myqcloud.com/${credentials.key}` + return fileUrl + } else { + throw new Error(`涓婁紶澶辫触锛岀姸鎬佺爜: ${uploadResponse.status}`) + } + + } catch (error) { + throw error + } } \ No newline at end of file -- Gitblit v1.8.0