feat: add cc-switch integration and modal for token management

- Introduced a new CCSwitchModal component for managing CCSwitch configurations.
- Updated the TokensPage to include functionality for opening the CCSwitch modal.
- Enhanced the useTokensData hook to handle CCSwitch URLs and trigger the modal.
- Modified chat settings to include a new "CC Switch" entry.
- Updated sidebar logic to skip certain links based on the new configuration.
This commit is contained in:
CaIon
2026-03-01 23:23:20 +08:00
parent 1583463436
commit c1cb03456c
12 changed files with 6361 additions and 992 deletions

View File

@@ -30,7 +30,7 @@ import {
import { ITEMS_PER_PAGE } from '../../constants';
import { useTableCompactMode } from '../common/useTableCompactMode';
export const useTokensData = (openFluentNotification) => {
export const useTokensData = (openFluentNotification, openCCSwitchModal) => {
const { t } = useTranslation();
// Basic state
@@ -124,6 +124,10 @@ export const useTokensData = (openFluentNotification) => {
// Open link function for chat integrations
const onOpenLink = async (type, url, record) => {
if (url && url.startsWith('ccswitch')) {
openCCSwitchModal(record.key);
return;
}
if (url && url.startsWith('fluent')) {
openFluentNotification(record.key);
return;
@@ -147,6 +151,16 @@ export const useTokensData = (openFluentNotification) => {
encodeToBase64(JSON.stringify(cherryConfig)),
);
url = url.replaceAll('{cherryConfig}', encodedConfig);
} else if (url.includes('{aionuiConfig}') === true) {
let aionuiConfig = {
platform: 'new-api',
baseUrl: serverAddress,
apiKey: 'sk-' + record.key,
};
let encodedConfig = encodeURIComponent(
encodeToBase64(JSON.stringify(aionuiConfig)),
);
url = url.replaceAll('{aionuiConfig}', encodedConfig);
} else {
let encodedServerAddress = encodeURIComponent(serverAddress);
url = url.replaceAll('{address}', encodedServerAddress);