diff --git a/.eslintrc-auto-import.json b/.eslintrc-auto-import.json index 3024d13..11be512 100644 --- a/.eslintrc-auto-import.json +++ b/.eslintrc-auto-import.json @@ -97,6 +97,7 @@ "useId": true, "useModel": true, "useTemplateRef": true, - "useListPageRequest": true + "useListPageRequest": true, + "useCaptcha": true } } diff --git a/env/.env b/env/.env index 598fc0a..9cbe363 100644 --- a/env/.env +++ b/env/.env @@ -7,8 +7,8 @@ VITE_WX_APPID = 'wxa2abb91f64032a2b' # h5部署网站的base,配置到 manifest.config.ts 里的 h5.router.base VITE_APP_PUBLIC_BASE=/ -VITE_SERVER_BASEURL = 'https://mapi.foxmail555.cc' -VITE_UPLOAD_BASEURL = 'https://ukw0y1.laf.run/upload' +VITE_SERVER_BASEURL = 'https://sapi.foxmail555.cc' +VITE_UPLOAD_BASEURL = 'https://sapi.foxmail555.cc/api/common/upload' # h5是否需要配置代理 VITE_APP_PROXY=false diff --git a/src/hooks/useCaptcha.ts b/src/hooks/useCaptcha.ts new file mode 100644 index 0000000..bde4915 --- /dev/null +++ b/src/hooks/useCaptcha.ts @@ -0,0 +1,11 @@ +export const useCaptcha = () => { + const codeUrl = ref('') + const refreshCode = () => { + const baseUrl = import.meta.env.VITE_SERVER_BASEURL + codeUrl.value = baseUrl + '/captcha.html?t=' + Date.now() + } + onMounted(() => { + refreshCode() + }) + return { codeUrl, refreshCode } +} diff --git a/src/hooks/useListPageRequest.ts b/src/hooks/useListPageRequest.ts index 3f51a1d..40566fc 100644 --- a/src/hooks/useListPageRequest.ts +++ b/src/hooks/useListPageRequest.ts @@ -52,6 +52,9 @@ function useListPageRequest( }) console.log(data) data.forEach((item: any) => { + if (String(item.createtime).length < 11) { + item.createtime = item.createtime * 1000 + } item.createtime = formatTime(item.createtime) item.image = getImageUrl(item.image) }) diff --git a/src/hooks/useUpload.ts b/src/hooks/useUpload.ts index adc083d..8323ce8 100644 --- a/src/hooks/useUpload.ts +++ b/src/hooks/useUpload.ts @@ -56,7 +56,12 @@ function uploadFile({ tempFilePath, formData, data, error, loading }) { name: 'file', formData, success: (uploadFileRes) => { - data.value = uploadFileRes.data as T + try { + data.value = JSON.parse(uploadFileRes.data).data.fullurl as T + } catch (e) { + console.log(e) + data.value = uploadFileRes.data as T + } }, fail: (err) => { console.error('uni.uploadFile err->', err) diff --git a/src/pages-sub/hot-news/index.vue b/src/pages-sub/hot-news/index.vue index 7c4d86a..d343cf2 100644 --- a/src/pages-sub/hot-news/index.vue +++ b/src/pages-sub/hot-news/index.vue @@ -6,7 +6,7 @@ }