refactor: 清理 Electron 遗留代码并优化项目结构
- 删除 Electron 主进程代码 (src/main/) - 删除构建产物文件夹 (build/, dist/, release/) - 清理 package.json 中的 Electron 依赖和脚本 - 删除 TypeScript 配置中的 Electron 相关文件 - 优化前端代码结构至 Tauri 标准结构 (src/renderer → src/) - 删除移动端图标和不必要文件 - 更新文档说明技术栈变更为 Tauri
This commit is contained in:
47
src/utils/providerConfigUtils.ts
Normal file
47
src/utils/providerConfigUtils.ts
Normal file
@@ -0,0 +1,47 @@
|
||||
// 供应商配置处理工具函数
|
||||
|
||||
// 处理includeCoAuthoredBy字段的添加/删除
|
||||
export const updateCoAuthoredSetting = (jsonString: string, disable: boolean): string => {
|
||||
try {
|
||||
const config = JSON.parse(jsonString)
|
||||
|
||||
if (disable) {
|
||||
// 添加或更新includeCoAuthoredBy字段
|
||||
config.includeCoAuthoredBy = false
|
||||
} else {
|
||||
// 删除includeCoAuthoredBy字段
|
||||
delete config.includeCoAuthoredBy
|
||||
}
|
||||
|
||||
return JSON.stringify(config, null, 2)
|
||||
} catch (err) {
|
||||
// 如果JSON解析失败,返回原始字符串
|
||||
return jsonString
|
||||
}
|
||||
}
|
||||
|
||||
// 从JSON配置中检查是否包含includeCoAuthoredBy设置
|
||||
export const checkCoAuthoredSetting = (jsonString: string): boolean => {
|
||||
try {
|
||||
const config = JSON.parse(jsonString)
|
||||
return config.includeCoAuthoredBy === false
|
||||
} catch (err) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
// 从JSON配置中提取并处理官网地址
|
||||
export const extractWebsiteUrl = (jsonString: string): string => {
|
||||
try {
|
||||
const config = JSON.parse(jsonString)
|
||||
const baseUrl = config?.env?.ANTHROPIC_BASE_URL
|
||||
|
||||
if (baseUrl && typeof baseUrl === 'string') {
|
||||
// 去掉 "api." 前缀
|
||||
return baseUrl.replace(/^https?:\/\/api\./, 'https://')
|
||||
}
|
||||
} catch (err) {
|
||||
// 忽略JSON解析错误
|
||||
}
|
||||
return ''
|
||||
}
|
||||
Reference in New Issue
Block a user