fix(commentList): 修改图片上传逻辑,使用文件对象代替base64

refactor(uploadImg): 重构图片上传方法,支持FormData方式上传
feat(upload): 添加获取上传配置的逻辑
chore: 更新构建文件和依赖版本
This commit is contained in:
DESKTOP-RQ919RC\Pc
2025-09-08 17:16:30 +08:00
parent d8f5b53e4a
commit 6c9221aa08
14 changed files with 121 additions and 82 deletions

View File

@@ -1,5 +1,5 @@
{
"date": "2025-09-01T06:41:35.910Z",
"date": "2025-09-08T09:13:26.255Z",
"preset": "node-server",
"framework": {
"name": "nuxt",

View File

@@ -1 +1 @@
import{_ as s,t as a,v as i,x as u,y as e,z as o}from"./DEG17TeB.js";const l={class:"antialiased bg-white dark:bg-black dark:text-white font-sans grid min-h-screen overflow-hidden place-content-center text-black"},c={class:"max-w-520px text-center"},d=["textContent"],p=["textContent"],f={__name:"error-500",props:{appName:{type:String,default:"Nuxt"},version:{type:String,default:""},statusCode:{type:Number,default:500},statusMessage:{type:String,default:"Server error"},description:{type:String,default:"This page is temporarily unavailable."}},setup(t){const r=t;return a({title:`${r.statusCode} - ${r.statusMessage} | ${r.appName}`,script:[{children:`!function(){const e=document.createElement("link").relList;if(!(e&&e.supports&&e.supports("modulepreload"))){for(const e of document.querySelectorAll('link[rel="modulepreload"]'))r(e);new MutationObserver((e=>{for(const o of e)if("childList"===o.type)for(const e of o.addedNodes)"LINK"===e.tagName&&"modulepreload"===e.rel&&r(e)})).observe(document,{childList:!0,subtree:!0})}function r(e){if(e.ep)return;e.ep=!0;const r=function(e){const r={};return e.integrity&&(r.integrity=e.integrity),e.referrerPolicy&&(r.referrerPolicy=e.referrerPolicy),"use-credentials"===e.crossOrigin?r.credentials="include":"anonymous"===e.crossOrigin?r.credentials="omit":r.credentials="same-origin",r}(e);fetch(e.href,r)}}();`}],style:[{children:'*,:after,:before{border-color:var(--un-default-border-color,#e5e7eb);border-style:solid;border-width:0;box-sizing:border-box}:after,:before{--un-content:""}html{line-height:1.5;-webkit-text-size-adjust:100%;font-family:ui-sans-serif,system-ui,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;font-feature-settings:normal;font-variation-settings:normal;-moz-tab-size:4;tab-size:4;-webkit-tap-highlight-color:transparent}body{line-height:inherit;margin:0}h1{font-size:inherit;font-weight:inherit}h1,p{margin:0}*,:after,:before{--un-rotate:0;--un-rotate-x:0;--un-rotate-y:0;--un-rotate-z:0;--un-scale-x:1;--un-scale-y:1;--un-scale-z:1;--un-skew-x:0;--un-skew-y:0;--un-translate-x:0;--un-translate-y:0;--un-translate-z:0;--un-pan-x: ;--un-pan-y: ;--un-pinch-zoom: ;--un-scroll-snap-strictness:proximity;--un-ordinal: ;--un-slashed-zero: ;--un-numeric-figure: ;--un-numeric-spacing: ;--un-numeric-fraction: ;--un-border-spacing-x:0;--un-border-spacing-y:0;--un-ring-offset-shadow:0 0 transparent;--un-ring-shadow:0 0 transparent;--un-shadow-inset: ;--un-shadow:0 0 transparent;--un-ring-inset: ;--un-ring-offset-width:0px;--un-ring-offset-color:#fff;--un-ring-width:0px;--un-ring-color:rgba(147,197,253,.5);--un-blur: ;--un-brightness: ;--un-contrast: ;--un-drop-shadow: ;--un-grayscale: ;--un-hue-rotate: ;--un-invert: ;--un-saturate: ;--un-sepia: ;--un-backdrop-blur: ;--un-backdrop-brightness: ;--un-backdrop-contrast: ;--un-backdrop-grayscale: ;--un-backdrop-hue-rotate: ;--un-backdrop-invert: ;--un-backdrop-opacity: ;--un-backdrop-saturate: ;--un-backdrop-sepia: }'}]}),(g,n)=>(u(),i("div",l,[n[0]||(n[0]=e("div",{class:"-bottom-1/2 fixed h-1/2 left-0 right-0 spotlight"},null,-1)),e("div",c,[e("h1",{class:"font-medium mb-8 sm:text-10xl text-8xl",textContent:o(t.statusCode)},null,8,d),e("p",{class:"font-light leading-tight mb-16 px-8 sm:px-0 sm:text-4xl text-xl",textContent:o(t.description)},null,8,p)])]))}},m=s(f,[["__scopeId","data-v-84d937c0"]]);export{m as default};
import{_ as s,t as a,v as i,x as u,y as e,z as o}from"./mbMJmbi0.js";const l={class:"antialiased bg-white dark:bg-black dark:text-white font-sans grid min-h-screen overflow-hidden place-content-center text-black"},c={class:"max-w-520px text-center"},d=["textContent"],p=["textContent"],f={__name:"error-500",props:{appName:{type:String,default:"Nuxt"},version:{type:String,default:""},statusCode:{type:Number,default:500},statusMessage:{type:String,default:"Server error"},description:{type:String,default:"This page is temporarily unavailable."}},setup(t){const r=t;return a({title:`${r.statusCode} - ${r.statusMessage} | ${r.appName}`,script:[{children:`!function(){const e=document.createElement("link").relList;if(!(e&&e.supports&&e.supports("modulepreload"))){for(const e of document.querySelectorAll('link[rel="modulepreload"]'))r(e);new MutationObserver((e=>{for(const o of e)if("childList"===o.type)for(const e of o.addedNodes)"LINK"===e.tagName&&"modulepreload"===e.rel&&r(e)})).observe(document,{childList:!0,subtree:!0})}function r(e){if(e.ep)return;e.ep=!0;const r=function(e){const r={};return e.integrity&&(r.integrity=e.integrity),e.referrerPolicy&&(r.referrerPolicy=e.referrerPolicy),"use-credentials"===e.crossOrigin?r.credentials="include":"anonymous"===e.crossOrigin?r.credentials="omit":r.credentials="same-origin",r}(e);fetch(e.href,r)}}();`}],style:[{children:'*,:after,:before{border-color:var(--un-default-border-color,#e5e7eb);border-style:solid;border-width:0;box-sizing:border-box}:after,:before{--un-content:""}html{line-height:1.5;-webkit-text-size-adjust:100%;font-family:ui-sans-serif,system-ui,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;font-feature-settings:normal;font-variation-settings:normal;-moz-tab-size:4;tab-size:4;-webkit-tap-highlight-color:transparent}body{line-height:inherit;margin:0}h1{font-size:inherit;font-weight:inherit}h1,p{margin:0}*,:after,:before{--un-rotate:0;--un-rotate-x:0;--un-rotate-y:0;--un-rotate-z:0;--un-scale-x:1;--un-scale-y:1;--un-scale-z:1;--un-skew-x:0;--un-skew-y:0;--un-translate-x:0;--un-translate-y:0;--un-translate-z:0;--un-pan-x: ;--un-pan-y: ;--un-pinch-zoom: ;--un-scroll-snap-strictness:proximity;--un-ordinal: ;--un-slashed-zero: ;--un-numeric-figure: ;--un-numeric-spacing: ;--un-numeric-fraction: ;--un-border-spacing-x:0;--un-border-spacing-y:0;--un-ring-offset-shadow:0 0 transparent;--un-ring-shadow:0 0 transparent;--un-shadow-inset: ;--un-shadow:0 0 transparent;--un-ring-inset: ;--un-ring-offset-width:0px;--un-ring-offset-color:#fff;--un-ring-width:0px;--un-ring-color:rgba(147,197,253,.5);--un-blur: ;--un-brightness: ;--un-contrast: ;--un-drop-shadow: ;--un-grayscale: ;--un-hue-rotate: ;--un-invert: ;--un-saturate: ;--un-sepia: ;--un-backdrop-blur: ;--un-backdrop-brightness: ;--un-backdrop-contrast: ;--un-backdrop-grayscale: ;--un-backdrop-hue-rotate: ;--un-backdrop-invert: ;--un-backdrop-opacity: ;--un-backdrop-saturate: ;--un-backdrop-sepia: }'}]}),(g,n)=>(u(),i("div",l,[n[0]||(n[0]=e("div",{class:"-bottom-1/2 fixed h-1/2 left-0 right-0 spotlight"},null,-1)),e("div",c,[e("h1",{class:"font-medium mb-8 sm:text-10xl text-8xl",textContent:o(t.statusCode)},null,8,d),e("p",{class:"font-light leading-tight mb-16 px-8 sm:px-0 sm:text-4xl text-xl",textContent:o(t.description)},null,8,p)])]))}},m=s(f,[["__scopeId","data-v-84d937c0"]]);export{m as default};

File diff suppressed because one or more lines are too long

View File

@@ -1 +1 @@
{"id":"5cb05798-4da7-4203-b6e9-f315f8f99c4a","timestamp":1756708871923}
{"id":"e2c32288-5fef-4097-afab-642f152db17b","timestamp":1757322770327}

View File

@@ -1 +0,0 @@
{"id":"5cb05798-4da7-4203-b6e9-f315f8f99c4a","timestamp":1756708871923,"matcher":{"static":{},"wildcard":{},"dynamic":{}},"prerendered":[]}

View File

@@ -0,0 +1 @@
{"id":"e2c32288-5fef-4097-afab-642f152db17b","timestamp":1757322770327,"matcher":{"static":{},"wildcard":{},"dynamic":{}},"prerendered":[]}

File diff suppressed because one or more lines are too long

View File

@@ -2609,75 +2609,75 @@ const assets$1 = {
"size": 2238,
"path": "../public/favicon.ico"
},
"/static/6S51YVf7.js": {
"/static/7PxzC_cV.js": {
"type": "text/javascript; charset=utf-8",
"etag": "\"24c9-YUsghr2pjjqJ3x4E5BHgseBcQQg\"",
"mtime": "2025-09-01T06:41:24.520Z",
"size": 9417,
"path": "../public/static/6S51YVf7.js"
"etag": "\"d3c-kp4b1SmIINFodGlWZuseLy8KhgQ\"",
"mtime": "2025-09-08T09:13:09.193Z",
"size": 3388,
"path": "../public/static/7PxzC_cV.js"
},
"/static/DEG17TeB.js": {
"/static/BLt8-I-t.js": {
"type": "text/javascript; charset=utf-8",
"etag": "\"69cdb-+dZzVgnhTzip7wxiL3e8h6p6SkQ\"",
"mtime": "2025-09-01T06:41:24.521Z",
"size": 433371,
"path": "../public/static/DEG17TeB.js"
"etag": "\"24c9-eZatPoRkYs/r8OM4lQC0ns1+7UA\"",
"mtime": "2025-09-08T09:13:09.193Z",
"size": 9417,
"path": "../public/static/BLt8-I-t.js"
},
"/static/empty-icon.CyaRoygc.png": {
"type": "image/png",
"etag": "\"17df-ZbUVuzPJ5DAL9B9xteitdPCiUxY\"",
"mtime": "2025-09-01T06:41:24.481Z",
"mtime": "2025-09-08T09:13:09.193Z",
"size": 6111,
"path": "../public/static/empty-icon.CyaRoygc.png"
},
"/static/entry.BIMASYCp.css": {
"type": "text/css; charset=utf-8",
"etag": "\"198ea-9FfCWH/xtWZDfy29j+hT7NuJWm4\"",
"mtime": "2025-09-01T06:41:24.481Z",
"mtime": "2025-09-08T09:13:09.177Z",
"size": 104682,
"path": "../public/static/entry.BIMASYCp.css"
},
"/static/error-404.CZkObG7r.css": {
"type": "text/css; charset=utf-8",
"etag": "\"de4-qBee3TVrfYv3V1By16k8mWrjcVQ\"",
"mtime": "2025-09-01T06:41:24.520Z",
"mtime": "2025-09-08T09:13:09.177Z",
"size": 3556,
"path": "../public/static/error-404.CZkObG7r.css"
},
"/static/error-500.BFrSi6nG.css": {
"type": "text/css; charset=utf-8",
"etag": "\"75c-1DSF9z8DiRXW3VbuCpNqepB9vI0\"",
"mtime": "2025-09-01T06:41:24.520Z",
"mtime": "2025-09-08T09:13:09.177Z",
"size": 1884,
"path": "../public/static/error-500.BFrSi6nG.css"
},
"/static/logo.DlviZpxD.png": {
"type": "image/png",
"etag": "\"843f-FSXGFGigIHmtzjdcQzuMz/a7E+o\"",
"mtime": "2025-09-01T06:41:24.480Z",
"mtime": "2025-09-08T09:13:09.177Z",
"size": 33855,
"path": "../public/static/logo.DlviZpxD.png"
},
"/static/RzIEFrlU.js": {
"/static/mbMJmbi0.js": {
"type": "text/javascript; charset=utf-8",
"etag": "\"d3c-cTJfU3gptXo+KvLw/SziT55BEtY\"",
"mtime": "2025-09-01T06:41:24.521Z",
"size": 3388,
"path": "../public/static/RzIEFrlU.js"
"etag": "\"69de0-cObBJ1tibC5NznFwd2bv9JCK348\"",
"mtime": "2025-09-08T09:13:09.193Z",
"size": 433632,
"path": "../public/static/mbMJmbi0.js"
},
"/static/builds/latest.json": {
"type": "application/json",
"etag": "\"47-je0j1XTn6y+XlJMYzJos9J7LGdc\"",
"mtime": "2025-09-01T06:41:28.240Z",
"etag": "\"47-6qO5m0z0/JLm7LnmiAzFI8m4cZ4\"",
"mtime": "2025-09-08T09:13:14.306Z",
"size": 71,
"path": "../public/static/builds/latest.json"
},
"/static/builds/meta/5cb05798-4da7-4203-b6e9-f315f8f99c4a.json": {
"/static/builds/meta/e2c32288-5fef-4097-afab-642f152db17b.json": {
"type": "application/json",
"etag": "\"8b-jagADAJL4QqGQjqxdeYmBFoASIk\"",
"mtime": "2025-09-01T06:41:28.242Z",
"etag": "\"8b-I118jjJg9Mfnf9WR8Cnw/IA7IFE\"",
"mtime": "2025-09-08T09:13:14.307Z",
"size": 139,
"path": "../public/static/builds/meta/5cb05798-4da7-4203-b6e9-f315f8f99c4a.json"
"path": "../public/static/builds/meta/e2c32288-5fef-4097-afab-642f152db17b.json"
}
};
@@ -4349,7 +4349,7 @@ function _expandFromEnv(value) {
const _inlineRuntimeConfig = {
"app": {
"baseURL": "/",
"buildId": "5cb05798-4da7-4203-b6e9-f315f8f99c4a",
"buildId": "e2c32288-5fef-4097-afab-642f152db17b",
"buildAssetsDir": "/static/",
"cdnURL": ""
},

View File

@@ -18,7 +18,7 @@ const client_manifest = {
"module": true,
"prefetch": true,
"preload": true,
"file": "6S51YVf7.js",
"file": "BLt8-I-t.js",
"name": "error-404",
"src": "node_modules/.store/nuxt@3.16.0/node_modules/nuxt/dist/app/components/error-404.vue",
"isDynamicEntry": true,
@@ -38,7 +38,7 @@ const client_manifest = {
"module": true,
"prefetch": true,
"preload": true,
"file": "RzIEFrlU.js",
"file": "7PxzC_cV.js",
"name": "error-500",
"src": "node_modules/.store/nuxt@3.16.0/node_modules/nuxt/dist/app/components/error-500.vue",
"isDynamicEntry": true,
@@ -58,7 +58,7 @@ const client_manifest = {
"module": true,
"prefetch": true,
"preload": true,
"file": "DEG17TeB.js",
"file": "mbMJmbi0.js",
"name": "entry",
"src": "node_modules/.store/nuxt@3.16.0/node_modules/nuxt/dist/app/entry.js",
"isEntry": true,

View File

@@ -13085,8 +13085,8 @@ const _sfc_main$2 = {
const file = item.getAsFile();
const reader = new FileReader();
reader.onload = (e) => {
const base64 = e.target.result;
uploadImg(base64).then((res) => {
e.target.result;
uploadImg(file).then((res) => {
let questionTextarea = null;
if (type2 == "you") questionTextarea = (void 0).querySelector(".your-answer-textarea");
else questionTextarea = (void 0).querySelector(".question-textarea");
@@ -13103,22 +13103,39 @@ const _sfc_main$2 = {
}
}
};
const uploadImg = (base64) => {
const uploadImg = (file) => {
return new Promise((resolve, reject) => {
detailLoading.value = true;
$ajax("/api/common/upload", {
data: base64
}).then((res) => {
if (res.code != 200) {
handleMsg("error", res.message || "上传失败");
return;
}
let data = res.data;
resolve(data);
}).finally(() => detailLoading.value = false);
const upload = () => {
let config = uploadConfig;
const formData = new FormData();
formData.append(config.requestName, file);
formData.append("type", "image");
formData.append("data", config.params.data);
$ajax(config.url, formData).then((res) => {
if (res.code != 200) {
handleMsg("error", res.message || "上传失败");
return;
}
let data = res.data;
resolve(data);
}).finally(() => detailLoading.value = false);
};
if (uploadConfig) upload();
else getUploadConfig().then(() => upload());
});
};
provide("uploadImg", uploadImg);
let uploadConfig = null;
const getUploadConfig = () => {
return new Promise((resolve, reject) => {
$ajax("https://api.gter.net/v1/config/upload?type=comment").then((res) => {
let data = res.data;
uploadConfig = data;
resolve();
});
});
};
let questionPlaceholderState = ref(false);
let yourAnswerPlaceholderState = ref(true);
const handleInput = () => {

View File

@@ -4,9 +4,9 @@ const styles = {
"app.vue": () => import('./app-styles.C0pZGo-Z.mjs').then(interopDefault),
"node_modules/.store/nuxt@3.16.0/node_modules/nuxt/dist/app/components/error-404.vue": () => import('./error-404-styles.BshXrwM5.mjs').then(interopDefault),
"node_modules/.store/nuxt@3.16.0/node_modules/nuxt/dist/app/components/error-500.vue": () => import('./error-500-styles.DobFeJtS.mjs').then(interopDefault),
"node_modules/.store/nuxt@3.16.0/node_modules/nuxt/dist/app/components/error-500.vue?vue&type=style&index=0&scoped=84d937c0&lang.css": () => import('./error-500-styles.DIlGYe2L.mjs').then(interopDefault),
"node_modules/.store/nuxt@3.16.0/node_modules/nuxt/dist/app/components/error-404.vue?vue&type=style&index=0&scoped=075d74b5&lang.css": () => import('./error-404-styles.CuaO5MB7.mjs').then(interopDefault),
"components/Like.vue": () => import('./Like-styles.DQDennjP.mjs').then(interopDefault),
"node_modules/.store/nuxt@3.16.0/node_modules/nuxt/dist/app/components/error-500.vue?vue&type=style&index=0&scoped=84d937c0&lang.css": () => import('./error-500-styles.DIlGYe2L.mjs').then(interopDefault),
"components/Like.vue?vue&type=style&index=0&scoped=972d2ebd&lang.css": () => import('./Like-styles.BIsA7GNG.mjs').then(interopDefault),
"app.vue?vue&type=style&index=0&lang.css": () => import('./app-styles.C_uXCS2z.mjs').then(interopDefault)
};

View File

@@ -1 +1 @@
{"version":3,"file":"styles.mjs","sources":["../../../../.nuxt/dist/server/styles.mjs"],"sourcesContent":null,"names":[],"mappings":"AAAA,MAAM,cAAc,GAAG,CAAC,IAAI,CAAC,CAAC,OAAO,IAAI,CAAC,IAAI;AAC9C,eAAe;AACf,EAAE,qEAAqE,EAAE,MAAM,OAAO,6BAAoC,CAAC,CAAC,IAAI,CAAC,cAAc,CAAC;AAChJ,EAAE,SAAS,EAAE,MAAM,OAAO,2BAAkC,CAAC,CAAC,IAAI,CAAC,cAAc,CAAC;AAClF,EAAE,qFAAqF,EAAE,MAAM,OAAO,iCAAwC,CAAC,CAAC,IAAI,CAAC,cAAc,CAAC;AACpK,EAAE,qFAAqF,EAAE,MAAM,OAAO,iCAAwC,CAAC,CAAC,IAAI,CAAC,cAAc,CAAC;AACpK,EAAE,qIAAqI,EAAE,MAAM,OAAO,iCAAwC,CAAC,CAAC,IAAI,CAAC,cAAc,CAAC;AACpN,EAAE,qBAAqB,EAAE,MAAM,OAAO,4BAAmC,CAAC,CAAC,IAAI,CAAC,cAAc,CAAC;AAC/F,EAAE,qIAAqI,EAAE,MAAM,OAAO,iCAAwC,CAAC,CAAC,IAAI,CAAC,cAAc,CAAC;AACpN,EAAE,qEAAqE,EAAE,MAAM,OAAO,4BAAmC,CAAC,CAAC,IAAI,CAAC,cAAc,CAAC;AAC/I,EAAE,yCAAyC,EAAE,MAAM,OAAO,2BAAkC,CAAC,CAAC,IAAI,CAAC,cAAc;AACjH;;;;"}
{"version":3,"file":"styles.mjs","sources":["../../../../.nuxt/dist/server/styles.mjs"],"sourcesContent":null,"names":[],"mappings":"AAAA,MAAM,cAAc,GAAG,CAAC,IAAI,CAAC,CAAC,OAAO,IAAI,CAAC,IAAI;AAC9C,eAAe;AACf,EAAE,qEAAqE,EAAE,MAAM,OAAO,6BAAoC,CAAC,CAAC,IAAI,CAAC,cAAc,CAAC;AAChJ,EAAE,SAAS,EAAE,MAAM,OAAO,2BAAkC,CAAC,CAAC,IAAI,CAAC,cAAc,CAAC;AAClF,EAAE,qFAAqF,EAAE,MAAM,OAAO,iCAAwC,CAAC,CAAC,IAAI,CAAC,cAAc,CAAC;AACpK,EAAE,qFAAqF,EAAE,MAAM,OAAO,iCAAwC,CAAC,CAAC,IAAI,CAAC,cAAc,CAAC;AACpK,EAAE,qIAAqI,EAAE,MAAM,OAAO,iCAAwC,CAAC,CAAC,IAAI,CAAC,cAAc,CAAC;AACpN,EAAE,qIAAqI,EAAE,MAAM,OAAO,iCAAwC,CAAC,CAAC,IAAI,CAAC,cAAc,CAAC;AACpN,EAAE,qBAAqB,EAAE,MAAM,OAAO,4BAAmC,CAAC,CAAC,IAAI,CAAC,cAAc,CAAC;AAC/F,EAAE,qEAAqE,EAAE,MAAM,OAAO,4BAAmC,CAAC,CAAC,IAAI,CAAC,cAAc,CAAC;AAC/I,EAAE,yCAAyC,EAAE,MAAM,OAAO,2BAAkC,CAAC,CAAC,IAAI,CAAC,cAAc;AACjH;;;;"}

55
app.vue
View File

@@ -513,7 +513,7 @@ import axios from "axios";
export default {
name: "#answer-app",
async setup() {
const author = "01346a38444d71aaadb3adad52b52c39";
const author = "921d45d85b2b50503704123611232948";
if (process.env.NODE_ENV !== "production" && document) document.cookie = "miucms_session=" + author;
@@ -1728,7 +1728,8 @@ export default {
reader.onload = (e) => {
const base64 = e.target.result;
uploadImg(base64).then((res) => {
// uploadImg(base64).then((res) => {
uploadImg(file).then((res) => {
let questionTextarea = null;
if (type == "you") questionTextarea = document.querySelector(".your-answer-textarea");
else questionTextarea = document.querySelector(".question-textarea");
@@ -1749,26 +1750,48 @@ export default {
}
};
// 上传图片 获取图片url
const uploadImg = (base64) => {
const uploadImg = (file) => {
return new Promise((resolve, reject) => {
detailLoading.value = true;
$ajax("/api/common/upload", {
data: base64,
})
.then((res) => {
if (res.code != 200) {
handleMsg("error", res.message || "上传失败");
return;
}
let data = res.data;
resolve(data);
})
.finally(() => (detailLoading.value = false));
const upload = () => {
let config = uploadConfig;
const formData = new FormData();
formData.append(config.requestName, file); // 文件数据
formData.append("type", "image"); // 文件名
formData.append("data", config.params.data); // 文件名
$ajax(config.url, formData)
.then((res) => {
if (res.code != 200) {
handleMsg("error", res.message || "上传失败");
return;
}
let data = res.data;
resolve(data);
})
.finally(() => (detailLoading.value = false));
};
if (uploadConfig) upload();
else getUploadConfig().then(() => upload());
});
};
provide("uploadImg", uploadImg);
let uploadConfig = null;
const getUploadConfig = () => {
return new Promise((resolve, reject) => {
$ajax("https://api.gter.net/v1/config/upload?type=comment").then((res) => {
let data = res.data;
uploadConfig = data;
resolve();
});
});
};
// 回答 的 placeholder 状态
let questionPlaceholderState = ref(false);
let yourAnswerPlaceholderState = ref(true); // 您的答案的 placeholder 状态
@@ -2339,7 +2362,7 @@ export default {
};
let isLikeGif = ref(false);
let isLikeTimer = null
let isLikeTimer = null;
return { isLikeGif, handleUpdateAnswers, commentListRef, closeEmojiMask, emojiMaskState, isCommentList, commentList, islike, handleLookOnly, zeroreply, replaceNumberObj, closeMyModel, myModelList, myModelState, listHeight, bottomTpsStyle, TAHomePage, sendMessage, avatarState, openUserInfo, isNeedLogin, handleInputYou, openListIAnswer, isListEmptyState, cutYourAnswerAnonymous, yourAnswer, handleLogo, inTheEndState, setItemUrl, seo, originUrl, handleMenuState, reasonList, checkList, alertShow, alertText, selectRadio, alertSubmit, cutType, dialogSrc, answerPage, handleDetailsScroll, replaceState, copyText, boxClass, questionPlaceholderState, yourAnswerPlaceholderState, handleInput, handlePaste, itemStyle, listStyle, listBoxStyle, myType, type, pitchIndex, cut, list, keyword, keywordText, getList, total, typeList, typePitch, getDetails, detailsInfo, detailsIsanswered, detailsIscollection, detailsIsmyself, detailShare, detailLoading, answerList, operateLike, operateCollect, IAnswerState, IAnswerEditState, IAnswerInfo, amendIAnswer, openCommentState, handleAllComment, myCollectionList, myCollectionCount, myQuestionsList, myQuestionsCount, myAnswerList, myAnswerCount, cutAnswerPopupState, handleDate, handleCollectionScroll, handleAnswersScroll, handleQuestionsScroll, cancelCollection, getMyCollection, questionsSetp, questionsObj, cutAnonymous, cutQuestionsSetp, cutQuestionsPopupState, questionsTypeList, postingIssue, choosingTheme, handleMy, changeAnonymous, changeAnonymousQuestions, pageHeaderHeight, pageListHeight, questionsTransmitState, questionsTransmitMaskState, closeAllTransmitState, closeTransmitState, handleAnswerTransmitList, closeDetailMode, tabListFixeState, handleListScroll, historicalSearchState, historicalSearchList, searchFocus, searchBlur, searchClick, handleClickHistoricalItem, handleClickClear, isSearchMode, questionsInit, myCount, msg, myOpenDetails, handleAnswerText, getCurrentUrl, loading };
},

View File

@@ -430,7 +430,7 @@ const handleFileUpload = (event, index, i) => {
const reader = new FileReader();
reader.onload = (e) => {
const base64 = e.target.result;
uploadImg(base64).then((res) => {
uploadImg(file).then((res) => {
const obj = {
base64,
...res,
@@ -540,8 +540,7 @@ const handleInputPaste = (event, index, ii) => {
const reader = new FileReader();
reader.onload = (e) => {
const base64 = e.target.result;
uploadImg(base64).then((res) => {
uploadImg(file).then((res) => {
const obj = {
base64,
...res,