feat(评论): 新增功能开关管理及评论点赞功能优化
- 在管理后台添加功能开关页面,支持控制评论点赞和文章点赞功能的开启/关闭 - 优化评论点赞功能,支持取消点赞和本地存储点赞状态 - 更新点赞UI样式,提升用户体验 - 添加相关API接口和文档说明
This commit is contained in:
38
cwd-api/src/api/admin/featureSettings.ts
Normal file
38
cwd-api/src/api/admin/featureSettings.ts
Normal file
@@ -0,0 +1,38 @@
|
||||
import { Context } from 'hono';
|
||||
import { Bindings } from '../../bindings';
|
||||
import {
|
||||
loadFeatureSettings,
|
||||
saveFeatureSettings
|
||||
} from '../../utils/featureSettings';
|
||||
|
||||
export const getFeatureSettings = async (c: Context<{ Bindings: Bindings }>) => {
|
||||
try {
|
||||
const settings = await loadFeatureSettings(c.env);
|
||||
return c.json(settings);
|
||||
} catch (e: any) {
|
||||
return c.json({ message: e.message || 'Failed to load feature settings' }, 500);
|
||||
}
|
||||
};
|
||||
|
||||
export const updateFeatureSettings = async (c: Context<{ Bindings: Bindings }>) => {
|
||||
try {
|
||||
const body = await c.req.json();
|
||||
const enableCommentLike =
|
||||
typeof body.enableCommentLike === 'boolean'
|
||||
? body.enableCommentLike
|
||||
: undefined;
|
||||
const enableArticleLike =
|
||||
typeof body.enableArticleLike === 'boolean'
|
||||
? body.enableArticleLike
|
||||
: undefined;
|
||||
|
||||
await saveFeatureSettings(c.env, {
|
||||
enableCommentLike,
|
||||
enableArticleLike
|
||||
});
|
||||
|
||||
return c.json({ message: 'Saved successfully' });
|
||||
} catch (e: any) {
|
||||
return c.json({ message: e.message || 'Failed to save feature settings' }, 500);
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user