数据层
设置站点信息
setSiteInfo() {
const url = window.location.host;
siteApi(url).then((res) => {
const resData = res || {};
this.siteInfo.siteLogo = resData.frontEndLogo;
this.siteInfo.siteName = resData.frontEndName;
this.siteInfo.siteDefaultName = import.meta.env.VITE_GLOB_APP_TITLE;
if (resData.frontEndLogo) {
const linkDom: any = document.querySelector('link[rel="icon"]');
if (linkDom) linkDom.href = this.siteInfo.siteLogo;
}
});
}
视图层
<!DOCTYPE html>
<html lang="zh-cn" id="htmlRoot">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<meta name="renderer" content="webkit" />
<meta
name="viewport"
content="width=device-width,initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.0,user-scalable=0"
/>
<title><%= title %></title>
<link rel="icon" href="/favicon.ico" />
<script>
this.globalThis || (this.globalThis = this);
</script>
</head>
<body>
<script>
(() => {
var htmlRoot = document.getElementById('htmlRoot');
var theme = window.localStorage.getItem('__APP__DARK__MODE__');
if (htmlRoot && theme) {
htmlRoot.setAttribute('data-theme', theme);
theme = htmlRoot = null;
}
})();
</script>
<div id="app">
<div class="app-loading">
<div class="app-loading-wrap">
</div>
<div class="app-loading-title"><%= title %></div>
</div>
</div>
<script src="/resource/omg/omg.min.js"></script>
<script type="module" src="/src/main.ts"></script>
</body>
</html>