@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.es.js CHANGED
@@ -1624,6 +1624,24 @@ const lowerCaseIncludes = (v1, v2) => {
1624
1624
  }
1625
1625
  return false;
1626
1626
  };
1627
+ const useVariablesInText = (text, data) => {
1628
+ const config2 = window.config || {};
1629
+ data = __spreadValues(__spreadValues({}, config2), data);
1630
+ const variables = text.match(/\{.*?\}/g);
1631
+ if (variables == null || variables.length === 0)
1632
+ return text;
1633
+ for (let i = 0; i < variables.length; i++) {
1634
+ const variable = variables[i];
1635
+ const v = variable.slice(1, variable.length - 1);
1636
+ const usedVariable = data[v];
1637
+ if (usedVariable != null) {
1638
+ text = text.replace(variable, usedVariable);
1639
+ } else {
1640
+ text = text.replace(variable, "");
1641
+ }
1642
+ }
1643
+ return text;
1644
+ };
1627
1645
  const useRequestData = (props2, callBack = () => {
1628
1646
  }) => {
1629
1647
  const {
@@ -1661,23 +1679,25 @@ const useRequestData = (props2, callBack = () => {
1661
1679
  }
1662
1680
  _params[key] = v;
1663
1681
  } else if (typeof value === "string") {
1664
- _params[key] = value;
1682
+ _params[key] = useVariablesInText(value);
1665
1683
  }
1666
1684
  });
1667
1685
  _params = __spreadValues(__spreadValues({}, _params), params);
1668
1686
  let urlParams = "";
1669
1687
  const keys = Object.keys(_params);
1670
1688
  const last = keys.length - 1;
1689
+ const keysLen = keys.length;
1671
1690
  keys.forEach((key, index2) => {
1672
- switch (index2) {
1673
- case 0:
1691
+ if (index2 === 0) {
1692
+ if (keysLen !== 1) {
1674
1693
  urlParams += `?${key}=${_params[key]}&`;
1675
- break;
1676
- case last:
1677
- urlParams += `${key}=${_params[key]}`;
1678
- break;
1679
- default:
1680
- urlParams += `${key}=${_params[key]}&`;
1694
+ } else {
1695
+ urlParams += `?${key}=${_params[key]}`;
1696
+ }
1697
+ } else if (index2 === last) {
1698
+ urlParams += `${key}=${_params[key]}`;
1699
+ } else {
1700
+ urlParams += `${key}=${_params[key]}&`;
1681
1701
  }
1682
1702
  });
1683
1703
  try {
@@ -1771,25 +1791,6 @@ const usePageUrl = (pageMode, pageId) => {
1771
1791
  console.log(pageMode);
1772
1792
  return pageMode === "preview" ? envPageUrl : proPageUrl;
1773
1793
  };
1774
- const useVariablesInText = (text, data = {}) => {
1775
- var _a2;
1776
- const config2 = (_a2 = window.config) != null ? _a2 : {};
1777
- data = __spreadValues(__spreadValues({}, config2), data);
1778
- const variables = text.match(/\{.*?\}/g);
1779
- if (variables == null || variables.length === 0)
1780
- return text;
1781
- for (let i = 0; i < variables.length; i++) {
1782
- const variable = variables[i];
1783
- const v = variable.slice(1, variable.length - 1);
1784
- const usedVariables = data[v];
1785
- if (usedVariables != null) {
1786
- text = text.replace(variable, usedVariables);
1787
- } else {
1788
- text = text.replace(variable, "");
1789
- }
1790
- }
1791
- return text;
1792
- };
1793
1794
  const request = axios.create({
1794
1795
  timeout: 1e3 * 10
1795
1796
  });
@@ -2381,7 +2382,19 @@ const useIndicatorData = (props2 = {}) => {
2381
2382
  }
2382
2383
  };
2383
2384
  };
2384
- 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")();
2385
+ const useHrefParamsToGlobalVariables = () => {
2386
+ const search = window.location.search;
2387
+ const params = search.slice(1).split("&");
2388
+ const len = params.length;
2389
+ for (let i = 0; i < len; i++) {
2390
+ const param = params[i];
2391
+ const keyAndValue = param.split("=");
2392
+ const key = keyAndValue[0];
2393
+ const value = keyAndValue[1];
2394
+ window.config[key] = value;
2395
+ }
2396
+ };
2397
+ 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")();
2385
2398
  const _sfc_main$n = defineComponent({
2386
2399
  name: "EcanPageConfig",
2387
2400
  props: __spreadValues({}, pageConfigComponentProps),
@@ -2491,7 +2504,7 @@ function _sfc_render$n(_ctx, _cache, $props, $setup, $data, $options) {
2491
2504
  ], 4)) : createCommentVNode("", true)
2492
2505
  ], 512);
2493
2506
  }
2494
- var PageConfig = /* @__PURE__ */ _export_sfc(_sfc_main$n, [["render", _sfc_render$n], ["__scopeId", "data-v-836b53bc"]]);
2507
+ var PageConfig = /* @__PURE__ */ _export_sfc(_sfc_main$n, [["render", _sfc_render$n], ["__scopeId", "data-v-5d709a9a"]]);
2495
2508
  const EcanPageConfig = withInstall(PageConfig);
2496
2509
  const providerConfig = {
2497
2510
  contextRequestUrl: "",
@@ -2503,6 +2516,7 @@ const _sfc_main$m = defineComponent({
2503
2516
  name: "EcanProviderConfig",
2504
2517
  props: __spreadValues({}, providerConfigComponentProps),
2505
2518
  setup(props2, { expose }) {
2519
+ useHrefParamsToGlobalVariables();
2506
2520
  const providerConfig2 = ref();
2507
2521
  const setTheme = () => {
2508
2522
  providerConfig2.value.setAttribute("datav-theme", props2.theme);
@@ -3586,11 +3600,13 @@ const buttonProps = __spreadProps(__spreadValues({}, props), {
3586
3600
  text: "\u6309\u94AE",
3587
3601
  mode: "default",
3588
3602
  danger: false,
3589
- shape: "default"
3603
+ shape: "default",
3604
+ href: "",
3605
+ target: "_self"
3590
3606
  });
3591
3607
  const buttonComponentProps = transformToComponentProps(buttonProps);
3592
3608
  const buttonEvents = ["click"];
3593
- var Button_vue_vue_type_style_index_0_lang = /* @__PURE__ */ (() => ".ecan-button .ant-btn {\n width: 100%;\n height: 100%;\n}\n")();
3609
+ 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")();
3594
3610
  const _sfc_main$c = defineComponent({
3595
3611
  name: "EcanButton",
3596
3612
  components: {
@@ -3602,9 +3618,19 @@ const _sfc_main$c = defineComponent({
3602
3618
  const events = props2.events;
3603
3619
  const emitEvent = useEmitEvent(events);
3604
3620
  const click = emitEvent("click");
3621
+ const myText = computed(() => useVariablesInText(props2.text));
3622
+ const myHref = computed(() => {
3623
+ const href = props2.href;
3624
+ if (href) {
3625
+ return useVariablesInText(href);
3626
+ }
3627
+ return void 0;
3628
+ });
3605
3629
  return {
3606
3630
  style: style2,
3607
- click
3631
+ click,
3632
+ myText,
3633
+ myHref
3608
3634
  };
3609
3635
  }
3610
3636
  });
@@ -3620,13 +3646,15 @@ function _sfc_render$c(_ctx, _cache, $props, $setup, $data, $options) {
3620
3646
  type: _ctx.mode,
3621
3647
  danger: _ctx.danger,
3622
3648
  ghost: _ctx.ghost,
3623
- shape: _ctx.shape
3649
+ shape: _ctx.shape,
3650
+ href: _ctx.myHref,
3651
+ target: _ctx.target
3624
3652
  }, {
3625
3653
  default: withCtx(() => [
3626
- createTextVNode(toDisplayString(_ctx.text), 1)
3654
+ createTextVNode(toDisplayString(_ctx.myText), 1)
3627
3655
  ]),
3628
3656
  _: 1
3629
- }, 8, ["onClick", "type", "danger", "ghost", "shape"])
3657
+ }, 8, ["onClick", "type", "danger", "ghost", "shape", "href", "target"])
3630
3658
  ], 4);
3631
3659
  }
3632
3660
  var Button = /* @__PURE__ */ _export_sfc(_sfc_main$c, [["render", _sfc_render$c]]);