<!--
 * @Author: Jason Liu
 * @Date: 2022-03-10 09:45:34
 * @Desc: 
-->
<template>
  <div id="app" :class="['app', appType]">
    <a-config-provider :locale="locale">
      <router-view />
    </a-config-provider>
  </div>
</template>

<script>
const antLane = {
  zh_CN: require("ant-design-vue/lib/locale-provider/zh_CN").default,
  en_US: require("ant-design-vue/lib/locale-provider/en_US").default,
  zh_HK: require("ant-design-vue/lib/locale-provider/zh_TW").default,
  pt_PT: require("ant-design-vue/lib/locale-provider/pt_PT").default,
  es_ES: require("ant-design-vue/lib/locale-provider/es_ES").default,
};
const { sysConfigByKeys } = require("w-vue-middle/api/appService");

import zhCN from "ant-design-vue/lib/locale-provider/zh_CN";
export default {
  name: "App",
  provide() {
    return {
      reload: this.reload,
    };
  },
  data() {
    return {
      themes: "winning_60",
      appType: undefined,
      isRouterAlive: true,
      locale: zhCN,
    };
  },
  computed: {
    antLocale() {
      return antLane[$winexI18n.LanName];
    },
  },
  created() {
    document.body.className = this.themes;
    this.getBiCaliberUrl();
  },
  mounted() {},
  methods: {
    /**
     * @Author: Jason Liu
     * @description: 获取BI服务应用信息
     */
    getBiCaliberUrl() {
      const systemConfigKeys = [
        "biCaliber.url", //
        "biCispatch.url", //BI调度地址
        "metadata.hdw.default.source", //默认数据源
        "metadata.hdw.default.target",
      ]; //系统参数清单
      sysConfigByKeys(systemConfigKeys.join(",")).then((req) => {
        systemConfigKeys.forEach((key) => {
          let config = req.data.find((item) => {
            return item.configKey == key;
          }) || { configValue: "0" };

          let appParameterName = key.replaceAll(".", "_");
          $storage.set(appParameterName, config.configValue);
        });

        return req;
      });
    },
    /**
     * @descripttion: 页面重载
     * @return {*}
     */
    reload() {
      this.isRouterAlive = false;
      this.$nextTick(function () {
        this.isRouterAlive = true;
      });
    },
  },
};
</script>
