chore: vConsole logs for org homepage image compress upload
Made-with: Cursor
This commit is contained in:
@@ -125,9 +125,15 @@ export default defineComponent({
|
||||
}
|
||||
imageUploading.value = true;
|
||||
try {
|
||||
console.info("[org-homepage] image upload start", {
|
||||
name: file.name,
|
||||
size: file.size,
|
||||
type: file.type,
|
||||
});
|
||||
const urlRaw = await ImageHelper.compress_by_form(file);
|
||||
if (!urlRaw) return;
|
||||
const url = urlRaw.split("?")[0];
|
||||
console.info("[org-homepage] compress ok, create_resource", { url });
|
||||
const rid = await ImageHelper.create_resource(url, file.name || "image.jpg", {
|
||||
res_type: "org_homepage",
|
||||
});
|
||||
@@ -135,6 +141,7 @@ export default defineComponent({
|
||||
showFailToast("资源登记失败,图片可能已上传但未绑定账号");
|
||||
return;
|
||||
}
|
||||
console.info("[org-homepage] create_resource ok", { rid });
|
||||
await insertMarkdownAtCaret(`\n\n`);
|
||||
showSuccessToast("已插入图片");
|
||||
} finally {
|
||||
|
||||
+11
-1
@@ -123,11 +123,21 @@ const ImageHelper = {
|
||||
compress_by_form: async (file: File): Promise<string | undefined> => {
|
||||
let data = new FormData();
|
||||
data.append('file', file)
|
||||
let {r, d, e} = await request({
|
||||
let {r, d, e, statusCode} = await request({
|
||||
url: '/api/ngx/image/form_upload_to_compress', method: 'POST', data,
|
||||
// @ts-ignore
|
||||
headers: {'Content-Type': 'multipart/form-data'},
|
||||
})
|
||||
const dSnippet =
|
||||
typeof d === 'string' ? d.trim().slice(0, 160) : JSON.stringify(d)?.slice(0, 160);
|
||||
console.info('[huike][compress_by_form]', {
|
||||
ok: r,
|
||||
statusCode,
|
||||
err: e,
|
||||
bodySnippet: dSnippet,
|
||||
fileName: file?.name,
|
||||
fileSize: file?.size,
|
||||
})
|
||||
if (r) {
|
||||
const raw = typeof d === 'string' ? d.trim() : '';
|
||||
if (raw && /^https?:\/\//i.test(raw) && !/\s/.test(raw)) {
|
||||
|
||||
Reference in New Issue
Block a user