Files
zyt/admin/live-readonly/OnlinePage.vue
T

64 lines
2.2 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<template>
<component v-if="view && entry" :is="view" :key="`${entry.id}:${user.menuVersion}`" />
<section v-else-if="entry" class="online-entry">
<h1>{{ entry.title }}</h1>
<p>这是正式账号菜单中的入口。此页未接入本地只读查询,未向线上发起业务请求。</p>
<template v-if="entry.officialHref">
<p>
{{
entry.external
? `该菜单指向 ${destinationHost},将单独打开。`
: '在正式后台打开后,将使用正式站点的原有权限,可能需要单独登录。'
}}
</p>
<a
:href="entry.officialHref"
target="_blank"
rel="noopener noreferrer"
referrerpolicy="no-referrer"
>{{ entry.external ? '打开菜单指定站点' : '在正式后台打开' }} ↗</a
>
</template>
<p v-else>未提供可直接打开的页面地址。</p>
</section>
</template>
<script setup lang="ts">
import { computed, defineAsyncComponent } from 'vue'
import { useRoute } from 'vue-router'
import { screens } from './screens'
import useUserStore from './user'
const route = useRoute(),
user = useUserStore()
const components = new Map(screens.map((s) => [s.key, defineAsyncComponent(s.component)]))
const entry = computed(() => user.entries[String(route.params.menuId)])
const destinationHost = computed(() => entry.value?.officialHref ? new URL(entry.value.officialHref).hostname : '')
const view = computed(() =>
entry.value?.liveKey && user.keys.includes(entry.value.liveKey)
? components.get(entry.value.liveKey)
: null
)
</script>
<style scoped>
.online-entry {
max-width: 800px;
padding: 24px;
background: var(--el-bg-color);
border: 1px solid var(--el-border-color-light);
border-radius: 12px;
}
.online-entry h1 {
font-size: 22px;
margin: 0 0 12px;
}
.online-entry p {
color: var(--el-text-color-regular);
margin: 8px 0;
}
.online-entry a {
display: inline-block;
margin-top: 12px;
color: var(--el-color-primary);
text-decoration: underline;
}
</style>