fix(*): 模型目录 - 修复前台开关、系统模型价格与访问控制

This commit is contained in:
ddCat
2026-08-22 20:57:31 +08:00
parent 5d9986f6c7
commit 1bb5d1423a
19 changed files with 989 additions and 84 deletions

View File

@@ -475,7 +475,20 @@ export function modelOptionsFromChannels(channels: ModelChannel[]) {
export function hasSystemModelPrice(channel: ModelChannel, model: string) {
if (channel.scope !== "system") return true;
return channel.modelCosts?.some((item) => item.model === model && Number.isFinite(item.unitPriceMicrocredits) && item.unitPriceMicrocredits >= 0) === true;
const positive = (value: number | undefined) => typeof value === "number" && Number.isFinite(value) && value > 0;
return channel.modelCosts?.some((item) => {
if (item.model !== model) return false;
const tiers = item.logicalPriceTiers || [];
if (tiers.length) {
return tiers.some((tier) => tier.billingMode === "token"
? [tier.inputTokenPriceMicrocredits, tier.outputTokenPriceMicrocredits, tier.cachedTokenPriceMicrocredits].some(positive)
: positive(tier.unitPriceMicrocredits));
}
if (item.billingMode === "token") {
return [item.inputTokenPriceMicrocredits, item.outputTokenPriceMicrocredits, item.cachedTokenPriceMicrocredits].some(positive);
}
return positive(item.unitPriceMicrocredits);
}) === true;
}
export function normalizeModelOptionValue(value: unknown, channels: ModelChannel[]) {

View File

@@ -29,6 +29,7 @@ export type FeatureAvailability = {
taskCenterEnabled: boolean;
creditsEnabled: boolean;
customChannelsEnabled: boolean;
frontendModelsEnabled: boolean;
desktopLocalChannelsEnabled: boolean;
configured?: boolean;
updatedBy?: string;
@@ -40,6 +41,7 @@ export const defaultFeatureAvailability: FeatureAvailability = {
taskCenterEnabled: true,
creditsEnabled: true,
customChannelsEnabled: true,
frontendModelsEnabled: true,
desktopLocalChannelsEnabled: false,
};