首页闪屏修复
This commit is contained in:
parent
18e3f0f987
commit
cc40ecd35d
|
|
@ -4,49 +4,9 @@ import {
|
||||||
iotSolutionsData,
|
iotSolutionsData,
|
||||||
multiScenarioData,
|
multiScenarioData,
|
||||||
softwareDevelopmentData,
|
softwareDevelopmentData,
|
||||||
smartHardwareData,
|
smartHardwareData
|
||||||
pageConfig
|
|
||||||
} from '~/data/indexData'
|
} from '~/data/indexData'
|
||||||
|
|
||||||
// 动态加载资源
|
|
||||||
const loadResources = () => {
|
|
||||||
// 加载CSS
|
|
||||||
pageConfig.cssFiles.forEach(href => {
|
|
||||||
if (!document.querySelector(`link[href="${href}"]`)) {
|
|
||||||
const link = document.createElement('link')
|
|
||||||
link.rel = 'stylesheet'
|
|
||||||
link.href = href
|
|
||||||
link.type = 'text/css'
|
|
||||||
document.head.appendChild(link)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
// 加载JS
|
|
||||||
pageConfig.jsFiles.forEach(src => {
|
|
||||||
if (!document.querySelector(`script[src="${src}"]`)) {
|
|
||||||
const script = document.createElement('script')
|
|
||||||
script.src = src
|
|
||||||
script.type = 'text/javascript'
|
|
||||||
document.head.appendChild(script)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
// 添加favicon
|
|
||||||
if (!document.querySelector('link[rel="shortcut icon"]')) {
|
|
||||||
const link = document.createElement('link')
|
|
||||||
link.rel = 'shortcut icon'
|
|
||||||
link.href = pageConfig.favicon
|
|
||||||
document.head.appendChild(link)
|
|
||||||
}
|
|
||||||
|
|
||||||
// 加载百度统计
|
|
||||||
const protocol = window.location.protocol === 'https:' ? 'https://' : 'http://'
|
|
||||||
const script = document.createElement('script')
|
|
||||||
script.src = `${protocol}hm.baidu.com/h.js?${pageConfig.baiduAnalytics}`
|
|
||||||
script.type = 'text/javascript'
|
|
||||||
document.head.appendChild(script)
|
|
||||||
}
|
|
||||||
|
|
||||||
// 处理锚点链接
|
// 处理锚点链接
|
||||||
const handleAnchorLinks = () => {
|
const handleAnchorLinks = () => {
|
||||||
if (window.location.hash) {
|
if (window.location.hash) {
|
||||||
|
|
@ -86,7 +46,6 @@ const handleDropdownImageHover = (index: number) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
loadResources()
|
|
||||||
handleAnchorLinks()
|
handleAnchorLinks()
|
||||||
|
|
||||||
// 绑定事件
|
// 绑定事件
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,34 @@
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
|
import {useHead} from "#app";
|
||||||
|
import {pageConfig} from "~/data/indexData";
|
||||||
|
|
||||||
|
// 使用 Nuxt 3 的 useHead 来管理头部资源
|
||||||
|
useHead({
|
||||||
|
link: [
|
||||||
|
{rel: 'stylesheet', href: '/css/bootstrap.min.css'},
|
||||||
|
{rel: 'stylesheet', href: '/css/main2.css'},
|
||||||
|
{rel: 'stylesheet', href: '/css/main.css'},
|
||||||
|
{rel: 'stylesheet', href: '/css/yuxi2019.css'},
|
||||||
|
{rel: 'shortcut icon', href: pageConfig.favicon}
|
||||||
|
],
|
||||||
|
script: [
|
||||||
|
|
||||||
|
{src: '/js/index.js'},
|
||||||
|
{src: '/js/gopcOm.js'},
|
||||||
|
{
|
||||||
|
innerHTML: `
|
||||||
|
var _hmt = _hmt || [];
|
||||||
|
(function() {
|
||||||
|
var protocol = window.location.protocol === 'https:' ? 'https://' : 'http://';
|
||||||
|
var hm = document.createElement("script");
|
||||||
|
hm.src = protocol + "hm.baidu.com/h.js?${pageConfig.baiduAnalytics}";
|
||||||
|
var s = document.getElementsByTagName("script")[0];
|
||||||
|
s.parentNode.insertBefore(hm, s);
|
||||||
|
})();
|
||||||
|
`
|
||||||
|
}
|
||||||
|
]
|
||||||
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user