- 新增评论框提示文案(placeholder)自定义功能,支持在后台设置 - 更新文档:重命名“点赞开关”为“功能开关”,调整侧边栏排序 - 优化前端组件,统一处理评论表单和回复编辑器的提示文案 - 修复CSS样式,确保操作按钮始终可见
44 lines
1.3 KiB
TypeScript
44 lines
1.3 KiB
TypeScript
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;
|
|
const rawCommentPlaceholder =
|
|
typeof body.commentPlaceholder === 'string' ? body.commentPlaceholder : undefined;
|
|
const commentPlaceholder =
|
|
rawCommentPlaceholder !== undefined ? rawCommentPlaceholder.trim() : undefined;
|
|
|
|
await saveFeatureSettings(c.env, {
|
|
enableCommentLike,
|
|
enableArticleLike,
|
|
commentPlaceholder
|
|
});
|
|
|
|
return c.json({ message: '保存成功!' });
|
|
} catch (e: any) {
|
|
return c.json({ message: e.message || 'Failed to save feature settings' }, 500);
|
|
}
|
|
};
|