cmswork 1.0.9 → 1.1.2
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/Lit/.vscode/settings.json +7 -0
- package/Lit/dist/assets/index-BwL3dWu4.css +1 -0
- package/Lit/dist/assets/index-C0k3p14F.js +129 -0
- package/Lit/dist/index.html +33 -0
- package/Lit/dist/vite.svg +1 -0
- package/Lit/index.html +44 -0
- package/Lit/package.json +28 -0
- package/Lit/public/vite.svg +1 -0
- package/Lit/src/a.html +43 -0
- package/Lit/src/app-element.ts +50 -0
- package/Lit/src/assets/common.ts +26 -0
- package/Lit/src/assets/lit.svg +1 -0
- package/Lit/src/child-element.ts +53 -0
- package/Lit/src/fetch-element.ts +76 -0
- package/Lit/src/index.css +39 -0
- package/Lit/src/markdown-element.ts +25 -0
- package/Lit/src/my-element.ts +144 -0
- package/Lit/src/nav-element.ts +32 -0
- package/Lit/src/store/redux.ts +34 -0
- package/Lit/src/styles/myelement.css +74 -0
- package/Lit/src/styles/myelement.less +88 -0
- package/Lit/src/vite-env.d.ts +1 -0
- package/Lit/tsconfig.json +25 -0
- package/Lit/vite.config.ts +31 -0
- package/Lit/yarn-error.log +579 -0
- package/Lit/yarn.lock +569 -0
- package/package.json +1 -1
- package/eamodio.gitlens-2024.12.704.vsix +0 -0
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import { LitElement, css, html } from "lit";
|
|
2
|
+
import { customElement, property } from "lit/decorators.js";
|
|
3
|
+
import litLogo from "./assets/lit.svg";
|
|
4
|
+
import viteLogo from "/vite.svg";
|
|
5
|
+
import "./child-element";
|
|
6
|
+
import { store,incremented } from './store/redux'
|
|
7
|
+
|
|
8
|
+
// 定义 DataObject 接口
|
|
9
|
+
interface DataObject {
|
|
10
|
+
name: string;
|
|
11
|
+
age:Number
|
|
12
|
+
}
|
|
13
|
+
@customElement("my-element")
|
|
14
|
+
export class MyElement extends LitElement {
|
|
15
|
+
static styles = [css``]
|
|
16
|
+
|
|
17
|
+
@property()
|
|
18
|
+
docsHint = "Click on the Vite and Lit logos to learn more";
|
|
19
|
+
@property({ type: Number })
|
|
20
|
+
count = 0;
|
|
21
|
+
|
|
22
|
+
@property({ type: Object})
|
|
23
|
+
dataObj:DataObject = {
|
|
24
|
+
name: "搜索",
|
|
25
|
+
age:90
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
@property({ type: Function })
|
|
29
|
+
externalFunction = (val: number) => {
|
|
30
|
+
console.log("默认方法", val);
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
arr: any[] = [
|
|
34
|
+
{
|
|
35
|
+
name: "一",
|
|
36
|
+
id: 1,
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
name: "二",
|
|
40
|
+
id: 2,
|
|
41
|
+
},
|
|
42
|
+
];
|
|
43
|
+
|
|
44
|
+
renderListFn() {
|
|
45
|
+
if (this.count > 10) {
|
|
46
|
+
return html`<span style="color: ${this.count > 15 ? "red" : "green"}"
|
|
47
|
+
>当前count大于10</span
|
|
48
|
+
>`;
|
|
49
|
+
} else {
|
|
50
|
+
return html`<span>当前count小于10</span>`;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
person:DataObject = {
|
|
54
|
+
name:'Forrest',
|
|
55
|
+
age:29
|
|
56
|
+
}
|
|
57
|
+
connectedCallback() {
|
|
58
|
+
super.connectedCallback();
|
|
59
|
+
|
|
60
|
+
const link = document.createElement('link');
|
|
61
|
+
link.rel = 'stylesheet';
|
|
62
|
+
link.href = '/src/styles/myelement.css';
|
|
63
|
+
if(this.shadowRoot)
|
|
64
|
+
this.shadowRoot.appendChild(link);
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
console.log('dataObj',this.dataObj)
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// 当属性变化时被调用的回调
|
|
71
|
+
updated(changedProperties: Map<string | number | symbol, unknown>) {
|
|
72
|
+
super.updated(changedProperties);
|
|
73
|
+
if (changedProperties.has('arr')) {
|
|
74
|
+
console.log('arr changed:', this.arr);
|
|
75
|
+
}
|
|
76
|
+
if (changedProperties.has('dataObj')) {
|
|
77
|
+
console.log('dataObj changed:', this.dataObj);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
callExternalFunction() {
|
|
83
|
+
if (this.externalFunction) {
|
|
84
|
+
this.externalFunction(this.count); // 调用外部函数
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
showMaterialUI:boolean = false
|
|
90
|
+
showMarkdown:boolean = false
|
|
91
|
+
addStore(){
|
|
92
|
+
store.dispatch(incremented(5))
|
|
93
|
+
}
|
|
94
|
+
render() {
|
|
95
|
+
return html`
|
|
96
|
+
<div>
|
|
97
|
+
<md-filled-button @click=${this.addStore}>ADDStore</md-filled-button>
|
|
98
|
+
|
|
99
|
+
<a href="https://vitejs.dev" target="_blank">
|
|
100
|
+
<img src=${viteLogo} class="logo" alt="Vite logo" />
|
|
101
|
+
</a>
|
|
102
|
+
<a href="https://lit.dev" target="_blank">
|
|
103
|
+
<img
|
|
104
|
+
src=${litLogo}
|
|
105
|
+
class="logo lit ${this.count > 20 && "big"}"
|
|
106
|
+
alt="Lit logo"
|
|
107
|
+
/>
|
|
108
|
+
</a>
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
<child-element
|
|
112
|
+
textVal="${this.count > 20
|
|
113
|
+
? "父组件的count大于20"
|
|
114
|
+
: "父组件引用子组件"}"
|
|
115
|
+
></child-element>
|
|
116
|
+
${this.arr.map((item) => html` <div>${item.name}</div> `)}
|
|
117
|
+
${this.renderListFn()}
|
|
118
|
+
</div>
|
|
119
|
+
<slot></slot>
|
|
120
|
+
<div class="card">
|
|
121
|
+
<button @click=${this._onClick} part="button">
|
|
122
|
+
count is ${this.count}
|
|
123
|
+
</button>
|
|
124
|
+
</div>
|
|
125
|
+
<p class="read-the-docs">${this.docsHint}</p>
|
|
126
|
+
<p class="read-the-docs">${this.dataObj.name}${this.dataObj.age}</p>
|
|
127
|
+
<p class="read-the-docs">${this.person.name}${this.person.age}</p>
|
|
128
|
+
<button @click="${this.callExternalFunction}">
|
|
129
|
+
Call External Function
|
|
130
|
+
</button>
|
|
131
|
+
</div>
|
|
132
|
+
`;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
private _onClick() {
|
|
136
|
+
this.count++;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
declare global {
|
|
141
|
+
interface HTMLElementTagNameMap {
|
|
142
|
+
"my-element": MyElement;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { LitElement, html, css } from 'lit';
|
|
2
|
+
import { customElement } from 'lit/decorators.js';
|
|
3
|
+
|
|
4
|
+
@customElement('nav-element')
|
|
5
|
+
export class NavElement extends LitElement {
|
|
6
|
+
static styles = [
|
|
7
|
+
css`
|
|
8
|
+
:host {
|
|
9
|
+
font-size: 1rem;
|
|
10
|
+
}
|
|
11
|
+
nav{
|
|
12
|
+
height:2rem;
|
|
13
|
+
}
|
|
14
|
+
`
|
|
15
|
+
];
|
|
16
|
+
render() {
|
|
17
|
+
return html`
|
|
18
|
+
<nav>
|
|
19
|
+
<a href="/">Home</a>
|
|
20
|
+
<a href="/child">child</a>
|
|
21
|
+
<a href="/markdown">markdown</a>
|
|
22
|
+
<a href="/fetch/23">fetch</a>
|
|
23
|
+
</nav>
|
|
24
|
+
`;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
declare global {
|
|
29
|
+
interface HTMLElementTagNameMap {
|
|
30
|
+
'nav-element': NavElement;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { createSlice, configureStore } from '@reduxjs/toolkit'
|
|
2
|
+
|
|
3
|
+
const counterSlice = createSlice({
|
|
4
|
+
name: 'counter',
|
|
5
|
+
initialState: {
|
|
6
|
+
value: 0
|
|
7
|
+
},
|
|
8
|
+
reducers: {
|
|
9
|
+
incremented: (state, action) => {
|
|
10
|
+
state.value += action.payload; // 使用 action.payload 来获取传入的参数
|
|
11
|
+
},
|
|
12
|
+
decremented: state => {
|
|
13
|
+
state.value -= 1
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
})
|
|
17
|
+
|
|
18
|
+
export const { incremented, decremented } = counterSlice.actions
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
export const store = configureStore({
|
|
22
|
+
reducer: counterSlice.reducer
|
|
23
|
+
})
|
|
24
|
+
|
|
25
|
+
// 可以订阅 store
|
|
26
|
+
// store.subscribe(() => console.log(store.getState()))
|
|
27
|
+
|
|
28
|
+
// 将我们所创建的 action 对象传递给 `dispatch`
|
|
29
|
+
// store.dispatch(incremented())
|
|
30
|
+
// {value: 1}
|
|
31
|
+
// store.dispatch(incremented())
|
|
32
|
+
// {value: 2}
|
|
33
|
+
// store.dispatch(decremented())
|
|
34
|
+
// {value: 1}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
:host {
|
|
2
|
+
max-width: 1280px;
|
|
3
|
+
margin: 0 auto;
|
|
4
|
+
padding: 2rem;
|
|
5
|
+
text-align: center;
|
|
6
|
+
}
|
|
7
|
+
.logo {
|
|
8
|
+
height: 6em;
|
|
9
|
+
padding: 1.5em;
|
|
10
|
+
will-change: filter;
|
|
11
|
+
transition: filter 300ms;
|
|
12
|
+
}
|
|
13
|
+
.logo .tips {
|
|
14
|
+
color: #888;
|
|
15
|
+
}
|
|
16
|
+
.big {
|
|
17
|
+
height: 12em;
|
|
18
|
+
}
|
|
19
|
+
.logo:hover {
|
|
20
|
+
filter: drop-shadow(0 0 2em #646cffaa);
|
|
21
|
+
}
|
|
22
|
+
.logo.lit:hover {
|
|
23
|
+
filter: drop-shadow(0 0 2em #325cffaa);
|
|
24
|
+
}
|
|
25
|
+
.card {
|
|
26
|
+
padding: 2em;
|
|
27
|
+
}
|
|
28
|
+
.read-the-docs {
|
|
29
|
+
color: #888;
|
|
30
|
+
}
|
|
31
|
+
::slotted(h1) {
|
|
32
|
+
font-size: 2.2em;
|
|
33
|
+
line-height: 1.1;
|
|
34
|
+
}
|
|
35
|
+
a {
|
|
36
|
+
font-weight: 500;
|
|
37
|
+
color: #646cff;
|
|
38
|
+
text-decoration: inherit;
|
|
39
|
+
}
|
|
40
|
+
a:hover {
|
|
41
|
+
color: #535bf2;
|
|
42
|
+
}
|
|
43
|
+
button {
|
|
44
|
+
border-radius: 8px;
|
|
45
|
+
border: 1px solid transparent;
|
|
46
|
+
padding: 0.6em 1.2em;
|
|
47
|
+
font-size: 1em;
|
|
48
|
+
font-weight: 500;
|
|
49
|
+
font-family: inherit;
|
|
50
|
+
background-color: #1a1a1a;
|
|
51
|
+
cursor: pointer;
|
|
52
|
+
transition: border-color 0.25s;
|
|
53
|
+
}
|
|
54
|
+
button:hover {
|
|
55
|
+
border-color: #646cff;
|
|
56
|
+
}
|
|
57
|
+
button:focus,
|
|
58
|
+
button:focus-visible {
|
|
59
|
+
outline: 4px auto -webkit-focus-ring-color;
|
|
60
|
+
}
|
|
61
|
+
@media (prefers-color-scheme: light) {
|
|
62
|
+
a:hover {
|
|
63
|
+
color: #747bff;
|
|
64
|
+
}
|
|
65
|
+
button {
|
|
66
|
+
background-color: #f9f9f9;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
.ckl {
|
|
70
|
+
font-size: 12px;
|
|
71
|
+
}
|
|
72
|
+
.ckl .lk {
|
|
73
|
+
color: #fff;
|
|
74
|
+
}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
:host {
|
|
2
|
+
max-width: 1280px;
|
|
3
|
+
margin: 0 auto;
|
|
4
|
+
padding: 2rem;
|
|
5
|
+
text-align: center;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
.logo {
|
|
10
|
+
height: 6em;
|
|
11
|
+
padding: 1.5em;
|
|
12
|
+
will-change: filter;
|
|
13
|
+
transition: filter 300ms;
|
|
14
|
+
.tips {
|
|
15
|
+
color: #888;
|
|
16
|
+
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
.big {
|
|
20
|
+
height: 12em;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
.logo:hover {
|
|
24
|
+
filter: drop-shadow(0 0 2em #646cffaa);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.logo.lit:hover {
|
|
28
|
+
filter: drop-shadow(0 0 2em #325cffaa);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
.card {
|
|
33
|
+
padding: 2em;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
.read-the-docs {
|
|
37
|
+
color: #888;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
::slotted(h1) {
|
|
41
|
+
font-size: 2.2em;
|
|
42
|
+
line-height: 1.1;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
a {
|
|
46
|
+
font-weight: 500;
|
|
47
|
+
color: #646cff;
|
|
48
|
+
text-decoration: inherit;
|
|
49
|
+
}
|
|
50
|
+
a:hover {
|
|
51
|
+
color: #535bf2;
|
|
52
|
+
}
|
|
53
|
+
// .ll
|
|
54
|
+
button {
|
|
55
|
+
border-radius: 8px;
|
|
56
|
+
border: 1px solid transparent;
|
|
57
|
+
padding: 0.6em 1.2em;
|
|
58
|
+
font-size: 1em;
|
|
59
|
+
font-weight: 500;
|
|
60
|
+
font-family: inherit;
|
|
61
|
+
background-color: #1a1a1a;
|
|
62
|
+
cursor: pointer;
|
|
63
|
+
transition: border-color 0.25s;
|
|
64
|
+
}
|
|
65
|
+
button:hover {
|
|
66
|
+
border-color: #646cff;
|
|
67
|
+
}
|
|
68
|
+
button:focus,
|
|
69
|
+
button:focus-visible {
|
|
70
|
+
outline: 4px auto -webkit-focus-ring-color;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
@media (prefers-color-scheme: light) {
|
|
74
|
+
a:hover {
|
|
75
|
+
color: #747bff;
|
|
76
|
+
}
|
|
77
|
+
button {
|
|
78
|
+
background-color: #f9f9f9;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
.ckl {
|
|
83
|
+
font-size: 12px;
|
|
84
|
+
.lk{
|
|
85
|
+
color: #fff;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
/// <reference types="vite/client" />
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2020",
|
|
4
|
+
"experimentalDecorators": true,
|
|
5
|
+
"useDefineForClassFields": false,
|
|
6
|
+
"module": "ESNext",
|
|
7
|
+
"lib": ["ES2020", "DOM", "DOM.Iterable"],
|
|
8
|
+
"skipLibCheck": true,
|
|
9
|
+
|
|
10
|
+
/* Bundler mode */
|
|
11
|
+
"moduleResolution": "bundler",
|
|
12
|
+
"allowImportingTsExtensions": true,
|
|
13
|
+
"resolveJsonModule": true,
|
|
14
|
+
"isolatedModules": true,
|
|
15
|
+
"noEmit": true,
|
|
16
|
+
|
|
17
|
+
/* Linting */
|
|
18
|
+
"strict": true,
|
|
19
|
+
"noUnusedLocals": true,
|
|
20
|
+
"noUnusedParameters": true,
|
|
21
|
+
"noFallthroughCasesInSwitch": true
|
|
22
|
+
},
|
|
23
|
+
"include": ["src"]
|
|
24
|
+
}
|
|
25
|
+
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { defineConfig } from 'vite'
|
|
2
|
+
import { resolve } from 'path'
|
|
3
|
+
// https://vitejs.dev/config/
|
|
4
|
+
export default defineConfig({
|
|
5
|
+
plugins: [
|
|
6
|
+
],
|
|
7
|
+
base: './',
|
|
8
|
+
esbuild: {
|
|
9
|
+
jsxFactory: 'h',
|
|
10
|
+
jsxFragment: 'h.f',
|
|
11
|
+
jsxInject: `import { h } from 'omi'`
|
|
12
|
+
},
|
|
13
|
+
css: {
|
|
14
|
+
preprocessorOptions: {
|
|
15
|
+
less: {
|
|
16
|
+
javascriptEnabled: true,
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
server: {
|
|
21
|
+
watch: {
|
|
22
|
+
usePolling: true, // 使用轮询来监视文件变化
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
resolve: {
|
|
26
|
+
alias: {
|
|
27
|
+
// "omi": resolve("./src/omi/index.ts"),
|
|
28
|
+
"@": resolve("./src/"),
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
})
|