交付双端基础、实时联系人和隔离浏览器

This commit is contained in:
xhgit committed 2026-11-13 18:03:32 +08:00
1 parent 43687d5e7e
commit 67fef3ff87
59 files changed
+5094 -1

No files matched your search

+49
View File
@@ -0,0 +1,49 @@
<script setup lang="ts">
import { ref } from 'vue'
import { useSession } from '../session'
const session = useSession()
const error = ref('')
const busy = ref(false)
const browser = window.xhchat?.openBrowser
async function act(action: () => Promise<void>) {
busy.value = true
error.value = ''
try {
await action()
} catch (cause) {
error.value = cause instanceof Error ? cause.message : '操作失败,请稍后重试'
} finally {
busy.value = false
}
}
</script>
<template>
<main v-if="session.identity" class="workspace">
<nav class="rail" aria-label="主导航">
<RouterLink class="mark" to="/devices" aria-label="XHChat">X</RouterLink>
<RouterLink class="rail-link" to="/contacts" title="联系人" aria-label="联系人">人</RouterLink>
<RouterLink class="rail-link" to="/devices" title="设备管理" aria-label="设备管理">▣</RouterLink>
<button v-if="browser" type="button" class="rail-link browser-button" title="浏览器" aria-label="浏览器" @click="act(browser)">◎</button>
</nav>
<aside class="account-panel">
<div class="account-summary">
<span class="avatar" aria-hidden="true">{{ session.identity.user.username[0]?.toUpperCase() }}</span>
<div><strong>{{ session.identity.user.username }}</strong><small>我的账号</small></div>
</div>
<nav class="panel-links" aria-label="工作区">
<RouterLink to="/contacts">联系人</RouterLink>
<RouterLink to="/devices">设备管理</RouterLink>
<button v-if="browser" class="plain mobile-browser" @click="act(browser)">浏览器</button>
</nav>
<div class="account-footer">
<p aria-live="polite"><span class="dot" :class="{ online: session.connection === '实时连接已建立' }"></span>{{ session.connection }}</p>
<p v-if="error" class="error" role="alert">{{ error }}</p>
<button class="plain" :disabled="busy" @click="act(session.logout)">退出登录</button>
</div>
</aside>
<RouterView />
</main>
</template>