<template>
  <ConfigProvider :locale="getAntdLocale">
    <AppProvider>
      <RouterView />
    </AppProvider>
  </ConfigProvider>
</template>

<script lang="ts" setup>
  import { ConfigProvider } from 'ant-design-vue';
  import { AppProvider } from '/@/components/Application';
  import { useTitle } from '/@/hooks/web/useTitle';
  import { useLocale } from '/@/locales/useLocale';
  // import { useLocale } from '/@/locales/useLocale';
  import { useUserStoreWithOut } from '/@/store/modules/user';
  import { useAppStoreWithOut } from '/@/store/modules/app';
  import { addressKey } from '/@/api/jyUserPlatform/index';
  import { useMessage } from '/@/hooks/web/useMessage';

  // support Multi-language
  const { createConfirm } = useMessage();
  const { getAntdLocale } = useLocale();
  const appStore = useAppStoreWithOut();
  let token = localStorage.getItem('token');
  if (token) {
    const userStore = useUserStoreWithOut();
    userStore.setToken(token);
    // localStorage.removeItem('token');
  }
  function getUrlParams2() {
    let url = window.location.href
    let urlStr = url.split('?')[1]
    const urlSearchParams = new URLSearchParams(urlStr)
    const result = Object.fromEntries(urlSearchParams.entries())
    let address = result['key']
    if(address){
      addressKey(address).then(res => {
        if(res.status == 1){
          createConfirm({
            iconType: 'warning',
            title: '警告',
            content: `此平台已被禁用`,
            onOk: async () => {
              onClose()
            },
            onCancel: async () => {
              onClose()
            },
          });
          return
        }
        appStore.setTitle(res.platformName);
      })
    }
  }
  const onClose = () => {
    window.opener = null;
    window.open('about:blank', '_top')?.close();
  };
  getUrlParams2()
  // Listening to page changes and dynamically changing site titles
  useTitle();
</script>

<style lang="less">
.desc-wrap-BasicTable {
  background-color: #f0f2f5;
  .vben-basic-table-form-container {
    padding: 0;
  }
}
.ant-checkbox-disabled + span {
  color: rgba(0, 0, 0, 0.85) !important;
}

</style>
