feat(features): 功能开放 - 增加自定义渠道开关

This commit is contained in:
MasterChiefCN
2026-08-15 13:25:50 +08:00
parent b2a7eef35d
commit f83ff03df3
16 changed files with 154 additions and 30 deletions

View File

@@ -40,7 +40,7 @@ const adminNavigation: Array<{ label: string; items: AdminNavigationItem[] }> =
{
label: "系统配置",
items: [
{ path: "/admin/settings/features", label: "功能开放", description: "菜单、页面与积分模式", icon: <ToggleLeft className="size-4" /> },
{ path: "/admin/settings/features", label: "功能开放", description: "菜单、渠道与积分模式", icon: <ToggleLeft className="size-4" /> },
{ path: "/admin/settings/drawing-engine", label: "绘图工具", description: "画布绘图节点默认引擎", icon: <Paintbrush className="size-4" /> },
{ path: "/admin/settings/runtime-policy", label: "资源与策略", description: "配额、并发、频控与超时", icon: <Settings2 className="size-4" /> },
{ path: "/admin/settings/access", label: "登录与注册", description: "注册策略与 Linux.do", icon: <ShieldCheck className="size-4" /> },

View File

@@ -1,17 +1,18 @@
import { useEffect, useState, type ReactNode } from "react";
import { App, Switch } from "antd";
import { Clapperboard, Coins, ListChecks, ToggleLeft } from "lucide-react";
import { Clapperboard, Coins, ListChecks, RadioTower, ToggleLeft } from "lucide-react";
import { getAdminFeatureAvailability, updateAdminFeatureAvailability } from "@/services/api/auth";
import { useUserStore, type FeatureAvailability } from "@/stores/use-user-store";
import { SettingsSectionCard } from "./admin-ui";
type FeatureKey = "shortDramaEnabled" | "taskCenterEnabled" | "creditsEnabled";
type FeatureKey = "shortDramaEnabled" | "taskCenterEnabled" | "creditsEnabled" | "customChannelsEnabled";
const featureRows: Array<{ key: FeatureKey; title: string; menu: string; description: string; icon: ReactNode }> = [
{ key: "shortDramaEnabled", title: "短剧创作", menu: "/projects", description: "关闭后隐藏短剧入口,并拦截项目列表、详情和项目 API。已有项目数据不会删除。", icon: <Clapperboard className="size-4" /> },
{ key: "taskCenterEnabled", title: "任务", menu: "/tasks", description: "关闭后仅隐藏并拦截任务中心页面;生成任务仍会创建、执行、记录和恢复。", icon: <ListChecks className="size-4" /> },
{ key: "creditsEnabled", title: "积分中心", menu: "/wallet", description: "关闭后隐藏用户积分入口,新创建的任务和系统渠道请求不再冻结或消费积分。", icon: <Coins className="size-4" /> },
{ key: "customChannelsEnabled", title: "自定义渠道", menu: "/settings?section=channels", description: "关闭后隐藏用户自定义渠道入口,并拦截模型目录拉取、渠道中转和新的生成任务。已有渠道配置不会删除。", icon: <RadioTower className="size-4" /> },
];
export default function FeatureAvailabilityPanel() {
@@ -41,6 +42,7 @@ export default function FeatureAvailabilityPanel() {
shortDramaEnabled: next.shortDramaEnabled,
taskCenterEnabled: next.taskCenterEnabled,
creditsEnabled: next.creditsEnabled,
customChannelsEnabled: next.customChannelsEnabled,
});
setFeatures(result.features);
setGlobalFeatures(result.features);
@@ -73,7 +75,7 @@ export default function FeatureAvailabilityPanel() {
<SettingsSectionCard
icon={<ToggleLeft className="size-4" />}
title="用户功能开放"
description="统一控制用户工作台入口、页面访问和积分消费策略。"
description="统一控制用户工作台入口、页面访问、渠道能力和积分消费策略。"
status={{ label: features ? `${enabledCount}/${featureRows.length} 已开放` : "读取中", color: enabledCount === featureRows.length ? "success" : "default" }}
>
<div className="divide-y divide-border/75">