SSideMenu.js 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. import { ref as R, computed as i, reactive as T, watch as K, onMounted as U, resolveComponent as _, openBlock as u, createElementBlock as B, createElementVNode as w, createVNode as v, withCtx as D, createBlock as g } from "vue";
  2. import { useRouter as L } from "vue-router";
  3. import { n as V, ad as $, cQ as A, cM as I } from "./index2.js";
  4. const N = { class: "s-menu-slide-common" }, j = { class: "menu-wrap" }, H = {
  5. __name: "SSideMenu",
  6. emits: ["collapsed"],
  7. setup(Q, { emit: k }) {
  8. const a = L(), b = k, p = $(), m = R(""), M = i(() => {
  9. const e = window.$menuTheme;
  10. return !e || !e.token ? {} : { components: { Menu: e.token } };
  11. }), n = T({
  12. collapsed: !1,
  13. selectedKeys: [],
  14. openKeys: [],
  15. preOpenKeys: []
  16. });
  17. K(
  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 h;
  25. const c = window.$l(((h = s.meta) == null ? void 0 : h.title) || s.name || ""), r = l === 0 && !s.children, d = O(o, s.path), f = {
  26. key: d,
  27. // icon: item.icon ? () => h(item.icon) : null,
  28. icon: null,
  29. label: t && r ? c.slice(0, 1) : c,
  30. // title: name,
  31. path: d
  32. };
  33. return s.children && (f.children = y(s.children, t, l + 1, d)), f;
  34. }), C = i(() => {
  35. var l;
  36. const e = ((l = p.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. }), E = i(() => y(C.value, n.collapsed)), S = () => {
  47. n.collapsed = !n.collapsed, n.openKeys = n.collapsed ? [] : n.preOpenKeys, b("collapsed", n.collapsed);
  48. }, x = (e) => {
  49. a.push(e.key), n.selectedKeys = [e.key], window.$utils.ls.set("selectedKeys", n.selectedKeys);
  50. }, P = (e) => {
  51. n.openKeys = e, $().setMenuOpenKeys(n.openKeys);
  52. };
  53. return U(() => {
  54. var o;
  55. m.value = window.$utils.env.VITE_APP_MENU_THEME || "light";
  56. const e = (window.$utils.env.VITE_APP_BASE_URL || "/").replace(/\/+$/, "");
  57. let t = ((o = a.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 = p.openKeys || [];
  60. n.openKeys = l;
  61. }), K(
  62. () => {
  63. var e;
  64. return (e = a.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 = I, o = A, s = _("DoubleRightOutlined"), c = _("DoubleLeftOutlined");
  71. return u(), B("div", N, [
  72. w("div", j, [
  73. v(o, { theme: M.value }, {
  74. default: D(() => [
  75. v(l, {
  76. openKeys: n.openKeys,
  77. "onUpdate:openKeys": t[0] || (t[0] = (r) => n.openKeys = r),
  78. selectedKeys: n.selectedKeys,
  79. "onUpdate:selectedKeys": t[1] || (t[1] = (r) => n.selectedKeys = r),
  80. mode: "inline",
  81. items: E.value,
  82. theme: m.value,
  83. onSelect: x,
  84. onOpenChange: P
  85. }, null, 8, ["openKeys", "selectedKeys", "items", "theme"])
  86. ]),
  87. _: 1
  88. }, 8, ["theme"])
  89. ]),
  90. w("div", {
  91. class: "right-border-btn",
  92. style: {
  93. backgroundColor: "var(--s-menu-bg, #ebf7fe)",
  94. color: "var(--s-menu-text, #344051)",
  95. border: "1px solid var(--s-menu-bg, #ebf7fe)"
  96. },
  97. onClick: S
  98. }, [
  99. n.collapsed ? (u(), g(s, { key: 0 })) : (u(), g(c, { key: 1 }))
  100. ])
  101. ]);
  102. };
  103. }
  104. }, F = /* @__PURE__ */ V(H, [["__scopeId", "data-v-2ec64017"]]);
  105. export {
  106. F as default
  107. };