@@ -29,43 +29,47 @@ export default class PlatformService {
29
29
30
30
/**
31
31
* 从 User-Agent 字符串中检测架构
32
+ * Mac 默认 ARM64,Windows 基于 UA 判断
32
33
*/
33
34
public getArchitectureFromUA ( userAgent : string ) : 'x64' | 'arm64' | 'Unknown' {
35
+ if ( ! userAgent ) return 'Unknown' ;
34
36
const ua = userAgent . toLowerCase ( ) ;
35
37
36
- // ARM64 检测
37
- if ( ua . includes ( 'arm64' ) || ua . includes ( 'aarch64' ) ) {
38
+ // === Mac 架构检测 ===
39
+ if ( ua . includes ( 'mac' ) || ua . includes ( 'darwin' ) ) {
40
+ // Mac 默认假设为 ARM64 (Apple Silicon)
38
41
return 'arm64' ;
39
42
}
40
43
41
- // Apple Silicon Mac 检测 (基于 Safari 版本和特征)
42
- if ( ua . includes ( 'mac' ) && ua . includes ( 'safari' ) ) {
43
- // Safari 14.0+ 更可能是 Apple Silicon (启发式)
44
- const safariMatch = ua . match ( / v e r s i o n \/ ( [ \d . ] + ) .* s a f a r i / ) ;
45
- if ( safariMatch ) {
46
- const version = parseFloat ( safariMatch [ 1 ] ) ;
47
- if ( version >= 14.0 ) {
48
- // 进一步检查是否有 Apple Silicon 的迹象
49
- if ( ua . includes ( 'applewebkit/605.1.15' ) || ua . includes ( 'version/14' ) ) {
50
- return 'arm64' ;
51
- }
52
- }
44
+ // === Windows 架构检测 ===
45
+ if ( ua . includes ( 'windows' ) || ua . includes ( 'win32' ) || ua . includes ( 'win64' ) ) {
46
+ // ARM64 Windows 检测
47
+ if ( ua . includes ( 'arm64' ) || ua . includes ( 'aarch64' ) ) {
48
+ return 'arm64' ;
49
+ }
50
+
51
+ // x64 Windows 检测
52
+ if ( ua . includes ( 'win64' ) || ua . includes ( 'x64' ) || ua . includes ( 'wow64' ) || ua . includes ( 'amd64' ) || ua . includes ( 'x86_64' ) ) {
53
+ return 'x64' ;
53
54
}
54
- }
55
55
56
- // x64 检测
57
- if ( ua . includes ( 'x64' ) || ua . includes ( 'x86_64' ) || ua . includes ( 'amd64' ) || ua . includes ( 'wow64' ) ) {
56
+ // Windows 默认假设为 x64
58
57
return 'x64' ;
59
58
}
60
59
61
- // 默认假设 x64 (大多数桌面系统)
62
- if ( ua . includes ( 'windows' ) || ua . includes ( 'mac' ) ) {
60
+ // === 通用架构检测 ===
61
+ if ( ua . includes ( 'arm64' ) || ua . includes ( 'aarch64' ) ) {
62
+ return 'arm64' ;
63
+ }
64
+
65
+ if ( ua . includes ( 'x64' ) || ua . includes ( 'x86_64' ) || ua . includes ( 'amd64' ) ) {
63
66
return 'x64' ;
64
67
}
65
68
66
69
return 'Unknown' ;
67
70
}
68
71
72
+
69
73
public async getReleases ( ) : Promise < GetReleasesDTO | null > {
70
74
try {
71
75
const response = await fetch ( 'https://cdn.algoux.cn/algo-bootstrap/version.json?t=' + Date . now ( ) ) ;
0 commit comments