yunshangxie-admin/index.html

69 lines
2.0 KiB
HTML
Raw Permalink Normal View History

2024-04-18 13:44:38 +08:00
<!DOCTYPE html>
<html lang="zh-cn">
2024-06-18 09:33:08 +08:00
<head>
<meta charset="UTF-8"/>
<!-- <link rel="icon" href="/favicon.ico"/>-->
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
2024-04-18 13:44:38 +08:00
<title></title>
2024-06-18 09:33:08 +08:00
</head>
<body>
<div id="app"></div>
<script type="module" src="/src/main.jsx"></script>
</body>
2024-04-18 13:44:38 +08:00
2024-06-18 09:33:08 +08:00
<script>
window.global = window;
</script>
<script type="module">
import axios from 'axios';
import store from "@/store";
async function setFaviconFromApi() {
// console.log(111111);
// var faviconUrl =localStorage.getItem('ico');
// localStorage.setItem('ico', '');
// try {
// // 假设 API 端点为 /api/favicon-url 返回 favicon 的 URL
// // const response = await fetch('/api/favicon-url');
// // if (!response.ok) {
// // console.error('Failed to fetch favicon URL');
// // }
// // const faviconUrl = await response.text();
//
// // 动态创建 link 标签并设置属性
// const link = document.createElement('link');
// link.rel = 'icon';
// link.href = '/favicon.ico';
// document.head.appendChild(link);
// } catch (error) {
// console.error('Error setting favicon:', error);
// }
if(typeof (store.state.user.association)=='object'){
var association=store.state.user.association;
}else{
var association=JSON.parse(store.state.user.association);
}
console.log(association);
let formData = new FormData();
formData.append('association_id', association.association_id);
axios.post(store.state.user.apiUrl + '/api/common/icoImage', formData)
.then(response => {
console.log(response);
var ico=response.data.data;
const link = document.createElement('link');
link.rel = 'icon';
link.href = store.state.user.apiUrl+ico;
document.head.appendChild(link);
})
.catch(error => {
console.error('获取失败', error);
});
}
// 页面加载完成后执行
document.addEventListener('DOMContentLoaded', () => {
setFaviconFromApi();
});
</script>
2024-04-18 13:44:38 +08:00
</html>