优化结构、逻辑 🥝
This commit is contained in:
parent
b8597a0724
commit
8a85c7342c
17
package.json
17
package.json
@ -14,16 +14,9 @@
|
||||
"@astrojs/rss": "^4.0.11",
|
||||
"@astrojs/sitemap": "^3.2.1",
|
||||
"@swup/astro": "^1.5.0",
|
||||
"aplayer": "^1.10.1",
|
||||
"astro": "^5.4.1",
|
||||
"dayjs": "^1.11.13",
|
||||
"dplayer": "^1.27.1",
|
||||
"hls.js": "^1.5.20",
|
||||
"mdast-util-to-string": "^4.0.0",
|
||||
"overlayscrollbars": "^2.11.1",
|
||||
"reading-time": "^1.5.0",
|
||||
"remark-directive": "^4.0.0",
|
||||
"twikoo": "1.6.41",
|
||||
"unist-util-visit": "^5.0.0",
|
||||
"vanilla-lazyload": "^19.1.3",
|
||||
"vh-plugin": "^1.2.2"
|
||||
},
|
||||
@ -31,7 +24,13 @@
|
||||
"@types/dplayer": "^1.25.5",
|
||||
"@types/nprogress": "^0.2.3",
|
||||
"cheerio": "^1.0.0",
|
||||
"less": "^4.2.2"
|
||||
"dayjs": "^1.11.13",
|
||||
"less": "^4.2.2",
|
||||
"mdast-util-to-string": "^4.0.0",
|
||||
"reading-time": "^1.5.0",
|
||||
"remark-directive": "^4.0.0",
|
||||
"typescript": "^5.8.2",
|
||||
"unist-util-visit": "^5.0.0"
|
||||
},
|
||||
"pnpm": {
|
||||
"onlyBuiltDependencies": [
|
||||
|
||||
@ -30,7 +30,8 @@ import "../styles/Base.less";
|
||||
<meta name="site" content={Site} />
|
||||
<meta name="author" content={Author} />
|
||||
<meta name="generator" content={Astro.generator} />
|
||||
<meta name="robots" content="max-image-preview:large" />
|
||||
<meta name="robots" content="index, follow, max-image-preview:large" />
|
||||
<meta itemprop="image" content={WebCover} />
|
||||
<!-- Open Graph -->
|
||||
<meta property="article:author" content={Author} />
|
||||
<meta property="og:type" content={PageCover ? "article" : "website"} />
|
||||
|
||||
@ -7,8 +7,8 @@ import "../styles/components/Search.less";
|
||||
<main>
|
||||
<div class="search-input">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path fill="#B4B4B4" d="m19.6 21l-6.3-6.3q-.75.6-1.725.95T9.5 16q-2.725 0-4.612-1.888T3 9.5t1.888-4.612T9.5 3t4.613 1.888T16 9.5q0 1.1-.35 2.075T14.7 13.3l6.3 6.3zM9.5 14q1.875 0 3.188-1.312T14 9.5t-1.312-3.187T9.5 5T6.313 6.313T5 9.5t1.313 3.188T9.5 14"></path></svg>
|
||||
<input type="text" placeholder="Search" />
|
||||
<input type="text" placeholder="搜索文章" />
|
||||
</div>
|
||||
<section class="vh-search-list"></section>
|
||||
<section class="vh-search-list"><em></em></section>
|
||||
</main>
|
||||
</section>
|
||||
</section>
|
||||
|
||||
@ -20,8 +20,6 @@ import "../styles/Layout.less";
|
||||
|
||||
<html lang="zh-CN">
|
||||
<Head Title={title} Keywords={keywords} Description={description} PageCover={pagecover}>
|
||||
<!-- TwikooJS 加载项 -->
|
||||
{Twikoo.envId && <script is:inline async src={`https://registry.npmmirror.com/twikoo/1.6.41/files/dist/twikoo.all.min.js`} />}
|
||||
<!-- 谷歌广告JS加载项 -->
|
||||
{ad_Client && (asideAD_Slot || articleAD_Slot) && <script is:inline async src={`https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=${ad_Client}`} crossorigin="anonymous" />}
|
||||
</Head>
|
||||
|
||||
@ -1,8 +1,11 @@
|
||||
import { LoadScript } from "../utils/index";
|
||||
import SITE_INFO from "../config";
|
||||
declare const twikoo: any;
|
||||
// 初始化评论插件
|
||||
export default async () => {
|
||||
const commentDOM = '.vh-comment>section'
|
||||
if (!document.querySelector(commentDOM) || !SITE_INFO.Twikoo.envId) return;
|
||||
document.querySelector(commentDOM)!.innerHTML = '<section></section>'
|
||||
await LoadScript("https://registry.npmmirror.com/twikoo/1.6.41/files/dist/twikoo.all.min.js");
|
||||
twikoo.init({ envId: SITE_INFO.Twikoo.envId, el: commentDOM })
|
||||
}
|
||||
@ -48,6 +48,8 @@ const indexInit = async (only: boolean = true) => {
|
||||
only && initMobileSidebar();
|
||||
// 顶部导航 Current 状态
|
||||
initLinkCurrent()
|
||||
// 文章评论初始化
|
||||
initComment();
|
||||
// 初始化文章功能脚本
|
||||
ArticleInit();
|
||||
// 图片懒加载初始化
|
||||
@ -56,8 +58,6 @@ const indexInit = async (only: boolean = true) => {
|
||||
initLinks();
|
||||
// 动态说说初始化
|
||||
initTalking();
|
||||
// 文章评论初始化
|
||||
initComment();
|
||||
// Google 广告
|
||||
GoogleAdInit();
|
||||
// 文章视频播放器初始化
|
||||
|
||||
@ -1,20 +1,18 @@
|
||||
import SITE_CONFIG from "../config";
|
||||
const { vhMusicApi } = SITE_CONFIG;
|
||||
import { $GET } from '../utils/index'
|
||||
import { LoadScript, LoadStyle } from "../utils/index";
|
||||
import 'aplayer/dist/APlayer.min.css';
|
||||
import APlayer from 'aplayer';
|
||||
|
||||
declare const APlayer: any;
|
||||
// 初始化音乐播放器
|
||||
export default async (musicList: any[]) => {
|
||||
export default async (MusicList: any[]) => {
|
||||
const musicDOM: any = document.querySelectorAll(".vh-node.vh-vhMusic");
|
||||
if (musicDOM.length === 0) return;
|
||||
// 载入依赖
|
||||
await LoadStyle("https://lf9-cdn-tos.bytecdntp.com/cdn/expire-1-M/aplayer/1.10.1/APlayer.min.css");
|
||||
await LoadScript("https://lf6-cdn-tos.bytecdntp.com/cdn/expire-1-M/aplayer/1.10.1/APlayer.min.js");
|
||||
if (!musicDOM.length) return;
|
||||
musicDOM.forEach(async (container: any) => {
|
||||
const { type = 'song', server = 'netease', id } = container.dataset;
|
||||
const audio = await $GET(`${vhMusicApi}?server=${server}&type=${type}&id=${id}&r=${Math.random()}`);
|
||||
const ap = new APlayer({ container, audio, lrcType: 3 });
|
||||
musicList.push(ap);
|
||||
MusicList.push(ap);
|
||||
});
|
||||
};
|
||||
|
||||
@ -31,7 +31,7 @@ const findAndModifyElements = (arr: any[], keyword: string) => {
|
||||
// 渲染页面
|
||||
let searchHTML = '';
|
||||
const renderSearch = (arr: any[]) => {
|
||||
searchHTML = !arr.length ? '' : arr.map(i => `<a class="vh-search-item" href="${i.url}"><span>${i.title}</span><p>${i.content}</p></a>`).join('');
|
||||
searchHTML = !arr.length ? '<em></em>' : arr.map(i => `<a class="vh-search-item" href="${i.url}"><span>${i.title}</span><p>${i.content}</p></a>`).join('');
|
||||
document.querySelector('.vh-header>.main>.vh-search>main>.vh-search-list')!.innerHTML = searchHTML;
|
||||
}
|
||||
|
||||
|
||||
@ -7,8 +7,8 @@ export default async (videoList: any[]) => {
|
||||
const videoDOM: any = document.querySelectorAll(".vh-node.vh-vhVideo");
|
||||
if (videoDOM.length === 0) return;
|
||||
// 载入依赖
|
||||
if (typeof Hls === "undefined") await LoadScript("https://registry.npmmirror.com/hls.js/1.5.20/files/dist/hls.min.js");
|
||||
await LoadScript("https://lf6-cdn-tos.bytecdntp.com/cdn/expire-1-M/dplayer/1.26.0/DPlayer.min.js");
|
||||
await LoadScript("https://registry.npmmirror.com/hls.js/1.5.20/files/dist/hls.min.js");
|
||||
videoDOM.forEach((i: any) => {
|
||||
const dp = new DPlayer({
|
||||
container: i,
|
||||
@ -21,9 +21,9 @@ export default async (videoList: any[]) => {
|
||||
customType: {
|
||||
hls: (video: any) => {
|
||||
if (Hls.isSupported()) {
|
||||
const hls = new Hls({ enableWorker: true, autoStartLoad: true, capLevelToPlayerSize: true });
|
||||
hls.loadSource(video.src);
|
||||
hls.attachMedia(video);
|
||||
dp.hls = new Hls({ enableWorker: true, autoStartLoad: true, capLevelToPlayerSize: true });
|
||||
dp.hls.loadSource(video.src);
|
||||
dp.hls.attachMedia(video);
|
||||
} else if (video.canPlayType("application/vnd.apple.mpegurl")) {
|
||||
video.src = i.getAttribute("data-url");
|
||||
}
|
||||
|
||||
4
src/type/twikoo.d.ts
vendored
4
src/type/twikoo.d.ts
vendored
@ -1,4 +0,0 @@
|
||||
|
||||
declare module 'twikoo' {
|
||||
function init(options: { envId: string, el: string }): void;
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user