功能:新增云管API与Web控制台并完成现场接入

This commit is contained in:
songyiming committed 2026-11-09 17:54:52 +08:00
1 parent 18a9ce995d
commit 3fb7b4da8c
79 files changed
+17367 -3

No files matched your search

+29
View File
@@ -0,0 +1,29 @@
import { defineStore } from 'pinia'
import { ref } from 'vue'
import { api, allPages, errorMessage, type Desktop, type Terminal, type User, type Task, type Audit, type Resource, type Settings, type Overview } from '../api'
export const usePlatform = defineStore('platform', () => {
const desktops = ref<Desktop[]>([]), terminals = ref<Terminal[]>([]), users = ref<User[]>([])
const tasks = ref<Task[]>([]), audits = ref<Audit[]>([]), resources = ref<Resource[]>([])
const settings = ref<Settings | null>(null), overview = ref<Overview | null>(null)
const loading = ref(false), error = ref(''), updatedAt = ref('')
let inFlight: Promise<void> | undefined
let generation = 0
function refresh() {
if (inFlight) return inFlight
loading.value = !updatedAt.value
const startedGeneration = generation
inFlight = (async () => {
try {
const [d, t, u, k, a, r, s, o] = await Promise.all([allPages(api.desktops), allPages(api.terminals), allPages(api.users), allPages(api.tasks), allPages(api.audits), api.resources(), api.settings(), api.overview()])
if (startedGeneration !== generation) return
desktops.value = d; terminals.value = t; users.value = u; tasks.value = k; audits.value = a; resources.value = r.items; settings.value = s; overview.value = o
updatedAt.value = new Date().toLocaleTimeString('zh-CN'); error.value = ''
} catch (e) { if (startedGeneration === generation) error.value = errorMessage(e) }
finally { if (startedGeneration === generation) { loading.value = false; inFlight = undefined } }
})()
return inFlight
}
function clear() { generation++; inFlight = undefined; loading.value = false; desktops.value = []; terminals.value = []; users.value = []; tasks.value = []; audits.value = []; resources.value = []; settings.value = null; overview.value = null; error.value = ''; updatedAt.value = '' }
return { desktops, terminals, users, tasks, audits, resources, settings, overview, loading, error, updatedAt, refresh, clear }
})