Files
console-dev/app/components/BackendNavEntry.vue
T
2026-11-06 00:04:38 +08:00

434 lines
15 KiB
Vue

<script>
import "~/assets/styles/BackendNavEntry.Bx6IPica.css";
import { toDisplayString } from "vue";
import { renderList } from "vue";
import { useId } from "vue";
import { normalizeClass } 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 { unref } from "vue";
import { defineComponent } from "vue";
import { createVNode } from "vue";
import { openBlock } from "vue";
import { useRoute } from "#app";
import { NuxtLink } from "#components";
import { Icon } from "#components";
import { c as backend_menu_c } from "~/lib/backend-menu.js";
import { n as backend_menu_n } from "~/lib/backend-menu.js";
import dialog from "primevue/dialog";
import button from "primevue/button";
import { t as _plugin_vue_export_helper_t } from "~/lib/_plugin-vue_export-helper.js";
var T = {
key: 0,
class: `nav-group`,
},
E = [`aria-expanded`],
D = {
class: `nav-label`,
},
O = [`inert`, `aria-hidden`],
k = {
class: `sub-nav-clip`,
},
A = {
class: `sub-nav-items`,
},
j = [`href`, `aria-current`, `onClick`],
M = {
class: `nav-label`,
},
N = [`href`],
P = {
class: `nav-label`,
},
F = [`title`],
I = {
class: `nav-label`,
},
L = Object.assign(
_plugin_vue_export_helper_t(
defineComponent({
__name: `BackendNavEntry`,
props: {
entry: {},
siblings: {},
nested: {
type: Boolean,
},
},
setup(m) {
let w = m,
R = useRoute(),
z = `configured-nav-${useId()}`,
B = ref(null);
function V(e) {
let t = e
.filter((e) => e.to)
.map((e) => ({
to: e.to,
}));
return e.some(
(e) =>
(e.to && backend_menu_c(e.to, R, t)) ||
(e.children && V(e.children)),
);
}
let H = computed(() => V(w.entry.children ?? [])),
U = computed(() => B.value ?? H.value),
W = computed(
() =>
!!w.entry.to &&
backend_menu_c(
w.entry.to,
R,
(w.siblings ?? [])
.filter((e) => e.to)
.map((e) => ({
to: e.to,
})),
),
),
G = ref(!1),
K;
function q(e, t) {
if (!w.entry.confirm) {
t && (e.preventDefault(), t());
return;
}
(e.preventDefault(),
(K =
t ??
(() =>
window.open(w.entry.href, `_blank`, `noopener,noreferrer`))),
(G.value = !0));
}
function J() {
G.value = !1;
let e = K;
((K = void 0), e?.());
}
return (n, a) => {
let c = Icon,
_ = L,
b = NuxtLink,
w = button,
R = dialog;
return (
openBlock(),
createElementBlock(
Fragment,
null,
[
m.entry.children?.length
? (openBlock(),
createElementBlock(`div`, T, [
createElementVNode(
`button`,
{
type: `button`,
class: normalizeClass([
`nav-item`,
{
active: unref(H),
},
]),
"aria-expanded": unref(U),
"aria-controls": z,
onClick: (a[0] ||= (e) => (B.value = !unref(U))),
},
[
createVNode(
c,
{
name: unref(backend_menu_n)(m.entry),
class: `nav-icon`,
},
null,
8,
[`name`],
),
createElementVNode(
`span`,
D,
toDisplayString(m.entry.label),
1,
),
createElementVNode(
`i`,
{
class: normalizeClass([
`pi pi-angle-down nav-arrow`,
{
open: unref(U),
},
]),
"aria-hidden": `true`,
},
null,
2,
),
],
10,
E,
),
createElementVNode(
`div`,
{
id: z,
class: normalizeClass([
`sub-nav`,
{
open: unref(U),
},
]),
inert: !unref(U),
"aria-hidden": !unref(U),
},
[
createElementVNode(`div`, k, [
createElementVNode(`div`, A, [
(openBlock(!0),
createElementBlock(
Fragment,
null,
renderList(
m.entry.children,
(e) => (
openBlock(),
createBlock(
_,
{
key: e.key,
entry: e,
siblings: m.entry.children,
nested: ``,
},
null,
8,
[`entry`, `siblings`],
)
),
),
128,
)),
]),
]),
],
10,
O,
),
]))
: m.entry.to
? (openBlock(),
createBlock(
b,
{
key: 1,
to: m.entry.to,
custom: ``,
},
{
default: withCtx(({ href: t, navigate: n }) => [
createElementVNode(
`a`,
{
href: t || void 0,
class: normalizeClass([
m.nested ? `sub-item` : `nav-item`,
{
active: unref(W),
},
]),
"aria-current": unref(W) ? `page` : void 0,
onClick: (e) => q(e, n),
},
[
m.nested
? createCommentVNode(``, !0)
: (openBlock(),
createBlock(
c,
{
key: 0,
name: unref(backend_menu_n)(m.entry),
class: `nav-icon`,
},
null,
8,
[`name`],
)),
createElementVNode(
`span`,
M,
toDisplayString(m.entry.label),
1,
),
],
10,
j,
),
]),
_: 1,
},
8,
[`to`],
))
: m.entry.href
? (openBlock(),
createElementBlock(
`a`,
{
key: 2,
href: m.entry.href,
class: normalizeClass(
m.nested
? `sub-item configured-external`
: `nav-item`,
),
target: `_blank`,
rel: `noopener noreferrer`,
onClick: (a[1] ||= (e) => q(e)),
},
[
m.nested
? createCommentVNode(``, !0)
: (openBlock(),
createBlock(
c,
{
key: 0,
name: unref(backend_menu_n)(m.entry),
class: `nav-icon`,
},
null,
8,
[`name`],
)),
createElementVNode(
`span`,
P,
toDisplayString(m.entry.label),
1,
),
(a[4] ||= createElementVNode(
`i`,
{
class: `pi pi-external-link external-icon`,
"aria-hidden": `true`,
},
null,
-1,
)),
],
10,
N,
))
: (openBlock(),
createElementBlock(
`button`,
{
key: 3,
type: `button`,
class: normalizeClass([
m.nested ? `sub-item` : `nav-item`,
`nav-unavailable`,
]),
disabled: ``,
title: m.entry.disabledReason,
},
[
m.nested
? createCommentVNode(``, !0)
: (openBlock(),
createBlock(
c,
{
key: 0,
name: unref(backend_menu_n)(m.entry),
class: `nav-icon`,
},
null,
8,
[`name`],
)),
createElementVNode(
`span`,
I,
toDisplayString(m.entry.label),
1,
),
(a[5] ||= createElementVNode(
`small`,
null,
`暂未开放`,
-1,
)),
],
10,
F,
)),
createVNode(
R,
{
visible: unref(G),
"onUpdate:visible": (a[3] ||= (e) =>
isRef(G) ? (G.value = e) : null),
header: `打开链接`,
modal: ``,
draggable: !1,
style: {
width: `420px`,
},
},
{
footer: withCtx(() => [
createVNode(w, {
label: `取消`,
severity: `secondary`,
outlined: ``,
onClick: (a[2] ||= (e) => (G.value = !1)),
}),
createVNode(w, {
label: `确认打开`,
onClick: J,
}),
]),
default: withCtx(() => [
createElementVNode(
`p`,
null,
`确认打开「` +
toDisplayString(m.entry.label) +
`」?`,
1,
),
]),
_: 1,
},
8,
[`visible`],
),
],
64,
)
);
};
},
}),
[[`__scopeId`, `data-v-b0009398`]],
),
{
__name: `BackendNavEntry`,
},
);
export {};
export default L;
</script>