create-mettle-app 0.1.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/LICENSE +21 -0
- package/README.md +33 -0
- package/index.js +258 -0
- package/package.json +41 -0
- package/template-amazed/README.md +1 -0
- package/template-amazed/_gitignore +25 -0
- package/template-amazed/babel.config.cjs +3 -0
- package/template-amazed/index.html +13 -0
- package/template-amazed/package.json +19 -0
- package/template-amazed/src/components/list.js +43 -0
- package/template-amazed/src/main.js +20 -0
- package/template-amazed/src/style/app.css +14 -0
- package/template-amazed/src/style/list.module.css +27 -0
- package/template-amazed/src/template/home.js +22 -0
- package/template-amazed/vite.config.js +14 -0
- package/template-amazed-apps/README.md +1 -0
- package/template-amazed-apps/_gitignore +25 -0
- package/template-amazed-apps/babel.config.cjs +3 -0
- package/template-amazed-apps/index.html +13 -0
- package/template-amazed-apps/package.json +20 -0
- package/template-amazed-apps/src/main.js +12 -0
- package/template-amazed-apps/src/router/index.js +21 -0
- package/template-amazed-apps/src/styles/app.css +7 -0
- package/template-amazed-apps/src/template/about.js +23 -0
- package/template-amazed-apps/src/template/home.js +42 -0
- package/template-amazed-apps/vite.config.js +14 -0
- package/template-amazed-jsx/README.md +1 -0
- package/template-amazed-jsx/_gitignore +25 -0
- package/template-amazed-jsx/babel.config.cjs +3 -0
- package/template-amazed-jsx/index.html +13 -0
- package/template-amazed-jsx/package.json +20 -0
- package/template-amazed-jsx/src/components/list.jsx +44 -0
- package/template-amazed-jsx/src/main.js +21 -0
- package/template-amazed-jsx/src/style/app.css +14 -0
- package/template-amazed-jsx/src/style/list.module.css +27 -0
- package/template-amazed-jsx/src/template/home.jsx +21 -0
- package/template-amazed-jsx/vite.config.js +14 -0
- package/template-amazed-jsx-apps/README.md +1 -0
- package/template-amazed-jsx-apps/_gitignore +25 -0
- package/template-amazed-jsx-apps/babel.config.cjs +3 -0
- package/template-amazed-jsx-apps/index.html +13 -0
- package/template-amazed-jsx-apps/package.json +21 -0
- package/template-amazed-jsx-apps/src/main.js +12 -0
- package/template-amazed-jsx-apps/src/router/index.js +21 -0
- package/template-amazed-jsx-apps/src/styles/app.css +7 -0
- package/template-amazed-jsx-apps/src/template/about.jsx +24 -0
- package/template-amazed-jsx-apps/src/template/home.jsx +44 -0
- package/template-amazed-jsx-apps/vite.config.js +14 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2021 maomincoding
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# Create-amazed-app
|
|
2
|
+
|
|
3
|
+
A set of fast building amazed.js project command line tool.
|
|
4
|
+
|
|
5
|
+
## Scaffolding Your First Amazed Project
|
|
6
|
+
|
|
7
|
+
**NPM**
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm create amazed-app@latest
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
**Yarn**
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
yarn create amazed-app
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
**PNPM**
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
pnpm create amazed-app
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Documentation
|
|
26
|
+
|
|
27
|
+
To learn more about create-amazed-app, check [its documentation](https://maomincoding.github.io/amazed-doc/tool/createAmazedApp/).
|
|
28
|
+
|
|
29
|
+
## License
|
|
30
|
+
|
|
31
|
+
[MIT](http://opensource.org/licenses/MIT)
|
|
32
|
+
|
|
33
|
+
Copyright (c) 2021-present, maomincoding
|
package/index.js
ADDED
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const fs = require('fs');
|
|
4
|
+
const path = require('path');
|
|
5
|
+
const argv = require('minimist')(process.argv.slice(2), { string: ['_'] });
|
|
6
|
+
const prompts = require('prompts');
|
|
7
|
+
const { yellow, red, lightYellow, cyan } = require('kolorist');
|
|
8
|
+
|
|
9
|
+
const cwd = process.cwd();
|
|
10
|
+
|
|
11
|
+
const FRAMEWORKS = [
|
|
12
|
+
{
|
|
13
|
+
name: 'create-amazed-app',
|
|
14
|
+
color: yellow,
|
|
15
|
+
variants: [
|
|
16
|
+
{
|
|
17
|
+
name: 'amazed',
|
|
18
|
+
display: 'JavaScript',
|
|
19
|
+
color: lightYellow,
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
name: 'amazed-apps',
|
|
23
|
+
display: 'JavaScript',
|
|
24
|
+
color: lightYellow,
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
name: 'amazed-jsx',
|
|
28
|
+
display: 'JavaScript',
|
|
29
|
+
color: cyan,
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
name: 'amazed-jsx-apps',
|
|
33
|
+
display: 'JavaScript',
|
|
34
|
+
color: cyan,
|
|
35
|
+
},
|
|
36
|
+
],
|
|
37
|
+
},
|
|
38
|
+
];
|
|
39
|
+
|
|
40
|
+
const TEMPLATES = FRAMEWORKS.map(
|
|
41
|
+
(f) => (f.variants && f.variants.map((v) => v.name)) || [f.name]
|
|
42
|
+
).reduce((a, b) => a.concat(b), []);
|
|
43
|
+
|
|
44
|
+
const renameFiles = {
|
|
45
|
+
_gitignore: '.gitignore',
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
async function init() {
|
|
49
|
+
let targetDir = argv._[0];
|
|
50
|
+
let template = argv.template || argv.t;
|
|
51
|
+
|
|
52
|
+
const defaultProjectName = !targetDir ? 'amazed-project' : targetDir;
|
|
53
|
+
|
|
54
|
+
let result = {};
|
|
55
|
+
|
|
56
|
+
try {
|
|
57
|
+
result = await prompts(
|
|
58
|
+
[
|
|
59
|
+
{
|
|
60
|
+
type: targetDir ? null : 'text',
|
|
61
|
+
name: 'projectName',
|
|
62
|
+
message: 'Project name:',
|
|
63
|
+
initial: defaultProjectName,
|
|
64
|
+
onState: (state) => (targetDir = state.value.trim() || defaultProjectName),
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
type: () => (!fs.existsSync(targetDir) || isEmpty(targetDir) ? null : 'confirm'),
|
|
68
|
+
name: 'overwrite',
|
|
69
|
+
message: () =>
|
|
70
|
+
(targetDir === '.' ? 'Current directory' : `Target directory "${targetDir}"`) +
|
|
71
|
+
` is not empty. Remove existing files and continue?`,
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
// @ts-ignore
|
|
75
|
+
type: (_, { overwrite } = {}) => {
|
|
76
|
+
if (overwrite === false) {
|
|
77
|
+
throw new Error(red('✖') + ' Operation cancelled');
|
|
78
|
+
}
|
|
79
|
+
return null;
|
|
80
|
+
},
|
|
81
|
+
name: 'overwriteChecker',
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
type: () => (isValidPackageName(targetDir) ? null : 'text'),
|
|
85
|
+
name: 'packageName',
|
|
86
|
+
message: 'Package name:',
|
|
87
|
+
initial: () => toValidPackageName(targetDir),
|
|
88
|
+
validate: (dir) => isValidPackageName(dir) || 'Invalid package.json name',
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
type: template && TEMPLATES.includes(template) ? null : 'select',
|
|
92
|
+
name: 'framework',
|
|
93
|
+
message:
|
|
94
|
+
typeof template === 'string' && !TEMPLATES.includes(template)
|
|
95
|
+
? `"${template}" isn't a valid template. Please choose from below: `
|
|
96
|
+
: 'Select a framework:',
|
|
97
|
+
initial: 0,
|
|
98
|
+
choices: FRAMEWORKS.map((framework) => {
|
|
99
|
+
const frameworkColor = framework.color;
|
|
100
|
+
return {
|
|
101
|
+
title: frameworkColor(framework.name),
|
|
102
|
+
value: framework,
|
|
103
|
+
};
|
|
104
|
+
}),
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
type: (framework) => (framework && framework.variants ? 'select' : null),
|
|
108
|
+
name: 'variant',
|
|
109
|
+
message: 'Select a variant:',
|
|
110
|
+
// @ts-ignore
|
|
111
|
+
choices: (framework) =>
|
|
112
|
+
framework.variants.map((variant) => {
|
|
113
|
+
const variantColor = variant.color;
|
|
114
|
+
return {
|
|
115
|
+
title: variantColor(variant.name),
|
|
116
|
+
value: variant.name,
|
|
117
|
+
};
|
|
118
|
+
}),
|
|
119
|
+
},
|
|
120
|
+
],
|
|
121
|
+
{
|
|
122
|
+
onCancel: () => {
|
|
123
|
+
throw new Error(red('✖') + ' Operation cancelled');
|
|
124
|
+
},
|
|
125
|
+
}
|
|
126
|
+
);
|
|
127
|
+
} catch (cancelled) {
|
|
128
|
+
console.log(cancelled.message);
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
// user choice associated with prompts
|
|
133
|
+
const { framework, overwrite, packageName, variant } = result;
|
|
134
|
+
|
|
135
|
+
const root = path.join(cwd, targetDir);
|
|
136
|
+
|
|
137
|
+
if (overwrite) {
|
|
138
|
+
emptyDir(root);
|
|
139
|
+
} else if (!fs.existsSync(root)) {
|
|
140
|
+
fs.mkdirSync(root);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
// determine template
|
|
144
|
+
template = variant || framework || template;
|
|
145
|
+
|
|
146
|
+
console.log(`\nScaffolding project in ${root}...`);
|
|
147
|
+
|
|
148
|
+
const templateDir = path.join(__dirname, `template-${template}`);
|
|
149
|
+
|
|
150
|
+
const write = (file, content) => {
|
|
151
|
+
const targetPath = renameFiles[file]
|
|
152
|
+
? path.join(root, renameFiles[file])
|
|
153
|
+
: path.join(root, file);
|
|
154
|
+
if (content) {
|
|
155
|
+
fs.writeFileSync(targetPath, content);
|
|
156
|
+
} else {
|
|
157
|
+
copy(path.join(templateDir, file), targetPath);
|
|
158
|
+
}
|
|
159
|
+
};
|
|
160
|
+
|
|
161
|
+
const files = fs.readdirSync(templateDir);
|
|
162
|
+
for (const file of files.filter((f) => f !== 'package.json')) {
|
|
163
|
+
write(file);
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
const pkg = require(path.join(templateDir, `package.json`));
|
|
167
|
+
|
|
168
|
+
pkg.name = packageName || targetDir;
|
|
169
|
+
|
|
170
|
+
write('package.json', JSON.stringify(pkg, null, 2));
|
|
171
|
+
|
|
172
|
+
const pkgInfo = pkgFromUserAgent(process.env.npm_config_user_agent);
|
|
173
|
+
const pkgManager = pkgInfo ? pkgInfo.name : 'npm';
|
|
174
|
+
|
|
175
|
+
console.log(`\nDone. Now run:\n`);
|
|
176
|
+
if (root !== cwd) {
|
|
177
|
+
console.log(` cd ${path.relative(cwd, root)}`);
|
|
178
|
+
}
|
|
179
|
+
switch (pkgManager) {
|
|
180
|
+
case 'yarn':
|
|
181
|
+
console.log(' yarn');
|
|
182
|
+
console.log(' yarn dev');
|
|
183
|
+
break;
|
|
184
|
+
default:
|
|
185
|
+
console.log(` ${pkgManager} install`);
|
|
186
|
+
console.log(` ${pkgManager} run dev`);
|
|
187
|
+
break;
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
function copy(src, dest) {
|
|
192
|
+
const stat = fs.statSync(src);
|
|
193
|
+
if (stat.isDirectory()) {
|
|
194
|
+
copyDir(src, dest);
|
|
195
|
+
} else {
|
|
196
|
+
fs.copyFileSync(src, dest);
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
function isValidPackageName(projectName) {
|
|
201
|
+
return /^(?:@[a-z0-9-*~][a-z0-9-*._~]*\/)?[a-z0-9-~][a-z0-9-._~]*$/.test(projectName);
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
function toValidPackageName(projectName) {
|
|
205
|
+
return projectName
|
|
206
|
+
.trim()
|
|
207
|
+
.toLowerCase()
|
|
208
|
+
.replace(/\s+/g, '-')
|
|
209
|
+
.replace(/^[._]/, '')
|
|
210
|
+
.replace(/[^a-z0-9-~]+/g, '-');
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
function copyDir(srcDir, destDir) {
|
|
214
|
+
fs.mkdirSync(destDir, { recursive: true });
|
|
215
|
+
for (const file of fs.readdirSync(srcDir)) {
|
|
216
|
+
const srcFile = path.resolve(srcDir, file);
|
|
217
|
+
const destFile = path.resolve(destDir, file);
|
|
218
|
+
copy(srcFile, destFile);
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
function isEmpty(path) {
|
|
223
|
+
return fs.readdirSync(path).length === 0;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
function emptyDir(dir) {
|
|
227
|
+
if (!fs.existsSync(dir)) {
|
|
228
|
+
return;
|
|
229
|
+
}
|
|
230
|
+
for (const file of fs.readdirSync(dir)) {
|
|
231
|
+
const abs = path.resolve(dir, file);
|
|
232
|
+
// baseline is Node 12 so can't use rmSync :(
|
|
233
|
+
if (fs.lstatSync(abs).isDirectory()) {
|
|
234
|
+
emptyDir(abs);
|
|
235
|
+
fs.rmdirSync(abs);
|
|
236
|
+
} else {
|
|
237
|
+
fs.unlinkSync(abs);
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
/**
|
|
243
|
+
* @param {string | undefined} userAgent process.env.npm_config_user_agent
|
|
244
|
+
* @returns object | undefined
|
|
245
|
+
*/
|
|
246
|
+
function pkgFromUserAgent(userAgent) {
|
|
247
|
+
if (!userAgent) return undefined;
|
|
248
|
+
const pkgSpec = userAgent.split(' ')[0];
|
|
249
|
+
const pkgSpecArr = pkgSpec.split('/');
|
|
250
|
+
return {
|
|
251
|
+
name: pkgSpecArr[0],
|
|
252
|
+
version: pkgSpecArr[1],
|
|
253
|
+
};
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
init().catch((e) => {
|
|
257
|
+
console.error(e);
|
|
258
|
+
});
|
package/package.json
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "create-mettle-app",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"license": "MIT",
|
|
5
|
+
"author": "maomincoding",
|
|
6
|
+
"bin": {
|
|
7
|
+
"create-amazed-app": "index.js",
|
|
8
|
+
"cs-app": "index.js"
|
|
9
|
+
},
|
|
10
|
+
"main": "index.js",
|
|
11
|
+
"private": false,
|
|
12
|
+
"keywords": [
|
|
13
|
+
"amazed",
|
|
14
|
+
"amazedjs",
|
|
15
|
+
"amazed-js",
|
|
16
|
+
"dom",
|
|
17
|
+
"mvvm",
|
|
18
|
+
"virtual dom",
|
|
19
|
+
"html",
|
|
20
|
+
"template",
|
|
21
|
+
"string",
|
|
22
|
+
"create-amazed",
|
|
23
|
+
"create-amazed-app"
|
|
24
|
+
],
|
|
25
|
+
"engines": {
|
|
26
|
+
"node": ">=12.0.0"
|
|
27
|
+
},
|
|
28
|
+
"repository": {
|
|
29
|
+
"type": "git",
|
|
30
|
+
"url": "https://github.com/maomincoding/create-amazed-app"
|
|
31
|
+
},
|
|
32
|
+
"bugs": {
|
|
33
|
+
"url": "https://github.com/maomincoding/create-amazed-app/issues"
|
|
34
|
+
},
|
|
35
|
+
"homepage": "https://github.com/maomincoding/create-amazed-app#readme",
|
|
36
|
+
"dependencies": {
|
|
37
|
+
"kolorist": "^1.5.0",
|
|
38
|
+
"minimist": "^1.2.5",
|
|
39
|
+
"prompts": "^2.4.2"
|
|
40
|
+
}
|
|
41
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# template-amazed
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
.DS_Store
|
|
2
|
+
node_modules
|
|
3
|
+
/dist
|
|
4
|
+
/buildDir
|
|
5
|
+
.parcel-cache
|
|
6
|
+
|
|
7
|
+
# local env files
|
|
8
|
+
.env.local
|
|
9
|
+
.env.*.local
|
|
10
|
+
|
|
11
|
+
# Log files
|
|
12
|
+
npm-debug.log*
|
|
13
|
+
yarn-debug.log*
|
|
14
|
+
yarn-error.log*
|
|
15
|
+
pnpm-debug.log*
|
|
16
|
+
|
|
17
|
+
# Editor directories and files
|
|
18
|
+
.idea
|
|
19
|
+
.vscode
|
|
20
|
+
*.suo
|
|
21
|
+
*.ntvs*
|
|
22
|
+
*.njsproj
|
|
23
|
+
*.sln
|
|
24
|
+
*.sw?
|
|
25
|
+
yarn.lock
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
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>amazed.js</title>
|
|
7
|
+
</head>
|
|
8
|
+
|
|
9
|
+
<body>
|
|
10
|
+
<div id="app"></div>
|
|
11
|
+
<script type="module" src="/src/main.js"></script>
|
|
12
|
+
</body>
|
|
13
|
+
</html>
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "template-amazed",
|
|
3
|
+
"version": "0.0.0",
|
|
4
|
+
"license": "MIT",
|
|
5
|
+
"scripts": {
|
|
6
|
+
"dev": "vite --open",
|
|
7
|
+
"serve": "vite preview",
|
|
8
|
+
"build": "vite build"
|
|
9
|
+
},
|
|
10
|
+
"devDependencies": {
|
|
11
|
+
"@babel/core": "^7.20.7",
|
|
12
|
+
"babel-plugin-amazed": "^0.0.3",
|
|
13
|
+
"vite": "^4.0.0",
|
|
14
|
+
"vite-plugin-babel": "^1.1.3"
|
|
15
|
+
},
|
|
16
|
+
"dependencies": {
|
|
17
|
+
"amazed": "^0.0.2"
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { defineComponent } from 'amazed';
|
|
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;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { defineComponent } from 'amazed';
|
|
2
|
+
import Home from './template/home';
|
|
3
|
+
import List from './components/list';
|
|
4
|
+
import './style/app.css';
|
|
5
|
+
|
|
6
|
+
defineComponent(
|
|
7
|
+
{
|
|
8
|
+
mount: '#app',
|
|
9
|
+
},
|
|
10
|
+
() => {
|
|
11
|
+
return () =>
|
|
12
|
+
html`<div class="inner">
|
|
13
|
+
<h1>Hello Amazed.js</h1>
|
|
14
|
+
<div class="app-tool">
|
|
15
|
+
<component $is=${Home} />
|
|
16
|
+
<component $is=${List} />
|
|
17
|
+
</div>
|
|
18
|
+
</div>`;
|
|
19
|
+
}
|
|
20
|
+
);
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
.listInner{
|
|
2
|
+
padding: 0;
|
|
3
|
+
margin: 0;
|
|
4
|
+
width: 400px;
|
|
5
|
+
}
|
|
6
|
+
.listInner li {
|
|
7
|
+
list-style: none;
|
|
8
|
+
text-align: center;
|
|
9
|
+
font-weight: bold;
|
|
10
|
+
padding: 10px;
|
|
11
|
+
margin: 10px 0;
|
|
12
|
+
background-color: #c6715b;
|
|
13
|
+
color: #fff;
|
|
14
|
+
border-radius: 20px;
|
|
15
|
+
animation: my1 1s ease-in;
|
|
16
|
+
}
|
|
17
|
+
.listInner button {
|
|
18
|
+
margin-top: 30px;
|
|
19
|
+
}
|
|
20
|
+
@keyframes my1 {
|
|
21
|
+
from {
|
|
22
|
+
opacity: 0.2;
|
|
23
|
+
}
|
|
24
|
+
to {
|
|
25
|
+
opacity: 1;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { defineComponent } from 'amazed';
|
|
2
|
+
|
|
3
|
+
const Home = defineComponent(({ setData }) => {
|
|
4
|
+
let count = 0;
|
|
5
|
+
|
|
6
|
+
function add() {
|
|
7
|
+
setData(() => {
|
|
8
|
+
count++;
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
return () =>
|
|
13
|
+
html`
|
|
14
|
+
<fragment>
|
|
15
|
+
<button onClick=${add}>Add</button>
|
|
16
|
+
<h1>${count}</h1>
|
|
17
|
+
<input value=${count} />
|
|
18
|
+
</fragment>
|
|
19
|
+
`;
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
export default Home;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { defineConfig } from 'vite';
|
|
2
|
+
import babel from 'vite-plugin-babel';
|
|
3
|
+
|
|
4
|
+
export default defineConfig({
|
|
5
|
+
// options
|
|
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
|
+
],
|
|
14
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# template-amazed-apps
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
.DS_Store
|
|
2
|
+
node_modules
|
|
3
|
+
/dist
|
|
4
|
+
/buildDir
|
|
5
|
+
.parcel-cache
|
|
6
|
+
|
|
7
|
+
# local env files
|
|
8
|
+
.env.local
|
|
9
|
+
.env.*.local
|
|
10
|
+
|
|
11
|
+
# Log files
|
|
12
|
+
npm-debug.log*
|
|
13
|
+
yarn-debug.log*
|
|
14
|
+
yarn-error.log*
|
|
15
|
+
pnpm-debug.log*
|
|
16
|
+
|
|
17
|
+
# Editor directories and files
|
|
18
|
+
.idea
|
|
19
|
+
.vscode
|
|
20
|
+
*.suo
|
|
21
|
+
*.ntvs*
|
|
22
|
+
*.njsproj
|
|
23
|
+
*.sln
|
|
24
|
+
*.sw?
|
|
25
|
+
yarn.lock
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
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>amazed.js</title>
|
|
7
|
+
</head>
|
|
8
|
+
|
|
9
|
+
<body>
|
|
10
|
+
<div id="app"></div>
|
|
11
|
+
<script type="module" src="/src/main.js"></script>
|
|
12
|
+
</body>
|
|
13
|
+
</html>
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "template-amazed-apps",
|
|
3
|
+
"version": "0.0.0",
|
|
4
|
+
"license": "MIT",
|
|
5
|
+
"scripts": {
|
|
6
|
+
"dev": "vite --open",
|
|
7
|
+
"serve": "vite preview",
|
|
8
|
+
"build": "vite build"
|
|
9
|
+
},
|
|
10
|
+
"devDependencies": {
|
|
11
|
+
"@babel/core": "^7.20.7",
|
|
12
|
+
"babel-plugin-amazed": "^0.0.3",
|
|
13
|
+
"vite": "^4.0.0",
|
|
14
|
+
"vite-plugin-babel": "^1.1.3"
|
|
15
|
+
},
|
|
16
|
+
"dependencies": {
|
|
17
|
+
"amazed": "^0.0.2",
|
|
18
|
+
"amazed-router": "^0.0.4"
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { resetView } from 'amazed';
|
|
2
|
+
import { initRouter } from 'amazed-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,23 @@
|
|
|
1
|
+
import { defineComponent } from 'amazed';
|
|
2
|
+
import { linkTo, toParse } from 'amazed-router';
|
|
3
|
+
|
|
4
|
+
const about = () =>
|
|
5
|
+
defineComponent(() => {
|
|
6
|
+
function goHome() {
|
|
7
|
+
linkTo({
|
|
8
|
+
path: '/',
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
function getOption() {
|
|
13
|
+
console.log(toParse());
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
return () => html`
|
|
17
|
+
<fragment>
|
|
18
|
+
<button onClick=${goHome}>goHome</button>
|
|
19
|
+
<h1 onClick=${getOption}>About</h1>
|
|
20
|
+
</fragment>
|
|
21
|
+
`;
|
|
22
|
+
});
|
|
23
|
+
export default about;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { defineComponent } from 'amazed';
|
|
2
|
+
import { linkTo } from 'amazed-router';
|
|
3
|
+
|
|
4
|
+
const home = () =>
|
|
5
|
+
defineComponent(({ setData }) => {
|
|
6
|
+
const state = {
|
|
7
|
+
msg: 'hello',
|
|
8
|
+
arr: [1, 2],
|
|
9
|
+
count: 3,
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
function goAbout() {
|
|
13
|
+
linkTo({
|
|
14
|
+
path: '/about',
|
|
15
|
+
query: {
|
|
16
|
+
id: 1,
|
|
17
|
+
name: 'maomin',
|
|
18
|
+
},
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function useChange() {
|
|
23
|
+
setData(() => {
|
|
24
|
+
state.msg = 'world';
|
|
25
|
+
state.count++;
|
|
26
|
+
state.arr.unshift(state.count);
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
return () => html`
|
|
31
|
+
<fragment>
|
|
32
|
+
<button onClick=${goAbout}>goAbout</button>
|
|
33
|
+
<h1>Home</h1>
|
|
34
|
+
<p onClick=${useChange}>${state.msg}</p>
|
|
35
|
+
<ul>
|
|
36
|
+
${state.arr.map((item) => html`<li key=${item}>${item}</li>`)}
|
|
37
|
+
</ul>
|
|
38
|
+
</fragment>
|
|
39
|
+
`;
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
export default home;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { defineConfig } from 'vite';
|
|
2
|
+
import babel from 'vite-plugin-babel';
|
|
3
|
+
|
|
4
|
+
export default defineConfig({
|
|
5
|
+
// options
|
|
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
|
+
],
|
|
14
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# template-amazed-jsx
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
.DS_Store
|
|
2
|
+
node_modules
|
|
3
|
+
/dist
|
|
4
|
+
/buildDir
|
|
5
|
+
.parcel-cache
|
|
6
|
+
|
|
7
|
+
# local env files
|
|
8
|
+
.env.local
|
|
9
|
+
.env.*.local
|
|
10
|
+
|
|
11
|
+
# Log files
|
|
12
|
+
npm-debug.log*
|
|
13
|
+
yarn-debug.log*
|
|
14
|
+
yarn-error.log*
|
|
15
|
+
pnpm-debug.log*
|
|
16
|
+
|
|
17
|
+
# Editor directories and files
|
|
18
|
+
.idea
|
|
19
|
+
.vscode
|
|
20
|
+
*.suo
|
|
21
|
+
*.ntvs*
|
|
22
|
+
*.njsproj
|
|
23
|
+
*.sln
|
|
24
|
+
*.sw?
|
|
25
|
+
yarn.lock
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
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>amazed.js</title>
|
|
7
|
+
</head>
|
|
8
|
+
|
|
9
|
+
<body>
|
|
10
|
+
<div id="app"></div>
|
|
11
|
+
<script type="module" src="/src/main.js"></script>
|
|
12
|
+
</body>
|
|
13
|
+
</html>
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "template-amazed-jsx",
|
|
3
|
+
"version": "0.0.0",
|
|
4
|
+
"license": "MIT",
|
|
5
|
+
"scripts": {
|
|
6
|
+
"dev": "vite --open",
|
|
7
|
+
"serve": "vite preview",
|
|
8
|
+
"build": "vite build"
|
|
9
|
+
},
|
|
10
|
+
"devDependencies": {
|
|
11
|
+
"@babel/core": "^7.20.7",
|
|
12
|
+
"babel-plugin-jsx-to-amazed": "^0.0.4",
|
|
13
|
+
"babel-plugin-amazed": "^0.0.3",
|
|
14
|
+
"vite": "^4.0.0",
|
|
15
|
+
"vite-plugin-babel": "^1.1.3"
|
|
16
|
+
},
|
|
17
|
+
"dependencies": {
|
|
18
|
+
"amazed": "^0.0.2"
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { defineComponent } from 'amazed';
|
|
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
|
+
<fragment>
|
|
30
|
+
<div class={style.listInner}>
|
|
31
|
+
<button onClick={useUnshift}>Unshift</button>
|
|
32
|
+
<button onClick={usePush}>Push</button>
|
|
33
|
+
<button onClick={useDel}>Del</button>
|
|
34
|
+
</div>
|
|
35
|
+
<ul class={style.listInner}>
|
|
36
|
+
{listState.arr.map((item) => (
|
|
37
|
+
<li key={item}>{item}</li>
|
|
38
|
+
))}
|
|
39
|
+
</ul>
|
|
40
|
+
</fragment>
|
|
41
|
+
);
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
export default List;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { defineComponent } from 'amazed';
|
|
2
|
+
import Home from './template/home';
|
|
3
|
+
import List from './components/list';
|
|
4
|
+
import './style/app.css';
|
|
5
|
+
|
|
6
|
+
defineComponent(
|
|
7
|
+
{
|
|
8
|
+
mount: '#app',
|
|
9
|
+
},
|
|
10
|
+
() => {
|
|
11
|
+
return () => (
|
|
12
|
+
<div class='inner'>
|
|
13
|
+
<h1>Hello Amazed.js</h1>
|
|
14
|
+
<div class='app-tool'>
|
|
15
|
+
<component $is={Home} />
|
|
16
|
+
<component $is={List} />
|
|
17
|
+
</div>
|
|
18
|
+
</div>
|
|
19
|
+
);
|
|
20
|
+
}
|
|
21
|
+
);
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
.listInner{
|
|
2
|
+
padding: 0;
|
|
3
|
+
margin: 0;
|
|
4
|
+
width: 400px;
|
|
5
|
+
}
|
|
6
|
+
.listInner li {
|
|
7
|
+
list-style: none;
|
|
8
|
+
text-align: center;
|
|
9
|
+
font-weight: bold;
|
|
10
|
+
padding: 10px;
|
|
11
|
+
margin: 10px 0;
|
|
12
|
+
background-color: #c6715b;
|
|
13
|
+
color: #fff;
|
|
14
|
+
border-radius: 20px;
|
|
15
|
+
animation: my1 1s ease-in;
|
|
16
|
+
}
|
|
17
|
+
.listInner button {
|
|
18
|
+
margin-top: 30px;
|
|
19
|
+
}
|
|
20
|
+
@keyframes my1 {
|
|
21
|
+
from {
|
|
22
|
+
opacity: 0.2;
|
|
23
|
+
}
|
|
24
|
+
to {
|
|
25
|
+
opacity: 1;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { defineComponent } from 'amazed';
|
|
2
|
+
|
|
3
|
+
const Home = defineComponent(({ setData }) => {
|
|
4
|
+
let count = 0;
|
|
5
|
+
|
|
6
|
+
function add() {
|
|
7
|
+
setData(() => {
|
|
8
|
+
count++;
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
return () => (
|
|
13
|
+
<fragment>
|
|
14
|
+
<button onClick={add}>Add</button>
|
|
15
|
+
<h1>{count}</h1>
|
|
16
|
+
<input value={count} />
|
|
17
|
+
</fragment>
|
|
18
|
+
);
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
export default Home;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { defineConfig } from 'vite';
|
|
2
|
+
import babel from 'vite-plugin-babel';
|
|
3
|
+
|
|
4
|
+
export default defineConfig({
|
|
5
|
+
// options
|
|
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
|
+
],
|
|
14
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# template-amazed-jsx-apps
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
.DS_Store
|
|
2
|
+
node_modules
|
|
3
|
+
/dist
|
|
4
|
+
/buildDir
|
|
5
|
+
.parcel-cache
|
|
6
|
+
|
|
7
|
+
# local env files
|
|
8
|
+
.env.local
|
|
9
|
+
.env.*.local
|
|
10
|
+
|
|
11
|
+
# Log files
|
|
12
|
+
npm-debug.log*
|
|
13
|
+
yarn-debug.log*
|
|
14
|
+
yarn-error.log*
|
|
15
|
+
pnpm-debug.log*
|
|
16
|
+
|
|
17
|
+
# Editor directories and files
|
|
18
|
+
.idea
|
|
19
|
+
.vscode
|
|
20
|
+
*.suo
|
|
21
|
+
*.ntvs*
|
|
22
|
+
*.njsproj
|
|
23
|
+
*.sln
|
|
24
|
+
*.sw?
|
|
25
|
+
yarn.lock
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
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>amazed.js</title>
|
|
7
|
+
</head>
|
|
8
|
+
|
|
9
|
+
<body>
|
|
10
|
+
<div id="app"></div>
|
|
11
|
+
<script type="module" src="/src/main.js"></script>
|
|
12
|
+
</body>
|
|
13
|
+
</html>
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "template-amazed-jsx-apps",
|
|
3
|
+
"version": "0.0.0",
|
|
4
|
+
"license": "MIT",
|
|
5
|
+
"scripts": {
|
|
6
|
+
"dev": "vite --open",
|
|
7
|
+
"serve": "vite preview",
|
|
8
|
+
"build": "vite build"
|
|
9
|
+
},
|
|
10
|
+
"devDependencies": {
|
|
11
|
+
"@babel/core": "^7.20.7",
|
|
12
|
+
"babel-plugin-jsx-to-amazed": "^0.0.4",
|
|
13
|
+
"babel-plugin-amazed": "^0.0.3",
|
|
14
|
+
"vite": "^4.0.0",
|
|
15
|
+
"vite-plugin-babel": "^1.1.3"
|
|
16
|
+
},
|
|
17
|
+
"dependencies": {
|
|
18
|
+
"amazed": "^0.0.2",
|
|
19
|
+
"amazed-router": "^0.0.4"
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { resetView } from 'amazed';
|
|
2
|
+
import { initRouter } from 'amazed-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,24 @@
|
|
|
1
|
+
import { defineComponent } from 'amazed';
|
|
2
|
+
import { linkTo, toParse } from 'amazed-router';
|
|
3
|
+
|
|
4
|
+
const about = () =>
|
|
5
|
+
defineComponent(() => {
|
|
6
|
+
function goHome() {
|
|
7
|
+
linkTo({
|
|
8
|
+
path: '/',
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
function getOption() {
|
|
13
|
+
console.log(toParse());
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
return () => (
|
|
17
|
+
<fragment>
|
|
18
|
+
<button onClick={goHome}>goHome</button>
|
|
19
|
+
<h1 onClick={getOption}>About</h1>
|
|
20
|
+
</fragment>
|
|
21
|
+
);
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
export default about;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { defineComponent } from 'amazed';
|
|
2
|
+
import { linkTo } from 'amazed-router';
|
|
3
|
+
|
|
4
|
+
const home = () =>
|
|
5
|
+
defineComponent(({ setData }) => {
|
|
6
|
+
const state = {
|
|
7
|
+
msg: 'hello',
|
|
8
|
+
arr: [1, 2],
|
|
9
|
+
count: 3,
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
function goAbout() {
|
|
13
|
+
linkTo({
|
|
14
|
+
path: '/about',
|
|
15
|
+
query: {
|
|
16
|
+
id: 1,
|
|
17
|
+
name: 'maomin',
|
|
18
|
+
},
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function useChange() {
|
|
23
|
+
setData(() => {
|
|
24
|
+
state.msg = 'world';
|
|
25
|
+
state.count++;
|
|
26
|
+
state.arr.unshift(state.count);
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
return () => (
|
|
31
|
+
<fragment>
|
|
32
|
+
<button onClick={goAbout}>goAbout</button>
|
|
33
|
+
<h1>Home</h1>
|
|
34
|
+
<p onClick={useChange}>{state.msg}</p>
|
|
35
|
+
<ul>
|
|
36
|
+
{state.arr.map((item) => (
|
|
37
|
+
<li key={item}>{item}</li>
|
|
38
|
+
))}
|
|
39
|
+
</ul>
|
|
40
|
+
</fragment>
|
|
41
|
+
);
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
export default home;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { defineConfig } from 'vite';
|
|
2
|
+
import babel from 'vite-plugin-babel';
|
|
3
|
+
|
|
4
|
+
export default defineConfig({
|
|
5
|
+
// options
|
|
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
|
+
],
|
|
14
|
+
});
|