geng
This commit is contained in:
@@ -0,0 +1,273 @@
|
||||
<script setup lang="ts">
|
||||
import { Button, Empty, Icon, List, NavBar, Popup, PullRefresh, Search, Tab, Tabs } from 'vant';
|
||||
import { computed, ref, watch } from 'vue';
|
||||
|
||||
import { api, ApiError, type Conversation } from '../api';
|
||||
import AccountSwitcher from '../components/AccountSwitcher.vue';
|
||||
import ConversationDetail from '../components/ConversationDetail.vue';
|
||||
import ConversationRow from '../components/ConversationRow.vue';
|
||||
import { useWide } from '../composables';
|
||||
import { permissions, session, viewedAccountId, viewedName } from '../session';
|
||||
|
||||
defineOptions({ name: 'ConversationsView' });
|
||||
|
||||
type Scope = 'all' | 'blocked';
|
||||
|
||||
const wide = useWide();
|
||||
const query = ref('');
|
||||
const scope = ref<Scope>('all');
|
||||
const items = ref<Conversation[]>([]);
|
||||
const cursor = ref('');
|
||||
const finished = ref(false);
|
||||
const loading = ref(false);
|
||||
const failed = ref(false);
|
||||
const errorText = ref('');
|
||||
const refreshing = ref(false);
|
||||
const blockedTotal = ref(0);
|
||||
const selected = ref<Conversation | null>(null);
|
||||
const sheet = ref(false);
|
||||
const switching = ref(false);
|
||||
let serial = 0;
|
||||
let controller: AbortController | null = null;
|
||||
let debounce: number | undefined;
|
||||
|
||||
const codes = computed(() => session.me?.permission_codes);
|
||||
const title = computed(() => (viewedAccountId.value === undefined ? '会话' : `${viewedName.value} 的会话`));
|
||||
const key = (item: Conversation) => `${item.account}|${item.conversation}`;
|
||||
|
||||
function reset() {
|
||||
serial += 1;
|
||||
controller?.abort();
|
||||
controller = null;
|
||||
items.value = [];
|
||||
cursor.value = '';
|
||||
finished.value = false;
|
||||
failed.value = false;
|
||||
errorText.value = '';
|
||||
loading.value = false;
|
||||
void loadMore();
|
||||
}
|
||||
|
||||
async function loadMore() {
|
||||
if (finished.value) return;
|
||||
const current = serial;
|
||||
controller = new AbortController();
|
||||
loading.value = true;
|
||||
try {
|
||||
const page = await api.conversations({
|
||||
accountId: viewedAccountId.value,
|
||||
q: query.value.trim(),
|
||||
scope: scope.value,
|
||||
cursor: cursor.value,
|
||||
limit: 30,
|
||||
signal: controller.signal,
|
||||
});
|
||||
if (current !== serial) return;
|
||||
const seen = new Set(items.value.map(key));
|
||||
items.value = items.value.concat(page.items.filter((item) => !seen.has(key(item))));
|
||||
cursor.value = page.next_cursor;
|
||||
finished.value = !page.has_more;
|
||||
blockedTotal.value = page.blocked_total;
|
||||
failed.value = false;
|
||||
if (wide.value && !selected.value && items.value.length) selected.value = items.value[0]!;
|
||||
} catch (error) {
|
||||
if (current !== serial || (error instanceof DOMException && error.name === 'AbortError')) return;
|
||||
failed.value = true;
|
||||
errorText.value = error instanceof ApiError ? error.message : '加载失败';
|
||||
} finally {
|
||||
if (current === serial) {
|
||||
loading.value = false;
|
||||
refreshing.value = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function onRefresh() {
|
||||
refreshing.value = true;
|
||||
reset();
|
||||
}
|
||||
|
||||
function open(item: Conversation) {
|
||||
selected.value = item;
|
||||
if (!wide.value) sheet.value = true;
|
||||
}
|
||||
|
||||
function onUpdated(updated: Conversation) {
|
||||
const index = items.value.findIndex((item) => key(item) === key(updated));
|
||||
const wasBlocked = index >= 0 ? items.value[index]!.blocked : selected.value?.blocked;
|
||||
if (index >= 0) {
|
||||
if (scope.value === 'blocked' && !updated.blocked) items.value.splice(index, 1);
|
||||
else items.value.splice(index, 1, updated);
|
||||
}
|
||||
if (wasBlocked !== updated.blocked) blockedTotal.value += updated.blocked ? 1 : -1;
|
||||
selected.value = updated;
|
||||
}
|
||||
|
||||
watch(query, () => {
|
||||
window.clearTimeout(debounce);
|
||||
debounce = window.setTimeout(reset, 350);
|
||||
});
|
||||
watch(scope, reset);
|
||||
watch(viewedAccountId, () => {
|
||||
selected.value = null;
|
||||
sheet.value = false;
|
||||
reset();
|
||||
});
|
||||
reset();
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="page">
|
||||
<NavBar :title="title" safe-area-inset-top fixed placeholder :border="false">
|
||||
<template v-if="permissions?.control_all" #right>
|
||||
<button type="button" class="nav-action" @click="switching = true">
|
||||
<Icon name="friends-o" /> 切换客服
|
||||
</button>
|
||||
</template>
|
||||
</NavBar>
|
||||
|
||||
<div :class="wide ? 'split' : 'single'">
|
||||
<section class="list-pane">
|
||||
<div class="toolbar">
|
||||
<Search v-model="query" shape="round" placeholder="搜索会话名称" :clearable="true" />
|
||||
<Tabs v-model:active="scope" shrink :border="false" class="tabs">
|
||||
<Tab name="all" title="全部会话" />
|
||||
<Tab name="blocked" :title="blockedTotal ? `忽略 ${blockedTotal}` : '忽略'" />
|
||||
</Tabs>
|
||||
</div>
|
||||
|
||||
<PullRefresh v-model="refreshing" class="list-body" @refresh="onRefresh">
|
||||
<List
|
||||
v-model:loading="loading"
|
||||
v-model:error="failed"
|
||||
:finished="finished"
|
||||
:error-text="`${errorText},点击重试`"
|
||||
:finished-text="items.length ? '没有更多了' : ''"
|
||||
:immediate-check="false"
|
||||
@load="loadMore"
|
||||
>
|
||||
<ConversationRow
|
||||
v-for="item in items"
|
||||
:key="key(item)"
|
||||
:item="item"
|
||||
:active="wide && selected !== null && key(selected) === key(item)"
|
||||
@select="open"
|
||||
/>
|
||||
</List>
|
||||
<Empty
|
||||
v-if="finished && !items.length && !failed"
|
||||
:image="query ? 'search' : 'default'"
|
||||
:description="
|
||||
query
|
||||
? '没有找到匹配的会话'
|
||||
: scope === 'blocked'
|
||||
? '忽略是空的'
|
||||
: '还没有归档的会话:电脑开启聊天备份后会自动出现'
|
||||
"
|
||||
>
|
||||
<Button v-if="query" round size="small" @click="query = ''">清除搜索</Button>
|
||||
</Empty>
|
||||
</PullRefresh>
|
||||
</section>
|
||||
|
||||
<section v-if="wide" class="detail-pane app-card">
|
||||
<ConversationDetail
|
||||
v-if="selected"
|
||||
:conversation="selected"
|
||||
:account-id="viewedAccountId"
|
||||
:can-add="Boolean(permissions?.blacklist_add)"
|
||||
:can-remove="Boolean(permissions?.blacklist_remove)"
|
||||
:add-code="codes?.blacklist_add ?? ''"
|
||||
:remove-code="codes?.blacklist_remove ?? ''"
|
||||
@updated="onUpdated"
|
||||
/>
|
||||
<Empty v-else image="default" description="选择左侧的会话查看详情" />
|
||||
</section>
|
||||
</div>
|
||||
|
||||
<Popup
|
||||
v-if="!wide"
|
||||
v-model:show="sheet"
|
||||
position="bottom"
|
||||
round
|
||||
closeable
|
||||
safe-area-inset-bottom
|
||||
class="sheet"
|
||||
>
|
||||
<ConversationDetail
|
||||
v-if="selected"
|
||||
:conversation="selected"
|
||||
:account-id="viewedAccountId"
|
||||
:can-add="Boolean(permissions?.blacklist_add)"
|
||||
:can-remove="Boolean(permissions?.blacklist_remove)"
|
||||
:add-code="codes?.blacklist_add ?? ''"
|
||||
:remove-code="codes?.blacklist_remove ?? ''"
|
||||
@updated="onUpdated"
|
||||
/>
|
||||
</Popup>
|
||||
|
||||
<AccountSwitcher v-if="permissions?.control_all" v-model:show="switching" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.page {
|
||||
min-height: 100%;
|
||||
}
|
||||
.nav-action {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
padding: 6px 0;
|
||||
border: 0;
|
||||
background: none;
|
||||
color: var(--app-primary);
|
||||
font-size: 14px;
|
||||
}
|
||||
.toolbar {
|
||||
position: sticky;
|
||||
top: calc(46px + env(safe-area-inset-top));
|
||||
z-index: 2;
|
||||
background: var(--app-bg);
|
||||
}
|
||||
.toolbar :deep(.van-search) {
|
||||
background: transparent;
|
||||
padding-bottom: 4px;
|
||||
}
|
||||
.tabs {
|
||||
--van-tabs-nav-background: transparent;
|
||||
padding: 0 4px;
|
||||
}
|
||||
.list-body {
|
||||
min-height: 60vh;
|
||||
}
|
||||
.single .list-pane {
|
||||
max-width: 720px;
|
||||
margin: 0 auto;
|
||||
}
|
||||
.split {
|
||||
display: grid;
|
||||
grid-template-columns: minmax(300px, 380px) minmax(0, 1fr);
|
||||
gap: 16px;
|
||||
padding: 0 24px 24px;
|
||||
max-width: 1180px;
|
||||
margin: 0 auto;
|
||||
align-items: start;
|
||||
}
|
||||
/* 圆角只裁列表本身:给整个列表栏 overflow:hidden 会让它变成吸顶的参照容器,
|
||||
搜索栏就会按 46px 偏移压到第一条会话上。overflow:clip 不产生滚动容器。 */
|
||||
.split .list-body {
|
||||
border-radius: 16px;
|
||||
overflow: clip;
|
||||
}
|
||||
.detail-pane {
|
||||
position: sticky;
|
||||
top: calc(46px + env(safe-area-inset-top) + 12px);
|
||||
margin-top: 12px;
|
||||
min-height: 320px;
|
||||
}
|
||||
.sheet {
|
||||
max-height: 88vh;
|
||||
padding-top: 8px;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,233 @@
|
||||
<script setup lang="ts">
|
||||
import { Button, Empty, Icon, NavBar, PullRefresh, Skeleton } from 'vant';
|
||||
import { computed, ref, watch } from 'vue';
|
||||
|
||||
import { api, ApiError, type DesktopsResponse, type Device } from '../api';
|
||||
import AccountSwitcher from '../components/AccountSwitcher.vue';
|
||||
import DevicePanel from '../components/DevicePanel.vue';
|
||||
import { useVisibleInterval, useWide } from '../composables';
|
||||
import { describeDevice } from '../format';
|
||||
import { permissions, session, viewedAccountId, viewedName } from '../session';
|
||||
|
||||
defineOptions({ name: 'DevicesView' });
|
||||
|
||||
const wide = useWide();
|
||||
const data = ref<DesktopsResponse | null>(null);
|
||||
const loading = ref(false);
|
||||
const refreshing = ref(false);
|
||||
const error = ref('');
|
||||
const selectedId = ref('');
|
||||
const switching = ref(false);
|
||||
let serial = 0;
|
||||
|
||||
const devices = computed<Device[]>(() => data.value?.items ?? []);
|
||||
const selected = computed(
|
||||
() => devices.value.find((item) => item.device_id === selectedId.value) ?? devices.value[0] ?? null,
|
||||
);
|
||||
const canControl = computed(() => Boolean(permissions.value?.control));
|
||||
const controlCode = computed(() => session.me?.permission_codes.control ?? 'wecom_rpa.remote/control');
|
||||
const title = computed(() => (viewedAccountId.value === undefined ? '我的电脑' : `${viewedName.value} 的电脑`));
|
||||
|
||||
async function load() {
|
||||
const current = ++serial;
|
||||
if (!data.value) loading.value = true;
|
||||
try {
|
||||
const response = await api.desktops(viewedAccountId.value);
|
||||
if (current !== serial) return;
|
||||
data.value = response;
|
||||
error.value = '';
|
||||
} catch (reason) {
|
||||
if (current !== serial) return;
|
||||
error.value = reason instanceof ApiError ? reason.message : '加载失败,请重试';
|
||||
} finally {
|
||||
if (current === serial) {
|
||||
loading.value = false;
|
||||
refreshing.value = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async function refresh() {
|
||||
refreshing.value = true;
|
||||
await load();
|
||||
}
|
||||
|
||||
watch(
|
||||
viewedAccountId,
|
||||
() => {
|
||||
data.value = null;
|
||||
selectedId.value = '';
|
||||
void load();
|
||||
},
|
||||
{ immediate: true },
|
||||
);
|
||||
useVisibleInterval(load, 5000);
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="page">
|
||||
<NavBar :title="title" safe-area-inset-top fixed placeholder :border="false">
|
||||
<template v-if="permissions?.control_all" #right>
|
||||
<button type="button" class="nav-action" @click="switching = true">
|
||||
<Icon name="friends-o" /> 切换客服
|
||||
</button>
|
||||
</template>
|
||||
</NavBar>
|
||||
|
||||
<PullRefresh v-model="refreshing" class="page-body" @refresh="refresh">
|
||||
<div v-if="loading && !data" class="content">
|
||||
<div class="app-card skeleton-card"><Skeleton title :row="4" /></div>
|
||||
</div>
|
||||
|
||||
<div v-else-if="error && !data" class="content">
|
||||
<Empty image="network" :description="error">
|
||||
<Button round type="primary" size="small" @click="load">重新加载</Button>
|
||||
</Empty>
|
||||
</div>
|
||||
|
||||
<div v-else-if="!devices.length" class="content">
|
||||
<Empty image="default" description="还没有登录过企微客服助手的电脑">
|
||||
<p class="empty-hint">
|
||||
在电脑上打开企微客服助手,用{{ viewedAccountId === undefined ? '同一个' : '该客服的' }} ZYT
|
||||
账号登录后,这里会显示电脑状态。
|
||||
</p>
|
||||
</Empty>
|
||||
</div>
|
||||
|
||||
<div v-else-if="wide" class="split">
|
||||
<aside class="split-list" aria-label="电脑列表">
|
||||
<button
|
||||
v-for="device in devices"
|
||||
:key="device.device_id"
|
||||
type="button"
|
||||
class="device-row app-card"
|
||||
:class="{ active: selected?.device_id === device.device_id }"
|
||||
@click="selectedId = device.device_id"
|
||||
>
|
||||
<Icon name="desktop-o" class="device-row-icon" />
|
||||
<span class="device-row-text">
|
||||
<strong>{{ device.device_name || '未命名电脑' }}</strong>
|
||||
<small :class="`tone-${describeDevice(device).tone}`">{{ describeDevice(device).label }}</small>
|
||||
</span>
|
||||
</button>
|
||||
<p v-if="error" class="stale app-muted">{{ error }}(显示的是上次的状态)</p>
|
||||
</aside>
|
||||
<section class="split-detail">
|
||||
<DevicePanel
|
||||
v-if="selected"
|
||||
:key="selected.device_id"
|
||||
:device="selected"
|
||||
:account-id="viewedAccountId"
|
||||
:can-control="canControl"
|
||||
:control-code="controlCode"
|
||||
@changed="load"
|
||||
/>
|
||||
</section>
|
||||
</div>
|
||||
|
||||
<div v-else class="content stack">
|
||||
<p v-if="error" class="stale app-muted">{{ error }}(显示的是上次的状态)</p>
|
||||
<DevicePanel
|
||||
v-for="device in devices"
|
||||
:key="device.device_id"
|
||||
:device="device"
|
||||
:account-id="viewedAccountId"
|
||||
:can-control="canControl"
|
||||
:control-code="controlCode"
|
||||
@changed="load"
|
||||
/>
|
||||
</div>
|
||||
</PullRefresh>
|
||||
|
||||
<AccountSwitcher v-if="permissions?.control_all" v-model:show="switching" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.page {
|
||||
min-height: 100%;
|
||||
}
|
||||
.page-body {
|
||||
min-height: calc(100vh - 46px - 50px);
|
||||
min-height: calc(100dvh - 46px - 50px);
|
||||
}
|
||||
.content {
|
||||
padding: 12px 16px 24px;
|
||||
max-width: 720px;
|
||||
margin: 0 auto;
|
||||
}
|
||||
.stack {
|
||||
display: grid;
|
||||
gap: 12px;
|
||||
}
|
||||
.skeleton-card {
|
||||
padding: 16px 0;
|
||||
}
|
||||
.empty-hint {
|
||||
max-width: 280px;
|
||||
margin: 0 auto;
|
||||
color: var(--app-muted);
|
||||
font-size: 13px;
|
||||
line-height: 1.6;
|
||||
text-align: center;
|
||||
}
|
||||
.nav-action {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
padding: 6px 0;
|
||||
border: 0;
|
||||
background: none;
|
||||
color: var(--app-primary);
|
||||
font-size: 14px;
|
||||
}
|
||||
.stale {
|
||||
margin: 0 4px;
|
||||
font-size: 12px;
|
||||
}
|
||||
.split {
|
||||
display: grid;
|
||||
grid-template-columns: minmax(240px, 320px) minmax(0, 1fr);
|
||||
gap: 16px;
|
||||
padding: 16px 24px 24px;
|
||||
max-width: 1080px;
|
||||
margin: 0 auto;
|
||||
align-items: start;
|
||||
}
|
||||
.split-list {
|
||||
display: grid;
|
||||
gap: 10px;
|
||||
}
|
||||
.device-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
width: 100%;
|
||||
padding: 12px 14px;
|
||||
text-align: left;
|
||||
color: inherit;
|
||||
cursor: pointer;
|
||||
}
|
||||
.device-row.active {
|
||||
border-color: var(--app-primary);
|
||||
box-shadow: 0 0 0 2px var(--app-primary-soft);
|
||||
}
|
||||
.device-row-icon {
|
||||
font-size: 20px;
|
||||
color: var(--app-primary);
|
||||
}
|
||||
.device-row-text {
|
||||
display: grid;
|
||||
gap: 2px;
|
||||
min-width: 0;
|
||||
}
|
||||
.device-row-text strong {
|
||||
font-size: 15px;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.device-row-text small {
|
||||
font-size: 12px;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,190 @@
|
||||
<script setup lang="ts">
|
||||
import { Button, CellGroup, Field, Form, NoticeBar } from 'vant';
|
||||
import { computed, ref } from 'vue';
|
||||
import { useRoute, useRouter } from 'vue-router';
|
||||
|
||||
import { api, ApiError } from '../api';
|
||||
import brandMark from '../brand-mark.png';
|
||||
import { signIn } from '../session';
|
||||
|
||||
const route = useRoute();
|
||||
const router = useRouter();
|
||||
const account = ref('');
|
||||
const password = ref('');
|
||||
const submitting = ref(false);
|
||||
const error = ref('');
|
||||
|
||||
const expired = computed(() => route.query.expired === '1');
|
||||
|
||||
function clientName(): string {
|
||||
const ua = navigator.userAgent;
|
||||
const device = /iPad/.test(ua)
|
||||
? 'iPad'
|
||||
: /iPhone/.test(ua)
|
||||
? 'iPhone'
|
||||
: /HarmonyOS/i.test(ua)
|
||||
? '鸿蒙'
|
||||
: /Android/.test(ua)
|
||||
? 'Android'
|
||||
: /Windows/.test(ua)
|
||||
? 'Windows'
|
||||
: /Mac OS/.test(ua)
|
||||
? 'Mac'
|
||||
: '浏览器';
|
||||
const shell = /wxwork/i.test(ua) ? '企业微信' : /MicroMessenger/i.test(ua) ? '微信' : '';
|
||||
return shell ? `${device} · ${shell}` : device;
|
||||
}
|
||||
|
||||
function safeRedirect(): string {
|
||||
const value = route.query.redirect;
|
||||
if (typeof value === 'string' && value.startsWith('/') && !value.startsWith('//') && !value.startsWith('/login')) {
|
||||
return value;
|
||||
}
|
||||
return '/desktops';
|
||||
}
|
||||
|
||||
async function submit() {
|
||||
if (submitting.value) return;
|
||||
error.value = '';
|
||||
submitting.value = true;
|
||||
try {
|
||||
const result = await api.login(account.value.trim(), password.value, clientName());
|
||||
password.value = '';
|
||||
signIn(result.access_token, result.me);
|
||||
await router.replace(safeRedirect());
|
||||
} catch (reason) {
|
||||
if (reason instanceof ApiError) {
|
||||
error.value = reason.message;
|
||||
if (reason.code === 'invalid_credentials') password.value = '';
|
||||
} else {
|
||||
error.value = '登录失败,请稍后重试';
|
||||
}
|
||||
} finally {
|
||||
submitting.value = false;
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<main class="login">
|
||||
<section class="login-card">
|
||||
<header class="login-head">
|
||||
<img class="login-mark" :src="brandMark" alt="甄养堂" width="72" height="72" />
|
||||
<h1>企微客服助手</h1>
|
||||
<p>手机控制台 · 使用 ZYT 账号登录</p>
|
||||
</header>
|
||||
|
||||
<NoticeBar
|
||||
v-if="expired"
|
||||
class="login-notice"
|
||||
left-icon="info-o"
|
||||
:scrollable="false"
|
||||
wrapable
|
||||
text="登录已失效或已在管理端被下线,请重新登录。"
|
||||
/>
|
||||
|
||||
<Form class="login-form" @submit="submit">
|
||||
<CellGroup inset>
|
||||
<Field
|
||||
v-model="account"
|
||||
name="account"
|
||||
label="账号"
|
||||
placeholder="ZYT 登录账号"
|
||||
autocomplete="username"
|
||||
autocapitalize="off"
|
||||
:spellcheck="false"
|
||||
enterkeyhint="next"
|
||||
clearable
|
||||
:rules="[{ required: true, message: '请输入账号' }]"
|
||||
/>
|
||||
<Field
|
||||
v-model="password"
|
||||
type="password"
|
||||
name="password"
|
||||
label="密码"
|
||||
placeholder="ZYT 登录密码"
|
||||
autocomplete="current-password"
|
||||
enterkeyhint="go"
|
||||
:rules="[{ required: true, message: '请输入密码' }]"
|
||||
/>
|
||||
</CellGroup>
|
||||
<p v-if="error" class="login-error" role="alert">{{ error }}</p>
|
||||
<div class="login-actions">
|
||||
<Button
|
||||
round
|
||||
block
|
||||
type="primary"
|
||||
native-type="submit"
|
||||
:loading="submitting"
|
||||
loading-text="正在登录…"
|
||||
>
|
||||
登录
|
||||
</Button>
|
||||
</div>
|
||||
</Form>
|
||||
<p class="login-foot">密码只用于向 ZYT 验证身份,不会保存在手机上。</p>
|
||||
</section>
|
||||
</main>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.login {
|
||||
min-height: 100vh;
|
||||
min-height: 100dvh;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding: calc(env(safe-area-inset-top) + 24px) 16px calc(env(safe-area-inset-bottom) + 24px);
|
||||
background:
|
||||
radial-gradient(120% 60% at 50% 0%, var(--app-primary-soft), transparent 70%),
|
||||
var(--app-bg);
|
||||
}
|
||||
.login-card {
|
||||
width: 100%;
|
||||
max-width: 420px;
|
||||
}
|
||||
.login-head {
|
||||
text-align: center;
|
||||
margin-bottom: 24px;
|
||||
}
|
||||
.login-mark {
|
||||
border-radius: 20px;
|
||||
box-shadow: var(--app-shadow);
|
||||
}
|
||||
.login-head h1 {
|
||||
margin: 16px 0 6px;
|
||||
font-size: 24px;
|
||||
font-weight: 700;
|
||||
letter-spacing: 0.5px;
|
||||
}
|
||||
.login-head p {
|
||||
margin: 0;
|
||||
color: var(--app-muted);
|
||||
font-size: 14px;
|
||||
}
|
||||
.login-notice {
|
||||
margin: 0 16px 12px;
|
||||
border-radius: 12px;
|
||||
}
|
||||
.login-form :deep(.van-cell-group--inset) {
|
||||
margin: 0;
|
||||
}
|
||||
.login-form {
|
||||
margin: 0 0;
|
||||
}
|
||||
.login-error {
|
||||
margin: 12px 16px 0;
|
||||
color: var(--app-danger);
|
||||
font-size: 14px;
|
||||
line-height: 1.5;
|
||||
}
|
||||
.login-actions {
|
||||
margin: 20px 16px 0;
|
||||
}
|
||||
.login-foot {
|
||||
margin: 16px 16px 0;
|
||||
text-align: center;
|
||||
color: var(--app-muted);
|
||||
font-size: 12px;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,149 @@
|
||||
<script setup lang="ts">
|
||||
import { Button, Cell, CellGroup, Icon, NavBar, showConfirmDialog } from 'vant';
|
||||
import { computed, ref } from 'vue';
|
||||
import { useRouter } from 'vue-router';
|
||||
|
||||
import { initial, relativeTime } from '../format';
|
||||
import { session, signOut } from '../session';
|
||||
|
||||
const router = useRouter();
|
||||
const leaving = ref(false);
|
||||
|
||||
const me = computed(() => session.me);
|
||||
const rows = computed(() => {
|
||||
const value = me.value;
|
||||
if (!value) return [];
|
||||
const { permissions: p, permission_codes: codes } = value;
|
||||
return [
|
||||
{ title: '查看本人电脑与会话', code: '登录即可', granted: true },
|
||||
{ title: '远程启停本人电脑', code: codes.control, granted: p.control },
|
||||
{ title: '查看并控制所有客服电脑', code: codes.control_all, granted: p.control_all },
|
||||
{ title: '会话加入忽略', code: codes.blacklist_add, granted: p.blacklist_add },
|
||||
{ title: '会话移出忽略', code: codes.blacklist_remove, granted: p.blacklist_remove },
|
||||
];
|
||||
});
|
||||
const expires = computed(() => {
|
||||
const at = me.value?.session.expires_at;
|
||||
return at ? new Date(at * 1000).toISOString() : '';
|
||||
});
|
||||
const isIos = /iPhone|iPad|iPod/.test(navigator.userAgent);
|
||||
|
||||
async function logout() {
|
||||
try {
|
||||
await showConfirmDialog({ title: '退出登录?', message: '退出后需要重新输入 ZYT 账号密码。', confirmButtonText: '退出' });
|
||||
} catch {
|
||||
return;
|
||||
}
|
||||
leaving.value = true;
|
||||
await signOut();
|
||||
await router.replace({ name: 'login' });
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="page">
|
||||
<NavBar title="我的" safe-area-inset-top fixed placeholder :border="false" />
|
||||
<div v-if="me" class="content">
|
||||
<section class="profile app-card">
|
||||
<span class="avatar" aria-hidden="true">{{ initial(me.account.nickname || me.account.sn) }}</span>
|
||||
<div class="profile-text">
|
||||
<h2>{{ me.account.nickname || me.account.sn }}</h2>
|
||||
<p class="app-muted">ZYT 账号 {{ me.account.sn || '—' }}</p>
|
||||
</div>
|
||||
<span v-if="me.permissions.root" class="root">超级管理员</span>
|
||||
</section>
|
||||
|
||||
<h3 class="section-title">手机端权限</h3>
|
||||
<CellGroup inset>
|
||||
<Cell v-for="row in rows" :key="row.title" :title="row.title" :label="row.code" center>
|
||||
<template #value>
|
||||
<span :class="row.granted ? 'tone-success' : 'tone-muted'">
|
||||
<Icon :name="row.granted ? 'passed' : 'close'" /> {{ row.granted ? '已开通' : '未开通' }}
|
||||
</span>
|
||||
</template>
|
||||
</Cell>
|
||||
</CellGroup>
|
||||
<p class="hint app-muted">
|
||||
权限在 ZYT「权限管理 → 角色管理」里勾选「企微客服助手」下的项目,调整后 10 分钟内自动生效,或退出重新登录。
|
||||
</p>
|
||||
|
||||
<h3 class="section-title">登录信息</h3>
|
||||
<CellGroup inset>
|
||||
<Cell title="登录时间" :value="relativeTime(me.session.created_at)" />
|
||||
<Cell title="最长有效至" :value="expires ? relativeTime(expires) : '—'" label="ZYT 登录失效后会提前退出" />
|
||||
</CellGroup>
|
||||
|
||||
<h3 class="section-title">添加到主屏幕</h3>
|
||||
<p class="hint app-muted">
|
||||
<template v-if="isIos">在 Safari 中点底部「分享」按钮,选择「添加到主屏幕」,之后像 App 一样打开。</template>
|
||||
<template v-else>在浏览器菜单中选择「添加到主屏幕」或「安装应用」,之后像 App 一样打开。</template>
|
||||
</p>
|
||||
|
||||
<div class="logout">
|
||||
<Button block round type="danger" plain :loading="leaving" @click="logout">退出登录</Button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.content {
|
||||
padding: 12px 0 32px;
|
||||
max-width: 720px;
|
||||
margin: 0 auto;
|
||||
}
|
||||
.profile {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 14px;
|
||||
margin: 0 16px;
|
||||
padding: 16px;
|
||||
}
|
||||
.avatar {
|
||||
flex: none;
|
||||
width: 54px;
|
||||
height: 54px;
|
||||
border-radius: 50%;
|
||||
display: grid;
|
||||
place-items: center;
|
||||
font-size: 22px;
|
||||
font-weight: 700;
|
||||
color: #fff;
|
||||
background: linear-gradient(135deg, #2f6fff, #5a65ff);
|
||||
}
|
||||
.profile-text {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
}
|
||||
.profile-text h2 {
|
||||
margin: 0 0 4px;
|
||||
font-size: 18px;
|
||||
}
|
||||
.profile-text p {
|
||||
margin: 0;
|
||||
font-size: 13px;
|
||||
}
|
||||
.root {
|
||||
flex: none;
|
||||
padding: 4px 10px;
|
||||
border-radius: 999px;
|
||||
font-size: 12px;
|
||||
font-weight: 600;
|
||||
color: var(--app-warning);
|
||||
background: var(--app-warning-soft);
|
||||
}
|
||||
.section-title {
|
||||
margin: 24px 32px 8px;
|
||||
font-size: 13px;
|
||||
font-weight: 600;
|
||||
color: var(--app-muted);
|
||||
}
|
||||
.hint {
|
||||
margin: 8px 32px 0;
|
||||
font-size: 12px;
|
||||
line-height: 1.6;
|
||||
}
|
||||
.logout {
|
||||
margin: 32px 16px 0;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,28 @@
|
||||
<script setup lang="ts">
|
||||
import { Tabbar, TabbarItem } from 'vant';
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="shell">
|
||||
<RouterView v-slot="{ Component }">
|
||||
<KeepAlive :include="['DevicesView', 'ConversationsView']">
|
||||
<component :is="Component" />
|
||||
</KeepAlive>
|
||||
</RouterView>
|
||||
<Tabbar route placeholder safe-area-inset-bottom class="shell-tabbar">
|
||||
<TabbarItem replace :to="{ name: 'desktops' }" icon="desktop-o">电脑</TabbarItem>
|
||||
<TabbarItem replace :to="{ name: 'conversations' }" icon="chat-o">会话</TabbarItem>
|
||||
<TabbarItem replace :to="{ name: 'me' }" icon="user-o">我的</TabbarItem>
|
||||
</Tabbar>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.shell {
|
||||
min-height: 100vh;
|
||||
min-height: 100dvh;
|
||||
}
|
||||
.shell-tabbar {
|
||||
border-top: 1px solid var(--app-border);
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user