feat: enhance network configuration settings and UI
- Added new fields for proxy URL, session affinity, and session affinity TTL in usage tracking. - Updated tauri configuration to increase window width. - Expanded Japanese and Chinese translations for new error messages and notices related to network settings. - Introduced new network configuration panel in the UI, allowing users to set port, LAN access, proxy URL, and session affinity options. - Implemented validation for port input and added error handling for network settings. - Refactored API access logic to support new provider record management functions. - Updated navigation to ensure the config page is always accessible. - Added tests for new provider record functionalities and network settings.
This commit is contained in:
1 parent
be2336320d
commit
ea4adbcba8
12 files changed
+1117
-160
No files matched your search
@@ -2,13 +2,14 @@ import { describe, expect, test } from 'bun:test';
|
||||
import { appUpdateIndicatorState } from '../src/appUpdateModel';
|
||||
import { canOpenAppPage, isAlwaysAvailablePage } from '../src/navigation';
|
||||
|
||||
describe('首页与版本管理导航', () => {
|
||||
test('内核停止时仅首页和版本管理始终可进入', () => {
|
||||
describe('首页、配置与版本管理导航', () => {
|
||||
test('内核停止时首页、配置和版本管理始终可进入', () => {
|
||||
expect(isAlwaysAvailablePage('home')).toBe(true);
|
||||
expect(isAlwaysAvailablePage('versions')).toBe(true);
|
||||
expect(isAlwaysAvailablePage('config')).toBe(true);
|
||||
expect(canOpenAppPage('home', false)).toBe(true);
|
||||
expect(canOpenAppPage('versions', false)).toBe(true);
|
||||
expect(canOpenAppPage('config', false)).toBe(false);
|
||||
expect(canOpenAppPage('config', false)).toBe(true);
|
||||
expect(canOpenAppPage('quota', false)).toBe(false);
|
||||
});
|
||||
|
||||
|
||||
@@ -10,7 +10,9 @@ import {
|
||||
modelSelectionForDiscovery,
|
||||
parseProviderHeaders,
|
||||
providerCategoryMatchesRecord,
|
||||
providerRecordWithDisabledState,
|
||||
providerSectionOrder,
|
||||
resolveProviderRecordIndex,
|
||||
sectionRecordsFromConfig,
|
||||
stripResponseFields,
|
||||
} from '../src/pages/ApiAccessPage';
|
||||
@@ -209,6 +211,54 @@ describe('API 接入配置合并', () => {
|
||||
expect(result['excluded-models']).toEqual(['claude-old-*', '*']);
|
||||
});
|
||||
|
||||
it('重新启用仅含全停用规则的普通提供商时删除停用规则', () => {
|
||||
const result = providerRecordWithDisabledState(
|
||||
'claude-api-key',
|
||||
{
|
||||
'api-key': 'claude-key',
|
||||
'excluded-models': ['*'],
|
||||
custom: { keep: true },
|
||||
'auth-index': 'runtime-only',
|
||||
},
|
||||
false,
|
||||
);
|
||||
|
||||
expect(result['excluded-models']).toBeUndefined();
|
||||
expect(result.custom).toEqual({ keep: true });
|
||||
expect(result['auth-index']).toBeUndefined();
|
||||
});
|
||||
|
||||
it('切换普通提供商时保留其他模型排除规则且不会重复追加停用规则', () => {
|
||||
const disabled = providerRecordWithDisabledState(
|
||||
'codex-api-key',
|
||||
{
|
||||
'api-key': 'codex-key',
|
||||
'excluded-models': ['preview-*', '*'],
|
||||
},
|
||||
true,
|
||||
);
|
||||
const enabled = providerRecordWithDisabledState('codex-api-key', disabled, false);
|
||||
|
||||
expect(disabled['excluded-models']).toEqual(['preview-*', '*']);
|
||||
expect(enabled['excluded-models']).toEqual(['preview-*']);
|
||||
});
|
||||
|
||||
it('运行时补全默认 Base URL 后仍能按原始索引找到配置记录', () => {
|
||||
const records = [
|
||||
{ 'api-key': 'first-key', 'base-url': 'https://first.example' },
|
||||
{ 'api-key': 'target-key' },
|
||||
];
|
||||
const index = resolveProviderRecordIndex(records, {
|
||||
section: 'claude-api-key',
|
||||
index: 1,
|
||||
name: 'Claude',
|
||||
apiKey: 'target-key',
|
||||
baseUrl: 'https://api.anthropic.com',
|
||||
});
|
||||
|
||||
expect(index).toBe(1);
|
||||
});
|
||||
|
||||
it('校验自定义请求头格式', () => {
|
||||
expect(parseProviderHeaders('Authorization: Bearer abc:def')).toEqual({
|
||||
Authorization: 'Bearer abc:def',
|
||||
|
||||
Reference in new issue
Block a user