feat: 后端版本迁移修改

This commit is contained in:
Blizzard
2026-05-24 01:38:28 +08:00
parent 058a575e10
commit f8d71ee800
29 changed files with 304 additions and 291 deletions
+4 -4
View File
@@ -24,7 +24,7 @@ Page({
},
fetchTopics() {
request.get('/topic/list').then(res => {
request.get('/plant/topic/list').then(res => {
const list = res.list || [];
const topics = list.map(t => t.title);
if (topics.length > 0) {
@@ -229,8 +229,8 @@ Page({
if (images.length > 0) {
const uploadPromises = images.map(filePath => {
return request.upload(filePath).then(res => {
// Res structure: { file: { id: "...", url: "..." } }
return res && res.file ? res.file.id : null;
// Backend returns flat FileInfo: {id, url, name, ...}
return res ? res.id : null;
});
});
@@ -257,7 +257,7 @@ Page({
ossIds: ossIds
};
await request.post('/post/publish', payload);
await request.post('/plant/post/publish', payload);
wx.hideLoading();
wx.showToast({ title: '发布成功', icon: 'success' });
+4 -4
View File
@@ -69,7 +69,7 @@ Page({
try {
// Correct API Endpoint and Params
const res = await request.post('/post/page', { current, pageSize, hasReviewed: 1 });
const res = await request.post('/plant/post/page', { current, pageSize, hasReviewed: 1 });
// Handle response structure: { code: 200, data: { list: [], ... } }
// OR if request.js unwraps it: { list: [], ... }
@@ -183,7 +183,7 @@ Page({
const type = post.likedByMe ? 2 : 1;
try {
await request.get('/post/like', { id: postId, type });
await request.get('/plant/post/like', { id: postId, type });
// Optimistic Update
const updatedPosts = this.data.posts.map(p => {
@@ -225,7 +225,7 @@ Page({
const type = post.isFavorited ? 2 : 1; // 1: Collect, 2: Cancel
try {
await request.get('/post/star', { id: postId, type });
await request.get('/plant/post/star', { id: postId, type });
// Optimistic Update
const updatedPosts = this.data.posts.map(p => {
@@ -283,7 +283,7 @@ Page({
}
try {
await request.post('/post/comment', {
await request.post('/plant/post/comment', {
postId: commentingPostId,
content: commentText.trim()
});