suncy-my-npm-test 1.0.45 → 1.0.47
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/README.md +48 -0
- package/dist/favicon.ico +0 -0
- package/dist/my-vue-webcomponents.es.js +193 -0
- package/dist/my-vue-webcomponents.umd.js +1 -0
- package/dist/static/index.html +11 -0
- package/package.json +61 -56
- package/packages/components/MyButton.vue +0 -76
- package/packages/index.js +0 -27
package/README.md
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# my-vue-project
|
|
2
|
+
|
|
3
|
+
This template should help get you started developing with Vue 3 in Vite.
|
|
4
|
+
|
|
5
|
+
## Recommended IDE Setup
|
|
6
|
+
|
|
7
|
+
[VS Code](https://code.visualstudio.com/) + [Vue (Official)](https://marketplace.visualstudio.com/items?itemName=Vue.volar) (and disable Vetur).
|
|
8
|
+
|
|
9
|
+
## Recommended Browser Setup
|
|
10
|
+
|
|
11
|
+
- Chromium-based browsers (Chrome, Edge, Brave, etc.):
|
|
12
|
+
- [Vue.js devtools](https://chromewebstore.google.com/detail/vuejs-devtools/nhdogjmejiglipccpnnnanhbledajbpd)
|
|
13
|
+
- [Turn on Custom Object Formatter in Chrome DevTools](http://bit.ly/object-formatters)
|
|
14
|
+
- Firefox:
|
|
15
|
+
- [Vue.js devtools](https://addons.mozilla.org/en-US/firefox/addon/vue-js-devtools/)
|
|
16
|
+
- [Turn on Custom Object Formatter in Firefox DevTools](https://fxdx.dev/firefox-devtools-custom-object-formatters/)
|
|
17
|
+
|
|
18
|
+
## Type Support for `.vue` Imports in TS
|
|
19
|
+
|
|
20
|
+
TypeScript cannot handle type information for `.vue` imports by default, so we replace the `tsc` CLI with `vue-tsc` for type checking. In editors, we need [Volar](https://marketplace.visualstudio.com/items?itemName=Vue.volar) to make the TypeScript language service aware of `.vue` types.
|
|
21
|
+
|
|
22
|
+
## Customize configuration
|
|
23
|
+
|
|
24
|
+
See [Vite Configuration Reference](https://vite.dev/config/).
|
|
25
|
+
|
|
26
|
+
## Project Setup
|
|
27
|
+
|
|
28
|
+
```sh
|
|
29
|
+
npm install
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
### Compile and Hot-Reload for Development
|
|
33
|
+
|
|
34
|
+
```sh
|
|
35
|
+
npm run dev
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
### Type-Check, Compile and Minify for Production
|
|
39
|
+
|
|
40
|
+
```sh
|
|
41
|
+
npm run build
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
### Lint with [ESLint](https://eslint.org/)
|
|
45
|
+
|
|
46
|
+
```sh
|
|
47
|
+
npm run lint
|
|
48
|
+
```
|
package/dist/favicon.ico
ADDED
|
Binary file
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
import { createApp as x, h as w, openBlock as m, createElementBlock as g, normalizeClass as E, createElementVNode as l, toDisplayString as f, renderSlot as h, createTextVNode as S, createCommentVNode as A, ref as k, computed as D } from "vue";
|
|
2
|
+
function N(o, { shadow: n = !0, styles: s = [] } = {}) {
|
|
3
|
+
const e = s.join("");
|
|
4
|
+
class i extends HTMLElement {
|
|
5
|
+
static observedAttributes = o.props ? Object.keys(o.props) : [];
|
|
6
|
+
constructor() {
|
|
7
|
+
super(), n && this.attachShadow({ mode: "open" }), this._app = null, this._props = {}, this._mounted = !1;
|
|
8
|
+
}
|
|
9
|
+
connectedCallback() {
|
|
10
|
+
this.mount();
|
|
11
|
+
}
|
|
12
|
+
disconnectedCallback() {
|
|
13
|
+
this.unmount();
|
|
14
|
+
}
|
|
15
|
+
attributeChangedCallback(t, a, r) {
|
|
16
|
+
a !== r && (this._props[t] = this.parseAttribute(t, r), this._mounted && this.updateProps());
|
|
17
|
+
}
|
|
18
|
+
// 解析属性值
|
|
19
|
+
parseAttribute(t, a) {
|
|
20
|
+
const r = o.props && o.props[t];
|
|
21
|
+
if (a != null) {
|
|
22
|
+
if (r) {
|
|
23
|
+
if (r === Boolean)
|
|
24
|
+
return a !== "false" && a !== null;
|
|
25
|
+
if (r === Number)
|
|
26
|
+
return Number(a);
|
|
27
|
+
if (r === Array || r === Object)
|
|
28
|
+
try {
|
|
29
|
+
return JSON.parse(a);
|
|
30
|
+
} catch {
|
|
31
|
+
return a;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
return a;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
// 序列化属性值
|
|
38
|
+
serializeAttribute(t) {
|
|
39
|
+
return t == null ? null : typeof t == "boolean" ? t ? "" : null : typeof t == "object" ? JSON.stringify(t) : String(t);
|
|
40
|
+
}
|
|
41
|
+
mount() {
|
|
42
|
+
if (this._mounted) return;
|
|
43
|
+
if (this._props = {}, o.props)
|
|
44
|
+
for (const r of Object.keys(o.props)) {
|
|
45
|
+
const d = this.getAttribute(r);
|
|
46
|
+
this._props[r] = this.parseAttribute(r, d);
|
|
47
|
+
}
|
|
48
|
+
const t = n ? this.shadowRoot : this;
|
|
49
|
+
if (e) {
|
|
50
|
+
const r = document.createElement("style");
|
|
51
|
+
r.textContent = e, t.appendChild(r);
|
|
52
|
+
}
|
|
53
|
+
const a = x({
|
|
54
|
+
...o,
|
|
55
|
+
props: Object.keys(this._props),
|
|
56
|
+
setup(r, { attrs: d, slots: c, emit: L }) {
|
|
57
|
+
const v = (u, p) => {
|
|
58
|
+
this.dispatchEvent(
|
|
59
|
+
new CustomEvent(u, {
|
|
60
|
+
detail: p,
|
|
61
|
+
bubbles: !0,
|
|
62
|
+
composed: !0
|
|
63
|
+
})
|
|
64
|
+
);
|
|
65
|
+
}, y = (u, ...p) => {
|
|
66
|
+
const C = u.replace(/([a-z0-9]|(?=[A-Z]))([A-Z])/g, "$1-$2").toLowerCase();
|
|
67
|
+
v(C, p[0]);
|
|
68
|
+
};
|
|
69
|
+
return o.setup ? o.setup(r, { attrs: d, slots: c, emit: y }) : {};
|
|
70
|
+
},
|
|
71
|
+
render() {
|
|
72
|
+
return w(o, this.$props);
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
a.mount(t), this._app = a, this._mounted = !0;
|
|
76
|
+
}
|
|
77
|
+
unmount() {
|
|
78
|
+
this._app && (this._app.unmount(), this._app = null), this._mounted = !1;
|
|
79
|
+
}
|
|
80
|
+
updateProps() {
|
|
81
|
+
this._app && this._app._instance && Object.assign(this._app._instance.props, this._props);
|
|
82
|
+
}
|
|
83
|
+
// 暴露一些方法供外部调用
|
|
84
|
+
get vueInstance() {
|
|
85
|
+
return this._app ? this._app._instance : null;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
return i;
|
|
89
|
+
}
|
|
90
|
+
const O = ".hello-world[data-v-c907aa73]{padding:20px;border-radius:8px;font-family:Arial,sans-serif;transition:all .3s ease}.hello-world.light[data-v-c907aa73]{background-color:#fff;color:#333;border:1px solid #e0e0e0}.hello-world.dark[data-v-c907aa73]{background-color:#333;color:#fff;border:1px solid #555555}.hello-world h1[data-v-c907aa73]{margin:0 0 16px;color:#42b983}.content[data-v-c907aa73]{margin-bottom:16px;padding:12px;background-color:#0000000d;border-radius:4px}.dark .content[data-v-c907aa73]{background-color:#ffffff1a}button[data-v-c907aa73],input[data-v-c907aa73]{margin:8px 4px;padding:8px 16px;border:1px solid #ddd;border-radius:4px;font-size:14px}.dark button[data-v-c907aa73],.dark input[data-v-c907aa73]{background-color:#444;color:#fff;border-color:#666}button[data-v-c907aa73]{background-color:#42b983;color:#fff;border:none;cursor:pointer;transition:background-color .3s}button[data-v-c907aa73]:hover{background-color:#3aa876}.details[data-v-c907aa73]{margin-top:16px;padding:12px;background-color:#42b9831a;border-radius:4px}.actions[data-v-c907aa73]{margin-top:20px;padding-top:16px;border-top:1px solid #eee}.dark .actions[data-v-c907aa73]{border-top-color:#555}", j = (o, n) => {
|
|
91
|
+
const s = o.__vccOpts || o;
|
|
92
|
+
for (const [e, i] of n)
|
|
93
|
+
s[e] = i;
|
|
94
|
+
return s;
|
|
95
|
+
}, I = {
|
|
96
|
+
name: "HelloWorld",
|
|
97
|
+
// Web Components 的属性声明
|
|
98
|
+
props: {
|
|
99
|
+
msg: {
|
|
100
|
+
type: String,
|
|
101
|
+
default: "Hello World"
|
|
102
|
+
},
|
|
103
|
+
value: {
|
|
104
|
+
type: String,
|
|
105
|
+
default: ""
|
|
106
|
+
},
|
|
107
|
+
theme: {
|
|
108
|
+
type: String,
|
|
109
|
+
default: "light",
|
|
110
|
+
validator: (o) => ["light", "dark"].includes(o)
|
|
111
|
+
},
|
|
112
|
+
count: {
|
|
113
|
+
type: Number,
|
|
114
|
+
default: 0
|
|
115
|
+
}
|
|
116
|
+
},
|
|
117
|
+
// 自定义事件
|
|
118
|
+
emits: ["click", "input", "count-changed"],
|
|
119
|
+
setup(o, { emit: n }) {
|
|
120
|
+
const s = k(!1), e = k(o.count), i = D(() => `${o.msg} (${e.value})`);
|
|
121
|
+
return {
|
|
122
|
+
showDetails: s,
|
|
123
|
+
internalCount: e,
|
|
124
|
+
message: i,
|
|
125
|
+
handleClick: () => {
|
|
126
|
+
n("click", { message: "Button clicked!" });
|
|
127
|
+
},
|
|
128
|
+
handleInput: (c) => {
|
|
129
|
+
n("input", c.target.value);
|
|
130
|
+
},
|
|
131
|
+
increment: () => {
|
|
132
|
+
e.value++, n("count-changed", e.value);
|
|
133
|
+
},
|
|
134
|
+
decrement: () => {
|
|
135
|
+
e.value--, n("count-changed", e.value);
|
|
136
|
+
},
|
|
137
|
+
toggleDetails: () => {
|
|
138
|
+
s.value = !s.value;
|
|
139
|
+
}
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
}, H = { class: "content" }, W = ["value"], z = {
|
|
143
|
+
key: 0,
|
|
144
|
+
class: "details"
|
|
145
|
+
}, B = { class: "actions" };
|
|
146
|
+
function T(o, n, s, e, i, b) {
|
|
147
|
+
return m(), g("div", {
|
|
148
|
+
class: E(["hello-world", s.theme])
|
|
149
|
+
}, [
|
|
150
|
+
l("h1", null, f(s.msg), 1),
|
|
151
|
+
l("div", H, [
|
|
152
|
+
h(o.$slots, "default", {}, () => [
|
|
153
|
+
n[5] || (n[5] = S("Default Content", -1))
|
|
154
|
+
], !0),
|
|
155
|
+
h(o.$slots, "footer", {}, void 0, !0)
|
|
156
|
+
]),
|
|
157
|
+
l("button", {
|
|
158
|
+
onClick: n[0] || (n[0] = (...t) => e.handleClick && e.handleClick(...t))
|
|
159
|
+
}, "Click me"),
|
|
160
|
+
l("input", {
|
|
161
|
+
value: s.value,
|
|
162
|
+
onInput: n[1] || (n[1] = (...t) => e.handleInput && e.handleInput(...t)),
|
|
163
|
+
placeholder: "Type something..."
|
|
164
|
+
}, null, 40, W),
|
|
165
|
+
e.showDetails ? (m(), g("div", z, [
|
|
166
|
+
l("p", null, "Count: " + f(s.count), 1),
|
|
167
|
+
l("button", {
|
|
168
|
+
onClick: n[2] || (n[2] = (...t) => e.increment && e.increment(...t))
|
|
169
|
+
}, "+"),
|
|
170
|
+
l("button", {
|
|
171
|
+
onClick: n[3] || (n[3] = (...t) => e.decrement && e.decrement(...t))
|
|
172
|
+
}, "-")
|
|
173
|
+
])) : A("", !0),
|
|
174
|
+
l("div", B, [
|
|
175
|
+
h(o.$slots, "actions", {}, () => [
|
|
176
|
+
l("button", {
|
|
177
|
+
onClick: n[4] || (n[4] = (...t) => e.toggleDetails && e.toggleDetails(...t))
|
|
178
|
+
}, f(e.showDetails ? "Hide" : "Show") + " Details", 1)
|
|
179
|
+
], !0)
|
|
180
|
+
])
|
|
181
|
+
], 2);
|
|
182
|
+
}
|
|
183
|
+
const V = /* @__PURE__ */ j(I, [["render", T], ["styles", [O]], ["__scopeId", "data-v-c907aa73"]]), J = [], _ = N(V, {
|
|
184
|
+
shadow: !0,
|
|
185
|
+
styles: J
|
|
186
|
+
});
|
|
187
|
+
customElements.define("hello-world", _);
|
|
188
|
+
typeof window < "u" && (window.MyVueWebComponents = {
|
|
189
|
+
HelloWorldElement: _
|
|
190
|
+
});
|
|
191
|
+
export {
|
|
192
|
+
_ as HelloWorldElement
|
|
193
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(function(i,t){typeof exports=="object"&&typeof module<"u"?t(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],t):(i=typeof globalThis<"u"?globalThis:i||self,t(i.MyVueWebComponents={},i.Vue))})(this,(function(i,t){"use strict";function b(n,{shadow:r=!0,styles:s=[]}={}){const o=s.join("");class d extends HTMLElement{static observedAttributes=n.props?Object.keys(n.props):[];constructor(){super(),r&&this.attachShadow({mode:"open"}),this._app=null,this._props={},this._mounted=!1}connectedCallback(){this.mount()}disconnectedCallback(){this.unmount()}attributeChangedCallback(e,l,a){l!==a&&(this._props[e]=this.parseAttribute(e,a),this._mounted&&this.updateProps())}parseAttribute(e,l){const a=n.props&&n.props[e];if(l!=null){if(a){if(a===Boolean)return l!=="false"&&l!==null;if(a===Number)return Number(l);if(a===Array||a===Object)try{return JSON.parse(l)}catch{return l}}return l}}serializeAttribute(e){return e==null?null:typeof e=="boolean"?e?"":null:typeof e=="object"?JSON.stringify(e):String(e)}mount(){if(this._mounted)return;if(this._props={},n.props)for(const a of Object.keys(n.props)){const c=this.getAttribute(a);this._props[a]=this.parseAttribute(a,c)}const e=r?this.shadowRoot:this;if(o){const a=document.createElement("style");a.textContent=o,e.appendChild(a)}const l=t.createApp({...n,props:Object.keys(this._props),setup(a,{attrs:c,slots:u,emit:W}){const w=(f,h)=>{this.dispatchEvent(new CustomEvent(f,{detail:h,bubbles:!0,composed:!0}))},N=(f,...h)=>{const V=f.replace(/([a-z0-9]|(?=[A-Z]))([A-Z])/g,"$1-$2").toLowerCase();w(V,h[0])};return n.setup?n.setup(a,{attrs:c,slots:u,emit:N}):{}},render(){return t.h(n,this.$props)}});l.mount(e),this._app=l,this._mounted=!0}unmount(){this._app&&(this._app.unmount(),this._app=null),this._mounted=!1}updateProps(){this._app&&this._app._instance&&Object.assign(this._app._instance.props,this._props)}get vueInstance(){return this._app?this._app._instance:null}}return d}const g=".hello-world[data-v-c907aa73]{padding:20px;border-radius:8px;font-family:Arial,sans-serif;transition:all .3s ease}.hello-world.light[data-v-c907aa73]{background-color:#fff;color:#333;border:1px solid #e0e0e0}.hello-world.dark[data-v-c907aa73]{background-color:#333;color:#fff;border:1px solid #555555}.hello-world h1[data-v-c907aa73]{margin:0 0 16px;color:#42b983}.content[data-v-c907aa73]{margin-bottom:16px;padding:12px;background-color:#0000000d;border-radius:4px}.dark .content[data-v-c907aa73]{background-color:#ffffff1a}button[data-v-c907aa73],input[data-v-c907aa73]{margin:8px 4px;padding:8px 16px;border:1px solid #ddd;border-radius:4px;font-size:14px}.dark button[data-v-c907aa73],.dark input[data-v-c907aa73]{background-color:#444;color:#fff;border-color:#666}button[data-v-c907aa73]{background-color:#42b983;color:#fff;border:none;cursor:pointer;transition:background-color .3s}button[data-v-c907aa73]:hover{background-color:#3aa876}.details[data-v-c907aa73]{margin-top:16px;padding:12px;background-color:#42b9831a;border-radius:4px}.actions[data-v-c907aa73]{margin-top:20px;padding-top:16px;border-top:1px solid #eee}.dark .actions[data-v-c907aa73]{border-top-color:#555}",k=(n,r)=>{const s=n.__vccOpts||n;for(const[o,d]of r)s[o]=d;return s},y={name:"HelloWorld",props:{msg:{type:String,default:"Hello World"},value:{type:String,default:""},theme:{type:String,default:"light",validator:n=>["light","dark"].includes(n)},count:{type:Number,default:0}},emits:["click","input","count-changed"],setup(n,{emit:r}){const s=t.ref(!1),o=t.ref(n.count),d=t.computed(()=>`${n.msg} (${o.value})`);return{showDetails:s,internalCount:o,message:d,handleClick:()=>{r("click",{message:"Button clicked!"})},handleInput:u=>{r("input",u.target.value)},increment:()=>{o.value++,r("count-changed",o.value)},decrement:()=>{o.value--,r("count-changed",o.value)},toggleDetails:()=>{s.value=!s.value}}}},_={class:"content"},C=["value"],x={key:0,class:"details"},E={class:"actions"};function S(n,r,s,o,d,m){return t.openBlock(),t.createElementBlock("div",{class:t.normalizeClass(["hello-world",s.theme])},[t.createElementVNode("h1",null,t.toDisplayString(s.msg),1),t.createElementVNode("div",_,[t.renderSlot(n.$slots,"default",{},()=>[r[5]||(r[5]=t.createTextVNode("Default Content",-1))],!0),t.renderSlot(n.$slots,"footer",{},void 0,!0)]),t.createElementVNode("button",{onClick:r[0]||(r[0]=(...e)=>o.handleClick&&o.handleClick(...e))},"Click me"),t.createElementVNode("input",{value:s.value,onInput:r[1]||(r[1]=(...e)=>o.handleInput&&o.handleInput(...e)),placeholder:"Type something..."},null,40,C),o.showDetails?(t.openBlock(),t.createElementBlock("div",x,[t.createElementVNode("p",null,"Count: "+t.toDisplayString(s.count),1),t.createElementVNode("button",{onClick:r[2]||(r[2]=(...e)=>o.increment&&o.increment(...e))},"+"),t.createElementVNode("button",{onClick:r[3]||(r[3]=(...e)=>o.decrement&&o.decrement(...e))},"-")])):t.createCommentVNode("",!0),t.createElementVNode("div",E,[t.renderSlot(n.$slots,"actions",{},()=>[t.createElementVNode("button",{onClick:r[4]||(r[4]=(...e)=>o.toggleDetails&&o.toggleDetails(...e))},t.toDisplayString(o.showDetails?"Hide":"Show")+" Details",1)],!0)])],2)}const p=b(k(y,[["render",S],["styles",[g]],["__scopeId","data-v-c907aa73"]]),{shadow:!0,styles:[]});customElements.define("hello-world",p),typeof window<"u"&&(window.MyVueWebComponents={HelloWorldElement:p}),i.HelloWorldElement=p,Object.defineProperty(i,Symbol.toStringTag,{value:"Module"})}));
|
package/package.json
CHANGED
|
@@ -1,56 +1,61 @@
|
|
|
1
|
-
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
"
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
"
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
"
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
"
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
"
|
|
47
|
-
"
|
|
48
|
-
"
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
"
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
"
|
|
56
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "suncy-my-npm-test",
|
|
3
|
+
"version": "1.0.47",
|
|
4
|
+
"private": false,
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/suncy-my-npm-test.umd.js",
|
|
7
|
+
"module": "./dist/suncy-my-npm-test.es.js",
|
|
8
|
+
"unpkg": "./dist/my-vue-webcomponents.umd.js",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"import": "./dist/suncy-my-npm-test.es.js",
|
|
12
|
+
"require": "./dist/suncy-my-npm-test.umd.js"
|
|
13
|
+
},
|
|
14
|
+
"./dist/*": "./dist/*"
|
|
15
|
+
},
|
|
16
|
+
"files": [
|
|
17
|
+
"dist"
|
|
18
|
+
],
|
|
19
|
+
"types": "dist/index.d.ts",
|
|
20
|
+
"peerDependencies": {
|
|
21
|
+
"vue": "^3.0.0"
|
|
22
|
+
},
|
|
23
|
+
"scripts": {
|
|
24
|
+
"dev": "vite",
|
|
25
|
+
"build:wc": "vite build --mode wc",
|
|
26
|
+
"build": "run-p type-check \"build-only {@}\" --",
|
|
27
|
+
"build:lib": "vite build --mode lib",
|
|
28
|
+
"preview": "vite preview",
|
|
29
|
+
"build-only": "vite build",
|
|
30
|
+
"type-check": "vue-tsc --build",
|
|
31
|
+
"lint": "eslint . --fix --cache",
|
|
32
|
+
"format": "prettier --write --experimental-cli src/"
|
|
33
|
+
},
|
|
34
|
+
"dependencies": {
|
|
35
|
+
"pinia": "^3.0.4",
|
|
36
|
+
"vue": "^3.0.0",
|
|
37
|
+
"vue-router": "^4.6.4"
|
|
38
|
+
},
|
|
39
|
+
"devDependencies": {
|
|
40
|
+
"@tsconfig/node24": "^24.0.4",
|
|
41
|
+
"@types/node": "^24.10.9",
|
|
42
|
+
"@vitejs/plugin-vue": "^6.0.3",
|
|
43
|
+
"@vitejs/plugin-vue-jsx": "^5.1.3",
|
|
44
|
+
"@vue/eslint-config-typescript": "^14.6.0",
|
|
45
|
+
"@vue/tsconfig": "^0.8.1",
|
|
46
|
+
"eslint": "^9.39.2",
|
|
47
|
+
"eslint-config-prettier": "^10.1.8",
|
|
48
|
+
"eslint-plugin-vue": "~10.7.0",
|
|
49
|
+
"jiti": "^2.6.1",
|
|
50
|
+
"npm-run-all2": "^8.0.4",
|
|
51
|
+
"prettier": "3.8.1",
|
|
52
|
+
"typescript": "~5.9.3",
|
|
53
|
+
"vite": "^7.3.1",
|
|
54
|
+
"vite-plugin-copy": "^0.1.6",
|
|
55
|
+
"vite-plugin-vue-devtools": "^8.0.5",
|
|
56
|
+
"vue-tsc": "^3.2.2"
|
|
57
|
+
},
|
|
58
|
+
"engines": {
|
|
59
|
+
"node": "^20.19.0 || >=22.12.0"
|
|
60
|
+
}
|
|
61
|
+
}
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<button
|
|
3
|
-
class="my-button"
|
|
4
|
-
:class="[typeClass, sizeClass]"
|
|
5
|
-
@click="$emit('click')"
|
|
6
|
-
>
|
|
7
|
-
<slot></slot>
|
|
8
|
-
</button>
|
|
9
|
-
</template>
|
|
10
|
-
|
|
11
|
-
<script>
|
|
12
|
-
export default {
|
|
13
|
-
name: 'MyButton',
|
|
14
|
-
props: {
|
|
15
|
-
type: {
|
|
16
|
-
type: String,
|
|
17
|
-
default: 'default',
|
|
18
|
-
validator: (value) => ['default', 'primary', 'success', 'warning', 'danger'].includes(value)
|
|
19
|
-
},
|
|
20
|
-
size: {
|
|
21
|
-
type: String,
|
|
22
|
-
default: 'medium',
|
|
23
|
-
validator: (value) => ['small', 'medium', 'large'].includes(value)
|
|
24
|
-
}
|
|
25
|
-
},
|
|
26
|
-
computed: {
|
|
27
|
-
typeClass() {
|
|
28
|
-
return `my-button--${this.type}`
|
|
29
|
-
},
|
|
30
|
-
sizeClass() {
|
|
31
|
-
return `my-button--${this.size}`
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
</script>
|
|
36
|
-
|
|
37
|
-
<style scoped>
|
|
38
|
-
.my-button {
|
|
39
|
-
padding: 10px 20px;
|
|
40
|
-
border: none;
|
|
41
|
-
border-radius: 4px;
|
|
42
|
-
cursor: pointer;
|
|
43
|
-
font-size: 14px;
|
|
44
|
-
transition: all 0.3s;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
.my-button--default {
|
|
48
|
-
background: #f0f0f0;
|
|
49
|
-
color: #333;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
.my-button--primary {
|
|
53
|
-
background: #409eff;
|
|
54
|
-
color: white;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
.my-button--success {
|
|
58
|
-
background: #67c23a;
|
|
59
|
-
color: white;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
.my-button--small {
|
|
63
|
-
padding: 8px 16px;
|
|
64
|
-
font-size: 12px;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
.my-button--medium {
|
|
68
|
-
padding: 10px 20px;
|
|
69
|
-
font-size: 14px;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
.my-button--large {
|
|
73
|
-
padding: 12px 24px;
|
|
74
|
-
font-size: 16px;
|
|
75
|
-
}
|
|
76
|
-
</style>
|
package/packages/index.js
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import MyButton from './components/MyButton.vue'
|
|
2
|
-
|
|
3
|
-
const components = {
|
|
4
|
-
MyButton,
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
const install = function(Vue) {
|
|
8
|
-
if (install.installed) return
|
|
9
|
-
|
|
10
|
-
Object.keys(components).forEach(key => {
|
|
11
|
-
Vue.component(components[key].name, components[key])
|
|
12
|
-
})
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
// 自动安装
|
|
16
|
-
if (typeof window !== 'undefined' && window.Vue) {
|
|
17
|
-
install(window.Vue)
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export default {
|
|
21
|
-
install,
|
|
22
|
-
...components
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export {
|
|
26
|
-
MyButton,
|
|
27
|
-
}
|