create-mettle-app 1.0.2 → 1.2.0
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/index.js +3 -13
- package/package.json +1 -1
- package/template-mettle/index.html +12 -10
- package/template-mettle/package.json +4 -6
- package/{template-mettle-jsx → template-mettle}/src/components/list.jsx +2 -5
- package/template-mettle/src/main.jsx +18 -0
- package/template-mettle/src/style/app.css +2 -2
- package/template-mettle/src/style/list.module.css +1 -1
- package/{template-mettle-jsx → template-mettle}/src/template/home.jsx +2 -7
- package/template-mettle/vite.config.js +2 -10
- package/template-mettle-apps/index.html +12 -10
- package/template-mettle-apps/package.json +5 -7
- package/template-mettle-apps/src/main.jsx +8 -0
- package/template-mettle-apps/src/router/index.js +21 -21
- package/template-mettle-apps/src/template/about.jsx +20 -0
- package/template-mettle-apps/src/template/home.jsx +40 -0
- package/template-mettle-apps/vite.config.js +2 -10
- package/template-mettle-apps-ts/README.md +1 -0
- package/{template-mettle-tsx-apps → template-mettle-apps-ts}/package.json +4 -4
- package/template-mettle-apps-ts/src/main.tsx +8 -0
- package/{template-mettle-tsx-apps → template-mettle-apps-ts}/src/router/index.ts +4 -4
- package/template-mettle-apps-ts/src/template/about.tsx +20 -0
- package/template-mettle-apps-ts/src/template/home.tsx +40 -0
- package/template-mettle-ts/README.md +1 -0
- package/{template-mettle-tsx → template-mettle-ts}/package.json +3 -3
- package/{template-mettle-tsx → template-mettle-ts}/src/components/list.tsx +2 -6
- package/template-mettle-ts/src/main.tsx +18 -0
- package/{template-mettle-tsx → template-mettle-ts}/src/style/app.css +2 -2
- package/{template-mettle-tsx → template-mettle-ts}/src/style/list.module.css +1 -1
- package/{template-mettle-tsx → template-mettle-ts}/src/template/home.tsx +2 -8
- package/template-mettle/babel.config.cjs +0 -3
- package/template-mettle/src/components/list.js +0 -43
- package/template-mettle/src/main.js +0 -20
- package/template-mettle/src/template/home.js +0 -22
- package/template-mettle-apps/babel.config.cjs +0 -3
- package/template-mettle-apps/src/main.js +0 -12
- package/template-mettle-apps/src/template/about.js +0 -23
- package/template-mettle-apps/src/template/home.js +0 -42
- package/template-mettle-jsx/README.md +0 -1
- package/template-mettle-jsx/babel.config.cjs +0 -3
- package/template-mettle-jsx/index.html +0 -13
- package/template-mettle-jsx/package.json +0 -20
- package/template-mettle-jsx/src/main.js +0 -21
- package/template-mettle-jsx/src/style/app.css +0 -14
- package/template-mettle-jsx/src/style/list.module.css +0 -27
- package/template-mettle-jsx/vite.config.js +0 -14
- package/template-mettle-jsx-apps/README.md +0 -1
- package/template-mettle-jsx-apps/babel.config.cjs +0 -3
- package/template-mettle-jsx-apps/index.html +0 -13
- package/template-mettle-jsx-apps/package.json +0 -21
- package/template-mettle-jsx-apps/src/main.js +0 -12
- package/template-mettle-jsx-apps/src/router/index.js +0 -21
- package/template-mettle-jsx-apps/src/template/about.jsx +0 -24
- package/template-mettle-jsx-apps/src/template/home.jsx +0 -44
- package/template-mettle-jsx-apps/vite.config.js +0 -14
- package/template-mettle-tsx/README.md +0 -1
- package/template-mettle-tsx/_gitignore +0 -25
- package/template-mettle-tsx/src/main.tsx +0 -21
- package/template-mettle-tsx-apps/README.md +0 -1
- package/template-mettle-tsx-apps/_gitignore +0 -25
- package/template-mettle-tsx-apps/src/main.tsx +0 -12
- package/template-mettle-tsx-apps/src/styles/app.css +0 -7
- package/template-mettle-tsx-apps/src/template/about.tsx +0 -24
- package/template-mettle-tsx-apps/src/template/home.tsx +0 -45
- /package/{template-mettle-jsx-apps → template-mettle-apps-ts}/_gitignore +0 -0
- /package/{template-mettle-tsx-apps → template-mettle-apps-ts}/index.html +0 -0
- /package/{template-mettle-jsx-apps → template-mettle-apps-ts}/src/styles/app.css +0 -0
- /package/{template-mettle-tsx-apps → template-mettle-apps-ts}/src/vite-env.d.ts +0 -0
- /package/{template-mettle-tsx-apps → template-mettle-apps-ts}/tsconfig.json +0 -0
- /package/{template-mettle-tsx-apps → template-mettle-apps-ts}/vite.config.ts +0 -0
- /package/{template-mettle-jsx → template-mettle-ts}/_gitignore +0 -0
- /package/{template-mettle-tsx → template-mettle-ts}/index.html +0 -0
- /package/{template-mettle-tsx → template-mettle-ts}/src/vite-env.d.ts +0 -0
- /package/{template-mettle-tsx → template-mettle-ts}/tsconfig.json +0 -0
- /package/{template-mettle-tsx → template-mettle-ts}/vite.config.ts +0 -0
package/index.js
CHANGED
|
@@ -16,30 +16,20 @@ const FRAMEWORKS = [
|
|
|
16
16
|
{
|
|
17
17
|
name: 'mettle',
|
|
18
18
|
display: 'JavaScript',
|
|
19
|
-
color: lightYellow,
|
|
20
|
-
},
|
|
21
|
-
{
|
|
22
|
-
name: 'mettle-apps',
|
|
23
|
-
display: 'JavaScript',
|
|
24
|
-
color: lightYellow,
|
|
25
|
-
},
|
|
26
|
-
{
|
|
27
|
-
name: 'mettle-jsx',
|
|
28
|
-
display: 'JavaScript',
|
|
29
19
|
color: cyan,
|
|
30
20
|
},
|
|
31
21
|
{
|
|
32
|
-
name: 'mettle-
|
|
22
|
+
name: 'mettle-apps',
|
|
33
23
|
display: 'JavaScript',
|
|
34
24
|
color: cyan,
|
|
35
25
|
},
|
|
36
26
|
{
|
|
37
|
-
name: 'mettle-
|
|
27
|
+
name: 'mettle-ts',
|
|
38
28
|
display: 'TypeScript',
|
|
39
29
|
color: blue,
|
|
40
30
|
},
|
|
41
31
|
{
|
|
42
|
-
name: 'mettle-
|
|
32
|
+
name: 'mettle-apps-ts',
|
|
43
33
|
display: 'TypeScript',
|
|
44
34
|
color: blue,
|
|
45
35
|
},
|
package/package.json
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
<!DOCTYPE html>
|
|
2
2
|
<html lang="en">
|
|
3
|
-
<head>
|
|
4
|
-
<meta charset="UTF-8" />
|
|
5
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
|
-
<title>create-mettle-app</title>
|
|
7
|
-
</head>
|
|
8
3
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
</
|
|
13
|
-
</
|
|
4
|
+
<head>
|
|
5
|
+
<meta charset="UTF-8" />
|
|
6
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
7
|
+
<title>create-mettle-app</title>
|
|
8
|
+
</head>
|
|
9
|
+
|
|
10
|
+
<body>
|
|
11
|
+
<div id="app"></div>
|
|
12
|
+
<script type="module" src="/src/main.jsx"></script>
|
|
13
|
+
</body>
|
|
14
|
+
|
|
15
|
+
</html>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"name": "template
|
|
2
|
+
"name": "template",
|
|
3
3
|
"version": "0.0.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"scripts": {
|
|
@@ -8,12 +8,10 @@
|
|
|
8
8
|
"build": "vite build"
|
|
9
9
|
},
|
|
10
10
|
"devDependencies": {
|
|
11
|
-
"
|
|
12
|
-
"
|
|
13
|
-
"vite": "^4.0.0",
|
|
14
|
-
"vite-plugin-babel": "^1.1.3"
|
|
11
|
+
"vite": "^6.1.0",
|
|
12
|
+
"vite-plugin-mettle": "^1.0.0"
|
|
15
13
|
},
|
|
16
14
|
"dependencies": {
|
|
17
|
-
"mettle": "^0.
|
|
15
|
+
"mettle": "^1.0.1"
|
|
18
16
|
}
|
|
19
17
|
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { defineComponent } from 'mettle';
|
|
2
1
|
import style from '../style/list.module.css';
|
|
3
2
|
|
|
4
|
-
|
|
3
|
+
export default function List({ setData }) {
|
|
5
4
|
const listState = {
|
|
6
5
|
arr: [1, 2],
|
|
7
6
|
};
|
|
@@ -39,6 +38,4 @@ const List = defineComponent(({ setData }) => {
|
|
|
39
38
|
</ul>
|
|
40
39
|
</fragment>
|
|
41
40
|
);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
export default List;
|
|
41
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { createApp } from 'mettle';
|
|
2
|
+
import Home from './template/home';
|
|
3
|
+
import List from './components/list';
|
|
4
|
+
import './style/app.css';
|
|
5
|
+
|
|
6
|
+
function App() {
|
|
7
|
+
return () => (
|
|
8
|
+
<div class='inner'>
|
|
9
|
+
<h1>Hello mettle.js</h1>
|
|
10
|
+
<div class='app-tool'>
|
|
11
|
+
<Home/>
|
|
12
|
+
<List/>
|
|
13
|
+
</div>
|
|
14
|
+
</div>
|
|
15
|
+
);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
createApp(<App />, '#app');
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const Home = defineComponent(({ setData }) => {
|
|
1
|
+
export default function Home({ setData }) {
|
|
4
2
|
let count = 0;
|
|
5
3
|
|
|
6
4
|
function add() {
|
|
@@ -8,7 +6,6 @@ const Home = defineComponent(({ setData }) => {
|
|
|
8
6
|
count++;
|
|
9
7
|
});
|
|
10
8
|
}
|
|
11
|
-
|
|
12
9
|
return () => (
|
|
13
10
|
<fragment>
|
|
14
11
|
<button onClick={add}>Add</button>
|
|
@@ -16,6 +13,4 @@ const Home = defineComponent(({ setData }) => {
|
|
|
16
13
|
<input value={count} />
|
|
17
14
|
</fragment>
|
|
18
15
|
);
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export default Home;
|
|
16
|
+
}
|
|
@@ -1,14 +1,6 @@
|
|
|
1
1
|
import { defineConfig } from 'vite';
|
|
2
|
-
import
|
|
2
|
+
import mettle from 'vite-plugin-mettle';
|
|
3
3
|
|
|
4
4
|
export default defineConfig({
|
|
5
|
-
|
|
6
|
-
server: {
|
|
7
|
-
strictPort: true,
|
|
8
|
-
port: 3002,
|
|
9
|
-
},
|
|
10
|
-
plugins: [
|
|
11
|
-
// Babel will try to pick up Babel config files (.babelrc or .babelrc.json)
|
|
12
|
-
babel(),
|
|
13
|
-
],
|
|
5
|
+
plugins: [mettle()],
|
|
14
6
|
});
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
<!DOCTYPE html>
|
|
2
2
|
<html lang="en">
|
|
3
|
-
<head>
|
|
4
|
-
<meta charset="UTF-8" />
|
|
5
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
|
-
<title>create-mettle-app</title>
|
|
7
|
-
</head>
|
|
8
3
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
</
|
|
13
|
-
</
|
|
4
|
+
<head>
|
|
5
|
+
<meta charset="UTF-8" />
|
|
6
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
7
|
+
<title>create-mettle-app</title>
|
|
8
|
+
</head>
|
|
9
|
+
|
|
10
|
+
<body>
|
|
11
|
+
<div id="app"></div>
|
|
12
|
+
<script type="module" src="/src/main.jsx"></script>
|
|
13
|
+
</body>
|
|
14
|
+
|
|
15
|
+
</html>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"name": "template
|
|
2
|
+
"name": "template",
|
|
3
3
|
"version": "0.0.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"scripts": {
|
|
@@ -8,13 +8,11 @@
|
|
|
8
8
|
"build": "vite build"
|
|
9
9
|
},
|
|
10
10
|
"devDependencies": {
|
|
11
|
-
"
|
|
12
|
-
"
|
|
13
|
-
"vite": "^4.0.0",
|
|
14
|
-
"vite-plugin-babel": "^1.1.3"
|
|
11
|
+
"vite": "^6.1.0",
|
|
12
|
+
"vite-plugin-mettle": "^1.0.0"
|
|
15
13
|
},
|
|
16
14
|
"dependencies": {
|
|
17
|
-
"mettle": "^0.
|
|
18
|
-
"mettle-router": "^0.
|
|
15
|
+
"mettle": "^1.0.1",
|
|
16
|
+
"mettle-router": "^0.6.0"
|
|
19
17
|
}
|
|
20
18
|
}
|
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
import { resetView } from 'mettle';
|
|
2
|
-
import { initRouter } from 'mettle-router';
|
|
3
|
-
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
|
|
7
|
-
const router = initRouter(
|
|
8
|
-
[
|
|
9
|
-
{
|
|
10
|
-
path: '/',
|
|
11
|
-
template:
|
|
12
|
-
},
|
|
13
|
-
{
|
|
14
|
-
path: '/about',
|
|
15
|
-
template:
|
|
16
|
-
},
|
|
17
|
-
],
|
|
18
|
-
resetView
|
|
19
|
-
);
|
|
20
|
-
|
|
21
|
-
export default router;
|
|
1
|
+
import { resetView } from 'mettle';
|
|
2
|
+
import { initRouter } from 'mettle-router';
|
|
3
|
+
|
|
4
|
+
import Home from '../template/home';
|
|
5
|
+
import About from '../template/about';
|
|
6
|
+
|
|
7
|
+
const router = initRouter(
|
|
8
|
+
[
|
|
9
|
+
{
|
|
10
|
+
path: '/',
|
|
11
|
+
template: Home,
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
path: '/about',
|
|
15
|
+
template: About,
|
|
16
|
+
},
|
|
17
|
+
],
|
|
18
|
+
resetView
|
|
19
|
+
);
|
|
20
|
+
|
|
21
|
+
export default router;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { linkTo, toParse } from 'mettle-router';
|
|
2
|
+
|
|
3
|
+
export default function About() {
|
|
4
|
+
function goHome() {
|
|
5
|
+
linkTo({
|
|
6
|
+
path: '/',
|
|
7
|
+
});
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
function getOption() {
|
|
11
|
+
console.log(toParse());
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
return () => (
|
|
15
|
+
<fragment>
|
|
16
|
+
<button onClick={goHome}>goHome</button>
|
|
17
|
+
<h1 onClick={getOption}>About</h1>
|
|
18
|
+
</fragment>
|
|
19
|
+
);
|
|
20
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { linkTo } from 'mettle-router';
|
|
2
|
+
|
|
3
|
+
export default function Home({ setData }) {
|
|
4
|
+
const state = {
|
|
5
|
+
msg: 'hello',
|
|
6
|
+
arr: [1, 2],
|
|
7
|
+
count: 3,
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
function goAbout() {
|
|
11
|
+
linkTo({
|
|
12
|
+
path: '/about',
|
|
13
|
+
query: {
|
|
14
|
+
id: 1,
|
|
15
|
+
name: 'maomin',
|
|
16
|
+
},
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function useChange() {
|
|
21
|
+
setData(() => {
|
|
22
|
+
state.msg = 'world';
|
|
23
|
+
state.count++;
|
|
24
|
+
state.arr.unshift(state.count);
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return () => (
|
|
29
|
+
<fragment>
|
|
30
|
+
<button onClick={goAbout}>goAbout</button>
|
|
31
|
+
<h1>Home</h1>
|
|
32
|
+
<p onClick={useChange}>{state.msg}</p>
|
|
33
|
+
<ul>
|
|
34
|
+
{state.arr.map((item) => (
|
|
35
|
+
<li key={item}>{item}</li>
|
|
36
|
+
))}
|
|
37
|
+
</ul>
|
|
38
|
+
</fragment>
|
|
39
|
+
);
|
|
40
|
+
}
|
|
@@ -1,14 +1,6 @@
|
|
|
1
1
|
import { defineConfig } from 'vite';
|
|
2
|
-
import
|
|
2
|
+
import mettle from 'vite-plugin-mettle';
|
|
3
3
|
|
|
4
4
|
export default defineConfig({
|
|
5
|
-
|
|
6
|
-
server: {
|
|
7
|
-
strictPort: true,
|
|
8
|
-
port: 3002,
|
|
9
|
-
},
|
|
10
|
-
plugins: [
|
|
11
|
-
// Babel will try to pick up Babel config files (.babelrc or .babelrc.json)
|
|
12
|
-
babel(),
|
|
13
|
-
],
|
|
5
|
+
plugins: [mettle()],
|
|
14
6
|
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# template-mettle-apps-ts
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"name": "template
|
|
2
|
+
"name": "template",
|
|
3
3
|
"version": "0.0.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"scripts": {
|
|
@@ -10,10 +10,10 @@
|
|
|
10
10
|
"devDependencies": {
|
|
11
11
|
"typescript": "~5.7.2",
|
|
12
12
|
"vite": "^6.1.0",
|
|
13
|
-
"vite-plugin-mettle": "^0.0
|
|
13
|
+
"vite-plugin-mettle": "^1.0.0"
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"mettle": "^0.
|
|
17
|
-
"mettle-router": "^0.
|
|
16
|
+
"mettle": "^1.0.1",
|
|
17
|
+
"mettle-router": "^0.6.0"
|
|
18
18
|
}
|
|
19
19
|
}
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import { resetView } from 'mettle';
|
|
2
2
|
import { initRouter } from 'mettle-router';
|
|
3
3
|
|
|
4
|
-
import
|
|
5
|
-
import
|
|
4
|
+
import Home from '../template/home';
|
|
5
|
+
import About from '../template/about';
|
|
6
6
|
|
|
7
7
|
const router = initRouter(
|
|
8
8
|
[
|
|
9
9
|
{
|
|
10
10
|
path: '/',
|
|
11
|
-
template:
|
|
11
|
+
template: Home,
|
|
12
12
|
},
|
|
13
13
|
{
|
|
14
14
|
path: '/about',
|
|
15
|
-
template:
|
|
15
|
+
template: About,
|
|
16
16
|
},
|
|
17
17
|
],
|
|
18
18
|
resetView
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { linkTo, toParse } from 'mettle-router';
|
|
2
|
+
|
|
3
|
+
export default function About() {
|
|
4
|
+
function goHome() {
|
|
5
|
+
linkTo({
|
|
6
|
+
path: '/',
|
|
7
|
+
});
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
function getOption() {
|
|
11
|
+
console.log(toParse());
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
return () => (
|
|
15
|
+
<fragment>
|
|
16
|
+
<button onClick={goHome}>goHome</button>
|
|
17
|
+
<h1 onClick={getOption}>About</h1>
|
|
18
|
+
</fragment>
|
|
19
|
+
);
|
|
20
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { linkTo } from 'mettle-router';
|
|
2
|
+
|
|
3
|
+
export default function Home({ setData }:any) {
|
|
4
|
+
const state = {
|
|
5
|
+
msg: 'hello',
|
|
6
|
+
arr: [1, 2],
|
|
7
|
+
count: 3,
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
function goAbout() {
|
|
11
|
+
linkTo({
|
|
12
|
+
path: '/about',
|
|
13
|
+
query: {
|
|
14
|
+
id: 1,
|
|
15
|
+
name: 'maomin',
|
|
16
|
+
},
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function useChange() {
|
|
21
|
+
setData(() => {
|
|
22
|
+
state.msg = 'world';
|
|
23
|
+
state.count++;
|
|
24
|
+
state.arr.unshift(state.count);
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return () => (
|
|
29
|
+
<fragment>
|
|
30
|
+
<button onClick={goAbout}>goAbout</button>
|
|
31
|
+
<h1>Home</h1>
|
|
32
|
+
<p onClick={useChange}>{state.msg}</p>
|
|
33
|
+
<ul>
|
|
34
|
+
{state.arr.map((item) => (
|
|
35
|
+
<li key={item}>{item}</li>
|
|
36
|
+
))}
|
|
37
|
+
</ul>
|
|
38
|
+
</fragment>
|
|
39
|
+
);
|
|
40
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# template-mettle-ts
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"name": "template
|
|
2
|
+
"name": "template",
|
|
3
3
|
"version": "0.0.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"scripts": {
|
|
@@ -10,9 +10,9 @@
|
|
|
10
10
|
"devDependencies": {
|
|
11
11
|
"typescript": "~5.7.2",
|
|
12
12
|
"vite": "^6.1.0",
|
|
13
|
-
"vite-plugin-mettle": "^0.0
|
|
13
|
+
"vite-plugin-mettle": "^1.0.0"
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"mettle": "^0.
|
|
16
|
+
"mettle": "^1.0.1"
|
|
17
17
|
}
|
|
18
18
|
}
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import { defineComponent } from 'mettle';
|
|
2
|
-
import type { OptionsProps } from 'mettle';
|
|
3
1
|
import style from '../style/list.module.css';
|
|
4
2
|
|
|
5
|
-
|
|
3
|
+
export default function List({ setData }:any) {
|
|
6
4
|
const listState = {
|
|
7
5
|
arr: [1, 2],
|
|
8
6
|
};
|
|
@@ -40,6 +38,4 @@ const List = defineComponent(({ setData }:OptionsProps) => {
|
|
|
40
38
|
</ul>
|
|
41
39
|
</fragment>
|
|
42
40
|
);
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
export default List;
|
|
41
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { createApp } from 'mettle';
|
|
2
|
+
import Home from './template/home';
|
|
3
|
+
import List from './components/list';
|
|
4
|
+
import './style/app.css';
|
|
5
|
+
|
|
6
|
+
function App() {
|
|
7
|
+
return () => (
|
|
8
|
+
<div class='inner'>
|
|
9
|
+
<h1>Hello mettle.js</h1>
|
|
10
|
+
<div class='app-tool'>
|
|
11
|
+
<Home/>
|
|
12
|
+
<List/>
|
|
13
|
+
</div>
|
|
14
|
+
</div>
|
|
15
|
+
);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
createApp(<App />, '#app');
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
import type { OptionsProps } from 'mettle';
|
|
3
|
-
|
|
4
|
-
const Home = defineComponent(({ setData }:OptionsProps) => {
|
|
1
|
+
export default function Home({ setData }:any) {
|
|
5
2
|
let count = 0;
|
|
6
3
|
|
|
7
4
|
function add() {
|
|
@@ -9,7 +6,6 @@ const Home = defineComponent(({ setData }:OptionsProps) => {
|
|
|
9
6
|
count++;
|
|
10
7
|
});
|
|
11
8
|
}
|
|
12
|
-
|
|
13
9
|
return () => (
|
|
14
10
|
<fragment>
|
|
15
11
|
<button onClick={add}>Add</button>
|
|
@@ -17,6 +13,4 @@ const Home = defineComponent(({ setData }:OptionsProps) => {
|
|
|
17
13
|
<input value={count} />
|
|
18
14
|
</fragment>
|
|
19
15
|
);
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export default Home;
|
|
16
|
+
}
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { defineComponent } from 'mettle';
|
|
2
|
-
import style from '../style/list.module.css';
|
|
3
|
-
|
|
4
|
-
const List = defineComponent(({ setData }) => {
|
|
5
|
-
const listState = {
|
|
6
|
-
arr: [1, 2],
|
|
7
|
-
};
|
|
8
|
-
let count = 3;
|
|
9
|
-
|
|
10
|
-
function usePush() {
|
|
11
|
-
setData(() => {
|
|
12
|
-
listState.arr.push(count++);
|
|
13
|
-
});
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
function useUnshift() {
|
|
17
|
-
setData(() => {
|
|
18
|
-
listState.arr.unshift(count++);
|
|
19
|
-
});
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
function useDel() {
|
|
23
|
-
setData(() => {
|
|
24
|
-
listState.arr.splice(1, 1);
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
return () =>
|
|
29
|
-
html`
|
|
30
|
-
<fragment>
|
|
31
|
-
<div class=${style.listInner}>
|
|
32
|
-
<button onClick=${useUnshift}>Unshift</button>
|
|
33
|
-
<button onClick=${usePush}>Push</button>
|
|
34
|
-
<button onClick=${useDel}>Del</button>
|
|
35
|
-
</div>
|
|
36
|
-
<ul class=${style.listInner}>
|
|
37
|
-
${listState.arr.map((item) => html`<li key=${item}>${item}</li>`)}
|
|
38
|
-
</ul>
|
|
39
|
-
</fragment>
|
|
40
|
-
`;
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
export default List;
|