Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
36848b46dc | ||
|
|
5bda4b19df | ||
|
|
476d297e4b | ||
|
|
ce7147025d | ||
|
|
080fb67974 | ||
|
|
f6f8069ce4 | ||
|
|
6328378da5 |
No files matched your search
@@ -10,7 +10,7 @@ jobs:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os: [windows-latest, macos-latest, macos-14, ubuntu-latest]
|
||||
os: [windows-latest, windows-11-arm, macos-latest, macos-14, ubuntu-latest]
|
||||
|
||||
runs-on: ${{ matrix.os }}
|
||||
|
||||
|
||||
@@ -1,10 +1,7 @@
|
||||
name: Release
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
- beta
|
||||
workflow_dispatch:
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
/coverage
|
||||
/.vite
|
||||
README.md
|
||||
CHANGELOG.md
|
||||
/src/routeTree.gen.ts
|
||||
.agents/
|
||||
openspec/
|
||||
@@ -2,6 +2,18 @@
|
||||
|
||||
# Changelog
|
||||
|
||||
## [0.6.0](https://github.com/Draculabo/AntigravityManager/compare/v0.5.0...v0.6.0) (2026-02-04)
|
||||
|
||||
### ✨ Features
|
||||
|
||||
* add cloud reset time UI ([#56](https://github.com/Draculabo/AntigravityManager/issues/56)) ([f6f8069](https://github.com/Draculabo/AntigravityManager/commit/f6f8069ce4673ae7027c6ba248daa18c8b602218))
|
||||
* windows install guidance ([#63](https://github.com/Draculabo/AntigravityManager/issues/63)) ([ce71470](https://github.com/Draculabo/AntigravityManager/commit/ce7147025d37648a82f6f6b300502ef4462bfde6))
|
||||
|
||||
### 🐛 Bug Fixes
|
||||
|
||||
* correct Windows install notice path ([5bda4b1](https://github.com/Draculabo/AntigravityManager/commit/5bda4b19dfc9ce64735cd39600d41a5deefc26ee))
|
||||
* **proxy:** route Claude Code CLI requests on /v1/chat/completions to Anthropic handler ([#61](https://github.com/Draculabo/AntigravityManager/issues/61)) ([476d297](https://github.com/Draculabo/AntigravityManager/commit/476d297e4b2dd3015f7ebcbb915b643730816dc6))
|
||||
|
||||
## [0.5.0](https://github.com/Draculabo/AntigravityManager/compare/v0.4.0...v0.5.0) (2026-01-30)
|
||||
|
||||
### ✨ Features
|
||||
|
||||
@@ -185,7 +185,7 @@ Download the latest release for your platform from the [Releases](https://github
|
||||
|
||||
| Platform | Download |
|
||||
|----------|----------|
|
||||
| Windows | [.exe installer](https://github.com/Draculabo/AntigravityManager/releases/latest) |
|
||||
| Windows (x64/ARM64) | [.exe installer](https://github.com/Draculabo/AntigravityManager/releases/latest) |
|
||||
| macOS | [.dmg installer](https://github.com/Draculabo/AntigravityManager/releases/latest) |
|
||||
| Linux | [.deb / .rpm](https://github.com/Draculabo/AntigravityManager/releases/latest) |
|
||||
|
||||
|
||||
+1
-1
@@ -184,7 +184,7 @@
|
||||
|
||||
| 平台 | 下载链接 |
|
||||
| ------- | ------------------------------------------------------------------------------ |
|
||||
| Windows | [.exe 安装包](https://github.com/Draculabo/AntigravityManager/releases/latest) |
|
||||
| Windows (x64/ARM64) | [.exe 安装包](https://github.com/Draculabo/AntigravityManager/releases/latest) |
|
||||
| macOS | [.dmg 安装包](https://github.com/Draculabo/AntigravityManager/releases/latest) |
|
||||
| Linux | [.deb / .rpm](https://github.com/Draculabo/AntigravityManager/releases/latest) |
|
||||
|
||||
|
||||
+233
-7
@@ -1,19 +1,115 @@
|
||||
import type { ForgeConfig } from '@electron-forge/shared-types';
|
||||
import crypto from 'crypto';
|
||||
import { FuseV1Options, FuseVersion } from '@electron/fuses';
|
||||
import type {
|
||||
HookFunction,
|
||||
HookFunctionErrorCallback,
|
||||
TargetArch,
|
||||
TargetPlatform,
|
||||
} from '@electron/packager';
|
||||
import { MakerDeb } from '@electron-forge/maker-deb';
|
||||
import { MakerDMG } from '@electron-forge/maker-dmg';
|
||||
import { MakerRpm } from '@electron-forge/maker-rpm';
|
||||
import { MakerSquirrel } from '@electron-forge/maker-squirrel';
|
||||
import { MakerZIP } from '@electron-forge/maker-zip';
|
||||
import { MakerDeb } from '@electron-forge/maker-deb';
|
||||
import { MakerRpm } from '@electron-forge/maker-rpm';
|
||||
import { VitePlugin } from '@electron-forge/plugin-vite';
|
||||
import { FusesPlugin } from '@electron-forge/plugin-fuses';
|
||||
import { FuseV1Options, FuseVersion } from '@electron/fuses';
|
||||
import { AutoUnpackNativesPlugin } from '@electron-forge/plugin-auto-unpack-natives';
|
||||
import { FusesPlugin } from '@electron-forge/plugin-fuses';
|
||||
import { VitePlugin } from '@electron-forge/plugin-vite';
|
||||
import type { ForgeConfig } from '@electron-forge/shared-types';
|
||||
import MakerAppImage from '@pengx17/electron-forge-maker-appimage';
|
||||
import setLanguages from 'electron-packager-languages';
|
||||
import * as fs from 'fs';
|
||||
import * as path from 'path';
|
||||
import { stringify as yamlStringify } from 'yaml';
|
||||
|
||||
const nativeModules = ['better-sqlite3', 'keytar', 'bindings', 'file-uri-to-path'];
|
||||
const ResolvedMakerAppImage = MakerAppImage;
|
||||
const keepLanguages = new Set(['en', 'en-US', 'zh-CN', 'ru']);
|
||||
|
||||
const isStartCommand = process.argv.some((arg) => arg.includes('start'));
|
||||
|
||||
const artifactRegex = /.*\.(?:exe|dmg|AppImage|zip|deb|rpm)$/;
|
||||
const platformNamesMap: Record<string, string> = {
|
||||
darwin: 'macos',
|
||||
linux: 'linux',
|
||||
win32: 'windows',
|
||||
};
|
||||
const ymlMapsMap: Record<string, string> = {
|
||||
darwin: 'latest-mac.yml',
|
||||
linux: 'latest-linux.yml',
|
||||
win32: 'latest.yml',
|
||||
};
|
||||
const ignorePatterns = [
|
||||
/^\/\.git/,
|
||||
/^\/\.github/,
|
||||
/^\/\.vscode/,
|
||||
/^\/\.idea/,
|
||||
/^\/openspec/,
|
||||
/^\/docs?/,
|
||||
/^\/scripts?/,
|
||||
/^\/tests?/,
|
||||
/^\/mocks?/,
|
||||
/^\/src/,
|
||||
/^\/node_modules\/\.cache/,
|
||||
];
|
||||
const setLanguagesHook = setLanguages([...keepLanguages.values()]);
|
||||
const packagerAfterCopy: HookFunction[] = [
|
||||
(
|
||||
buildPath: string,
|
||||
electronVersion: string,
|
||||
platform: TargetPlatform,
|
||||
arch: TargetArch,
|
||||
callback: HookFunctionErrorCallback,
|
||||
) => {
|
||||
if (platform !== 'win32') {
|
||||
callback();
|
||||
return;
|
||||
}
|
||||
|
||||
setLanguagesHook(buildPath, electronVersion, platform, arch, callback);
|
||||
},
|
||||
];
|
||||
|
||||
function normalizeArtifactName(value?: string) {
|
||||
if (!value) {
|
||||
return 'app';
|
||||
}
|
||||
|
||||
return value.trim().replace(/\s+/g, '-');
|
||||
}
|
||||
|
||||
function isSquirrelArtifact(artifactPath: string) {
|
||||
const fileName = path.basename(artifactPath);
|
||||
if (fileName === 'RELEASES') {
|
||||
return true;
|
||||
}
|
||||
|
||||
return artifactPath.endsWith('.nupkg');
|
||||
}
|
||||
|
||||
const appImageMaker = new ResolvedMakerAppImage({
|
||||
config: {
|
||||
icons: [
|
||||
{
|
||||
file: 'images/32x32.png',
|
||||
size: 32,
|
||||
},
|
||||
{
|
||||
file: 'images/64x64.png',
|
||||
size: 64,
|
||||
},
|
||||
{
|
||||
file: 'images/128x128.png',
|
||||
size: 128,
|
||||
},
|
||||
{
|
||||
file: 'images/[email protected]',
|
||||
size: 256,
|
||||
},
|
||||
],
|
||||
},
|
||||
});
|
||||
appImageMaker.name = '@pengx17/electron-forge-maker-appimage';
|
||||
|
||||
const config: ForgeConfig = {
|
||||
packagerConfig: {
|
||||
asar: {
|
||||
@@ -23,6 +119,9 @@ const config: ForgeConfig = {
|
||||
executableName: 'antigravity-manager',
|
||||
icon: 'images/icon', // Electron Forge automatically adds .icns/.ico
|
||||
extraResource: ['src/assets'], // Copy assets folder to resources/assets
|
||||
afterCopy: packagerAfterCopy,
|
||||
ignore: ignorePatterns,
|
||||
prune: true,
|
||||
},
|
||||
rebuildConfig: {},
|
||||
hooks: {
|
||||
@@ -63,8 +162,135 @@ const config: ForgeConfig = {
|
||||
console.warn(`Assets directory not found: ${assetsSrc}`);
|
||||
}
|
||||
},
|
||||
postMake: async (_config, makeResults) => {
|
||||
if (!makeResults?.length) {
|
||||
return makeResults;
|
||||
}
|
||||
|
||||
const ymlByPlatform = new Map<
|
||||
string,
|
||||
{
|
||||
basePath: string;
|
||||
yml: {
|
||||
version?: string;
|
||||
files: {
|
||||
url: string;
|
||||
sha512: string;
|
||||
size: number;
|
||||
}[];
|
||||
releaseDate?: string;
|
||||
};
|
||||
}
|
||||
>();
|
||||
|
||||
makeResults = makeResults.map((result) => {
|
||||
const productName = normalizeArtifactName(result.packageJSON.productName);
|
||||
const platformName = platformNamesMap[result.platform] || result.platform;
|
||||
const version = result.packageJSON.version;
|
||||
const platformKey = result.platform;
|
||||
|
||||
if (!ymlByPlatform.has(platformKey)) {
|
||||
ymlByPlatform.set(platformKey, {
|
||||
basePath: '',
|
||||
yml: {
|
||||
version,
|
||||
files: [],
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
const platformState = ymlByPlatform.get(platformKey)!;
|
||||
|
||||
result.artifacts = result.artifacts
|
||||
.map((artifact) => {
|
||||
if (!artifact) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (isSquirrelArtifact(artifact)) {
|
||||
return artifact;
|
||||
}
|
||||
|
||||
if (!artifactRegex.test(artifact)) {
|
||||
return artifact;
|
||||
}
|
||||
|
||||
if (!platformState.basePath) {
|
||||
platformState.basePath = path.dirname(artifact);
|
||||
}
|
||||
|
||||
const newArtifact = `${path.dirname(artifact)}/${productName}-${version}-${platformName}-${result.arch}${path.extname(artifact)}`;
|
||||
if (newArtifact !== artifact) {
|
||||
fs.renameSync(artifact, newArtifact);
|
||||
}
|
||||
|
||||
try {
|
||||
const fileData = fs.readFileSync(newArtifact);
|
||||
const hash = crypto.createHash('sha512').update(fileData).digest('base64');
|
||||
const { size } = fs.statSync(newArtifact);
|
||||
|
||||
platformState.yml.files.push({
|
||||
url: path.basename(newArtifact),
|
||||
sha512: hash,
|
||||
size,
|
||||
});
|
||||
} catch {
|
||||
console.error(`Failed to hash ${newArtifact}`);
|
||||
}
|
||||
|
||||
return newArtifact;
|
||||
})
|
||||
.filter((artifact) => artifact !== null);
|
||||
|
||||
return result;
|
||||
});
|
||||
|
||||
const releaseDate = new Date().toISOString();
|
||||
for (const [platform, platformState] of ymlByPlatform.entries()) {
|
||||
const ymlFileName = ymlMapsMap[platform];
|
||||
if (!ymlFileName || !platformState.basePath) {
|
||||
continue;
|
||||
}
|
||||
|
||||
platformState.yml.releaseDate = releaseDate;
|
||||
const ymlPath = path.join(platformState.basePath, ymlFileName);
|
||||
fs.writeFileSync(ymlPath, yamlStringify(platformState.yml));
|
||||
|
||||
const sampleResult = makeResults.find((result) => result.platform === platform);
|
||||
if (!sampleResult) {
|
||||
continue;
|
||||
}
|
||||
|
||||
makeResults.push({
|
||||
artifacts: [ymlPath],
|
||||
platform: sampleResult.platform,
|
||||
arch: sampleResult.arch,
|
||||
packageJSON: sampleResult.packageJSON,
|
||||
});
|
||||
}
|
||||
|
||||
return makeResults;
|
||||
},
|
||||
},
|
||||
makers: [new MakerSquirrel({}), new MakerZIP({}, ['darwin']), new MakerRpm({}), new MakerDeb({})],
|
||||
makers: [
|
||||
new MakerSquirrel({
|
||||
setupIcon: 'images/icon.ico',
|
||||
iconUrl:
|
||||
'https://raw.githubusercontent.com/Draculabo/AntigravityManager/main/images/icon.ico',
|
||||
}),
|
||||
new MakerDMG(
|
||||
{
|
||||
overwrite: true,
|
||||
icon: 'images/icon.icns',
|
||||
iconSize: 160,
|
||||
},
|
||||
['darwin'],
|
||||
),
|
||||
new MakerZIP({}, ['darwin']),
|
||||
appImageMaker,
|
||||
new MakerRpm({}),
|
||||
new MakerDeb({}),
|
||||
],
|
||||
publishers: [
|
||||
{
|
||||
/*
|
||||
|
||||
Generated
+1816
-5
File diff suppressed because it is too large.
Load diff
+4
-1
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "antigravity-manager",
|
||||
"productName": "Antigravity Manager",
|
||||
"version": "0.5.0",
|
||||
"version": "0.6.0",
|
||||
"description": "Antigravity Manager - Electron App",
|
||||
"main": ".vite/build/main.js",
|
||||
"private": true,
|
||||
@@ -25,6 +25,7 @@
|
||||
"devDependencies": {
|
||||
"@electron-forge/cli": "^7.10.2",
|
||||
"@electron-forge/maker-deb": "^7.10.2",
|
||||
"@electron-forge/maker-dmg": "^7.10.2",
|
||||
"@electron-forge/maker-rpm": "^7.10.2",
|
||||
"@electron-forge/maker-squirrel": "^7.10.2",
|
||||
"@electron-forge/maker-zip": "^7.10.2",
|
||||
@@ -33,6 +34,7 @@
|
||||
"@electron-forge/plugin-vite": "^7.10.2",
|
||||
"@electron-forge/publisher-github": "^7.10.2",
|
||||
"@electron-forge/shared-types": "^7.8.1",
|
||||
"@pengx17/electron-forge-maker-appimage": "^1.2.1",
|
||||
"@electron/fuses": "~1.8.0",
|
||||
"@electron/rebuild": "^3.7.1",
|
||||
"@eslint/compat": "^1.4.1",
|
||||
@@ -61,6 +63,7 @@
|
||||
"electron": "^37.3.1",
|
||||
"electron-devtools-installer": "^4.0.0",
|
||||
"electron-playwright-helpers": "^1.8.2",
|
||||
"electron-packager-languages": "^0.6.0",
|
||||
"eslint": "^9.39.1",
|
||||
"eslint-config-prettier": "^10.1.8",
|
||||
"eslint-plugin-prettier": "^5.5.4",
|
||||
|
||||
@@ -40,11 +40,11 @@ export const AccountCard: React.FC<AccountCardProps> = ({
|
||||
|
||||
const initials = account.name
|
||||
? account.name
|
||||
.split(' ')
|
||||
.map((n) => n[0])
|
||||
.join('')
|
||||
.toUpperCase()
|
||||
.slice(0, 2)
|
||||
.split(' ')
|
||||
.map((n) => n[0])
|
||||
.join('')
|
||||
.toUpperCase()
|
||||
.slice(0, 2)
|
||||
: account.email[0].toUpperCase();
|
||||
|
||||
// 处理鼠标移动,计算 3D 旋转角度
|
||||
|
||||
@@ -19,7 +19,7 @@ import {
|
||||
import { Checkbox } from '@/components/ui/checkbox';
|
||||
|
||||
import { MoreVertical, Trash, RefreshCw, Box, Power } from 'lucide-react';
|
||||
import { formatDistanceToNow } from 'date-fns';
|
||||
import { formatDistanceToNow, differenceInMinutes, differenceInHours, isBefore } from 'date-fns';
|
||||
import { Badge } from '@/components/ui/badge';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
|
||||
@@ -50,11 +50,64 @@ export function CloudAccountCard({
|
||||
|
||||
// Helpers to get quota color
|
||||
const getQuotaColor = (percentage: number) => {
|
||||
if (percentage > 80) return 'text-green-500';
|
||||
if (percentage > 20) return 'text-yellow-500';
|
||||
if (percentage > 80) {
|
||||
return 'text-green-500';
|
||||
}
|
||||
if (percentage > 20) {
|
||||
return 'text-yellow-500';
|
||||
}
|
||||
return 'text-red-500';
|
||||
};
|
||||
|
||||
const formatTimeRemaining = (dateStr: string) => {
|
||||
const targetDate = new Date(dateStr);
|
||||
if (Number.isNaN(targetDate.getTime())) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const now = new Date();
|
||||
if (isBefore(targetDate, now)) {
|
||||
return '0h 0m';
|
||||
}
|
||||
|
||||
// Calculate difference in hours and minutes
|
||||
const diffHrs = differenceInHours(targetDate, now);
|
||||
const diffMins = differenceInMinutes(targetDate, now) - diffHrs * 60;
|
||||
if (diffHrs >= 24) {
|
||||
const diffDays = Math.floor(diffHrs / 24);
|
||||
const remainingHrs = diffHrs % 24;
|
||||
return `${diffDays}d ${remainingHrs}h`;
|
||||
}
|
||||
|
||||
return `${diffHrs}h ${diffMins}m`;
|
||||
};
|
||||
|
||||
const getResetTimeLabel = (resetTime?: string) => {
|
||||
if (!resetTime) {
|
||||
return t('cloud.card.resetUnknown');
|
||||
}
|
||||
|
||||
const remaining = formatTimeRemaining(resetTime);
|
||||
if (!remaining) {
|
||||
return t('cloud.card.resetUnknown');
|
||||
}
|
||||
|
||||
return `${t('cloud.card.resetPrefix')}: ${remaining}`;
|
||||
};
|
||||
|
||||
const getResetTimeTitle = (resetTime?: string) => {
|
||||
if (!resetTime) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const resetDate = new Date(resetTime);
|
||||
if (Number.isNaN(resetDate.getTime())) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
return `${t('cloud.card.resetTime')}: ${resetDate.toLocaleString()}`;
|
||||
};
|
||||
|
||||
const modelQuotas = Object.entries(account.quota?.models || {});
|
||||
|
||||
return (
|
||||
@@ -169,15 +222,30 @@ export function CloudAccountCard({
|
||||
<div className="space-y-2">
|
||||
{modelQuotas.length > 0 ? (
|
||||
modelQuotas.map(([modelName, info]) => (
|
||||
<div key={modelName} className="flex items-center justify-between text-sm">
|
||||
<span className="text-muted-foreground max-w-[120px] truncate" title={modelName}>
|
||||
<div
|
||||
key={modelName}
|
||||
className="hover:bg-muted/40 grid grid-cols-[minmax(0,1fr)_auto] items-start gap-3 rounded-md px-1.5 py-1 text-sm transition-colors"
|
||||
>
|
||||
<span className="text-muted-foreground min-w-0 truncate" title={modelName}>
|
||||
{modelName.replace('models/', '')}
|
||||
</span>
|
||||
<div className="flex items-center gap-2">
|
||||
<span className={`font-mono font-bold ${getQuotaColor(info.percentage)}`}>
|
||||
{info.percentage}%
|
||||
<div className="flex flex-col items-end gap-1">
|
||||
<span
|
||||
className="text-muted-foreground text-[10px] leading-none"
|
||||
title={getResetTimeTitle(info.resetTime)}
|
||||
>
|
||||
{getResetTimeLabel(info.resetTime)}
|
||||
</span>
|
||||
<span className="text-muted-foreground text-xs">{t('cloud.card.left')}</span>
|
||||
<div className="flex items-baseline gap-1.5">
|
||||
<span
|
||||
className={`font-mono leading-none font-bold ${getQuotaColor(info.percentage)}`}
|
||||
>
|
||||
{info.percentage}%
|
||||
</span>
|
||||
<span className="text-muted-foreground text-[10px]">
|
||||
{t('cloud.card.left')}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
))
|
||||
|
||||
@@ -394,7 +394,7 @@ export function CloudAccountList() {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="grid gap-4 md:grid-cols-2 lg:grid-cols-3">
|
||||
<div className="grid gap-4 md:grid-cols-2 xl:grid-cols-3">
|
||||
{accounts?.map((account) => (
|
||||
<CloudAccountCard
|
||||
key={account.id}
|
||||
|
||||
@@ -241,6 +241,9 @@ i18n
|
||||
refresh: 'Refresh Quota',
|
||||
delete: 'Delete Account',
|
||||
noQuota: 'No quota data',
|
||||
resetPrefix: 'reset',
|
||||
resetTime: 'Reset time',
|
||||
resetUnknown: 'Unknown',
|
||||
},
|
||||
list: {
|
||||
noAccounts: 'No cloud accounts added yet.',
|
||||
@@ -428,8 +431,7 @@ i18n
|
||||
title: '隐私',
|
||||
description: '控制你的数据如何用于改进应用。',
|
||||
error_reporting: '错误上报',
|
||||
error_reporting_desc:
|
||||
'发送匿名错误报告以帮助我们改进应用。不收集个人数据。',
|
||||
error_reporting_desc: '发送匿名错误报告以帮助我们改进应用。不收集个人数据。',
|
||||
restart_note: '错误上报设置会在重启应用后生效。',
|
||||
},
|
||||
proxy: {
|
||||
@@ -553,6 +555,9 @@ i18n
|
||||
refresh: '刷新配额',
|
||||
delete: '删除账号',
|
||||
noQuota: '无配额数据',
|
||||
resetPrefix: '重置',
|
||||
resetTime: '重置时间',
|
||||
resetUnknown: '未知',
|
||||
},
|
||||
list: {
|
||||
noAccounts: '暂无云账号。',
|
||||
@@ -688,7 +693,8 @@ i18n
|
||||
description: 'Управление вашими аккаунтами Antigravity Google Gemini.',
|
||||
noBackups: {
|
||||
title: 'Бэкапы не найдены',
|
||||
description: 'Создайте резервную копию вашего текущего аккаунта Antigravity, чтобы начать.',
|
||||
description:
|
||||
'Создайте резервную копию вашего текущего аккаунта Antigravity, чтобы начать.',
|
||||
action: 'Создать бэкап текущего аккаунта',
|
||||
},
|
||||
},
|
||||
@@ -741,7 +747,8 @@ i18n
|
||||
error_reporting: 'Отчеты об ошибках',
|
||||
error_reporting_desc:
|
||||
'Отправляйте анонимные отчеты об ошибках, чтобы помочь нам улучшить приложение. Личные данные не собираются.',
|
||||
restart_note: 'Изменения в отчетах об ошибках вступят в силу после перезапуска приложения.',
|
||||
restart_note:
|
||||
'Изменения в отчетах об ошибках вступят в силу после перезапуска приложения.',
|
||||
},
|
||||
proxy: {
|
||||
title: 'Верхнеуровневый прокси',
|
||||
@@ -865,6 +872,9 @@ i18n
|
||||
refresh: 'Обновить квоту',
|
||||
delete: 'Удалить аккаунт',
|
||||
noQuota: 'Нет данных',
|
||||
resetPrefix: 'Сброс',
|
||||
resetTime: 'Время сброса',
|
||||
resetUnknown: 'Неизвестно',
|
||||
},
|
||||
list: {
|
||||
noAccounts: 'Нет добавленных облачных аккаунтов.',
|
||||
|
||||
+71
-1
@@ -1,13 +1,21 @@
|
||||
import './instrument'; // MUST be the first import to ensure Sentry initializes before app ready
|
||||
import { app, BrowserWindow } from 'electron';
|
||||
import { app, BrowserWindow, dialog, shell } from 'electron';
|
||||
import type { MessageBoxOptions } from 'electron';
|
||||
import path from 'path';
|
||||
import fs from 'fs';
|
||||
import squirrelStartup from 'electron-squirrel-startup';
|
||||
|
||||
import { ipcMain } from 'electron/main';
|
||||
import { ipcContext } from '@/ipc/context';
|
||||
import { IPC_CHANNELS } from './constants';
|
||||
import { updateElectronApp, UpdateSourceType } from 'update-electron-app';
|
||||
import { logger } from './utils/logger';
|
||||
import {
|
||||
getExpectedInstallRoot,
|
||||
getInstallNoticeText,
|
||||
isRunningFromExpectedInstallDir as isRunningFromExpectedInstallDirUtil,
|
||||
resolveInstallNoticeLanguage,
|
||||
} from './utils/installNotice';
|
||||
import { CloudAccountRepo } from './ipc/database/cloudHandler';
|
||||
import { initDatabase } from './ipc/database/handler';
|
||||
import { CloudMonitorService } from './services/CloudMonitorService';
|
||||
@@ -58,6 +66,11 @@ ipcMain.on(IPC_CHANNELS.CHANGE_LANGUAGE, (event, lang) => {
|
||||
|
||||
app.disableHardwareAcceleration();
|
||||
|
||||
if (squirrelStartup) {
|
||||
app.quit();
|
||||
process.exit(0);
|
||||
}
|
||||
|
||||
const inDevelopment = process.env.NODE_ENV === 'development';
|
||||
|
||||
// Keep a global reference of the window object, if you don't, the window will
|
||||
@@ -67,6 +80,62 @@ let globalMainWindow: BrowserWindow | null = null;
|
||||
let isQuitting = false;
|
||||
let startupConfig: AppConfig | null = null;
|
||||
let shouldStartHidden = false;
|
||||
let hasShownInstallNotice = false;
|
||||
|
||||
function isRunningFromExpectedInstallDir() {
|
||||
return isRunningFromExpectedInstallDirUtil({
|
||||
platform: process.platform,
|
||||
isPackaged: app.isPackaged,
|
||||
localAppData: process.env.LOCALAPPDATA,
|
||||
appName: app.getName(),
|
||||
execPath: process.execPath,
|
||||
});
|
||||
}
|
||||
|
||||
function showWindowsInstallNoticeIfNeeded() {
|
||||
if (hasShownInstallNotice) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (isRunningFromExpectedInstallDir()) {
|
||||
return;
|
||||
}
|
||||
|
||||
const expectedRoot = getExpectedInstallRoot({
|
||||
platform: process.platform,
|
||||
localAppData: process.env.LOCALAPPDATA,
|
||||
appName: app.getName(),
|
||||
});
|
||||
if (!expectedRoot) {
|
||||
return;
|
||||
}
|
||||
|
||||
hasShownInstallNotice = true;
|
||||
const language = resolveInstallNoticeLanguage({
|
||||
configLanguage: startupConfig?.language,
|
||||
locale: app.getLocale(),
|
||||
});
|
||||
const text = getInstallNoticeText(language);
|
||||
|
||||
const options: MessageBoxOptions = {
|
||||
type: 'info',
|
||||
title: text.title,
|
||||
message: text.message,
|
||||
detail: `${text.detailPrefix}${expectedRoot}`,
|
||||
buttons: [...text.buttons],
|
||||
defaultId: 1,
|
||||
};
|
||||
|
||||
const showPromise = globalMainWindow
|
||||
? dialog.showMessageBox(globalMainWindow, options)
|
||||
: dialog.showMessageBox(options);
|
||||
|
||||
showPromise.then(({ response }) => {
|
||||
if (response === 0) {
|
||||
shell.openPath(expectedRoot);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
const gotSingleInstanceLock = app.requestSingleInstanceLock();
|
||||
|
||||
@@ -154,6 +223,7 @@ function createWindow({ startHidden }: { startHidden: boolean }) {
|
||||
}
|
||||
|
||||
logger.info('Window created');
|
||||
showWindowsInstallNoticeIfNeeded();
|
||||
|
||||
mainWindow.on('close', (event) => {
|
||||
if (!isQuitting) {
|
||||
|
||||
@@ -44,6 +44,24 @@ export class ProxyController {
|
||||
@Post('chat/completions')
|
||||
async chatCompletions(@Body() body: OpenAIChatRequest, @Res() res: FastifyReply) {
|
||||
try {
|
||||
// Claude Code CLI compatibility:
|
||||
// Claude CLI uses OpenAI-style /v1/chat/completions
|
||||
if (body.model?.startsWith('claude-')) {
|
||||
const result = await this.proxyService.handleAnthropicMessages(
|
||||
body as unknown as AnthropicChatRequest,
|
||||
);
|
||||
|
||||
if (body.stream && result instanceof Observable) {
|
||||
res.header('Content-Type', 'text/event-stream');
|
||||
res.header('Cache-Control', 'no-cache');
|
||||
res.header('Connection', 'keep-alive');
|
||||
res.send(result);
|
||||
} else {
|
||||
res.status(HttpStatus.OK).send(result);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
const result = await this.proxyService.handleChatCompletions(body);
|
||||
|
||||
if (body.stream && result instanceof Observable) {
|
||||
|
||||
@@ -0,0 +1,129 @@
|
||||
import path from 'path';
|
||||
|
||||
export type InstallNoticeLanguage = 'zh-CN' | 'en' | 'ru';
|
||||
|
||||
const installNoticeText: Record<
|
||||
InstallNoticeLanguage,
|
||||
{
|
||||
title: string;
|
||||
message: string;
|
||||
detailPrefix: string;
|
||||
buttons: [string, string];
|
||||
}
|
||||
> = {
|
||||
'zh-CN': {
|
||||
title: '建议从开始菜单启动',
|
||||
message:
|
||||
'检测到你正在从非安装路径启动应用。为了确保自动更新生效,请从开始菜单或桌面快捷方式启动。如果没有快捷方式,请重新运行安装包。',
|
||||
detailPrefix: '安装目录:',
|
||||
buttons: ['打开安装目录', '知道了'],
|
||||
},
|
||||
en: {
|
||||
title: 'Please launch from the Start menu',
|
||||
message:
|
||||
'We detected the app is running from a non-install location. To ensure auto-updates work, launch it from the Start menu or desktop shortcut. If no shortcut exists, run the installer again.',
|
||||
detailPrefix: 'Install location: ',
|
||||
buttons: ['Open install folder', 'OK'],
|
||||
},
|
||||
ru: {
|
||||
title: 'Запускайте приложение из меню «Пуск»',
|
||||
message:
|
||||
'Обнаружен запуск из неустановленного пути. Чтобы автообновления работали, запускайте приложение из меню «Пуск» или ярлыка. Если ярлыка нет, запустите установщик ещё раз.',
|
||||
detailPrefix: 'Папка установки: ',
|
||||
buttons: ['Открыть папку', 'Понятно'],
|
||||
},
|
||||
};
|
||||
|
||||
export function resolveInstallNoticeLanguage({
|
||||
configLanguage,
|
||||
locale,
|
||||
}: {
|
||||
configLanguage?: string | null;
|
||||
locale?: string | null;
|
||||
}): InstallNoticeLanguage {
|
||||
const rawLanguage = configLanguage || locale;
|
||||
if (!rawLanguage) {
|
||||
return 'en';
|
||||
}
|
||||
|
||||
const normalized = rawLanguage.toLowerCase();
|
||||
if (normalized.startsWith('zh')) {
|
||||
return 'zh-CN';
|
||||
}
|
||||
|
||||
if (normalized.startsWith('ru')) {
|
||||
return 'ru';
|
||||
}
|
||||
|
||||
return 'en';
|
||||
}
|
||||
|
||||
export function getInstallNoticeText(language: InstallNoticeLanguage) {
|
||||
return installNoticeText[language] || installNoticeText.en;
|
||||
}
|
||||
|
||||
function getPathApi(platform: string) {
|
||||
if (platform === 'win32') {
|
||||
return path.win32;
|
||||
}
|
||||
|
||||
return path;
|
||||
}
|
||||
|
||||
function normalizeWindowsInstallDirName(appName: string) {
|
||||
return appName
|
||||
.trim()
|
||||
.replace(/[^a-zA-Z0-9]+/g, '_')
|
||||
.replace(/^_+|_+$/g, '')
|
||||
.toLowerCase();
|
||||
}
|
||||
|
||||
export function getExpectedInstallRoot({
|
||||
platform,
|
||||
localAppData,
|
||||
appName,
|
||||
}: {
|
||||
platform: string;
|
||||
localAppData?: string | null;
|
||||
appName: string;
|
||||
}) {
|
||||
if (platform !== 'win32') {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!localAppData) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const pathApi = getPathApi(platform);
|
||||
const installDirName = normalizeWindowsInstallDirName(appName);
|
||||
return pathApi.resolve(pathApi.join(localAppData, installDirName));
|
||||
}
|
||||
|
||||
export function isRunningFromExpectedInstallDir({
|
||||
platform,
|
||||
isPackaged,
|
||||
localAppData,
|
||||
appName,
|
||||
execPath,
|
||||
}: {
|
||||
platform: string;
|
||||
isPackaged: boolean;
|
||||
localAppData?: string | null;
|
||||
appName: string;
|
||||
execPath: string;
|
||||
}) {
|
||||
if (platform !== 'win32' || !isPackaged) {
|
||||
return true;
|
||||
}
|
||||
|
||||
const expectedRoot = getExpectedInstallRoot({ platform, localAppData, appName });
|
||||
if (!expectedRoot) {
|
||||
return true;
|
||||
}
|
||||
|
||||
const pathApi = getPathApi(platform);
|
||||
const normalizedExecPath = pathApi.resolve(execPath);
|
||||
|
||||
return normalizedExecPath.toLowerCase().startsWith(expectedRoot.toLowerCase() + pathApi.sep);
|
||||
}
|
||||
@@ -26,6 +26,7 @@
|
||||
},
|
||||
"include": [
|
||||
"src/**/*",
|
||||
"types/**/*.d.ts",
|
||||
"./package.json",
|
||||
"./forge.config.ts",
|
||||
"*.mts",
|
||||
|
||||
Vendored
+38
@@ -0,0 +1,38 @@
|
||||
declare module 'electron-packager-languages' {
|
||||
type AfterCopyHook = (
|
||||
buildPath: string,
|
||||
electronVersion: string,
|
||||
platform: string,
|
||||
arch: string,
|
||||
callback: () => void,
|
||||
) => void;
|
||||
|
||||
interface SetLanguagesOptions {
|
||||
allowRemovingAll?: boolean;
|
||||
}
|
||||
|
||||
function setLanguages(languages: string[], options?: SetLanguagesOptions): AfterCopyHook;
|
||||
|
||||
export = setLanguages;
|
||||
}
|
||||
|
||||
declare module '@pengx17/electron-forge-maker-appimage' {
|
||||
import type MakerBase from '@electron-forge/maker-base';
|
||||
import type { ForgePlatform } from '@electron-forge/shared-types';
|
||||
|
||||
export interface AppImageForgeConfig {
|
||||
template?: string;
|
||||
chmodChromeSandbox?: string;
|
||||
icons?: { file: string; size: number }[];
|
||||
}
|
||||
|
||||
export interface MakerAppImageConfig {
|
||||
config?: AppImageForgeConfig;
|
||||
}
|
||||
|
||||
export default class MakerAppImage extends MakerBase<MakerAppImageConfig> {
|
||||
name: string;
|
||||
defaultPlatforms: ForgePlatform[];
|
||||
isSupportedOnCurrentPlatform(): boolean;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user