@widget-js/cli 1.1.4 → 1.1.6

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@widget-js/cli",
3
- "version": "1.1.4",
3
+ "version": "1.1.6",
4
4
  "main": "lib/index.js",
5
5
  "author": "Neo Fu",
6
6
  "license": "MIT",
@@ -8,7 +8,6 @@
8
8
  "bin": {
9
9
  "widget": "lib/index.js"
10
10
  },
11
- "type": "module",
12
11
  "publishConfig": {
13
12
  "access": "public"
14
13
  },
@@ -22,20 +21,21 @@
22
21
  "@widget-js/ssh-config": "^4.2.1",
23
22
  "ali-oss": "^6.17.1",
24
23
  "archiver": "^5.3.1",
25
- "chalk": "^5.2.0",
24
+ "chalk": "^4.1.2",
26
25
  "change-case": "^4.1.2",
27
26
  "commander": "^9.4.1",
28
27
  "consola": "^2.15.3",
29
28
  "ejs": "^3.1.8",
30
29
  "figlet": "^1.5.2",
31
30
  "gradient-string": "^2.0.2",
32
- "inquirer": "^9.1.4",
31
+ "inquirer": "^8.0.0",
33
32
  "ora": "^6.2.0",
34
33
  "package-json": "^8.1.0",
35
34
  "semver": "^7.3.8",
36
35
  "shelljs": "^0.8.5",
37
36
  "ssh2-sftp-client": "^9.0.4",
38
- "ws": "^8.11.0"
37
+ "ws": "^8.11.0",
38
+ "@widget-js/utils": "0.7.7"
39
39
  },
40
40
  "devDependencies": {
41
41
  "@types/ali-oss": "^6.16.7",
@@ -49,7 +49,7 @@
49
49
  "@types/ssh2-sftp-client": "^9.0.0",
50
50
  "jest": "^29.5.0",
51
51
  "pinst": "^3.0.0",
52
- "prettier": "^2.8.4",
52
+ "prettier": "^2.8.8",
53
53
  "rimraf": "^4.4.1",
54
54
  "ts-jest": "^29.0.3",
55
55
  "ts-loader": "^9.4.1",
@@ -57,15 +57,17 @@
57
57
  "tsup": "^6.5.0",
58
58
  "typescript": "^4.9.4",
59
59
  "webpack": "^5.75.0",
60
- "webpack-cli": "^5.0.0"
60
+ "webpack-cli": "^5.0.0",
61
+ "@widget-js/core": "0.7.2"
61
62
  },
62
63
  "scripts": {
63
- "build": "rimraf ./lib/ && tsup src/index.ts --dts --format esm,cjs",
64
- "watch": "tsup src/index.ts --dts --format esm,cjs --watch",
64
+ "build": "rimraf ./lib/ && tsup src/index.ts --format cjs",
65
+ "watch": "tsup src/index.ts --format cjs --watch",
65
66
  "build:run": "npm run build && npm run widget",
66
67
  "prebuild": "",
67
68
  "widget": "node ./lib/index.js",
68
69
  "widget:ftp": "node ./lib/index.js release -t ftp",
70
+ "widget:create": "npm run build && node ./lib/index.js create",
69
71
  "pnpm:publish": "pnpm publish --no-git-checks"
70
72
  }
71
73
  }
@@ -1,7 +1,6 @@
1
1
  import path from "path";
2
2
  import fs from "fs";
3
3
  import consola from "consola";
4
- import {fileURLToPath} from "url";
5
4
  import promptChecker from "./promts/promptChecker";
6
5
  import {paramCase, snakeCase} from "change-case";
7
6
  import inquirer from "inquirer";
@@ -9,213 +8,219 @@ import ejs from "ejs";
9
8
  import shell from "shelljs";
10
9
  import exit from "./utils.js";
11
10
  import chalk from "chalk";
11
+ import {WidgetUtils} from "@widget-js/utils";
12
+ import prettier, {BuiltInParserName} from "prettier";
13
+
14
+ // import vm from "vm";
15
+
12
16
  interface RenderOptions {
13
- name: string,
14
- snakeCaseName: string,
15
- paramCaseName: string,
16
- packageName: string,
17
- title: string,
18
- configurable: string,
19
- width: number,
20
- height: number,
21
- maxWidth: number,
22
- minHeight: number,
23
- maxHeight: number,
24
- minWidth: number
17
+ name: string,
18
+ snakeCaseName: string,
19
+ paramCaseName: string,
20
+ packageName: string,
21
+ widgetName: string,
22
+ title: string,
23
+ configurable: string,
24
+ width: number,
25
+ height: number,
26
+ maxWidth: number,
27
+ minHeight: number,
28
+ maxHeight: number,
29
+ minWidth: number,
25
30
  }
26
- export default async function createWidget() {
27
- let widgetJson = path.join(process.cwd(), "widget.json");
28
- if (!fs.existsSync(widgetJson)) {
29
- consola.error("没有在根目录找到widget.json文件")
30
- exit();
31
- }
32
-
33
- let widgetPackage = JSON.parse(fs.readFileSync(widgetJson).toString());
34
31
 
35
- let widgetFolder = path.join(process.cwd(), "./src/widgets");
36
- let devOptions = widgetPackage["devOptions"] ?? {};
37
- if (devOptions["folder"]) {
38
- widgetFolder = devOptions["folder"];
39
- consola.info(`组件路径:${widgetFolder}`);
32
+ export default async function createWidget() {
33
+ let widgetPackage = await WidgetUtils.scanWidgetPackage(process.cwd());
34
+ if (!widgetPackage) {
35
+ consola.error("widget.ts or widget.json not found")
36
+ return;
37
+ }
38
+ let widgetFolder = path.join(process.cwd(), "./src/widgets");
39
+ let devOptions = widgetPackage["devOptions"] ?? {};
40
+ if (devOptions["folder"]) {
41
+ widgetFolder = devOptions["folder"];
42
+ consola.info(`组件路径:${widgetFolder}`);
43
+ } else {
44
+ consola.info(`没有配置devOptions.folder,使用默认路径${widgetFolder}`);
45
+ }
46
+
47
+ if (!fs.existsSync(widgetFolder)) {
48
+ fs.mkdirSync(widgetFolder, {recursive: true});
49
+ }
50
+
51
+ const getMiddleValue = (arr: number[]) => {
52
+ if (arr.length === 1) {
53
+ return arr[0];
54
+ } else if (arr.length === 2) {
55
+ return Math.max(...arr);
40
56
  } else {
41
- consola.info(`没有配置devOptions.folder,使用默认路径${widgetFolder}`);
42
- }
43
-
44
- if (!fs.existsSync(widgetFolder)) {
45
- fs.mkdirSync(widgetFolder, {recursive: true});
57
+ const max = Math.max(...arr);
58
+ const min = Math.min(...arr);
59
+ const sum = arr[0] + arr[1] + arr[2];
60
+ return sum - max - min;
46
61
  }
47
-
48
- const __filename = fileURLToPath(import.meta.url);
49
- const __dirname = path.dirname(__filename);
50
-
51
- const getMiddleValue = (arr:number[]) => {
52
- if (arr.length === 1) {
53
- return arr[0];
54
- } else if (arr.length === 2) {
55
- return Math.max(...arr);
56
- } else {
57
- const max = Math.max(...arr);
58
- const min = Math.min(...arr);
59
- const sum = arr[0] + arr[1] + arr[2];
60
- return sum - max - min;
61
- }
62
+ }
63
+
64
+ let name = await promptChecker({
65
+ type: "input",
66
+ name: 'name',
67
+ message: chalk.blue("请输入组件名(大驼峰式),如:CountdownClock")
68
+ }, (answer) => {
69
+ const name = answer.name;
70
+ if (name == null || name === '') {
71
+ consola.log(chalk.red('组件名不能为空'));
72
+ return false;
62
73
  }
63
-
64
- let name = await promptChecker({
65
- type: "input",
66
- name: 'name',
67
- message: chalk.blue("请输入组件名(大驼峰式),如:CountdownClock")
68
- }, (answer) => {
69
- const name = answer.name;
70
- if (name == null || name === '') {
71
- consola.log(chalk.red('组件名不能为空'));
72
- return false;
73
- }
74
- return true;
75
- })
76
-
77
- consola.log(chalk.green(name))
78
-
79
- let title = await promptChecker({
80
- type: "input",
81
- name: 'title',
82
- message: chalk.blue("请输入组件标题,如:倒计时")
83
- })
84
- consola.log(chalk.green(title))
85
- let answerW = await promptChecker({
86
- type: "checkbox",
87
- name: 'w',
88
- message: chalk.blue("请选择组件宽度,最多选3个,例如选中2,4,6,代表组件最小宽为2,默认宽为4,最大宽为6,单选代表不可拉伸"),
89
- choices: [1, 2, 3, 4, 5, 6]
90
- }, (answer) => {
91
- if (answer.w.length === 0) {
92
- consola.log(chalk.red('宽度必须选择'));
93
- return false;
94
- }
95
-
96
- if (answer.w.length > 3) {
97
- consola.log(chalk.red('宽度最多选择3个'));
98
- return false;
99
- }
100
- return true;
101
- })
102
- consola.log(chalk.green(answerW))
103
-
104
- let answerH = await promptChecker({
105
- type: "checkbox",
106
- name: 'h',
107
- message: chalk.blue("请选择组件高度,最多选3个,例如选中1,2,代表组件最小高为1,默认高为2,最大高为2,单选代表不可拉伸"),
108
- choices: [1, 2, 3, 4, 5, 6]
109
- }, (answer) => {
110
- if (answer.h.length === 0) {
111
- consola.log(chalk.red('高度必须选择'));
112
- return false;
113
- }
114
-
115
- if (answer.h.length > 3) {
116
- consola.log(chalk.red('高度最多选择3个'));
117
- return false;
118
- }
119
- return true;
120
- })
121
-
122
- consola.log(chalk.green(answerH))
123
-
124
- let configurable = await promptChecker({
125
- type: "confirm",
126
- name: 'configurable',
127
- message: chalk.blue("组件是否可配置,例如修改背景颜色,字体大小等")
128
- })
129
-
130
- consola.log(chalk.green(configurable))
131
-
132
- const width = getMiddleValue(answerW);
133
- const height = getMiddleValue(answerH);
134
- const minWidth = Math.min(...answerW);
135
- const maxWidth = Math.max(...answerW);
136
- const minHeight = Math.min(...answerH);
137
- const maxHeight = Math.max(...answerH);
138
- const snakeCaseName = snakeCase(name);
139
- const paramCaseName = paramCase(name);
140
- const packageName = "com.wisdom.widgets." + snakeCaseName;
141
-
142
- const widgetDir = path.join(widgetFolder, paramCaseName)
143
- if (!fs.existsSync(widgetDir)) {
144
- fs.mkdirSync(widgetDir);
145
- } else {
146
- let answer = await inquirer.prompt([{
147
- type: 'confirm',
148
- name: 'override',
149
- message: chalk.red('组件名已存在,是否继续?')
150
- }])
151
- if (!answer.override) {
152
- exit()
153
- }
74
+ return true;
75
+ })
76
+
77
+ consola.log(chalk.green(name))
78
+
79
+ let title = await promptChecker({
80
+ type: "input",
81
+ name: 'title',
82
+ message: chalk.blue("请输入组件标题,如:倒计时")
83
+ })
84
+ consola.log(chalk.green(title))
85
+ let answerW = await promptChecker({
86
+ type: "checkbox",
87
+ name: 'w',
88
+ message: chalk.blue("请选择组件宽度,最多选3个,例如选中2,4,6,代表组件最小宽为2,默认宽为4,最大宽为6,单选代表不可拉伸"),
89
+ choices: [1, 2, 3, 4, 5, 6]
90
+ }, (answer) => {
91
+ if (answer.w.length === 0) {
92
+ consola.log(chalk.red('宽度必须选择'));
93
+ return false;
154
94
  }
155
95
 
156
- const renderOptions:RenderOptions = {
157
- name: name,
158
- snakeCaseName: snakeCaseName,
159
- paramCaseName: paramCaseName,
160
- packageName: packageName,
161
- title: title,
162
- configurable: configurable,
163
- width: width,
164
- height: height,
165
- maxWidth: maxWidth,
166
- minHeight: minHeight,
167
- maxHeight: maxHeight,
168
- minWidth: minWidth
96
+ if (answer.w.length > 3) {
97
+ consola.log(chalk.red('宽度最多选择3个'));
98
+ return false;
169
99
  }
170
-
171
- function renderToFile(templateFile:string, outputFile:string, renderOptions:RenderOptions) {
172
- const defineTemplatePath = path.join(__dirname, '../template', templateFile)
173
- let defineTemplate = fs.readFileSync(defineTemplatePath, 'utf8');
174
- fs.writeFileSync(outputFile, ejs.render(defineTemplate, renderOptions))
100
+ return true;
101
+ })
102
+ consola.log(chalk.green(answerW))
103
+
104
+ let answerH = await promptChecker({
105
+ type: "checkbox",
106
+ name: 'h',
107
+ message: chalk.blue("请选择组件高度,最多选3个,例如选中1,2,代表组件最小高为1,默认高为2,最大高为2,单选代表不可拉伸"),
108
+ choices: [1, 2, 3, 4, 5, 6]
109
+ }, (answer) => {
110
+ if (answer.h.length === 0) {
111
+ consola.log(chalk.red('高度必须选择'));
112
+ return false;
175
113
  }
176
114
 
177
- const widgetDefineFile = path.resolve(widgetDir, `${name}.widget.ts`)
178
- const widgetFile = path.resolve(widgetDir, `${name}Widget.vue`);
179
- const widgetViewFile = path.resolve(widgetDir, `${name}WidgetView.vue`)
180
- const widgetRoutesFile = path.resolve(widgetDir, `${name}WidgetRoutes.ts`)
181
-
182
- renderToFile('WidgetDefine.ejs', widgetDefineFile, renderOptions);
183
- renderToFile('Widget.ejs', widgetFile, renderOptions);
184
- renderToFile('WidgetView.ejs', widgetViewFile, renderOptions);
185
- renderToFile('WidgetRoutes.ejs', widgetRoutesFile, renderOptions);
186
- if (configurable) {
187
- const configFile = path.resolve(widgetDir, `${name}ConfigView.vue`)
188
- renderToFile('WidgetConfig.ejs', configFile, renderOptions);
115
+ if (answer.h.length > 3) {
116
+ consola.log(chalk.red('高度最多选择3个'));
117
+ return false;
189
118
  }
190
- if (devOptions["useStorybook"]) {
191
- const storiesFile = path.resolve(widgetDir, `${name}Widget.stories.ts`)
192
- renderToFile('stories.ejs', storiesFile, renderOptions);
119
+ return true;
120
+ })
121
+
122
+ consola.log(chalk.green(answerH))
123
+
124
+ let configurable = await promptChecker({
125
+ type: "confirm",
126
+ name: 'configurable',
127
+ message: chalk.blue("组件是否可配置,例如修改背景颜色,字体大小等")
128
+ })
129
+
130
+ consola.log(chalk.green(configurable))
131
+
132
+ const width = getMiddleValue(answerW);
133
+ const height = getMiddleValue(answerH);
134
+ const minWidth = Math.min(...answerW);
135
+ const maxWidth = Math.max(...answerW);
136
+ const minHeight = Math.min(...answerH);
137
+ const maxHeight = Math.max(...answerH);
138
+ const snakeCaseName = snakeCase(name);
139
+ const paramCaseName = paramCase(name);
140
+
141
+ const widgetName = widgetPackage.name + '.' + snakeCaseName;
142
+
143
+ const widgetDir = path.join(widgetFolder, paramCaseName)
144
+ if (!fs.existsSync(widgetDir)) {
145
+ fs.mkdirSync(widgetDir);
146
+ } else {
147
+ let answer = await inquirer.prompt([{
148
+ type: 'confirm',
149
+ name: 'override',
150
+ message: chalk.red('组件名已存在,是否继续?')
151
+ }])
152
+ if (!answer.override) {
153
+ exit()
193
154
  }
194
-
155
+ }
156
+
157
+ const renderOptions: RenderOptions = {
158
+ name: name,
159
+ snakeCaseName: snakeCaseName,
160
+ paramCaseName: paramCaseName,
161
+ packageName: widgetPackage.name,
162
+ widgetName: widgetName,
163
+ title: title,
164
+ configurable: configurable,
165
+ width: width,
166
+ height: height,
167
+ maxWidth: maxWidth,
168
+ minHeight: minHeight,
169
+ maxHeight: maxHeight,
170
+ minWidth: minWidth
171
+ }
172
+
173
+ function renderToFile(templateFile: string, outputFile: string, parser: BuiltInParserName, renderOptions: RenderOptions) {
174
+ const defineTemplatePath = path.join(__dirname, '../template', templateFile)
175
+ let defineTemplate = fs.readFileSync(defineTemplatePath, 'utf8');
176
+ // Format the EJS code using Prettier
177
+
178
+ let code = ejs.render(defineTemplate, renderOptions);
179
+ let fileFormat = outputFile.split('.');
180
+ const formattedEJSCode = prettier.format(code, {
181
+ parser: parser, tabWidth: 2, singleQuote: true
182
+ });
183
+ fs.writeFileSync(outputFile, formattedEJSCode)
184
+ }
185
+
186
+ const widgetDefineFile = path.resolve(widgetDir, `${name}.widget.ts`)
187
+ const widgetFile = path.resolve(widgetDir, `${name}Widget.vue`);
188
+ const widgetViewFile = path.resolve(widgetDir, `${name}WidgetView.vue`)
189
+ const widgetRoutesFile = path.resolve(widgetDir, `${name}WidgetRoutes.ts`)
190
+
191
+ renderToFile('WidgetDefine.ejs', widgetDefineFile, 'typescript', renderOptions);
192
+ renderToFile('Widget.ejs', widgetFile, 'vue', renderOptions);
193
+ renderToFile('WidgetView.ejs', widgetViewFile, 'vue', renderOptions);
194
+ renderToFile('WidgetRoutes.ejs', widgetRoutesFile, 'typescript', renderOptions);
195
+ if (configurable) {
196
+ const configFile = path.resolve(widgetDir, `${name}ConfigView.vue`)
197
+ renderToFile('WidgetConfig.ejs', configFile, 'vue', renderOptions)
198
+ ;
199
+ }
195
200
  // 注册路由
196
- const routeFile = path.join(widgetFolder, 'widget-router.ts');
197
- let routeContent;
198
- if (fs.existsSync(routeFile)) {
199
- routeContent = fs.readFileSync(routeFile, 'utf8');
200
- } else {
201
- routeContent = fs.readFileSync(path.join(__dirname, "../template/widget-router.ts"), 'utf8');
202
- }
203
- const importRouteStr = `import ${name}WidgetRoutes from "./${paramCaseName}/${name}WidgetRoutes";`
204
- const routeStr = `...${name}WidgetRoutes,`
205
- if (!routeContent.includes(importRouteStr)) {
206
- routeContent = routeContent.replaceAll("//FBI WANING! IMPORT PLACE", `${importRouteStr}\n//FBI WANING! IMPORT PLACE`)
207
- }
208
- if (!routeContent.includes(routeStr)) {
209
- routeContent = routeContent.replaceAll("//FBI WANING! ROUTE PLACE", `${routeStr}\n //FBI WANING! ROUTE PLACE`)
210
- }
211
-
212
- fs.writeFileSync(routeFile, routeContent)
201
+ const routeFile = path.join(widgetFolder, 'widget-router.ts');
202
+ let routeContent;
203
+ if (fs.existsSync(routeFile)) {
204
+ routeContent = fs.readFileSync(routeFile, 'utf8');
205
+ } else {
206
+ routeContent = fs.readFileSync(path.join(__dirname, "../template/widget-router.ts"), 'utf8');
207
+ }
208
+ const importRouteStr = `import ${name}WidgetRoutes from "./${paramCaseName}/${name}WidgetRoutes";`
209
+ const routeStr = `...${name}WidgetRoutes,`
210
+ if (!routeContent.includes(importRouteStr)) {
211
+ routeContent = routeContent.replaceAll("//FBI WANING! IMPORT PLACE", `${importRouteStr}\n//FBI WANING! IMPORT PLACE`)
212
+ }
213
+ if (!routeContent.includes(routeStr)) {
214
+ routeContent = routeContent.replaceAll("//FBI WANING! ROUTE PLACE", `${routeStr}\n //FBI WANING! ROUTE PLACE`)
215
+ }
216
+
217
+ fs.writeFileSync(routeFile, routeContent)
213
218
 
214
219
  //添加到版本控制
215
- let gitAdd = `git add ${widgetDir}`;
216
- consola.info(chalk.grey(gitAdd))
217
- shell.exec(gitAdd);
218
- consola.log("=================")
219
- consola.info(`已创建组件:${widgetDir}`)
220
- consola.success("Happy coding!")
220
+ let gitAdd = `git add ${widgetDir}`;
221
+ consola.info(chalk.grey(gitAdd))
222
+ shell.exec(gitAdd);
223
+ consola.log("=================")
224
+ consola.info(`已创建组件:${widgetDir}`)
225
+ consola.success("Happy coding!")
221
226
  }
package/src/index.ts CHANGED
@@ -3,14 +3,11 @@ import fs from "fs";
3
3
  import path from "path";
4
4
  import * as process from "process";
5
5
 
6
- import {fileURLToPath} from "url";
7
6
  import figlet from "figlet";
8
7
  import gradient from "gradient-string";
9
8
 
10
- const __filename = fileURLToPath(import.meta.url);
11
- const __dirname = path.dirname(__filename);
12
9
  //
13
- const packageJsonPath = path.join(__dirname, "../package.json");
10
+ const packageJsonPath = path.join(process.cwd(), "package.json");
14
11
  let cliPackage = JSON.parse(fs.readFileSync(packageJsonPath).toString());
15
12
 
16
13
  console.log(gradient.pastel.multiline(figlet.textSync("widget-cli", {horizontalLayout: "full"})));
@@ -49,6 +49,9 @@ const release = async (options: any) => {
49
49
  if (!fs.existsSync(installerPath)) {
50
50
  installerPath = path.join(`./packaged/electron-${version}-setup-win-x64.exe`)
51
51
  }
52
+ if (!fs.existsSync(installerPath)) {
53
+ installerPath = path.join(`./packaged/app-${version}-setup-win-x64.exe`)
54
+ }
52
55
  const updateZipPath = path.join(`./packaged/update.zip`)
53
56
 
54
57
  console.log(chalk.blue('压缩更新文件中'))
@@ -2,11 +2,8 @@
2
2
  <!-- TODO 这里只写组件内容,不做自定义数据、业务处理 -->
3
3
  </template>
4
4
 
5
- <script lang="ts">
5
+ <script lang="ts" setup>
6
6
 
7
- export default {
8
- name: "<%= name %>Widget",
9
- }
10
7
  </script>
11
8
 
12
9
  <style scoped>
@@ -1,5 +1,4 @@
1
1
  <template>
2
-
3
2
  <widget-edit-dialog :widget-params="widgetParams" :option="widgetConfigOption"
4
3
  :widget-data="widgetData"
5
4
  @confirm="onSaveClick()">
@@ -9,35 +8,24 @@
9
8
  </widget-edit-dialog>
10
9
  </template>
11
10
 
12
- <script lang="ts">
13
-
14
- import <%= name %>Widget from "./<%= name%>Widget.vue";
15
- import {useWidget, WidgetConfigOption, WidgetEditDialog} from "@widget-js/vue3";
11
+ <script lang="ts" setup>
12
+ import {useWidget, WidgetConfigOption,WidgetEditDialog} from "@widget-js/vue3";
16
13
  import {WidgetData, WidgetDataApi} from "@widget-js/core";
17
14
  import {reactive} from "vue";
18
15
 
19
- export default {
20
- name: "",
21
- components: {<%= name %>Widget, WidgetEditDialog},
22
- setup() {
23
- const {widgetData, widgetParams} = useWidget(WidgetData)
16
+ const {widgetData, widgetParams} = useWidget(WidgetData)
24
17
 
25
- //修改成需要设置组件参数配置
26
- const widgetConfigOption = reactive(new WidgetConfigOption({
27
- custom: true,
28
- backgroundColor: true,
29
- borderRadius: true,
30
- preview: false
31
- }));
18
+ //修改成需要设置组件参数配置
19
+ const widgetConfigOption = reactive(new WidgetConfigOption({
20
+ custom: true,
21
+ backgroundColor: true,
22
+ borderRadius: true,
23
+ preview: false
24
+ }));
32
25
 
33
- return {widgetData, widgetParams, widgetConfigOption}
34
- },
35
- methods: {
36
- async onSaveClick() {
37
- await WidgetDataApi.save(this.widgetData);
38
- window.close();
39
- }
40
- }
26
+ const onSaveClick = async () => {
27
+ await WidgetDataApi.save(widgetData);
28
+ window.close();
41
29
  }
42
30
  </script>
43
31
 
@@ -1,41 +1,40 @@
1
1
  import {Widget, WidgetKeyword} from "@widget-js/core";
2
2
  //TODO 修改组件信息,标题,描述,关键词
3
- const name = "cn.widgetjs.widgets.<%= snakeCaseName%>";
3
+ const name = "<%= widgetName %>";
4
4
  //组件标题
5
- const title = {"zh-CN": "<%= title%>"};
5
+ const title = {"zh-CN": "<%= title %>"};
6
6
  //组件描述
7
7
  const description = {"zh-CN": ""};
8
8
  //组件关键词
9
9
  const keywords = [WidgetKeyword.RECOMMEND];
10
10
  //组件路由地址
11
- const url = "/widget/<%= snakeCaseName%>";
11
+ const url = "/widget/<%= snakeCaseName %>";
12
12
  //配置页路由地址
13
- const configUrl = <% if (configurable) { %>"/widget/config/<%= snakeCaseName%>"<% } else { %>undefined<% } %>;
13
+ const configUrl = <% if (configurable) { %>"/widget/config/<%= snakeCaseName %>"<% } else { %>undefined<% } %>;
14
14
  //组件关键词
15
15
  const <%= name %>WidgetDefine = new Widget({
16
- name: name,
17
- title: title,
18
- description: description,
19
- keywords: keywords,
20
- lang: "zh-CN",
21
- width: <%= width %>,
22
- height: <%= height %>,
23
- minWidth: <%= minWidth %>,
24
- maxWidth: <%= maxWidth %>,
25
- minHeight: <%= minHeight %>,
26
- maxHeight: <%= maxHeight %>,
27
- routes: [
28
- {
29
- url: url,
30
- name: 'index'
31
- },
32
- <% if (configurable) { %>
33
- {
34
- url: configUrl,
35
- name: 'config'
36
- },
37
- <% } %>
38
- ]
16
+ name: name,
17
+ title: title,
18
+ description: description,
19
+ keywords: keywords,
20
+ lang: "zh-CN",
21
+ width: <%= width %>,
22
+ height: <%= height %>,
23
+ minWidth: <%= minWidth %>,
24
+ maxWidth: <%= maxWidth %>,
25
+ minHeight: <%= minHeight %>,
26
+ maxHeight: <%= maxHeight %>,
27
+ routes: [
28
+ {
29
+ url: url,
30
+ name: 'index'
31
+ },
32
+ <% if (configurable) { %> {
33
+ url: configUrl,
34
+ name: 'config'
35
+ },
36
+ <% } %>
37
+ ]
39
38
  })
40
39
 
41
40
  export default <%= name %>WidgetDefine;