Files
console-dev/app/pages/remote-console.vue
T

434 lines
18 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.
<script>
/**
* 独立远控窗口:校验 hostId 与受支持模块后挂载 RemoteConsole;mf_dcim 先收集操作密码,页面只管理连接界面,不在前端保存长期远控凭据。
*/
import "~/assets/styles/RemoteConsole.DLmX5UZu.css";
import "~/assets/styles/remote-console.zcxaOxxS.css";
definePageMeta({
layout: !1,
});
import { toDisplayString } from "vue";
import { onBeforeUnmount } from "vue";
import { watch } from "vue";
import { createBlock } from "vue";
import { ref } from "vue";
import { withCtx } from "vue";
import { createCommentVNode } from "vue";
import { computed } from "vue";
import { isRef } from "vue";
import { createElementBlock } from "vue";
import { Fragment } from "vue";
import { createElementVNode } from "vue";
import { createTextVNode } from "vue";
import { unref } from "vue";
import { defineComponent } from "vue";
import { createVNode } from "vue";
import { openBlock } from "vue";
import { withModifiers } from "vue";
import { useRoute } from "#app";
import { useHead } from "#app";
import { NuxtLink } from "#components";
import button from "primevue/button";
import { t as _plugin_vue_export_helper_t } from "~/lib/_plugin-vue_export-helper.js";
import inputtext from "primevue/inputtext";
import OperatePasswordGate from "~/components/OperatePasswordGate.vue";
import RemoteConsole from "~/components/instance/RemoteConsole.vue";
import { logoUrl } from "~/utils/brand.js";
import { t as composables_t } from "~/lib/composables-2.js";
var O = {
class: `standalone-console`,
},
k = {
class: `console-page-header`,
},
A = {
key: 0,
class: `console-page-host`,
},
j = {
class: `console-page-content`,
},
M = {
key: 0,
class: `console-intro`,
"aria-labelledby": `console-invalid-title`,
},
N = {
key: 1,
class: `console-intro`,
"aria-labelledby": `console-closed-title`,
},
P = _plugin_vue_export_helper_t(
defineComponent({
__name: `remote-console`,
setup(m) {
(composables_t({
layout: !1,
}),
useHead({
title: `远程控制台 - 破碎工坊云`,
}));
let S = useRoute(),
P = ref(!0),
F = ref(``),
I = ref(!1),
L = computed(() =>
/^\d+$/.test(String(S.query.hostId || ``))
? String(S.query.hostId)
: ``,
),
R = new Set([
`kky_ecs`,
`mf_cloud`,
`remf_cloud`,
`mf_dcim`,
`remf_dcim`,
`remf_finance`,
`remf_finance_dcim`,
`remf_finance_common`,
`idcsmart_common`,
]),
z = computed(() =>
R.has(String(S.query.module)) ? String(S.query.module) : ``,
),
B = computed(() =>
L.value
? {
path: `/servers/server`,
query: {
id: L.value,
},
}
: {
path: `/cloud-servers`,
},
),
V = computed(() => z.value === `mf_dcim` && !I.value);
// 用户确认操作密码后开放远控组件挂载,实际鉴权由远控请求和网关完成。
function H() {
((I.value = !0), (P.value = !0));
}
// 重新连接时清空密码与确认状态,必要时重新显示密码门禁。
function U() {
((F.value = ``), (I.value = !1), (P.value = !0));
}
return (
watch(P, (e) => {
e || ((F.value = ``), (I.value = !1));
}),
watch([L, z], () => {
((F.value = ``), (I.value = !1), (P.value = !0));
}),
onBeforeUnmount(() => {
F.value = ``;
}),
// 仅在编号与模块有效且密码门禁已通过时挂载远控组件;无效/已关闭状态显示返回入口与重连操作。
(t, n) => {
let i = RemoteConsole,
s = NuxtLink,
m = button,
v = inputtext,
y = OperatePasswordGate;
return (
openBlock(),
createElementBlock(`main`, O, [
unref(L) && unref(z) && unref(P) && !unref(V)
? (openBlock(),
createBlock(
i,
{
key: 0,
visible: unref(P),
"onUpdate:visible": (n[0] ||= (e) =>
isRef(P) ? (P.value = e) : null),
"host-id": unref(L),
module: unref(z),
"operate-password": unref(F),
},
null,
8,
[`visible`, `host-id`, `module`, `operate-password`],
))
: (openBlock(),
createElementBlock(
Fragment,
{
key: 1,
},
[
createElementVNode(`header`, k, [
createVNode(
s,
{
to: unref(B),
class: `console-page-brand`,
},
{
default: withCtx(() => [
...(n[2] ||= [
createElementVNode(
`img`,
{
src: logoUrl,
alt: `破碎工坊云`,
},
null,
-1,
),
]),
]),
_: 1,
},
8,
[`to`],
),
unref(L)
? (openBlock(),
createElementBlock(
`span`,
A,
`实例 #` + toDisplayString(unref(L)),
1,
))
: createCommentVNode(``, !0),
]),
createElementVNode(`div`, j, [
!unref(L) || !unref(z)
? (openBlock(),
createElementBlock(`section`, M, [
(n[4] ||= createElementVNode(
`i`,
{
class: `pi pi-link intro-icon`,
"aria-hidden": `true`,
},
null,
-1,
)),
(n[5] ||= createElementVNode(
`h1`,
{
id: `console-invalid-title`,
},
`控制台链接已失效`,
-1,
)),
(n[6] ||= createElementVNode(
`p`,
null,
`请从实例详情页重新打开远程控制台。`,
-1,
)),
createVNode(
s,
{
to: `/cloud-servers`,
class: `console-return`,
},
{
default: withCtx(() => [
...(n[3] ||= [
createTextVNode(`返回云服务器`, -1),
createElementVNode(
`i`,
{
class: `pi pi-arrow-right`,
"aria-hidden": `true`,
},
null,
-1,
),
]),
]),
_: 1,
},
),
]))
: unref(P)
? (openBlock(),
createElementBlock(
`form`,
{
key: 2,
class: `console-intro console-operation`,
"aria-labelledby": `console-operation-title`,
onSubmit: withModifiers(H, [`prevent`]),
},
[
(n[14] ||= createElementVNode(
`i`,
{
class: `pi pi-desktop intro-icon`,
"aria-hidden": `true`,
},
null,
-1,
)),
(n[15] ||= createElementVNode(
`h1`,
{
id: `console-operation-title`,
},
`连接远程控制台`,
-1,
)),
(n[16] ||= createElementVNode(
`p`,
null,
`在此标签页中查看和操作实例屏幕。`,
-1,
)),
createVNode(y, null, {
default: withCtx(() => [
(n[11] ||= createElementVNode(
`label`,
{
for: `console-operation-password`,
},
[
createTextVNode(`操作密码`),
createElementVNode(
`span`,
null,
`选填`,
),
],
-1,
)),
createVNode(
v,
{
id: `console-operation-password`,
modelValue: unref(F),
"onUpdate:modelValue": (n[1] ||= (
e,
) =>
isRef(F) ? (F.value = e) : null),
type: `password`,
autocomplete: `off`,
fluid: ``,
"aria-describedby": `console-operation-help`,
},
null,
8,
[`modelValue`],
),
(n[12] ||= createElementVNode(
`p`,
{
id: `console-operation-help`,
class: `operation-help`,
},
`若此实例开启了操作验证,请填写操作密码。`,
-1,
)),
]),
_: 1,
}),
createVNode(m, {
type: `submit`,
label: `连接控制台`,
icon: `pi pi-arrow-right`,
fluid: ``,
}),
createVNode(
s,
{
to: unref(B),
class: `console-return`,
},
{
default: withCtx(() => [
...(n[13] ||= [
createTextVNode(`返回实例详情`, -1),
]),
]),
_: 1,
},
8,
[`to`],
),
],
32,
))
: (openBlock(),
createElementBlock(`section`, N, [
(n[8] ||= createElementVNode(
`i`,
{
class: `pi pi-desktop intro-icon`,
"aria-hidden": `true`,
},
null,
-1,
)),
(n[9] ||= createElementVNode(
`h1`,
{
id: `console-closed-title`,
},
`远程控制台已关闭`,
-1,
)),
(n[10] ||= createElementVNode(
`p`,
null,
`远程会话已结束,实例继续运行。您可以关闭此标签页,或重新打开控制台。`,
-1,
)),
createVNode(m, {
label: `重新打开控制台`,
icon: `pi pi-refresh`,
onClick: U,
}),
createVNode(
s,
{
to: unref(B),
class: `console-return`,
},
{
default: withCtx(() => [
...(n[7] ||= [
createTextVNode(`返回实例详情`, -1),
createElementVNode(
`i`,
{
class: `pi pi-arrow-right`,
"aria-hidden": `true`,
},
null,
-1,
),
]),
]),
_: 1,
},
8,
[`to`],
),
])),
]),
(n[17] ||= createElementVNode(
`footer`,
{
class: `console-page-footer`,
},
`关闭控制台不会关闭实例`,
-1,
)),
],
64,
)),
])
);
}
);
},
}),
[[`__scopeId`, `data-v-5f7e2625`]],
);
export {};
export default P;
</script>