mirror of
https://github.com/farion1231/cc-switch.git
synced 2026-04-17 16:52:44 +08:00
fix(opencode): enable usage auto-query for providers in config
For OpenCode (additive mode), use isInConfig instead of isCurrent to determine whether to enable usage auto-query. This allows providers that have been added to the config to have their usage queried automatically.
This commit is contained in:
@@ -11,6 +11,7 @@ interface UsageFooterProps {
|
|||||||
appId: AppId;
|
appId: AppId;
|
||||||
usageEnabled: boolean; // 是否启用了用量查询
|
usageEnabled: boolean; // 是否启用了用量查询
|
||||||
isCurrent: boolean; // 是否为当前激活的供应商
|
isCurrent: boolean; // 是否为当前激活的供应商
|
||||||
|
isInConfig?: boolean; // OpenCode: 是否已添加到配置
|
||||||
inline?: boolean; // 是否内联显示(在按钮左侧)
|
inline?: boolean; // 是否内联显示(在按钮左侧)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -20,12 +21,15 @@ const UsageFooter: React.FC<UsageFooterProps> = ({
|
|||||||
appId,
|
appId,
|
||||||
usageEnabled,
|
usageEnabled,
|
||||||
isCurrent,
|
isCurrent,
|
||||||
|
isInConfig = false,
|
||||||
inline = false,
|
inline = false,
|
||||||
}) => {
|
}) => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
|
||||||
// 统一的用量查询(自动查询仅对当前激活的供应商启用)
|
// 统一的用量查询(自动查询仅对当前激活的供应商启用)
|
||||||
const autoQueryInterval = isCurrent
|
// OpenCode(累加模式):使用 isInConfig 代替 isCurrent
|
||||||
|
const shouldAutoQuery = appId === "opencode" ? isInConfig : isCurrent;
|
||||||
|
const autoQueryInterval = shouldAutoQuery
|
||||||
? provider.meta?.usage_script?.autoQueryInterval || 0
|
? provider.meta?.usage_script?.autoQueryInterval || 0
|
||||||
: 0;
|
: 0;
|
||||||
|
|
||||||
|
|||||||
@@ -136,7 +136,9 @@ export function ProviderCard({
|
|||||||
const usageEnabled = provider.meta?.usage_script?.enabled ?? false;
|
const usageEnabled = provider.meta?.usage_script?.enabled ?? false;
|
||||||
|
|
||||||
// 获取用量数据以判断是否有多套餐
|
// 获取用量数据以判断是否有多套餐
|
||||||
const autoQueryInterval = isCurrent
|
// OpenCode(累加模式):使用 isInConfig 代替 isCurrent
|
||||||
|
const shouldAutoQuery = appId === "opencode" ? isInConfig : isCurrent;
|
||||||
|
const autoQueryInterval = shouldAutoQuery
|
||||||
? provider.meta?.usage_script?.autoQueryInterval || 0
|
? provider.meta?.usage_script?.autoQueryInterval || 0
|
||||||
: 0;
|
: 0;
|
||||||
|
|
||||||
@@ -333,6 +335,7 @@ export function ProviderCard({
|
|||||||
appId={appId}
|
appId={appId}
|
||||||
usageEnabled={usageEnabled}
|
usageEnabled={usageEnabled}
|
||||||
isCurrent={isCurrent}
|
isCurrent={isCurrent}
|
||||||
|
isInConfig={isInConfig}
|
||||||
inline={true}
|
inline={true}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
@@ -398,6 +401,7 @@ export function ProviderCard({
|
|||||||
appId={appId}
|
appId={appId}
|
||||||
usageEnabled={usageEnabled}
|
usageEnabled={usageEnabled}
|
||||||
isCurrent={isCurrent}
|
isCurrent={isCurrent}
|
||||||
|
isInConfig={isInConfig}
|
||||||
inline={false}
|
inline={false}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user