SSkeletonLayout.js 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. import { ref as d, onMounted as T, onActivated as L, resolveDirective as P, openBlock as l, createElementBlock as i, normalizeStyle as c, createElementVNode as r, toDisplayString as S, Fragment as V, renderList as A, withDirectives as b, createBlock as _, withCtx as w, createTextVNode as N, resolveDynamicComponent as z, createCommentVNode as f, vShow as E, renderSlot as m, nextTick as M } from "vue";
  2. import { n as W, B as X } from "./index2.js";
  3. const F = { class: "title" }, I = { class: "btns" }, j = {
  4. key: 0,
  5. style: { "margin-left": "8px" }
  6. }, q = /* @__PURE__ */ Object.assign({ name: "SSkeletonLayout" }, {
  7. __name: "SSkeletonLayout",
  8. props: {
  9. // 页面标题
  10. title: {
  11. type: String,
  12. required: !0
  13. },
  14. // 工具条按钮:[{ key, name, icon, type, show, disabled, action }]
  15. buttons: {
  16. type: Array,
  17. default: () => []
  18. },
  19. bgColor: {
  20. type: String,
  21. default: ""
  22. }
  23. },
  24. emits: ["btnCallback"],
  25. setup(p, { emit: $ }) {
  26. const h = d(null), v = d(null), k = d(null), y = d(232), a = d(0);
  27. function g() {
  28. M(() => {
  29. var o, t, n, C;
  30. const e = ((t = (o = h.value) == null ? void 0 : o.parentNode) == null ? void 0 : t.offsetHeight) || 0, s = ((n = v.value) == null ? void 0 : n.offsetHeight) || 0, u = ((C = k.value) == null ? void 0 : C.offsetHeight) || 0;
  31. a.value = Math.max(e - s - u, 0);
  32. });
  33. }
  34. T(() => g()), L(() => g());
  35. const D = $, H = {
  36. add: "PlusCircleOutlined",
  37. edit: "FormOutlined",
  38. delete: "DeleteOutlined",
  39. remove: "DeleteOutlined",
  40. import: "UploadOutlined",
  41. export: "DownloadOutlined",
  42. assign: "ClusterOutlined",
  43. execute: "PlayCircleOutlined",
  44. pause: "PauseCircleOutlined",
  45. resume: "PoweroffOutlined",
  46. approve: "HighlightOutlined",
  47. setting: "SettingOutlined",
  48. TopOfType: "VerticalAlignTopOutlined",
  49. TOP: "VerticalAlignTopOutlined",
  50. synchronize: "SyncOutlined"
  51. };
  52. function x(e) {
  53. D("btnCallback", e.key);
  54. }
  55. function O(e) {
  56. return typeof e.icon == "string" ? e.icon : typeof e.icon == "boolean" && e.icon && H[e.key] || "";
  57. }
  58. const B = {
  59. mounted(e) {
  60. e.style.cursor = "e-resize", document.addEventListener("selectstart", (s) => {
  61. s.preventDefault();
  62. }), e.onmousedown = (s) => {
  63. const u = s.clientX, o = y.value;
  64. document.onmousemove = (t) => {
  65. const n = t.clientX - u;
  66. if (n < 0) {
  67. if (o + n <= 232) return;
  68. y.value = o + n;
  69. } else {
  70. if (o + n >= 500) return;
  71. y.value = o + n;
  72. }
  73. }, document.onmouseup = () => {
  74. document.onmousemove = document.onmousedown = null;
  75. };
  76. };
  77. }
  78. };
  79. return (e, s) => {
  80. const u = X, o = P("action");
  81. return l(), i("div", {
  82. class: "s-skeleton-layout",
  83. ref_key: "layout",
  84. ref: h,
  85. style: c({ backgroundColor: p.bgColor })
  86. }, [
  87. r("div", {
  88. class: "tools",
  89. ref_key: "tools",
  90. ref: v
  91. }, [
  92. r("div", F, S(p.title), 1),
  93. r("div", I, [
  94. (l(!0), i(V, null, A(p.buttons, (t) => (l(), i("span", {
  95. class: "item-btn",
  96. key: t.key
  97. }, [
  98. b((l(), _(u, {
  99. class: "btn",
  100. disabled: !!t.disabled,
  101. type: t.type || t.key === "add" ? "primary" : "default",
  102. onClick: (n) => x(t)
  103. }, {
  104. icon: w(() => [
  105. O(t) ? (l(), _(z(O(t)), { key: 0 })) : f("", !0)
  106. ]),
  107. default: w(() => [
  108. N(" " + S(e.$l(t.name)), 1)
  109. ]),
  110. _: 2
  111. }, 1032, ["disabled", "type", "onClick"])), [
  112. [o, t.action || t.key],
  113. [E, t.show !== !1]
  114. ])
  115. ]))), 128)),
  116. e.$slots.otherBtns ? (l(), i("span", j, [
  117. m(e.$slots, "otherBtns", {}, void 0, !0)
  118. ])) : f("", !0)
  119. ])
  120. ], 512),
  121. r("div", {
  122. class: "skeleton-layout-main",
  123. style: c({ height: a.value + "px" })
  124. }, [
  125. e.$slots.tree ? (l(), i("div", {
  126. key: 0,
  127. class: "side s-side-tree",
  128. ref: "side",
  129. style: c([{ height: a.value + "px", width: y.value + "px" }, { "overflow-y": "auto" }])
  130. }, [
  131. m(e.$slots, "tree", {}, void 0, !0)
  132. ], 4)) : f("", !0),
  133. e.$slots.tree ? b((l(), i("div", {
  134. key: 1,
  135. class: "side-bar s-theme-bg",
  136. style: c({ height: a.value + "px" })
  137. }, null, 4)), [
  138. [B]
  139. ]) : f("", !0),
  140. r("div", {
  141. class: "skeleton-content",
  142. style: c({ height: a.value + "px" })
  143. }, [
  144. m(e.$slots, "default", {}, void 0, !0)
  145. ], 4)
  146. ], 4),
  147. r("div", {
  148. class: "other",
  149. ref_key: "other",
  150. ref: k
  151. }, [
  152. m(e.$slots, "other", {}, void 0, !0)
  153. ], 512)
  154. ], 4);
  155. };
  156. }
  157. }), J = /* @__PURE__ */ W(q, [["__scopeId", "data-v-257b2962"]]);
  158. export {
  159. J as default
  160. };