<!DOCTYPE html>
<html>

<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width,initial-scale=1.0">
  <title></title>
  <link id="fav_icon" rel="icon" href="" type="image/x-icon">
  <% if(htmlWebpackPlugin.vite){%>
  <!--
  <vite>
  {
      "module_vmid": "module",
      "project_vmid": "project"
  }
  </vite>
  -->
  <!--预览时 公共库-->
  <link rel="stylesheet" href="/assets_platform/element-ui/index.css">
  <link rel="stylesheet" href="<%=VITE_APP_BASE_API%>/sysfunc/runtime/desktopTheme/desktopThemeInterface.sgm?pn=<%=VITE_APP_PN%>&id=element">
  <link rel="stylesheet" href="<%=VITE_APP_BASE_API%>/sysfunc/runtime/desktopTheme/desktopThemeInterface.sgm?pn=<%=VITE_APP_PN%>&id=hivuimain">
  <!-- <script src="/assets_platform/zrender/zrender.min.js"></script> -->
  <script src="/assets_platform/vue/vue.min.js"></script>
  <script src="/assets_platform/vuex/vuex.min.js"></script>
  <script src="/assets_platform/vue-router/vue-router.min.js"></script>
  <script src="/assets_platform/element-ui/index.js"></script>
  <script src="/assets_platform/eap/eap.umd.min.js"></script>

  <script type="text/javascript">
      // Don't register the service worker
      // until the page has fully loaded
      // Is service worker available?
      if ('serviceWorker' in navigator) {
          // 在页面加载时检查是否已经注册了 Service Worker
          navigator.serviceWorker.getRegistrations().then(function (registrations){
              var len = registrations.length;
              if (len > 0) {
                  console.log('Service Worker already registered');
              } else {
                  // 如果没有注册，那么进行注册
                  window.addEventListener('load', function(){
                      navigator.serviceWorker.register('/assets_platform/workbox3/sw.js',{scope:'/'})
                          .then(registration => {
                              console.log('Service Worker registered: ', registration);
                          })
                          .catch(error => {
                              console.error('Service Worker registration failed: ', error);
                          });
                  });
              }
          });
      }
  </script>
  <%}%>

  <% if(!htmlWebpackPlugin.vite){%>
  <link rel="stylesheet" href="${serverPath}/render/assets_platform/element-ui/index.css">
  <link rel="stylesheet" href="${serverPath}/sysfunc/runtime/desktopTheme/desktopThemeInterface.sgm?pn=${projectName}/${devGroup}&id=element">
  <link rel="stylesheet" href="${serverPath}/sysfunc/runtime/desktopTheme/desktopThemeInterface.sgm?pn=${projectName}/${devGroup}&id=hivuimain">
  <!-- <script src="${serverPath}/render/assets_platform/zrender/zrender.min.js"></script> -->
  <script src="${serverPath}/render/assets_platform/vue/vue.min.js"></script>
  <script src="${serverPath}/render/assets_platform/vuex/vuex.min.js"></script>
  <script src="${serverPath}/render/assets_platform/vue-router/vue-router.min.js"></script>
  <script src="${serverPath}/render/assets_platform/element-ui/index.js"></script>


  <script src="${serverPath}/render/assets_platform/vue-i18n/vue-i18n.js"></script>
  <script src="${serverPath}/render/${devGroup}/${projectName}/lang/element-ui/${locale}.js"></script>
  <script src="${serverPath}/render/${devGroup}/${projectName}/hivuiLogin/lang/zh-CN.js"></script>
  <!--<script src="${serverPath}/render/${devGroup}/${projectName}/lang/desktop/hi-ui/${locale}.js"></script>
  <script src="${serverPath}/${devGroup}/${projectName}/lang/project/desktop/${locale}.js"></script> -->
  <script src="${serverPath}/lang/ref?pn=${projectName}/${devGroup}&vmId=hiui&filePath=${devGroup}/${projectName}/lang/hi-ui/def.language&locale=${locale}"></script>
  <script src="${serverPath}/lang/ref?pn=${projectName}/${devGroup}&vmId=tpl&filePath=${devGroup}/${projectName}/hivuiLogin/lang/def.language&locale=${locale}"></script>
  <script src="${serverPath}/lang/static?pn=${projectName}/${devGroup}&vmId=project"></script>
  <script src="${serverPath}/render/assets_platform/eap/eap.umd.min.js"></script>

  <script>
    try{
      window.global={
              pName:"${projectName}",
              pUser:"${devGroup}",
              pn:"${projectName}/${devGroup}"
            }
      // 统一输出语言包 zh-CN 名
      if(!window.GLOBAL_LANG_TPL){
        console.error(window.location.href+',当前模板语言包不存在')
      }
      if(!window.GLOBAL_LANG_HIUI){
        console.error(window.location.href+',hiui语言包不存在')
      }
      window.lang = window.lang ||{};
      window.lang.keys = Object.assign({},window.GLOBAL_LANG_TPL||{},window.GLOBAL_LANG_HIUI||{},window.GLOBAL_LANG_PROJECT||{},window.GLOBAL_LANG_MODULE||{});
      Vue.prototype._i18n  = new VueI18n({
        locale: 'localelang',
        messages: {
          'localelang':window.lang.keys,
        },
        silentTranslationWarn: true, // 去除国际化警告
      });
      (function(lang){
          lang = lang.split('-');
          lang= lang[0]+((lang[1]||'').charAt(0).toUpperCase() + (lang[1]||'').slice(1));
          ELEMENT.locale(ELEMENT.lang[lang])
      })('${locale}');
    }catch(e){
      console.log('语言包加载出错！')
    }
  </script>

  <!--发布时 公共库-->
  <!-- <script src="${serverPath}/render/assets_platform/vendor_dll/vuelibs.dll.js"></script> -->
  <script src="${serverPath}/render/assets_platform/vendor_dll/vendor.dll.js"></script>
  <script src="${serverPath}/render/assets_platform/customSysCfg/index.js"></script>
  <script src="${serverPath}/vm/render/${devGroup}/${projectName}/setting/desktop/base.js"></script>
  <script src="${serverPath}/render/${devGroup}/${projectName}/setting/desktop/appsetting.js"></script>

  <%}%>
</head>

<body>
  <div id="app">
      <div style="padding:50px 0;text-align:center;">
          <div>
            <img id="main_loading_logo" style="display:none;" src="" />
            <div id="hide_loading_logo" style="display:none;height:230px;width:230px;margin:auto;"></div>
          </div>
          <div><span class="sysInit"></span><a href="javascript:location.reload();"><span class="clickRefresh"></span></a></div>

        </div>
  </div>
  <script>
    if(window.GLOBAL_LANG_TPL){
      document.querySelector(".sysInit").innerText=window.GLOBAL_LANG_TPL.hivuiLogin_sysInit;
      document.querySelector(".clickRefresh").innerText=window.GLOBAL_LANG_TPL.hivuiLogin_clickRefresh;
    }
    let _img=window.customSysCofig&&window.customSysCofig.sysLoadLogo&&window.customSysCofig.sysLoadLogo.src;
    if(_img && window.customSysCofig.sysLoadLogo.hide){
      document.getElementById("hide_loading_logo").style.display="block";
    }else{
      document.getElementById("main_loading_logo").src = (_img || (window._global ? "./assets/logo_max.png" : "./static/img/logo_max.png"));
      document.getElementById("main_loading_logo").style.display="inline";
    }


    if(window.customSysCofig){
      if(window.customSysCofig.syTitle){
        document.title=window.customSysCofig.syTitle;
      }
      if(window.customSysCofig.loginTitle){
        document.title=window.customSysCofig.loginTitle;
      }
      if(window.customSysCofig.favicon){
        document.getElementById("fav_icon").href=window.customSysCofig.favicon;
      }

    }
    <% if(!htmlWebpackPlugin.vite){%>
    window.__loginCfg={
      pageType:"${pageType}",
      redirect:"${redirect}",
    }
    <%}%>
  </script>
  <% if(htmlWebpackPlugin.vite==true){%>
    <script type="module" src="/<%=htmlWebpackPlugin.project%>/hivuiLogin/index.js"></script>
  <script>
      //预览时判断60s还没有加载完，自动重刷
      var _winLoadedCtrl = window.setInterval(function(){
          if(document.getElementById("main_loading_logo")){
            window.location.reload();
          }else{
            window.clearInterval(_winLoadedCtrl);
          }
        },60*1000)
    </script>
  <%}%>
  <!-- built files will be auto injected -->
</body>

</html>