my-element-plus-ext 1.0.35 → 1.0.37

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,125 +1,74 @@
1
- import { resolveComponent as j, createBlock as f, openBlock as z, withCtx as P, renderSlot as _, createTextVNode as C } from "vue";
2
- import b from "element-plus";
3
- const S = /* @__PURE__ */ Object.assign({
1
+ import { resolveComponent as _, createBlock as g, openBlock as b, withCtx as f, renderSlot as M, createTextVNode as P } from "vue";
2
+ import $ from "element-plus";
3
+ const B = /* @__PURE__ */ Object.assign({
4
4
  name: "MyButton"
5
5
  }, {
6
6
  __name: "MyButton",
7
- setup(e) {
8
- return (r, t) => {
9
- const n = j("el-button");
10
- return z(), f(n, null, {
11
- default: P(() => [
12
- _(r.$slots, "default", {}, () => [
13
- t[0] || (t[0] = C("默认按钮", -1))
7
+ setup(t) {
8
+ return (n, o) => {
9
+ const e = _("el-button");
10
+ return b(), g(e, null, {
11
+ default: f(() => [
12
+ M(n.$slots, "default", {}, () => [
13
+ o[0] || (o[0] = P("默认按钮", -1))
14
14
  ])
15
15
  ]),
16
16
  _: 3
17
17
  });
18
18
  };
19
19
  }
20
- }), E = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
20
+ }), I = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
21
21
  __proto__: null,
22
- default: S
23
- }, Symbol.toStringTag, { value: "Module" })), p = {
22
+ default: B
23
+ }, Symbol.toStringTag, { value: "Module" })), h = {
24
24
  /**
25
25
  * 设置主题色
26
26
  * @param {string} primaryColor - 主色,如 #409EFF
27
- * @param {Object} options - 其他颜色配置
28
27
  */
29
- setTheme(e, r = {}) {
30
- const t = {
31
- primary: e,
32
- success: r.success || "#67C23A",
33
- warning: r.warning || "#E6A23C",
34
- danger: r.danger || "#F56C6C",
35
- info: r.info || "#909399"
36
- }, s = ((l) => {
28
+ setTheme(t) {
29
+ const n = {
30
+ primary: t
31
+ }, e = ((r) => {
37
32
  document.documentElement.style;
38
- const a = (c) => {
39
- const i = parseInt(l.slice(1, 3), 16), m = parseInt(l.slice(3, 5), 16), y = parseInt(l.slice(5, 7), 16), u = Math.round(i + (255 - i) * (c / 100)), g = Math.round(m + (255 - m) * (c / 100)), h = Math.round(y + (255 - y) * (c / 100));
40
- return `rgb(${u}, ${g}, ${h})`;
41
- }, d = (c) => {
42
- const i = parseInt(l.slice(1, 3), 16), m = parseInt(l.slice(3, 5), 16), y = parseInt(l.slice(5, 7), 16), u = Math.round(i * (1 - c / 100)), g = Math.round(m * (1 - c / 100)), h = Math.round(y * (1 - c / 100));
43
- return `rgb(${u}, ${g}, ${h})`;
33
+ const c = (s) => {
34
+ const i = parseInt(r.slice(1, 3), 16), a = parseInt(r.slice(3, 5), 16), m = parseInt(r.slice(5, 7), 16), u = Math.round(i + (255 - i) * (s / 100)), p = Math.round(a + (255 - a) * (s / 100)), d = Math.round(m + (255 - m) * (s / 100));
35
+ return `rgb(${u}, ${p}, ${d})`;
36
+ }, y = (s) => {
37
+ const i = parseInt(r.slice(1, 3), 16), a = parseInt(r.slice(3, 5), 16), m = parseInt(r.slice(5, 7), 16), u = Math.round(i * (1 - s / 100)), p = Math.round(a * (1 - s / 100)), d = Math.round(m * (1 - s / 100));
38
+ return `rgb(${u}, ${p}, ${d})`;
44
39
  };
45
40
  return {
46
- light3: a(30),
47
- light5: a(50),
48
- light7: a(70),
49
- light9: a(90),
50
- dark2: d(20)
41
+ light3: c(30),
42
+ light5: c(50),
43
+ light7: c(70),
44
+ light9: c(90),
45
+ dark2: y(20)
51
46
  };
52
- })(t.primary), o = document.documentElement;
53
- o.style.setProperty("--zj-color-primary", t.primary), o.style.setProperty("--el-color-primary", t.primary), o.style.setProperty("--zj-color-primary-light-3", s.light3), o.style.setProperty("--el-color-primary-light-3", s.light3), o.style.setProperty("--zj-color-primary-light-5", s.light5), o.style.setProperty("--el-color-primary-light-5", s.light5), o.style.setProperty("--zj-color-primary-light-9", s.light9), o.style.setProperty("--el-color-primary-light-9", s.light9), o.style.setProperty("--zj-color-primary-dark-2", s.dark2), o.style.setProperty("--el-color-primary-dark-2", s.dark2), Object.keys(t).forEach((l) => {
54
- l !== "primary" && (o.style.setProperty(`--zj-color-${l}`, t[l]), o.style.setProperty(`--el-color-${l}`, t[l]));
55
- }), localStorage.setItem("zj-theme-colors", JSON.stringify(t));
56
- },
57
- /**
58
- * 重置为默认主题
59
- */
60
- resetTheme() {
61
- const e = document.documentElement;
62
- [
63
- "--zj-color-primary",
64
- "--el-color-primary",
65
- "--zj-color-primary-light-3",
66
- "--el-color-primary-light-3",
67
- "--zj-color-primary-light-5",
68
- "--el-color-primary-light-5",
69
- "--zj-color-primary-light-9",
70
- "--el-color-primary-light-9",
71
- "--zj-color-primary-dark-2",
72
- "--el-color-primary-dark-2",
73
- "--zj-color-success",
74
- "--el-color-success",
75
- "--zj-color-warning",
76
- "--el-color-warning",
77
- "--zj-color-danger",
78
- "--el-color-danger",
79
- "--zj-color-info",
80
- "--el-color-info"
81
- ].forEach((t) => {
82
- e.style.removeProperty(t);
83
- }), localStorage.removeItem("zj-theme-colors");
47
+ })(n.primary), l = document.documentElement;
48
+ l.style.setProperty("--el-color-primary", n.primary), l.style.setProperty("--el-color-primary-light-3", e.light3), l.style.setProperty("--el-color-primary-light-5", e.light5), l.style.setProperty("--el-color-primary-light-9", e.light9), l.style.setProperty("--el-color-primary-dark-2", e.dark2);
84
49
  },
85
50
  /**
86
51
  * 初始化主题(从localStorage恢复)
87
52
  */
88
- initTheme() {
89
- const e = localStorage.getItem("zj-theme-colors");
90
- if (e)
91
- try {
92
- const r = JSON.parse(e);
93
- this.setTheme(r.primary, r);
94
- } catch (r) {
95
- console.warn("Failed to load saved theme:", r);
96
- }
97
- },
98
- /**
99
- * 获取当前主题色
100
- */
101
- getCurrentTheme() {
102
- const e = document.documentElement;
103
- return {
104
- primary: getComputedStyle(e).getPropertyValue("--zj-color-primary").trim() || "#409EFF",
105
- success: getComputedStyle(e).getPropertyValue("--zj-color-success").trim() || "#67C23A",
106
- warning: getComputedStyle(e).getPropertyValue("--zj-color-warning").trim() || "#E6A23C",
107
- danger: getComputedStyle(e).getPropertyValue("--zj-color-danger").trim() || "#F56C6C",
108
- info: getComputedStyle(e).getPropertyValue("--zj-color-info").trim() || "#909399"
109
- };
53
+ initTheme(t = "#409EFF") {
54
+ try {
55
+ this.setTheme(t);
56
+ } catch (n) {
57
+ console.warn("Failed to load saved theme:", n);
58
+ }
110
59
  }
111
- }, I = /* @__PURE__ */ Object.assign({ "./components/MyButton.vue": E }), M = Object.values(I).map((e) => e.default), $ = (e, r = {}) => {
112
- e.use(b);
113
- for (const [t, n] of Object.entries(ElementPlusIconsVue))
114
- e.component(t, n);
115
- M.forEach((t) => {
116
- const n = t.__name || t.name;
117
- n && e.component(n, t);
118
- }), r.theme && p.setTheme(r.theme.primary, r.theme), p.initTheme(), e.config.globalProperties.$theme = p;
119
- }, T = {
120
- install: $,
121
- themeUtils: p
60
+ }, j = /* @__PURE__ */ Object.assign({ "./components/MyButton.vue": I }), k = Object.values(j).map((t) => t.default), v = (t, n = {}) => {
61
+ t.use($);
62
+ for (const [o, e] of Object.entries(ElementPlusIconsVue))
63
+ t.component(o, e);
64
+ k.forEach((o) => {
65
+ const e = o.__name || o.name;
66
+ e && t.component(e, o);
67
+ }), h.initTheme(n.theme), t.config.globalProperties.$theme = h;
68
+ }, S = {
69
+ install: v,
70
+ themeUtils: h
122
71
  };
123
72
  export {
124
- T as default
73
+ S as default
125
74
  };