SSideMenu.js 3.9 KB

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