fix(client): 添加put方法并修复publish接口调用
This commit is contained in:
@@ -318,7 +318,7 @@ export default class UserManager {
|
||||
async publishDraft(draftId) {
|
||||
if (!this.isLoggedIn) return false;
|
||||
try {
|
||||
await put(`/drafts/${draftId}/publish`, null, { params: { userId: this.userId } });
|
||||
await put(`/drafts/${draftId}/publish?userId=${this.userId}`);
|
||||
return true;
|
||||
} catch (e) {
|
||||
console.error('发布草稿失败:', e);
|
||||
@@ -333,7 +333,7 @@ export default class UserManager {
|
||||
async unpublishDraft(draftId) {
|
||||
if (!this.isLoggedIn) return false;
|
||||
try {
|
||||
await put(`/drafts/${draftId}/unpublish`, null, { params: { userId: this.userId } });
|
||||
await put(`/drafts/${draftId}/unpublish?userId=${this.userId}`);
|
||||
return true;
|
||||
} catch (e) {
|
||||
console.error('取消发布失败:', e);
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
// ============================================
|
||||
// 环境配置(切换这里即可)
|
||||
// ============================================
|
||||
const ENV = 'cloud'; // 'local' = 本地后端, 'cloud' = 微信云托管
|
||||
const ENV = 'local'; // 'local' = 本地后端, 'cloud' = 微信云托管
|
||||
|
||||
const CONFIG = {
|
||||
local: {
|
||||
@@ -117,6 +117,10 @@ export function del(url, data) {
|
||||
return request({ url, method: 'DELETE', data });
|
||||
}
|
||||
|
||||
export function put(url, data) {
|
||||
return request({ url, method: 'PUT', data });
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取静态资源完整URL(图片等)
|
||||
* @param {string} path - 相对路径,如 /uploads/stories/1/characters/1.jpg
|
||||
@@ -177,4 +181,4 @@ export function getDraftNodeBackground(storyId, draftId, nodeKey) {
|
||||
return getStaticUrl(`/uploads/stories/${storyId}/drafts/${draftId}/${nodeKey}/background.jpg`);
|
||||
}
|
||||
|
||||
export default { request, get, post, del, getStaticUrl, getCharacterAvatar, getStoryCover, getNodeBackground, getNodeCharacter, getDraftNodeBackground };
|
||||
export default { request, get, post, put, del, getStaticUrl, getCharacterAvatar, getStoryCover, getNodeBackground, getNodeCharacter, getDraftNodeBackground };
|
||||
|
||||
Reference in New Issue
Block a user