70 lines
		
	
	
		
			2.1 KiB
		
	
	
	
		
			HTML
		
	
	
	
	
	
			
		
		
	
	
			70 lines
		
	
	
		
			2.1 KiB
		
	
	
	
		
			HTML
		
	
	
	
	
	
<!DOCTYPE html>
 | 
						|
<html lang="zh-cn">
 | 
						|
<head>
 | 
						|
    <meta charset="UTF-8"/>
 | 
						|
<!--    <link rel="icon" href="/favicon.ico"/>-->
 | 
						|
    <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
 | 
						|
    <meta name="referer" content="no-referrer">
 | 
						|
    <title></title>
 | 
						|
</head>
 | 
						|
<body>
 | 
						|
<div id="app"></div>
 | 
						|
<script type="module" src="/src/main.jsx"></script>
 | 
						|
</body>
 | 
						|
 | 
						|
<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', 1);
 | 
						|
    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>
 | 
						|
</html>
 |