SSideMenu.js 3.3 KB

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