SThemeConfig.js 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. var j = Object.defineProperty, G = Object.defineProperties;
  2. var J = Object.getOwnPropertyDescriptors;
  3. var b = Object.getOwnPropertySymbols;
  4. var K = Object.prototype.hasOwnProperty, Q = Object.prototype.propertyIsEnumerable;
  5. var S = (n, l, a) => l in n ? j(n, l, { enumerable: !0, configurable: !0, writable: !0, value: a }) : n[l] = a, u = (n, l) => {
  6. for (var a in l || (l = {}))
  7. K.call(l, a) && S(n, a, l[a]);
  8. if (b)
  9. for (var a of b(l))
  10. Q.call(l, a) && S(n, a, l[a]);
  11. return n;
  12. }, C = (n, l) => G(n, J(l));
  13. import { computed as B, ref as f, watch as W, resolveComponent as X, openBlock as d, createBlock as Y, withCtx as T, createElementVNode as t, toDisplayString as r, createElementBlock as v, Fragment as I, renderList as x, normalizeClass as Z, normalizeStyle as E, createCommentVNode as ee, createVNode as F, unref as te, createTextVNode as se } from "vue";
  14. import { n as oe, dq as p, dr as k, I as le, ds as ae, B as ne, dt as ce, du as ue, dv as re, dw as ie } from "./index2.js";
  15. const de = { class: "s-theme-config" }, ve = { class: "section" }, me = { class: "section-title" }, _e = { class: "preset-list" }, pe = ["title", "onClick"], he = { class: "name" }, ge = { class: "theme-container" }, Ce = {
  16. key: 0,
  17. class: "disabled-box"
  18. }, fe = { class: "section" }, ke = { class: "section-title" }, ye = { class: "color-row" }, $e = ["value"], we = { class: "tip" }, be = { class: "section" }, Se = { class: "section-title" }, Be = { class: "customer-grid" }, Te = { class: "cell-label" }, Ie = ["value", "onInput"], xe = { class: "cell-hex" }, Ee = { class: "tip" }, Fe = { class: "actions" }, He = {
  19. __name: "SThemeConfig",
  20. props: {
  21. /**
  22. * 是否显示,配合 v-model:value 使用
  23. */
  24. value: {
  25. type: Boolean,
  26. default: !1
  27. }
  28. },
  29. emits: ["update:value", "change"],
  30. setup(n, { emit: l }) {
  31. const a = n, h = l, m = B({
  32. get: () => a.value,
  33. set: (e) => h("update:value", e)
  34. }), H = B(() => s.value.code !== "customer"), _ = f(p()), L = ae, s = f(u({}, window.$theme || {})), i = f(k()), y = /^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/, N = (e) => y.test(String(e || "").trim()) ? String(e).trim() : "#000000";
  35. W(
  36. () => a.value,
  37. (e) => {
  38. e && (_.value = p(), s.value = u({}, window.$theme || {}), i.value = k());
  39. }
  40. );
  41. const g = () => {
  42. const e = ie(s.value);
  43. s.value = u({}, e), h("change", u({}, e));
  44. }, R = (e) => {
  45. s.value = u({}, e), g();
  46. }, $ = (e) => {
  47. s.value = ce(e), g();
  48. }, V = (e) => {
  49. const c = e.target.value;
  50. s.value = C(u({}, s.value), { color: c });
  51. }, z = (e) => {
  52. const c = String(e.target.value || "").trim();
  53. if (!y.test(c)) {
  54. s.value = C(u({}, s.value), { color: window.$theme && window.$theme.color || "" });
  55. return;
  56. }
  57. $(c);
  58. }, D = (e, c) => {
  59. i.value = ue({ [e]: c }), s.value = u({}, i.value), _.value = p(), g();
  60. }, O = () => {
  61. const e = re();
  62. s.value = u({}, e), i.value = k(), _.value = p(), h("change", u({}, e));
  63. }, A = () => {
  64. m.value = !1;
  65. }, M = () => {
  66. m.value = !1;
  67. };
  68. return (e, c) => {
  69. const P = le, U = ne, q = X("s-modal");
  70. return d(), Y(q, {
  71. value: m.value,
  72. "onUpdate:value": c[1] || (c[1] = (o) => m.value = o),
  73. title: e.$l("主题配置"),
  74. width: "620px",
  75. "save-btn-text": e.$l("完成"),
  76. onHandSave: A,
  77. onHandCancel: M
  78. }, {
  79. default: T(() => [
  80. t("div", de, [
  81. t("div", ve, [
  82. t("div", me, r(e.$l("预设主题")), 1),
  83. t("div", _e, [
  84. (d(!0), v(I, null, x(_.value, (o) => (d(), v("div", {
  85. key: o.name,
  86. class: Z(["preset-item", { active: s.value.name === o.name }]),
  87. title: o.color,
  88. onClick: (w) => R(o)
  89. }, [
  90. t("span", {
  91. class: "dot",
  92. style: E({ backgroundColor: o.color })
  93. }, null, 4),
  94. t("span", he, r(o.name), 1)
  95. ], 10, pe))), 128))
  96. ])
  97. ]),
  98. t("div", ge, [
  99. H.value ? (d(), v("div", Ce)) : ee("", !0),
  100. t("div", fe, [
  101. t("div", ke, r(e.$l("主题色")), 1),
  102. t("div", ye, [
  103. t("input", {
  104. class: "color-picker",
  105. type: "color",
  106. value: s.value.color,
  107. onInput: c[0] || (c[0] = (o) => $(o.target.value))
  108. }, null, 40, $e),
  109. F(P, {
  110. class: "hex-input",
  111. value: s.value.color,
  112. maxlength: 7,
  113. onChange: V,
  114. onBlur: z
  115. }, null, 8, ["value"]),
  116. t("span", we, r(e.$l("修改后立即生效")), 1)
  117. ]),
  118. t("div", {
  119. class: "theme-preview",
  120. style: E({ backgroundColor: s.value.color })
  121. }, null, 4)
  122. ]),
  123. t("div", be, [
  124. t("div", Se, r(e.$l("customer 颜色")), 1),
  125. t("div", Be, [
  126. (d(!0), v(I, null, x(te(L), (o) => (d(), v("div", {
  127. key: o.key,
  128. class: "customer-cell"
  129. }, [
  130. t("span", Te, r(e.$l(o.label)), 1),
  131. t("input", {
  132. class: "color-picker small",
  133. type: "color",
  134. value: N(i.value[o.key]),
  135. onInput: (w) => D(o.key, w.target.value)
  136. }, null, 40, Ie),
  137. t("span", xe, r(i.value[o.key]), 1)
  138. ]))), 128))
  139. ]),
  140. t("div", Ee, r(e.$l("修改 customer 颜色会自动切换到 customer 主题")), 1)
  141. ])
  142. ]),
  143. t("div", Fe, [
  144. F(U, {
  145. size: "small",
  146. onClick: O
  147. }, {
  148. default: T(() => [
  149. se(r(e.$l("恢复默认")), 1)
  150. ]),
  151. _: 1
  152. })
  153. ])
  154. ])
  155. ]),
  156. _: 1
  157. }, 8, ["value", "title", "save-btn-text"]);
  158. };
  159. }
  160. }, Ve = /* @__PURE__ */ oe(He, [["__scopeId", "data-v-94895ebb"]]);
  161. export {
  162. Ve as default
  163. };