SSideMenu.js 4.5 KB

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