大量优化修改扣积分规则

This commit is contained in:
Azmat@qq.com
2026-09-04 17:20:22 +08:00
parent 3e904479d9
commit 15718a60bf
41 changed files with 1590 additions and 429 deletions
+33 -9
View File
@@ -28,7 +28,6 @@ import {
AccountPage,
AssetFactoryPage,
AuthScreen,
Dashboard,
FreeCreatePage,
QuickCreatePage,
OmniCreatePage,
@@ -122,6 +121,12 @@ export function App() {
const [projects, setProjects] = useState<Project[]>([]);
const [projectTotal, setProjectTotal] = useState(0);
const [modelConfigs, setModelConfigs] = useState<ModelConfig[]>([]);
const refreshModelConfigs = useCallback(() => {
void api.modelConfigs()
.then((modelData) => setModelConfigs(modelData?.results || []))
.catch(() => undefined);
}, []);
const [billing, setBilling] = useState<BillingSummary | null>(null);
const [unreadCount, setUnreadCount] = useState(0);
// YYX#row22:未读生成任务 —— 导航「图片生成」总数 + 每个商品的未读分数(商品角标)
@@ -344,23 +349,39 @@ export function App() {
if (user.is_platform_admin && !team && route.admin === undefined) {
navigateAdmin("", { replace: true });
} else if (!user.is_platform_admin && route.admin !== undefined) {
navigate("dashboard", { replace: true });
navigate("omniCreate", { replace: true });
}
// navigate/navigateAdmin 为组件内函数,故意不入依赖避免每次渲染重跑
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [booting, user, team, route.admin]);
// 子账号(非主账号)纠回:团队 / 消费 页仅主账号(owner=超管)可见,子账号直接拉回工作台(PMC#3)。
// 子账号(非主账号)纠回:团队 / 消费 页仅主账号(owner=超管)可见,子账号直接拉回全能创作(PMC#3)。
// role 为空时(身份尚未带回角色)不拦,避免误纠超管。
useLayoutEffect(() => {
if (booting || !user || !role) return;
if (!isOwner && isOwnerOnlyPage(page)) {
navigate("dashboard", { replace: true });
navigate("omniCreate", { replace: true });
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [booting, user, role, isOwner, page]);
// 工作台暂时隐藏:普通入口落到 dashboard 时改走全能创作。
// /admin/* 故意用 page=dashboard + route.admin 占位,绝不能再踢去 omni,否则会和上面的超管 gating 对踢死循环。
useLayoutEffect(() => {
if (booting || !user || page !== "dashboard") return;
if (route.admin !== undefined) return;
navigate("omniCreate", { replace: true });
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [booting, user, page, route.admin]);
// Load preferences + sessions when entering settings.
// 进创作相关页时重拉模型目录,避免后台刚改能力/积分,前端还捧着首屏缓存
useEffect(() => {
if (!authed || !dataLoaded) return;
if (!["freeCreate", "omniCreate", "omniSession", "omniHistory", "quickCreate", "videoReplace", "pipeline"].includes(page)) return;
refreshModelConfigs();
}, [authed, page, dataLoaded, refreshModelConfigs]);
useEffect(() => {
if (!authed || (page !== "settings" && page !== "settingsNotify")) return;
loadSettingsData();
@@ -856,7 +877,7 @@ export function App() {
navigateAdmin("", { replace: true });
return;
}
navigate("dashboard", { replace: true });
navigate("omniCreate", { replace: true });
// 先把工作台必需数据拉好,这期间「登录页」保持「登录成功,正在进入工作台…」提示(authed 仍 false → AuthScreen 不卸载),
// 数据就绪后才揭开外壳直接进有数据的工作台 —— 避免中间闪一个空白「加载中…」页(PMC#7)。
try {
@@ -923,9 +944,10 @@ export function App() {
const currentTeam: Team = team;
function renderPage() {
switch (page) {
switch (page) {
case "dashboard":
return <Dashboard products={products} projects={projects} productTotal={productTotal} projectTotal={projectTotal} billing={billing} userName={currentUser.username} loading={!dataLoaded} navigate={navigate} onDelete={deleteProjectAction} />;
// 工作台隐藏期间不渲染该页,上面的 effect 会改到全能创作
return null;
case "products":
return (
<ProductsPage
@@ -1079,7 +1101,7 @@ export function App() {
/>
);
case "omniCreate":
return <OmniCreatePage navigate={navigate} onNotify={(type, text) => setNotice({ type, text })} />;
return <OmniCreatePage modelConfigs={modelConfigs} navigate={navigate} onNotify={(type, text) => setNotice({ type, text })} />;
case "omniHistory":
return <OmniHistoryPage navigate={navigate} onNotify={(type, text) => setNotice({ type, text })} />;
case "omniSession":
@@ -1089,6 +1111,7 @@ export function App() {
firstMessage={route.firstMessage}
firstRefs={route.firstRefs}
firstUploads={route.firstUploads}
modelConfigs={modelConfigs}
navigate={navigate}
onNotify={(type, text) => setNotice({ type, text })}
/>
@@ -1140,7 +1163,7 @@ export function App() {
case "settingsNotify":
return <SettingsPage user={currentUser} team={currentTeam} initialSection="notify" preferences={preferences} sessions={sessions} onSavePreferences={savePreferences} onRevokeSession={revokeSession} onRevokeOthers={revokeOtherSessions} onSaveProfile={saveProfile} onChangePassword={changeOwnPassword} onUploadAvatar={uploadOwnAvatar} onResetAvatar={resetOwnAvatar} onNotify={(text) => setNotice({ type: "success", text })} onLogout={logout} />;
default:
return <Dashboard products={products} projects={projects} productTotal={productTotal} projectTotal={projectTotal} billing={billing} userName={currentUser.username} loading={!dataLoaded} navigate={navigate} onDelete={deleteProjectAction} />;
return <OmniCreatePage modelConfigs={modelConfigs} navigate={navigate} onNotify={(type, text) => setNotice({ type, text })} />;
}
}
@@ -1182,6 +1205,7 @@ export function App() {
scriptModelName={publicModelDisplayName(pipelineTextModel, "AI")}
textModels={modelConfigs.filter((m) => m.capability === "text" && m.status === "active")}
videoModels={modelConfigs.filter((m) => m.capability === "video" && m.status === "active")}
imageModels={modelConfigs.filter((m) => m.capability === "image" && m.status === "active")}
loading={loading}
navigate={navigate}
onBack={() => goBack("projects")}