STopMenu.js 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. import { ref as d, reactive as u, watch as m, onMounted as i, openBlock as _, createElementBlock as y, createElementVNode as h, createVNode as K } from "vue";
  2. import { c as f } from "./routeConvert.js";
  3. import { r as v, aM as M, aN as w } from "./index2.js";
  4. const E = { class: "s-menu-common" }, k = { class: "menu-wrap" }, S = {
  5. __name: "STopMenu",
  6. emits: ["collapsed"],
  7. setup(T, { emit: b }) {
  8. const c = d([]), l = d(""), n = u({
  9. collapsed: !1,
  10. selectedKeys: ["1"],
  11. openKeys: ["sub1"],
  12. preOpenKeys: ["sub1"]
  13. });
  14. m(
  15. () => n.openKeys,
  16. (o, s) => {
  17. n.preOpenKeys = s;
  18. }
  19. );
  20. const r = (o) => o.map((e) => {
  21. const t = {
  22. key: e.path,
  23. // icon: item.icon ? () => h(item.icon) : null,
  24. icon: null,
  25. label: e.name || e.meta.title,
  26. title: e.name || e,
  27. path: e.path
  28. };
  29. return e.children && (t.children = r(e.children)), t;
  30. }), p = (o) => {
  31. window.$push(o.key);
  32. };
  33. return i(() => {
  34. l.value = window.$utils.env.VITE_APP_MENU_THEME || "dark";
  35. const s = M().dynamics, e = f(s.find((a) => a.path === "/")), t = e && e.children || [];
  36. c.value = r(t.filter((a) => !a.meta.hidden));
  37. }), (o, s) => {
  38. const e = w;
  39. return _(), y("div", E, [
  40. h("div", k, [
  41. K(e, {
  42. openKeys: n.openKeys,
  43. "onUpdate:openKeys": s[0] || (s[0] = (t) => n.openKeys = t),
  44. selectedKeys: n.selectedKeys,
  45. "onUpdate:selectedKeys": s[1] || (s[1] = (t) => n.selectedKeys = t),
  46. mode: "horizontal",
  47. theme: l.value,
  48. items: c.value,
  49. onSelect: p
  50. }, null, 8, ["openKeys", "selectedKeys", "theme", "items"])
  51. ])
  52. ]);
  53. };
  54. }
  55. }, V = /* @__PURE__ */ v(S, [["__scopeId", "data-v-d34b8d4d"]]);
  56. export {
  57. V as default
  58. };