@ecan-bi/datav 1.0.42 → 1.0.43

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/dist/index.umd.js CHANGED
@@ -1634,6 +1634,24 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
1634
1634
  }
1635
1635
  return false;
1636
1636
  };
1637
+ const useVariablesInText = (text, data) => {
1638
+ const config2 = window.config || {};
1639
+ data = __spreadValues(__spreadValues({}, config2), data);
1640
+ const variables = text.match(/\{.*?\}/g);
1641
+ if (variables == null || variables.length === 0)
1642
+ return text;
1643
+ for (let i = 0; i < variables.length; i++) {
1644
+ const variable = variables[i];
1645
+ const v = variable.slice(1, variable.length - 1);
1646
+ const usedVariable = data[v];
1647
+ if (usedVariable != null) {
1648
+ text = text.replace(variable, usedVariable);
1649
+ } else {
1650
+ text = text.replace(variable, "");
1651
+ }
1652
+ }
1653
+ return text;
1654
+ };
1637
1655
  const useRequestData = (props2, callBack = () => {
1638
1656
  }) => {
1639
1657
  const {
@@ -1671,23 +1689,25 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
1671
1689
  }
1672
1690
  _params[key] = v;
1673
1691
  } else if (typeof value === "string") {
1674
- _params[key] = value;
1692
+ _params[key] = useVariablesInText(value);
1675
1693
  }
1676
1694
  });
1677
1695
  _params = __spreadValues(__spreadValues({}, _params), params);
1678
1696
  let urlParams = "";
1679
1697
  const keys = Object.keys(_params);
1680
1698
  const last = keys.length - 1;
1699
+ const keysLen = keys.length;
1681
1700
  keys.forEach((key, index2) => {
1682
- switch (index2) {
1683
- case 0:
1701
+ if (index2 === 0) {
1702
+ if (keysLen !== 1) {
1684
1703
  urlParams += `?${key}=${_params[key]}&`;
1685
- break;
1686
- case last:
1687
- urlParams += `${key}=${_params[key]}`;
1688
- break;
1689
- default:
1690
- urlParams += `${key}=${_params[key]}&`;
1704
+ } else {
1705
+ urlParams += `?${key}=${_params[key]}`;
1706
+ }
1707
+ } else if (index2 === last) {
1708
+ urlParams += `${key}=${_params[key]}`;
1709
+ } else {
1710
+ urlParams += `${key}=${_params[key]}&`;
1691
1711
  }
1692
1712
  });
1693
1713
  try {
@@ -1781,25 +1801,6 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
1781
1801
  console.log(pageMode);
1782
1802
  return pageMode === "preview" ? envPageUrl : proPageUrl;
1783
1803
  };
1784
- const useVariablesInText = (text, data = {}) => {
1785
- var _a2;
1786
- const config2 = (_a2 = window.config) != null ? _a2 : {};
1787
- data = __spreadValues(__spreadValues({}, config2), data);
1788
- const variables = text.match(/\{.*?\}/g);
1789
- if (variables == null || variables.length === 0)
1790
- return text;
1791
- for (let i = 0; i < variables.length; i++) {
1792
- const variable = variables[i];
1793
- const v = variable.slice(1, variable.length - 1);
1794
- const usedVariables = data[v];
1795
- if (usedVariables != null) {
1796
- text = text.replace(variable, usedVariables);
1797
- } else {
1798
- text = text.replace(variable, "");
1799
- }
1800
- }
1801
- return text;
1802
- };
1803
1804
  const request = axios__default["default"].create({
1804
1805
  timeout: 1e3 * 10
1805
1806
  });
@@ -2391,7 +2392,19 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
2391
2392
  }
2392
2393
  };
2393
2394
  };
2394
- var PageConfig_vue_vue_type_style_index_0_scoped_true_lang = /* @__PURE__ */ (() => "#container[data-v-836b53bc] {\n position: fixed;\n top: 0;\n left: 0;\n overflow: hidden;\n transform-origin: left top;\n z-index: 999;\n}\n.page-config[data-v-836b53bc] {\n position: relative;\n overflow: hidden;\n background-size: cover;\n}\n")();
2395
+ const useHrefParamsToGlobalVariables = () => {
2396
+ const search = window.location.search;
2397
+ const params = search.slice(1).split("&");
2398
+ const len = params.length;
2399
+ for (let i = 0; i < len; i++) {
2400
+ const param = params[i];
2401
+ const keyAndValue = param.split("=");
2402
+ const key = keyAndValue[0];
2403
+ const value = keyAndValue[1];
2404
+ window.config[key] = value;
2405
+ }
2406
+ };
2407
+ var PageConfig_vue_vue_type_style_index_0_scoped_true_lang = /* @__PURE__ */ (() => "#container[data-v-5d709a9a] {\n position: fixed;\n top: 0;\n left: 0;\n overflow: hidden;\n transform-origin: left top;\n z-index: 999;\n}\n.page-config[data-v-5d709a9a] {\n position: relative;\n overflow: hidden;\n background-size: cover;\n}\n")();
2395
2408
  const _sfc_main$n = vue.defineComponent({
2396
2409
  name: "EcanPageConfig",
2397
2410
  props: __spreadValues({}, pageConfigComponentProps),
@@ -2501,7 +2514,7 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
2501
2514
  ], 4)) : vue.createCommentVNode("", true)
2502
2515
  ], 512);
2503
2516
  }
2504
- var PageConfig = /* @__PURE__ */ _export_sfc(_sfc_main$n, [["render", _sfc_render$n], ["__scopeId", "data-v-836b53bc"]]);
2517
+ var PageConfig = /* @__PURE__ */ _export_sfc(_sfc_main$n, [["render", _sfc_render$n], ["__scopeId", "data-v-5d709a9a"]]);
2505
2518
  const EcanPageConfig = withInstall(PageConfig);
2506
2519
  const providerConfig = {
2507
2520
  contextRequestUrl: "",
@@ -2513,6 +2526,7 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
2513
2526
  name: "EcanProviderConfig",
2514
2527
  props: __spreadValues({}, providerConfigComponentProps),
2515
2528
  setup(props2, { expose }) {
2529
+ useHrefParamsToGlobalVariables();
2516
2530
  const providerConfig2 = vue.ref();
2517
2531
  const setTheme = () => {
2518
2532
  providerConfig2.value.setAttribute("datav-theme", props2.theme);
@@ -3596,11 +3610,13 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
3596
3610
  text: "\u6309\u94AE",
3597
3611
  mode: "default",
3598
3612
  danger: false,
3599
- shape: "default"
3613
+ shape: "default",
3614
+ href: "",
3615
+ target: "_self"
3600
3616
  });
3601
3617
  const buttonComponentProps = transformToComponentProps(buttonProps);
3602
3618
  const buttonEvents = ["click"];
3603
- var Button_vue_vue_type_style_index_0_lang = /* @__PURE__ */ (() => ".ecan-button .ant-btn {\n width: 100%;\n height: 100%;\n}\n")();
3619
+ var Button_vue_vue_type_style_index_0_lang = /* @__PURE__ */ (() => ".ecan-button .ant-btn {\n width: 100%;\n height: 100%;\n display: flex;\n justify-content: center;\n align-items: center;\n}\n")();
3604
3620
  const _sfc_main$c = vue.defineComponent({
3605
3621
  name: "EcanButton",
3606
3622
  components: {
@@ -3612,9 +3628,19 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
3612
3628
  const events = props2.events;
3613
3629
  const emitEvent = useEmitEvent(events);
3614
3630
  const click = emitEvent("click");
3631
+ const myText = vue.computed(() => useVariablesInText(props2.text));
3632
+ const myHref = vue.computed(() => {
3633
+ const href = props2.href;
3634
+ if (href) {
3635
+ return useVariablesInText(href);
3636
+ }
3637
+ return void 0;
3638
+ });
3615
3639
  return {
3616
3640
  style: style2,
3617
- click
3641
+ click,
3642
+ myText,
3643
+ myHref
3618
3644
  };
3619
3645
  }
3620
3646
  });
@@ -3630,13 +3656,15 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
3630
3656
  type: _ctx.mode,
3631
3657
  danger: _ctx.danger,
3632
3658
  ghost: _ctx.ghost,
3633
- shape: _ctx.shape
3659
+ shape: _ctx.shape,
3660
+ href: _ctx.myHref,
3661
+ target: _ctx.target
3634
3662
  }, {
3635
3663
  default: vue.withCtx(() => [
3636
- vue.createTextVNode(vue.toDisplayString(_ctx.text), 1)
3664
+ vue.createTextVNode(vue.toDisplayString(_ctx.myText), 1)
3637
3665
  ]),
3638
3666
  _: 1
3639
- }, 8, ["onClick", "type", "danger", "ghost", "shape"])
3667
+ }, 8, ["onClick", "type", "danger", "ghost", "shape", "href", "target"])
3640
3668
  ], 4);
3641
3669
  }
3642
3670
  var Button = /* @__PURE__ */ _export_sfc(_sfc_main$c, [["render", _sfc_render$c]]);