ol-base-components 2.1.2 → 2.1.3
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 +1 -1
- package/src/api/runApi.js +4 -3
- package/src/globalData.js +17 -0
- package/src/package/index.js +8 -3
package/package.json
CHANGED
package/src/api/runApi.js
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
const fs = require("fs");
|
|
2
3
|
const path = require("path");
|
|
3
4
|
const SwaggerClient = require("swagger-client");
|
|
4
5
|
const Vue = require("vue"); // 引入 Vue
|
|
6
|
+
import globalData from "../globalData";
|
|
5
7
|
|
|
6
8
|
// const swaggerUrl = "http://220.179.249.140:20019/swagger/v1/swagger.json";
|
|
7
|
-
|
|
8
|
-
const swaggerUrl = Vue.prototype.$swaggerUrl || ""; // 使用 Vue.prototype 中的 url
|
|
9
|
+
const swaggerUrl = getGlobalData("swaggerUrl") || "";
|
|
9
10
|
const modulesDir =
|
|
10
|
-
|
|
11
|
+
getGlobalData("outputDir") || path.join(__dirname, "./modules");
|
|
11
12
|
|
|
12
13
|
SwaggerClient(swaggerUrl)
|
|
13
14
|
.then((client) => {
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// globalData.js
|
|
2
|
+
class GlobalData {
|
|
3
|
+
constructor() {
|
|
4
|
+
this.data = {};
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
set(key, value) {
|
|
8
|
+
this.data[key] = value;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
get(key) {
|
|
12
|
+
return this.data[key];
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const instance = new GlobalData();
|
|
17
|
+
export default instance;
|
package/src/package/index.js
CHANGED
|
@@ -2,6 +2,7 @@ import OlTable from "./table";
|
|
|
2
2
|
import OlSearch from "./formSearch";
|
|
3
3
|
import Dialog from "./dialog";
|
|
4
4
|
import SwaggerClient from "swagger-client";
|
|
5
|
+
import globalData from "../globalData";
|
|
5
6
|
|
|
6
7
|
const consoleTooltip = () => {
|
|
7
8
|
// 定义颜色和样式
|
|
@@ -188,11 +189,15 @@ const install = async function (
|
|
|
188
189
|
Vue,
|
|
189
190
|
options = {
|
|
190
191
|
swaggerUrl: "",
|
|
191
|
-
outputDir:
|
|
192
|
+
outputDir: "",
|
|
192
193
|
}
|
|
193
194
|
) {
|
|
194
|
-
if (options && options.swaggerUrl)
|
|
195
|
-
|
|
195
|
+
if (options && options.swaggerUrl)
|
|
196
|
+
globalData.set("swaggerUrl", options.swaggerUrl);
|
|
197
|
+
if (options && options.outputDir)
|
|
198
|
+
globalData.set("outputDir", options.outputDir);
|
|
199
|
+
|
|
200
|
+
// 设置全局数据
|
|
196
201
|
components.map((item) => {
|
|
197
202
|
Vue.component(`ol-${item.name}`, item);
|
|
198
203
|
});
|