2
This commit is contained in:
1 parent
5ac164b407
commit
f93f6095af
94 files changed
+7877
-4018
No files matched your search
+24
-213
@@ -7,78 +7,22 @@ enum DistroArch {
|
||||
x86_64,
|
||||
}
|
||||
|
||||
/// LXC 容器镜像元数据规格(用于根据下载源动态解析真实下载路径)
|
||||
class LxcImageSpec {
|
||||
/// 发行版代号 (例如 'debian', 'archlinux', 'fedora')
|
||||
final String distribution;
|
||||
|
||||
/// 版本标识 (例如 'bookworm', 'current', '43')
|
||||
final String release;
|
||||
|
||||
/// 变体标识 (例如 'default', 'cloud')
|
||||
final String variant;
|
||||
|
||||
const LxcImageSpec({
|
||||
required this.distribution,
|
||||
required this.release,
|
||||
this.variant = 'default',
|
||||
});
|
||||
}
|
||||
|
||||
/// 发行版下载镜像源定义
|
||||
class DistroMirror {
|
||||
final String id;
|
||||
final String name;
|
||||
final String baseUrl;
|
||||
final bool isDefault;
|
||||
|
||||
const DistroMirror({
|
||||
required this.id,
|
||||
required this.name,
|
||||
required this.baseUrl,
|
||||
this.isDefault = false,
|
||||
});
|
||||
}
|
||||
|
||||
/// 发行版条目清单模型
|
||||
/// 单一主系统条目清单模型
|
||||
class DistroManifestItem {
|
||||
/// 唯一标识符 (例如 'ubuntu', 'alpine', 'debian')
|
||||
final String id;
|
||||
|
||||
/// 显示名称 (例如 'Ubuntu', 'Alpine Linux', 'Debian')
|
||||
final String name;
|
||||
|
||||
/// 版本文本 (例如 '24.04.5 LTS', '3.20.3', '12 (Bookworm)')
|
||||
final String version;
|
||||
|
||||
/// 是否推荐
|
||||
final bool isRecommended;
|
||||
|
||||
/// 是否为软件内置安装包(打包在 assets 中,受删除保护且无需网络下载)
|
||||
final bool isBuiltin;
|
||||
|
||||
/// LXC 镜像元数据(在线下载型系统专属,用于动态源解析器自动发现真实路径)
|
||||
final LxcImageSpec? lxcSpec;
|
||||
|
||||
/// 对应架构资源包映射 (架构 -> 下载 URL 或 Asset 路径)
|
||||
final Map<DistroArch, String> packages;
|
||||
|
||||
/// 系统图标或装饰图标
|
||||
final IconData iconData;
|
||||
|
||||
/// 品牌主题色(用于图标底色/装饰)
|
||||
final Color brandColor;
|
||||
|
||||
/// 本地资产图标路径 (例如 'assets/icons/distros/ubuntu.png')
|
||||
final String? assetIconPath;
|
||||
|
||||
const DistroManifestItem({
|
||||
required this.id,
|
||||
required this.name,
|
||||
required this.version,
|
||||
this.isRecommended = false,
|
||||
this.isBuiltin = false,
|
||||
this.lxcSpec,
|
||||
this.isBuiltin = true,
|
||||
required this.packages,
|
||||
required this.iconData,
|
||||
required this.brandColor,
|
||||
@@ -99,175 +43,42 @@ class DistroManifestItem {
|
||||
return packages.containsKey(currentArch);
|
||||
}
|
||||
|
||||
/// 获取当前设备适用的资源包路径或 URL
|
||||
/// 获取当前设备适用的内置资源包路径
|
||||
String? get currentPackageSource {
|
||||
return packages[currentArch];
|
||||
}
|
||||
}
|
||||
|
||||
/// 系统资源库静态目录(包含内置与经过验证的高速在线源)
|
||||
/// 系统资源库静态目录(单一内置系统:Ubuntu 24.04 LTS)
|
||||
class DistroRepository {
|
||||
static const List<DistroManifestItem> availableDistros = [
|
||||
// 1. Ubuntu 24.04 LTS (推荐,软件内置)
|
||||
DistroManifestItem(
|
||||
id: 'ubuntu',
|
||||
name: 'Ubuntu',
|
||||
version: '24.04.5 LTS (Noble Numbat)',
|
||||
isRecommended: true,
|
||||
isBuiltin: true,
|
||||
iconData: Icons.donut_large_rounded,
|
||||
brandColor: Color(0xFFE95420), // Ubuntu Orange
|
||||
assetIconPath: 'assets/icons/distros/ubuntu.png',
|
||||
packages: {
|
||||
DistroArch.arm64: 'assets/distros/ubuntu-base-24.04.5-base-arm64.tar.gz',
|
||||
DistroArch.x86_64: 'assets/distros/ubuntu-base-24.04.5-base-x86_64.tar.gz',
|
||||
},
|
||||
),
|
||||
|
||||
// 2. Alpine 3.20 (软件内置)
|
||||
DistroManifestItem(
|
||||
id: 'alpine',
|
||||
name: 'Alpine Linux',
|
||||
version: '3.20.3 (musl libc)',
|
||||
isRecommended: false,
|
||||
isBuiltin: true,
|
||||
iconData: Icons.landscape_rounded,
|
||||
brandColor: Color(0xFF0D597F), // Alpine Blue
|
||||
assetIconPath: 'assets/icons/distros/alpine.png',
|
||||
packages: {
|
||||
DistroArch.arm64: 'assets/distros/alpine-minirootfs-3.20.3-aarch64.tar.gz',
|
||||
DistroArch.x86_64: 'assets/distros/alpine-minirootfs-3.20.3-x86_64.tar.gz',
|
||||
},
|
||||
),
|
||||
|
||||
// 3. Debian 12 (Bookworm) - 在线下载,不占 APK 体积
|
||||
DistroManifestItem(
|
||||
id: 'debian',
|
||||
name: 'Debian',
|
||||
version: '12 (Bookworm)',
|
||||
isRecommended: false,
|
||||
isBuiltin: false,
|
||||
lxcSpec: LxcImageSpec(
|
||||
distribution: 'debian',
|
||||
release: 'bookworm',
|
||||
variant: 'default',
|
||||
),
|
||||
iconData: Icons.all_inclusive_rounded,
|
||||
brandColor: Color(0xFFA80030), // Debian Red
|
||||
assetIconPath: 'assets/icons/distros/debian.png',
|
||||
packages: {
|
||||
DistroArch.arm64: 'https://mirrors.tuna.tsinghua.edu.cn/lxc-images/images/debian/bookworm/arm64/default/20260913_05:24/rootfs.tar.xz',
|
||||
DistroArch.x86_64: 'https://mirrors.tuna.tsinghua.edu.cn/lxc-images/images/debian/bookworm/amd64/default/20260913_05:24/rootfs.tar.xz',
|
||||
},
|
||||
),
|
||||
|
||||
// 4. Arch Linux - 在线源
|
||||
DistroManifestItem(
|
||||
id: 'arch',
|
||||
name: 'Arch Linux',
|
||||
version: 'Rolling Release',
|
||||
isRecommended: false,
|
||||
isBuiltin: false,
|
||||
lxcSpec: LxcImageSpec(
|
||||
distribution: 'archlinux',
|
||||
release: 'current',
|
||||
variant: 'default',
|
||||
),
|
||||
iconData: Icons.change_history_rounded,
|
||||
brandColor: Color(0xFF1793D1), // Arch Cyan
|
||||
assetIconPath: 'assets/icons/distros/arch.png',
|
||||
packages: {
|
||||
DistroArch.arm64: 'https://mirrors.tuna.tsinghua.edu.cn/lxc-images/images/archlinux/current/arm64/default/20260913_04:18/rootfs.tar.xz',
|
||||
DistroArch.x86_64: 'https://mirrors.tuna.tsinghua.edu.cn/lxc-images/images/archlinux/current/amd64/default/20260913_04:18/rootfs.tar.xz',
|
||||
},
|
||||
),
|
||||
|
||||
// 5. Fedora 43 - 在线源
|
||||
DistroManifestItem(
|
||||
id: 'fedora',
|
||||
name: 'Fedora',
|
||||
version: '43 (Container Base)',
|
||||
isRecommended: false,
|
||||
isBuiltin: false,
|
||||
lxcSpec: LxcImageSpec(
|
||||
distribution: 'fedora',
|
||||
release: '43',
|
||||
variant: 'default',
|
||||
),
|
||||
iconData: Icons.language_rounded,
|
||||
brandColor: Color(0xFF51A2DA), // Fedora Blue
|
||||
assetIconPath: 'assets/icons/distros/fedora.png',
|
||||
packages: {
|
||||
DistroArch.arm64: 'https://mirrors.tuna.tsinghua.edu.cn/lxc-images/images/fedora/43/arm64/default/20260913_20:33/rootfs.tar.xz',
|
||||
DistroArch.x86_64: 'https://mirrors.tuna.tsinghua.edu.cn/lxc-images/images/fedora/43/amd64/default/20260913_20:33/rootfs.tar.xz',
|
||||
},
|
||||
),
|
||||
];
|
||||
|
||||
/// 可选的高速开源软件镜像源
|
||||
static const List<DistroMirror> availableMirrors = [
|
||||
DistroMirror(
|
||||
id: 'tsinghua',
|
||||
name: 'Tsinghua TUNA Mirror',
|
||||
baseUrl: 'https://mirrors.tuna.tsinghua.edu.cn/lxc-images/',
|
||||
isDefault: true,
|
||||
),
|
||||
DistroMirror(
|
||||
id: 'bfsu',
|
||||
name: 'BFSU Open Source Mirror',
|
||||
baseUrl: 'https://mirrors.bfsu.edu.cn/lxc-images/',
|
||||
),
|
||||
DistroMirror(
|
||||
id: 'iscas',
|
||||
name: 'ISCAS Open Source Mirror',
|
||||
baseUrl: 'https://mirror.iscas.ac.cn/lxc-images/',
|
||||
),
|
||||
DistroMirror(
|
||||
id: 'official',
|
||||
name: 'LinuxContainers Official Mirror',
|
||||
baseUrl: 'https://images.linuxcontainers.org/',
|
||||
),
|
||||
];
|
||||
|
||||
/// 默认推荐镜像源(清华大学源)
|
||||
static DistroMirror get defaultMirror =>
|
||||
availableMirrors.firstWhere((m) => m.isDefault, orElse: () => availableMirrors.first);
|
||||
|
||||
/// 根据 ID 检索镜像源
|
||||
static DistroMirror getMirrorById(String id) {
|
||||
return availableMirrors.firstWhere(
|
||||
(m) => m.id == id,
|
||||
orElse: () => defaultMirror,
|
||||
);
|
||||
}
|
||||
|
||||
/// 根据当前机器架构过滤,仅返回本架构支持的发行版列表
|
||||
static List<DistroManifestItem> get currentArchDistros {
|
||||
return availableDistros.where((d) => d.isSupportedOnCurrentDevice).toList();
|
||||
}
|
||||
|
||||
/// 默认系统实例名称
|
||||
static const String defaultSystemName = 'ubuntu';
|
||||
|
||||
/// 根据 ID 查找发行版配置
|
||||
static const DistroManifestItem ubuntuItem = DistroManifestItem(
|
||||
id: defaultSystemName,
|
||||
name: 'Ubuntu',
|
||||
version: '24.04.5 LTS (Noble Numbat)',
|
||||
isBuiltin: true,
|
||||
iconData: Icons.donut_large_rounded,
|
||||
brandColor: Color(0xFFE95420), // Ubuntu Orange
|
||||
assetIconPath: 'assets/icons/distros/ubuntu.png',
|
||||
packages: {
|
||||
DistroArch.arm64: 'assets/distros/ubuntu-base-24.04.5-base-arm64.tar.gz',
|
||||
DistroArch.x86_64: 'assets/distros/ubuntu-base-24.04.5-base-x86_64.tar.gz',
|
||||
},
|
||||
);
|
||||
|
||||
static const List<DistroManifestItem> availableDistros = [ubuntuItem];
|
||||
|
||||
/// 根据 ID 查找系统配置
|
||||
static DistroManifestItem? getById(String id) {
|
||||
try {
|
||||
return availableDistros.firstWhere((e) => e.id == id);
|
||||
} catch (_) {
|
||||
return null;
|
||||
}
|
||||
if (id == defaultSystemName) return ubuntuItem;
|
||||
return null;
|
||||
}
|
||||
|
||||
/// 内置 Ubuntu 资源包路径(自动匹配当前 CPU 架构)
|
||||
static String get builtinUbuntuAssetPath {
|
||||
return getById('ubuntu')?.currentPackageSource ??
|
||||
return ubuntuItem.currentPackageSource ??
|
||||
'assets/distros/ubuntu-base-24.04.5-base-arm64.tar.gz';
|
||||
}
|
||||
|
||||
/// 内置 Alpine 资源包路径(自动匹配当前 CPU 架构)
|
||||
static String get builtinAlpineAssetPath {
|
||||
return getById('alpine')?.currentPackageSource ??
|
||||
'assets/distros/alpine-minirootfs-3.20.3-aarch64.tar.gz';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,9 +5,13 @@ class LspLanguageConfig {
|
||||
final List<String> fileExtensions;
|
||||
final String serverCommand;
|
||||
final List<String> serverArgs;
|
||||
final String apkPackage;
|
||||
final String package;
|
||||
final bool enabled;
|
||||
|
||||
/// 兼容别名
|
||||
String get apkPackage => package;
|
||||
String get aptPackage => package;
|
||||
|
||||
const LspLanguageConfig({
|
||||
required this.id,
|
||||
required this.name,
|
||||
@@ -15,11 +19,12 @@ class LspLanguageConfig {
|
||||
required this.fileExtensions,
|
||||
required this.serverCommand,
|
||||
this.serverArgs = const [],
|
||||
required this.apkPackage,
|
||||
required this.package,
|
||||
this.enabled = true,
|
||||
});
|
||||
|
||||
factory LspLanguageConfig.fromJson(Map<String, dynamic> json) {
|
||||
final pkg = (json['package'] ?? json['aptPackage'] ?? json['apkPackage']) as String? ?? '';
|
||||
return LspLanguageConfig(
|
||||
id: json['id'] as String? ?? '',
|
||||
name: json['name'] as String? ?? '',
|
||||
@@ -34,7 +39,7 @@ class LspLanguageConfig {
|
||||
?.map((e) => e.toString())
|
||||
.toList() ??
|
||||
[],
|
||||
apkPackage: json['apkPackage'] as String? ?? '',
|
||||
package: pkg,
|
||||
enabled: json['enabled'] as bool? ?? true,
|
||||
);
|
||||
}
|
||||
@@ -47,7 +52,8 @@ class LspLanguageConfig {
|
||||
'fileExtensions': fileExtensions,
|
||||
'serverCommand': serverCommand,
|
||||
'serverArgs': serverArgs,
|
||||
'apkPackage': apkPackage,
|
||||
'package': package,
|
||||
'apkPackage': package,
|
||||
'enabled': enabled,
|
||||
};
|
||||
}
|
||||
@@ -59,6 +65,7 @@ class LspLanguageConfig {
|
||||
List<String>? fileExtensions,
|
||||
String? serverCommand,
|
||||
List<String>? serverArgs,
|
||||
String? package,
|
||||
String? apkPackage,
|
||||
bool? enabled,
|
||||
}) {
|
||||
@@ -69,13 +76,13 @@ class LspLanguageConfig {
|
||||
fileExtensions: fileExtensions ?? this.fileExtensions,
|
||||
serverCommand: serverCommand ?? this.serverCommand,
|
||||
serverArgs: serverArgs ?? this.serverArgs,
|
||||
apkPackage: apkPackage ?? this.apkPackage,
|
||||
package: package ?? apkPackage ?? this.package,
|
||||
enabled: enabled ?? this.enabled,
|
||||
);
|
||||
}
|
||||
|
||||
/// 官方默认预设语言列表
|
||||
static List<LspLanguageConfig> get defaultPresets => [
|
||||
/// 官方内置语言支持模版(基于 Ubuntu 官方 apt 工具链,仅作探测与安装指引,不默认写入用户配置)
|
||||
static List<LspLanguageConfig> get builtinPresets => [
|
||||
const LspLanguageConfig(
|
||||
id: 'c_cpp',
|
||||
name: 'C / C++',
|
||||
@@ -83,7 +90,7 @@ class LspLanguageConfig {
|
||||
fileExtensions: ['.c', '.cpp', '.cc', '.cxx', '.h', '.hpp'],
|
||||
serverCommand: 'clangd',
|
||||
serverArgs: ['--background-index'],
|
||||
apkPackage: 'clang-extra-tools',
|
||||
package: 'clangd',
|
||||
enabled: true,
|
||||
),
|
||||
const LspLanguageConfig(
|
||||
@@ -93,7 +100,7 @@ class LspLanguageConfig {
|
||||
fileExtensions: ['.py'],
|
||||
serverCommand: 'pylsp',
|
||||
serverArgs: [],
|
||||
apkPackage: 'py3-lsp-server',
|
||||
package: 'python3-pylsp',
|
||||
enabled: true,
|
||||
),
|
||||
const LspLanguageConfig(
|
||||
@@ -103,7 +110,7 @@ class LspLanguageConfig {
|
||||
fileExtensions: ['.rs'],
|
||||
serverCommand: 'rust-analyzer',
|
||||
serverArgs: [],
|
||||
apkPackage: 'rust-analyzer',
|
||||
package: 'rust-analyzer',
|
||||
enabled: true,
|
||||
),
|
||||
const LspLanguageConfig(
|
||||
@@ -113,7 +120,7 @@ class LspLanguageConfig {
|
||||
fileExtensions: ['.go'],
|
||||
serverCommand: 'gopls',
|
||||
serverArgs: [],
|
||||
apkPackage: 'gopls',
|
||||
package: 'gopls',
|
||||
enabled: true,
|
||||
),
|
||||
const LspLanguageConfig(
|
||||
@@ -123,8 +130,56 @@ class LspLanguageConfig {
|
||||
fileExtensions: ['.sh', '.bash'],
|
||||
serverCommand: 'bash-language-server',
|
||||
serverArgs: ['start'],
|
||||
apkPackage: 'bash-language-server',
|
||||
package: 'bash-language-server',
|
||||
enabled: true,
|
||||
),
|
||||
const LspLanguageConfig(
|
||||
id: 'java',
|
||||
name: 'Java',
|
||||
languageId: 'java',
|
||||
fileExtensions: ['.java'],
|
||||
serverCommand: 'jdtls',
|
||||
serverArgs: [],
|
||||
package: 'jdtls',
|
||||
enabled: true,
|
||||
),
|
||||
const LspLanguageConfig(
|
||||
id: 'typescript',
|
||||
name: 'TypeScript',
|
||||
languageId: 'typescript',
|
||||
fileExtensions: ['.ts', '.mts', '.tsx'],
|
||||
serverCommand: 'typescript-language-server',
|
||||
serverArgs: ['--stdio'],
|
||||
package: 'typescript-language-server',
|
||||
enabled: true,
|
||||
),
|
||||
const LspLanguageConfig(
|
||||
id: 'lua',
|
||||
name: 'Lua',
|
||||
languageId: 'lua',
|
||||
fileExtensions: ['.lua'],
|
||||
serverCommand: 'lua-language-server',
|
||||
serverArgs: [],
|
||||
package: 'lua-language-server',
|
||||
enabled: true,
|
||||
),
|
||||
];
|
||||
|
||||
/// 保持向后兼容别名
|
||||
static List<LspLanguageConfig> get defaultPresets => builtinPresets;
|
||||
|
||||
/// 根据文件后缀从内置预设模版中匹配支持的语言
|
||||
static LspLanguageConfig? findBuiltinByExtension(String ext) {
|
||||
if (ext.isEmpty) return null;
|
||||
final normalized = ext.startsWith('.') ? ext.toLowerCase() : '.$ext'.toLowerCase();
|
||||
for (final preset in builtinPresets) {
|
||||
for (final item in preset.fileExtensions) {
|
||||
final itemNorm = item.startsWith('.') ? item.toLowerCase() : '.$item'.toLowerCase();
|
||||
if (itemNorm == normalized) {
|
||||
return preset;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -82,6 +82,45 @@ class ModuleFailureText extends NoticeText {
|
||||
});
|
||||
}
|
||||
|
||||
/// 后台组件安装/卸载阶段通知(支持排队、执行中)
|
||||
class ComponentInstallPhaseText extends NoticeText {
|
||||
final String componentName;
|
||||
final bool isUninstall;
|
||||
final bool isQueued;
|
||||
final String? detail;
|
||||
|
||||
const ComponentInstallPhaseText({
|
||||
required this.componentName,
|
||||
this.isUninstall = false,
|
||||
this.isQueued = false,
|
||||
this.detail,
|
||||
});
|
||||
}
|
||||
|
||||
/// 后台组件安装/卸载成功通知
|
||||
class ComponentInstallDoneText extends NoticeText {
|
||||
final String componentName;
|
||||
final bool isUninstall;
|
||||
|
||||
const ComponentInstallDoneText({
|
||||
required this.componentName,
|
||||
this.isUninstall = false,
|
||||
});
|
||||
}
|
||||
|
||||
/// 后台组件安装/卸载失败通知
|
||||
class ComponentInstallFailureText extends NoticeText {
|
||||
final String componentName;
|
||||
final bool isUninstall;
|
||||
final String? error;
|
||||
|
||||
const ComponentInstallFailureText({
|
||||
required this.componentName,
|
||||
this.isUninstall = false,
|
||||
this.error,
|
||||
});
|
||||
}
|
||||
|
||||
/// 一条通知(业务无关:任务探测、以后的下载/编译进度都可复用)
|
||||
@immutable
|
||||
class NoticeItem {
|
||||
|
||||
@@ -139,6 +139,31 @@ class RunTask {
|
||||
return l10n.detectedTaskSingleRustDesc;
|
||||
case 'detected_single_js':
|
||||
return l10n.detectedTaskSingleJsDesc;
|
||||
case 'detected_single_java':
|
||||
return l10n.detectedTaskSingleJavaDesc;
|
||||
case 'detected_single_ts':
|
||||
return l10n.detectedTaskSingleTsDesc;
|
||||
case 'detected_single_lua':
|
||||
return l10n.detectedTaskSingleLuaDesc;
|
||||
case 'detected_single_perl':
|
||||
return l10n.detectedTaskSinglePerlDesc;
|
||||
case 'detected_single_php':
|
||||
return l10n.detectedTaskSinglePhpDesc;
|
||||
case 'detected_python_pip_install':
|
||||
return l10n.detectedTaskPythonPipInstallDesc;
|
||||
case 'detected_python_run_main':
|
||||
case 'detected_python_run_app':
|
||||
return l10n.detectedTaskPythonRunMainDesc;
|
||||
case 'detected_python_pytest':
|
||||
return l10n.detectedTaskPythonPytestDesc;
|
||||
case 'detected_maven_package':
|
||||
return l10n.detectedTaskMavenPackageDesc;
|
||||
case 'detected_maven_compile':
|
||||
return l10n.detectedTaskMavenCompileDesc;
|
||||
case 'detected_maven_test':
|
||||
return l10n.detectedTaskMavenTestDesc;
|
||||
case 'detected_maven_clean':
|
||||
return l10n.detectedTaskMavenCleanDesc;
|
||||
default:
|
||||
return description ?? '';
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user