From ba94ceae1315174798ae1967ef62268c6d16cd5b Mon Sep 17 00:00:00 2001 From: Codex Assistant <codex@example.com> Date: 星期一, 06 十月 2025 22:07:06 +0800 Subject: [PATCH] feat: 评审与活动相关改动 - backend(GraphQL): Activity schema 增加 updateActivityState(id, state);实现 resolver/service 仅更新 state=2 作为逻辑删除 - backend(GraphQL): region.graphqls 新增 Query leafRegions - backend(GraphQL): player.graphqls 的 projectReviewApplications 增加可选参数 regionId - backend(Service): listProjectReviewApplications 绑定 regionId 参数,修复 QueryParameterException - frontend(web): 新增 api/activity.js 的 updateActivityState 并接入 activity-list 删除逻辑 - frontend(web): review-list.vue 权限仅校验登录,移除角色限制;查询参数修正为 name/regionId - frontend(web): 删除未引用的 ActivityList.vue - frontend(web): projectReviewNew.js GraphQL 查询增加 name 参数 --- web/src/utils/upload-logo-browser.ts | 226 +++++++++++++++++++++++++++---------------------------- 1 files changed, 111 insertions(+), 115 deletions(-) diff --git a/web/src/utils/upload-logo-browser.ts b/web/src/utils/upload-logo-browser.ts index b8c6eb2..d930b73 100644 --- a/web/src/utils/upload-logo-browser.ts +++ b/web/src/utils/upload-logo-browser.ts @@ -1,116 +1,112 @@ -// 娴忚鍣ㄧ涓婁紶logo鏂囦欢鐨勫伐鍏峰嚱鏁� -import { uploadToCOS } from './cos' - -/** - * 灏哢I鐩綍涓嬬殑logo鏂囦欢涓婁紶鍒癈OS - * 杩欎釜鍑芥暟鐢ㄤ簬鍦ㄦ祻瑙堝櫒涓笂浼爈ogo鏂囦欢 - */ -export const uploadLogoToCOS = async (): Promise<{ - success: boolean - url?: string - error?: string -}> => { - try { - // 鑾峰彇logo鏂囦欢 - const logoFile = await fetchLogoFile() - - if (!logoFile) { - return { - success: false, - error: 'Logo鏂囦欢涓嶅瓨鍦ㄦ垨鏃犳硶璁块棶' - } - } - - console.log('寮�濮嬩笂浼爈ogo鏂囦欢:', logoFile.name, logoFile.size, 'bytes') - - // 涓婁紶鍒癈OS鐨刟vatars鐩綍 - const url = await uploadToCOS(logoFile, 'avatars/') - - console.log('Logo涓婁紶鎴愬姛:', url) - - return { - success: true, - url: url - } - - } catch (error: any) { - console.error('Logo涓婁紶澶辫触:', error) - return { - success: false, - error: error.message || '涓婁紶澶辫触' - } - } -} - -/** - * 鑾峰彇logo鏂囦欢 - * 鐢变簬娴忚鍣ㄥ畨鍏ㄩ檺鍒讹紝鏃犳硶鐩存帴璇诲彇鏈湴鏂囦欢绯荤粺 - * 杩欓噷鎻愪緵鍑犵鑾峰彇logo鏂囦欢鐨勬柟寮� - */ -async function fetchLogoFile(): Promise<File | null> { - try { - // 鏂瑰紡1: 浠巔ublic鐩綍鑾峰彇锛堝鏋渓ogo鏂囦欢鏀惧湪public鐩綍涓嬶級 - const response = await fetch('/logo.jpg') - if (response.ok) { - const blob = await response.blob() - return new File([blob], 'logo.jpg', { type: 'image/jpeg' }) - } - } catch (error) { - console.log('浠巔ublic鐩綍鑾峰彇logo澶辫触锛屽皾璇曞叾浠栨柟寮�') - } - - try { - // 鏂瑰紡2: 浠嶶I鐩綍鑾峰彇锛堥渶瑕侀厤缃潤鎬佹枃浠舵湇鍔★級 - const response = await fetch('/UI/logo.jpg') - if (response.ok) { - const blob = await response.blob() - return new File([blob], 'logo.jpg', { type: 'image/jpeg' }) - } - } catch (error) { - console.log('浠嶶I鐩綍鑾峰彇logo澶辫触') - } - - // 鏂瑰紡3: 杩斿洖null锛岄渶瑕佺敤鎴锋墜鍔ㄩ�夋嫨鏂囦欢 - return null -} - -/** - * 鍒涘缓涓�涓猯ogo鏂囦欢閫夋嫨鍣� - * 褰撴棤娉曡嚜鍔ㄨ幏鍙杔ogo鏂囦欢鏃讹紝璁╃敤鎴锋墜鍔ㄩ�夋嫨 - */ -export const createLogoFileSelector = (): Promise<File | null> => { - return new Promise((resolve) => { - const input = document.createElement('input') - input.type = 'file' - input.accept = 'image/*' - input.style.display = 'none' - - input.onchange = (event) => { - const target = event.target as HTMLInputElement - const file = target.files?.[0] - - if (file) { - // 楠岃瘉鏄惁涓簂ogo鏂囦欢 - if (file.name.toLowerCase().includes('logo')) { - resolve(file) - } else { - console.warn('閫夋嫨鐨勬枃浠跺悕涓嶅寘鍚�"logo"锛岃纭鏄惁涓烘纭殑logo鏂囦欢') - resolve(file) // 浠嶇劧杩斿洖鏂囦欢锛岃鐢ㄦ埛鍐冲畾 - } - } else { - resolve(null) - } - - // 娓呯悊DOM - document.body.removeChild(input) - } - - input.oncancel = () => { - resolve(null) - document.body.removeChild(input) - } - - document.body.appendChild(input) - input.click() - }) +// 娴忚鍣ㄧ涓婁紶logo鏂囦欢鐨勫伐鍏峰嚱鏁� +import { uploadToCOS } from './cos' + +/** + * 灏哢I鐩綍涓嬬殑logo鏂囦欢涓婁紶鍒癈OS + * 杩欎釜鍑芥暟鐢ㄤ簬鍦ㄦ祻瑙堝櫒涓笂浼爈ogo鏂囦欢 + */ +export const uploadLogoToCOS = async (): Promise<{ + success: boolean + url?: string + error?: string +}> => { + try { + // 鑾峰彇logo鏂囦欢 + const logoFile = await fetchLogoFile() + + if (!logoFile) { + return { + success: false, + error: 'Logo鏂囦欢涓嶅瓨鍦ㄦ垨鏃犳硶璁块棶' + } + } + + // 涓婁紶鍒癈OS鐨刟vatars鐩綍 + const url = await uploadToCOS(logoFile, 'avatars/') + + return { + success: true, + url: url + } + + } catch (error: any) { + console.error('Logo涓婁紶澶辫触:', error) + return { + success: false, + error: error.message || '涓婁紶澶辫触' + } + } +} + +/** + * 鑾峰彇logo鏂囦欢 + * 鐢变簬娴忚鍣ㄥ畨鍏ㄩ檺鍒讹紝鏃犳硶鐩存帴璇诲彇鏈湴鏂囦欢绯荤粺 + * 杩欓噷鎻愪緵鍑犵鑾峰彇logo鏂囦欢鐨勬柟寮� + */ +async function fetchLogoFile(): Promise<File | null> { + try { + // 鏂瑰紡1: 浠巔ublic鐩綍鑾峰彇锛堝鏋渓ogo鏂囦欢鏀惧湪public鐩綍涓嬶級 + const response = await fetch('/logo.jpg') + if (response.ok) { + const blob = await response.blob() + return new File([blob], 'logo.jpg', { type: 'image/jpeg' }) + } + } catch (error) { + // 浠巔ublic鐩綍鑾峰彇logo澶辫触锛屽皾璇曞叾浠栨柟寮� + } + + try { + // 鏂瑰紡2: 浠嶶I鐩綍鑾峰彇锛堥渶瑕侀厤缃潤鎬佹枃浠舵湇鍔★級 + const response = await fetch('/UI/logo.jpg') + if (response.ok) { + const blob = await response.blob() + return new File([blob], 'logo.jpg', { type: 'image/jpeg' }) + } + } catch (error) { + // 浠嶶I鐩綍鑾峰彇logo澶辫触 + } + + // 鏂瑰紡3: 杩斿洖null锛岄渶瑕佺敤鎴锋墜鍔ㄩ�夋嫨鏂囦欢 + return null +} + +/** + * 鍒涘缓涓�涓猯ogo鏂囦欢閫夋嫨鍣� + * 褰撴棤娉曡嚜鍔ㄨ幏鍙杔ogo鏂囦欢鏃讹紝璁╃敤鎴锋墜鍔ㄩ�夋嫨 + */ +export const createLogoFileSelector = (): Promise<File | null> => { + return new Promise((resolve) => { + const input = document.createElement('input') + input.type = 'file' + input.accept = 'image/*' + input.style.display = 'none' + + input.onchange = (event) => { + const target = event.target as HTMLInputElement + const file = target.files?.[0] + + if (file) { + // 楠岃瘉鏄惁涓簂ogo鏂囦欢 + if (file.name.toLowerCase().includes('logo')) { + resolve(file) + } else { + console.warn('閫夋嫨鐨勬枃浠跺悕涓嶅寘鍚�"logo"锛岃纭鏄惁涓烘纭殑logo鏂囦欢') + resolve(file) // 浠嶇劧杩斿洖鏂囦欢锛岃鐢ㄦ埛鍐冲畾 + } + } else { + resolve(null) + } + + // 娓呯悊DOM + document.body.removeChild(input) + } + + input.oncancel = () => { + resolve(null) + document.body.removeChild(input) + } + + document.body.appendChild(input) + input.click() + }) } \ No newline at end of file -- Gitblit v1.8.0