SSideMenu.js 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. import { ref as R, computed as u, reactive as T, watch as h, onMounted as L, resolveComponent as _, openBlock as p, createElementBlock as U, createElementVNode as v, createVNode as w, withCtx as A, normalizeStyle as B, createBlock as k } from "vue";
  2. import { useRouter as D } from "vue-router";
  3. import { n as V, ad as g, cP as I, cL as N } from "./index2.js";
  4. const j = { class: "s-menu-slide-common" }, z = { class: "menu-wrap" }, H = {
  5. __name: "SSideMenu",
  6. emits: ["collapsed"],
  7. setup(W, { emit: $ }) {
  8. const d = D(), M = $, m = g(), r = R(""), b = u(() => {
  9. const e = window.$menuTheme;
  10. return r.value !== "dark" || !e || !e.token ? {} : { components: { Menu: e.token } };
  11. }), n = T({
  12. collapsed: !1,
  13. selectedKeys: [],
  14. openKeys: [],
  15. preOpenKeys: []
  16. });
  17. h(
  18. () => n.openKeys,
  19. (e, t) => {
  20. n.preOpenKeys = t;
  21. }
  22. );
  23. const O = (e, t) => t ? t.startsWith("/") ? t : e ? `${e.replace(/\/+$/, "")}/${t}` : `/${t}` : e || "", y = (e, t, l = 0, o = "") => e.map((s) => {
  24. var K;
  25. const c = window.$l(((K = s.meta) == null ? void 0 : K.title) || s.name || ""), a = l === 0 && !s.children, i = O(o, s.path), f = {
  26. key: i,
  27. // icon: item.icon ? () => h(item.icon) : null,
  28. icon: null,
  29. label: t && a ? c.slice(0, 1) : c,
  30. title: c,
  31. path: i
  32. };
  33. return s.children && (f.children = y(s.children, t, l + 1, i)), f;
  34. }), C = u(() => {
  35. var l;
  36. const e = ((l = m.dynamics[0]) == null ? void 0 : l.children) || [], t = (window.$staticRoutes || []).filter(
  37. (o) => {
  38. var s, c;
  39. return o && o.path && ((s = o.meta) == null ? void 0 : s.title) && !((c = o.meta) != null && c.hidden);
  40. }
  41. );
  42. return [...e, ...t].filter((o) => {
  43. var s;
  44. return !((s = o.meta) != null && s.hidden);
  45. });
  46. }), S = u(() => y(C.value, n.collapsed)), E = () => {
  47. n.collapsed = !n.collapsed, n.openKeys = n.collapsed ? [] : n.preOpenKeys, M("collapsed", n.collapsed);
  48. }, P = (e) => {
  49. d.push(e.key), n.selectedKeys = [e.key], window.$utils.ls.set("selectedKeys", n.selectedKeys);
  50. }, x = (e) => {
  51. n.openKeys = e, g().setMenuOpenKeys(n.openKeys);
  52. };
  53. return L(() => {
  54. var o;
  55. r.value = window.$utils.env.VITE_APP_MENU_THEME || "dark";
  56. const e = (window.$utils.env.VITE_APP_BASE_URL || "/").replace(/\/+$/, "");
  57. let t = ((o = d.currentRoute.value) == null ? void 0 : o.path) || "";
  58. t || (t = location.pathname, e && t.indexOf(e) === 0 && (t = t.slice(e.length) || "/")), window.$utils.ls.set("selectedKeys", [t]), n.selectedKeys = window.$utils.ls.get("selectedKeys") || [];
  59. const l = m.openKeys || [];
  60. n.openKeys = l;
  61. }), h(
  62. () => {
  63. var e;
  64. return (e = d.currentRoute.value) == null ? void 0 : e.path;
  65. },
  66. (e) => {
  67. e && (n.selectedKeys = [e], window.$utils.ls.set("selectedKeys", n.selectedKeys));
  68. }
  69. ), (e, t) => {
  70. const l = N, o = I, s = _("DoubleRightOutlined"), c = _("DoubleLeftOutlined");
  71. return p(), U("div", j, [
  72. v("div", z, [
  73. w(o, { theme: b.value }, {
  74. default: A(() => [
  75. w(l, {
  76. openKeys: n.openKeys,
  77. "onUpdate:openKeys": t[0] || (t[0] = (a) => n.openKeys = a),
  78. selectedKeys: n.selectedKeys,
  79. "onUpdate:selectedKeys": t[1] || (t[1] = (a) => n.selectedKeys = a),
  80. mode: "inline",
  81. items: S.value,
  82. theme: r.value,
  83. onSelect: P,
  84. onOpenChange: x
  85. }, null, 8, ["openKeys", "selectedKeys", "items", "theme"])
  86. ]),
  87. _: 1
  88. }, 8, ["theme"])
  89. ]),
  90. v("div", {
  91. class: "right-border-btn",
  92. style: B({
  93. backgroundColor: r.value === "dark" ? "var(--s-menu-bg, #e8ecf3)" : "#fff",
  94. color: r.value === "dark" ? "var(--s-menu-text, #344051)" : "#000000A6",
  95. border: `1px solid ${r.value === "dark" ? "var(--s-menu-bg, #e8ecf3)" : "#ececec"}`
  96. }),
  97. onClick: E
  98. }, [
  99. n.collapsed ? (p(), k(s, { key: 0 })) : (p(), k(c, { key: 1 }))
  100. ], 4)
  101. ]);
  102. };
  103. }
  104. }, J = /* @__PURE__ */ V(H, [["__scopeId", "data-v-778de210"]]);
  105. export {
  106. J as default
  107. };