ol-base-components 2.1.1 → 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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ol-base-components",
3
- "version": "2.1.1",
3
+ "version": "2.1.3",
4
4
  "private": false,
5
5
  "main": "src/package/index.js",
6
6
  "bin": {
package/src/api/runApi.js CHANGED
@@ -1,12 +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 modulesDir = Vue.prototype.$outputDir || path.join(__dirname, "./modules"); // 使用 Vue.prototype 中的 outputDir
9
+ const swaggerUrl = getGlobalData("swaggerUrl") || "";
10
+ const modulesDir =
11
+ getGlobalData("outputDir") || path.join(__dirname, "./modules");
10
12
 
11
13
  SwaggerClient(swaggerUrl)
12
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;
@@ -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
  // 定义颜色和样式
@@ -187,10 +188,16 @@ function hideLoading() {
187
188
  const install = async function (
188
189
  Vue,
189
190
  options = {
190
- url: "",
191
+ swaggerUrl: "",
192
+ outputDir: "",
191
193
  }
192
194
  ) {
193
- if (options && options.url) Vue.prototype.$swaggerUrl = options.url;
195
+ if (options && options.swaggerUrl)
196
+ globalData.set("swaggerUrl", options.swaggerUrl);
197
+ if (options && options.outputDir)
198
+ globalData.set("outputDir", options.outputDir);
199
+
200
+ // 设置全局数据
194
201
  components.map((item) => {
195
202
  Vue.component(`ol-${item.name}`, item);
196
203
  });