From 2c4684630940dc36ca8722686e7a882e467a8a42 Mon Sep 17 00:00:00 2001 From: kevin Date: Thu, 27 Aug 2026 19:26:19 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=90=AC=E7=A7=BB=E9=99=84=E4=BB=B6/?= =?UTF-8?q?=E5=A4=B4=E5=83=8F=E7=AB=AF=E7=82=B9=E6=A8=A1=E6=9D=BF=20JS=20?= =?UTF-8?q?=E8=87=B3=20/api=20=E8=B7=AF=E5=BE=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - article_create.html:附件上传/删除/列表 fetch 改 /api/admin/articles/attachments (删除改用 DELETE 方法),与新路由匹配 - profile.html:头像上传 fetch 改 /api/profile/avatar - 验证:grep 确认模板/static 无残留旧 URL,go build/vet/test 全绿 --- templates/admin/article_create.html | 8 ++++---- templates/pages/profile.html | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/templates/admin/article_create.html b/templates/admin/article_create.html index 7708a42..e981135 100644 --- a/templates/admin/article_create.html +++ b/templates/admin/article_create.html @@ -206,8 +206,8 @@ var easyMDE = new EasyMDE({ delBtn.className = 'text-red-600 hover:text-red-800 font-medium cursor-pointer bg-transparent border-none'; delBtn.onclick = function () { if (!confirm("{{index .Tr "article_att_delete_confirm"}}")) return; - fetch('/admin/articles/attachments/' + att.id + '/delete', { - method: 'POST', + fetch('/api/admin/articles/attachments/' + att.id, { + method: 'DELETE', headers: { 'X-CSRF-Token': csrfToken } }) .then(function (r) { return r.json(); }) @@ -232,7 +232,7 @@ var easyMDE = new EasyMDE({ if (articleID) { fd.append('article_id', articleID); } else { fd.append('session_token', sessionToken); } msgEl.textContent = "{{index .Tr "article_att_uploading"}}"; - fetch('/admin/articles/attachments', { + fetch('/api/admin/articles/attachments', { method: 'POST', headers: { 'X-CSRF-Token': csrfToken }, body: fd @@ -249,7 +249,7 @@ var easyMDE = new EasyMDE({ // Edit page: load existing attachments. if (articleID) { - fetch('/admin/articles/' + articleID + '/attachments') + fetch('/api/admin/articles/' + articleID + '/attachments') .then(function (r) { return r.json(); }) .then(function (r) { (r.attachments || []).forEach(addRow); diff --git a/templates/pages/profile.html b/templates/pages/profile.html index e2fb2d4..228a019 100644 --- a/templates/pages/profile.html +++ b/templates/pages/profile.html @@ -195,7 +195,7 @@ var formData = new FormData(); formData.append('avatar', blob, 'avatar.jpg'); - fetch('/profile/avatar', { + fetch('/api/profile/avatar', { method: 'POST', headers: { 'X-CSRF-Token': csrfToken }, body: formData,