feat: add ArkTS shell code skeleton placeholders

This commit is contained in:
OpenClaw committed 2026-03-09 14:16:11 +08:00
1 parent 339756c1aa
commit f8f18f185e
32 files changed
+561

No files matched your search

@@ -0,0 +1,13 @@
export interface NativeInstalledAppDTO {
appId: string
name: string
icon?: string
version?: string
runnable: boolean
}
export class NativeAppAdapter {
async listInstalledApps(): Promise<NativeInstalledAppDTO[]> {
return []
}
}
@@ -0,0 +1,21 @@
export interface NativePackagePreviewDTO {
name: string
version?: string
icon?: string
size?: number
valid: boolean
}
export class NativeImportAdapter {
async pickFile(): Promise<string | null> {
return null
}
async inspectPackage(_fileUri: string): Promise<NativePackagePreviewDTO> {
return { name: '', valid: false }
}
async importPackage(_fileUri: string): Promise<{ appId: string }> {
return { appId: '' }
}
}
@@ -0,0 +1,7 @@
export class NativeRuntimeAdapter {
async startSession(_appId: string): Promise<void> {}
async restartSession(_appId: string): Promise<void> {}
async stopSession(): Promise<void> {}
async notifyPageShow(): Promise<void> {}
async notifyPageHide(): Promise<void> {}
}
@@ -0,0 +1,11 @@
@Component
export struct AppCard {
@Prop title: string = ''
build() {
Column() {
Text(this.title)
}
.padding(16)
}
}
@@ -0,0 +1,16 @@
import type { AppItemVM } from '../../models/AppItemVM'
@Component
export struct AppListView {
@Prop items: AppItemVM[] = []
build() {
List() {
ForEach(this.items, (item: AppItemVM) => {
ListItem() {
Text(item.name)
}
}, (item: AppItemVM) => item.id)
}
}
}
@@ -0,0 +1,6 @@
@Component
export struct ImportEntryButton {
build() {
Button('导入应用')
}
}
@@ -0,0 +1,13 @@
@Component
export struct ConfirmDialog {
@Prop title: string = '确认'
@Prop content: string = ''
build() {
Column() {
Text(this.title)
Text(this.content).margin({ top: 8 })
}
.padding(16)
}
}
@@ -0,0 +1,12 @@
@Component
export struct EmptyState {
@Prop text: string = '暂无数据'
build() {
Column() {
Text(this.text)
}
.width('100%')
.padding(24)
}
}
@@ -0,0 +1,13 @@
@Component
export struct LoadingBlock {
@Prop text: string = '加载中'
build() {
Column() {
LoadingProgress()
Text(this.text).margin({ top: 8 })
}
.width('100%')
.padding(16)
}
}
@@ -0,0 +1,12 @@
@Component
export struct PageHeader {
@Prop title: string = ''
build() {
Row() {
Text(this.title).fontSize(20).fontWeight(FontWeight.Medium)
}
.width('100%')
.padding(16)
}
}
@@ -0,0 +1,13 @@
@Component
export struct StatusBanner {
@Prop text: string = ''
build() {
if (this.text) {
Text(this.text)
.width('100%')
.padding(12)
.backgroundColor('#FFF3CD')
}
}
}
@@ -0,0 +1,12 @@
@Component
export struct ImportProgressPanel {
@Prop text: string = '导入中'
build() {
Column() {
LoadingProgress()
Text(this.text).margin({ top: 8 })
}
.padding(16)
}
}
@@ -0,0 +1,8 @@
@Component
export struct ImportResultPanel {
@Prop text: string = ''
build() {
Text(this.text).padding(16)
}
}
@@ -0,0 +1,6 @@
@Component
export struct ImportSourceSelector {
build() {
Button('选择本地文件')
}
}
@@ -0,0 +1,11 @@
@Component
export struct PackagePreviewCard {
@Prop name: string = ''
build() {
Column() {
Text(this.name || '未选择文件')
}
.padding(16)
}
}
@@ -0,0 +1,10 @@
@Component
export struct RuntimeContainer {
build() {
Column() {
Text('Runtime Surface Placeholder')
}
.width('100%')
.height('100%')
}
}
@@ -0,0 +1,10 @@
@Component
export struct RuntimeStatusOverlay {
@Prop text: string = ''
build() {
if (this.text) {
Text(this.text).padding(16)
}
}
}
@@ -0,0 +1,11 @@
@Component
export struct RuntimeToolbar {
build() {
Row({ space: 12 }) {
Button('返回')
Button('重启')
Button('退出')
}
.padding(16)
}
}
+7
View File
@@ -0,0 +1,7 @@
export interface AppItemVM {
id: string
name: string
icon?: string
version?: string
status: 'ready' | 'invalid'
}
@@ -0,0 +1,7 @@
export interface PackagePreviewVM {
name: string
version?: string
icon?: string
sizeText?: string
valid: boolean
}
@@ -0,0 +1 @@
export type RuntimePhase = 'idle' | 'starting' | 'running' | 'error' | 'stopped'
+4
View File
@@ -0,0 +1,4 @@
export interface UiError {
message: string
retryable: boolean
}
+20
View File
@@ -0,0 +1,20 @@
import { AppCatalogStore } from '../store/AppCatalogStore'
@Entry
@Component
struct AppListPage {
private store: AppCatalogStore = new AppCatalogStore()
aboutToAppear(): void {
this.store.loadApps()
}
build() {
Column() {
Text('AppListPage')
Text(`apps: ${this.store.items.length}`)
}
.width('100%')
.height('100%')
}
}
+15
View File
@@ -0,0 +1,15 @@
import { ImportStore } from '../store/ImportStore'
@Component
export struct ImportPage {
private store: ImportStore = new ImportStore()
build() {
Column() {
Text('ImportPage')
Text(`phase: ${this.store.phase}`)
}
.width('100%')
.height('100%')
}
}
+15
View File
@@ -0,0 +1,15 @@
import { RuntimeSessionStore } from '../store/RuntimeSessionStore'
@Component
export struct RunPage {
private store: RuntimeSessionStore = new RuntimeSessionStore()
build() {
Column() {
Text('RunPage')
Text(`phase: ${this.store.phase}`)
}
.width('100%')
.height('100%')
}
}
+17
View File
@@ -0,0 +1,17 @@
import { NativeAppAdapter } from '../adapters/NativeAppAdapter'
import type { AppItemVM } from '../models/AppItemVM'
export class AppService {
constructor(private readonly adapter: NativeAppAdapter = new NativeAppAdapter()) {}
async listApps(): Promise<AppItemVM[]> {
const apps = await this.adapter.listInstalledApps()
return apps.map((item) => ({
id: item.appId,
name: item.name,
icon: item.icon,
version: item.version,
status: item.runnable ? 'ready' : 'invalid'
}))
}
}
@@ -0,0 +1,25 @@
import { NativeImportAdapter } from '../adapters/NativeImportAdapter'
import type { PackagePreviewVM } from '../models/PackagePreviewVM'
export class ImportService {
constructor(private readonly adapter: NativeImportAdapter = new NativeImportAdapter()) {}
async pickMrpFile(): Promise<string | null> {
return this.adapter.pickFile()
}
async analyzePackage(fileUri: string): Promise<PackagePreviewVM> {
const result = await this.adapter.inspectPackage(fileUri)
return {
name: result.name,
version: result.version,
icon: result.icon,
sizeText: result.size ? `${result.size}` : undefined,
valid: result.valid
}
}
async importPackage(fileUri: string): Promise<{ appId: string }> {
return this.adapter.importPackage(fileUri)
}
}
@@ -0,0 +1,25 @@
import { NativeRuntimeAdapter } from '../adapters/NativeRuntimeAdapter'
export class RuntimeService {
constructor(private readonly adapter: NativeRuntimeAdapter = new NativeRuntimeAdapter()) {}
async start(appId: string): Promise<void> {
await this.adapter.startSession(appId)
}
async restart(appId: string): Promise<void> {
await this.adapter.restartSession(appId)
}
async stop(): Promise<void> {
await this.adapter.stopSession()
}
async onPageShow(): Promise<void> {
await this.adapter.notifyPageShow()
}
async onPageHide(): Promise<void> {
await this.adapter.notifyPageHide()
}
}
@@ -0,0 +1,31 @@
import { AppService } from '../services/AppService'
import type { AppItemVM } from '../models/AppItemVM'
import type { UiError } from '../models/UiError'
export class AppCatalogStore {
items: AppItemVM[] = []
loading: boolean = false
error: UiError | null = null
constructor(private readonly service: AppService = new AppService()) {}
async loadApps(): Promise<void> {
this.loading = true
this.error = null
try {
this.items = await this.service.listApps()
} catch (_error) {
this.error = { message: '应用列表加载失败', retryable: true }
} finally {
this.loading = false
}
}
async refreshApps(): Promise<void> {
await this.loadApps()
}
clearError(): void {
this.error = null
}
}
+55
View File
@@ -0,0 +1,55 @@
import { ImportService } from '../services/ImportService'
import type { PackagePreviewVM } from '../models/PackagePreviewVM'
import type { UiError } from '../models/UiError'
export type ImportPhase = 'idle' | 'picking' | 'analyzing' | 'importing' | 'success' | 'failed'
export class ImportStore {
phase: ImportPhase = 'idle'
selectedFile: string | null = null
previewInfo: PackagePreviewVM | null = null
error: UiError | null = null
constructor(private readonly service: ImportService = new ImportService()) {}
async pickFile(): Promise<void> {
this.phase = 'picking'
this.selectedFile = await this.service.pickMrpFile()
this.phase = this.selectedFile ? 'analyzing' : 'idle'
}
async analyzeSelectedFile(): Promise<void> {
if (!this.selectedFile) {
return
}
try {
this.previewInfo = await this.service.analyzePackage(this.selectedFile)
this.phase = 'idle'
} catch (_error) {
this.phase = 'failed'
this.error = { message: '包解析失败', retryable: true }
}
}
async startImport(): Promise<void> {
if (!this.selectedFile) {
return
}
this.phase = 'importing'
this.error = null
try {
await this.service.importPackage(this.selectedFile)
this.phase = 'success'
} catch (_error) {
this.phase = 'failed'
this.error = { message: '导入失败', retryable: true }
}
}
reset(): void {
this.phase = 'idle'
this.selectedFile = null
this.previewInfo = null
this.error = null
}
}
@@ -0,0 +1,52 @@
import { RuntimeService } from '../services/RuntimeService'
import type { UiError } from '../models/UiError'
import type { RuntimePhase } from '../models/RuntimeSessionState'
export class RuntimeSessionStore {
currentAppId: string | null = null
phase: RuntimePhase = 'idle'
error: UiError | null = null
canRestart: boolean = false
canExit: boolean = false
constructor(private readonly service: RuntimeService = new RuntimeService()) {}
async startSession(appId: string): Promise<void> {
this.currentAppId = appId
this.phase = 'starting'
this.error = null
try {
await this.service.start(appId)
this.phase = 'running'
this.canRestart = true
this.canExit = true
} catch (_error) {
this.phase = 'error'
this.error = { message: '启动失败', retryable: true }
}
}
async restartSession(): Promise<void> {
if (!this.currentAppId) {
return
}
try {
await this.service.restart(this.currentAppId)
this.phase = 'running'
} catch (_error) {
this.phase = 'error'
this.error = { message: '重启失败', retryable: true }
}
}
async stopSession(): Promise<void> {
await this.service.stop()
this.phase = 'stopped'
this.canExit = false
this.canRestart = false
}
clearError(): void {
this.error = null
}
}