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.
- package/dist/index.css +1 -1
- package/dist/my-element-lib.mjs +48 -99
- package/dist/my-element-lib.umd.js +2 -2
- package/package.json +1 -1
package/dist/my-element-lib.mjs
CHANGED
|
@@ -1,125 +1,74 @@
|
|
|
1
|
-
import { resolveComponent as
|
|
2
|
-
import
|
|
3
|
-
const
|
|
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(
|
|
8
|
-
return (
|
|
9
|
-
const
|
|
10
|
-
return
|
|
11
|
-
default:
|
|
12
|
-
|
|
13
|
-
|
|
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
|
-
}),
|
|
20
|
+
}), I = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
21
21
|
__proto__: null,
|
|
22
|
-
default:
|
|
23
|
-
}, Symbol.toStringTag, { value: "Module" })),
|
|
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(
|
|
30
|
-
const
|
|
31
|
-
primary:
|
|
32
|
-
|
|
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
|
|
39
|
-
const i = parseInt(
|
|
40
|
-
return `rgb(${u}, ${
|
|
41
|
-
},
|
|
42
|
-
const i = parseInt(
|
|
43
|
-
return `rgb(${u}, ${
|
|
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:
|
|
47
|
-
light5:
|
|
48
|
-
light7:
|
|
49
|
-
light9:
|
|
50
|
-
dark2:
|
|
41
|
+
light3: c(30),
|
|
42
|
+
light5: c(50),
|
|
43
|
+
light7: c(70),
|
|
44
|
+
light9: c(90),
|
|
45
|
+
dark2: y(20)
|
|
51
46
|
};
|
|
52
|
-
})(
|
|
53
|
-
|
|
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
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
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
|
-
},
|
|
112
|
-
|
|
113
|
-
for (const [
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
const
|
|
117
|
-
|
|
118
|
-
}),
|
|
119
|
-
},
|
|
120
|
-
install:
|
|
121
|
-
themeUtils:
|
|
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
|
-
|
|
73
|
+
S as default
|
|
125
74
|
};
|