From 50e1dc2139bcbc7a270fff1c0660f6c443d68cc6 Mon Sep 17 00:00:00 2001 From: yixu Date: Mon, 22 Sep 2025 17:36:39 +0800 Subject: [PATCH] update --- src/components/GenerateImg.vue | 4 +- src/components/MyPhoto.vue | 7 +-- src/libs/utils.js | 89 +--------------------------------- 3 files changed, 8 insertions(+), 92 deletions(-) diff --git a/src/components/GenerateImg.vue b/src/components/GenerateImg.vue index 51a6b09..0cc6972 100644 --- a/src/components/GenerateImg.vue +++ b/src/components/GenerateImg.vue @@ -32,9 +32,9 @@ const beforeUpload = (file) => { return false; } - const isLt2M = file.size / 1024 / 1024 < 5; + const isLt2M = file.size / 1024 / 1024 < 10; if (!isLt2M) { - ElMessage.error('图片大小不能超过5MB!'); + ElMessage.error('图片大小不能超过10MB!'); return false; } diff --git a/src/components/MyPhoto.vue b/src/components/MyPhoto.vue index 9c79ce9..2c15bcd 100644 --- a/src/components/MyPhoto.vue +++ b/src/components/MyPhoto.vue @@ -35,8 +35,9 @@ const fetchImages = async () => { }) const data = await response.json() if (response.status == 200 || response.status == 201) { - images.value = data.data; - const foundItem = data.data.find(item => item.is_public === true); + // 只保留result_url存在的记录 + images.value = data.data.filter(item => item.result_url); + const foundItem = images.value.find(item => item.is_public === true); if (foundItem) { globalStore.result_url = foundItem.result_url; globalStore.mergeId = foundItem.id @@ -44,7 +45,7 @@ const fetchImages = async () => { } else { displayZhuli.value = false; } - imageList.value = data; + imageList.value = images.value; const hasPublicImage = images.value.some(item => item.is_public); if (hasPublicImage) { diff --git a/src/libs/utils.js b/src/libs/utils.js index 8c08e41..dab8051 100644 --- a/src/libs/utils.js +++ b/src/libs/utils.js @@ -139,7 +139,7 @@ export const Request = async (url, data, type, noloading, noerror) => { headers.Authorization = `Bearer ${Storage.get("userinfos").api_token}` } else { Storage.clear() - weui.alert("错误的请求") + weui.alert("登录失效,请重新登录") } } @@ -190,92 +190,7 @@ export const Request = async (url, data, type, noloading, noerror) => { return { res: response, json: result } } else if (response.status == 401) { Storage.clear() - weui.alert("错误的请求") - // window.location.reload() - return - } else { - if (!noerror) { - weui.alert(message) - } - return { res: response, json: result } - } - - } catch (error) { - if (!noerror) { - weui.alert(message) - } - loading && loading.hide() - } -} - -export const RequestImg = async (url, data, type, noloading, noerror) => { - let headers = { - 'Content-Type': 'multipart/form-data', - Accept: "application/json", - "Source": "faceFamily", - 'App-Channel': getUserBrowersName(), - refer: document.referrer, - blackbox: Storage.get("blackbox") ? Storage.get("blackbox") : false - } - - if (url != "sms/sendCode" && url != "sms/authPhone" && url != "wechat/login" && url != "wechat/jssdk") { - if (isLogin()) { - headers.Authorization = `Bearer ${Storage.get("userinfos").api_token}` - } else { - Storage.clear() - weui.alert("错误的请求") - return - } - } - - if (isBaseLogin() && url == "sms/authPhone") { - headers.Authorization = `Bearer ${Storage.get("userinfos").api_token}` - } - - let loading = false - if (!noloading) { - loading = weui.loading() - } - - let message = "请求失败,请重试" - - let fetchData = { - method: type || 'POST', - headers: new Headers(headers), - } - - if (fetchData.method == "POST") { - fetchData.body = JSON.stringify(data) - } - - let requrl = 'https://huodong2.lzlj.com/api/faceFamily/upload/image' - - if (type === "GET") { - let paramArr = [] - Object.keys(data).forEach(v => { - paramArr.push(`${v}=${data[v]}`) - }) - requrl = paramArr.length === 0 ? `${requrl}` : `${requrl}?${paramArr.join("&")}` - } - - try { - const response = await fetch(`${requrl}`, fetchData) - const result = await response.json() - message = result.message || message - if (getParam("debug")) { - console.log("url:", url) - console.log("data:", data) - console.log(response) - console.log(result) - } - - loading && loading.hide() - - if (response.status == 200 || response.status == 201) { - return { res: response, json: result } - } else if (response.status == 401) { - Storage.clear() - weui.alert("错误的请求") + weui.alert("登录失效,请重新登录") // window.location.reload() return } else {