SSideMenu.js 2.5 KB

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