fix(canvas): hide realtime button when feature or service is disabled
This commit is contained in:
parent
d4c77d90e0
commit
3d7f0c5485
@ -35,6 +35,7 @@ const LOVART_PROMPT_TAG_VISIBILITY_KEY = "lovart_prompt_tag_visibility";
|
||||
const CONTACT_CONFIG_KEY = "contact_config";
|
||||
const MEMBERSHIP_CONFIG_KEY = "membership_config";
|
||||
const MEMBERSHIP_USER_OVERRIDES_KEY = "membership_user_plan_overrides";
|
||||
const REALTIME_CANVAS_CONFIG_KEY = "realtime_canvas_config";
|
||||
|
||||
function normalizeHomeVariant(value: unknown): "classic" | "lovart" {
|
||||
return value === "lovart" ? "lovart" : "classic";
|
||||
@ -152,6 +153,7 @@ export async function GET() {
|
||||
pointsSystemConfigSetting,
|
||||
pointsPackagesSetting,
|
||||
dulupayConfigSetting,
|
||||
realtimeCanvasConfigSetting,
|
||||
] = await Promise.all([
|
||||
db.select().from(siteSettings).limit(1).then(rows => rows[0]),
|
||||
db
|
||||
@ -232,6 +234,12 @@ export async function GET() {
|
||||
.where(eq(systemSettings.key, DULUPAY_CONFIG_KEY))
|
||||
.limit(1)
|
||||
.then(rows => rows[0]),
|
||||
db
|
||||
.select()
|
||||
.from(systemSettings)
|
||||
.where(eq(systemSettings.key, REALTIME_CANVAS_CONFIG_KEY))
|
||||
.limit(1)
|
||||
.then(rows => rows[0]),
|
||||
]);
|
||||
|
||||
const notification = notificationSetting?.value || { enabled: false, title: "", content: "" };
|
||||
@ -259,6 +267,8 @@ export async function GET() {
|
||||
const dulupayConfig = isAdmin
|
||||
? normalizeDulupayConfig(dulupayConfigSetting?.value)
|
||||
: normalizeDulupayForPublic(dulupayConfigSetting?.value);
|
||||
const realtimeCanvasServiceEnabled =
|
||||
(realtimeCanvasConfigSetting?.value as { enabled?: boolean } | undefined)?.enabled !== false;
|
||||
|
||||
// 如果没有设置记录,返回默认值
|
||||
const baseSettings = settings || {
|
||||
@ -284,6 +294,7 @@ export async function GET() {
|
||||
rankingEnabled: true,
|
||||
canvasEnabled: true,
|
||||
realtimeCanvasEnabled: true,
|
||||
realtimeCanvasServiceEnabled: true,
|
||||
canvasDefaultModelId: null,
|
||||
canvasAutoModeDefaultModelId: null,
|
||||
canvasDetailDefaultModelId: null,
|
||||
@ -326,6 +337,7 @@ export async function GET() {
|
||||
pointsSystemConfig,
|
||||
pointsPackages,
|
||||
dulupayConfig,
|
||||
realtimeCanvasServiceEnabled,
|
||||
});
|
||||
|
||||
// 禁用缓存,确保总是获取最新设置
|
||||
|
||||
@ -130,6 +130,7 @@ export default function CanvasEditorPage({ params }: PageProps) {
|
||||
siteLogo?: string | null;
|
||||
siteLogoDark?: string | null;
|
||||
realtimeCanvasEnabled?: boolean;
|
||||
realtimeCanvasServiceEnabled?: boolean;
|
||||
}>("/api/site-settings", fetcher);
|
||||
|
||||
// 生成配置
|
||||
@ -753,7 +754,8 @@ export default function CanvasEditorPage({ params }: PageProps) {
|
||||
<TooltipContent side="right">添加图片</TooltipContent>
|
||||
</Tooltip>
|
||||
|
||||
{siteSettingsData?.realtimeCanvasEnabled ? (
|
||||
{siteSettingsData?.realtimeCanvasEnabled === true &&
|
||||
siteSettingsData?.realtimeCanvasServiceEnabled !== false ? (
|
||||
<Tooltip>
|
||||
<TooltipTrigger asChild>
|
||||
<Button
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user