fix: make Android tasks use extensions automatically and populate marketplace

This commit is contained in:
chenmingxuan committed 2026-10-14 22:32:38 +08:00
1 parent 6663233ab8
commit 9c82a40cbf
32 files changed
+341 -131

No files matched your search

@@ -0,0 +1,54 @@
import { Component, inject, output, signal } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { RouterLink } from '@angular/router';
import { InstalledPlugin, PluginService } from '../../services/plugin.service';
export interface TaskPluginOptions {
plugins?: { id: string; profile: string; version?: string }[];
}
@Component({
selector: 'app-task-plugins', standalone: true, imports: [FormsModule, RouterLink],
templateUrl: './task-plugins.component.html', styleUrl: './task-plugins.component.scss'
})
export class TaskPluginsComponent {
changed = output<TaskPluginOptions>();
private api = inject(PluginService);
automatic = true;
selected: Record<string, string> = {};
open = signal(false);
loading = signal(false);
error = signal('');
plugins = signal<InstalledPlugin[]>([]);
summary() {
return this.automatic ? '自动' : Object.keys(this.selected).length ? `已选 ${Object.keys(this.selected).length} 个` : '本次停用';
}
available() {
return this.plugins().filter(p => p.enabled && p.profiles.some(profile => profile.authorized) &&
p.manifest.targets.some(target => target === 'android' || target === 'mixed'));
}
toggle() {
this.open.update(v => !v);
if (this.open()) this.load();
}
load() {
this.loading.set(true); this.error.set('');
this.api.list().subscribe({
next: value => { this.plugins.set(value.plugins); this.loading.set(false); },
error: () => { this.error.set('暂时无法读取插件。'); this.loading.set(false); }
});
}
choose(plugin: InstalledPlugin, event: Event) {
if ((event.target as HTMLInputElement).checked) {
const profiles = plugin.profiles.filter(p => p.authorized);
this.selected[plugin.manifest.id] = (profiles.find(p => p.is_default) || profiles[0]).name;
} else delete this.selected[plugin.manifest.id];
this.emit();
}
emit() {
this.changed.emit(this.automatic ? {} : {
plugins: Object.entries(this.selected).map(([id, profile]) => ({ id, profile }))
});
}
}