code
stringlengths
1
1.05M
repo_name
stringlengths
6
83
path
stringlengths
3
242
language
stringclasses
222 values
license
stringclasses
20 values
size
int64
1
1.05M
import { render } from 'astro:content'; import dayjs from 'dayjs'; import utc from 'dayjs/plugin/utc'; import timezone from 'dayjs/plugin/timezone'; import { description150 } from '../layouts/BlogPost.astro'; // 使用插件 dayjs.extend(utc); dayjs.extend(timezone); // 默认使用中国时区 dayjs.tz.setDefault('Asia/Shanghai'); /** * 处理文章的 frontmatter 数据 * @param post 文章数据对象 * @returns 处理后的文章数据对象 */ export async function processFrontmatter(post: any) { const { remarkPluginFrontmatter } = await render(post); // 处理 abbrlink const abbrlink = post.data.abbrlink || remarkPluginFrontmatter.abbrlink; // 处理创建日期和更新日期 const createDate = dayjs(remarkPluginFrontmatter.date) .tz(remarkPluginFrontmatter.date.timezone) .format("YYYY-MM-DD HH:mm:ss"); const updateDate = dayjs(remarkPluginFrontmatter.updated) .tz(remarkPluginFrontmatter.updated.timezone) .format("YYYY-MM-DD HH:mm:ss"); // 创建一个新对象,包含处理后的数据 return { ...post, data: { ...post.data, abbrlink, date: typeof post.data.date === 'string' && post.data.date.trim() !== '' ? post.data.date : post.data.date instanceof Date ? dayjs(post.data.date).tz(post.data.date.timezone).format("YYYY-MM-DD HH:mm:ss") : createDate, updated: typeof post.data.updated === 'string' && post.data.updated.trim() !== '' ? post.data.updated : post.data.updated instanceof Date ? dayjs(post.data.updated).tz(post.data.updated.timezone).format("YYYY-MM-DD HH:mm:ss") : updateDate, description: post.data.description || description150(post.body), } }; }
2303_806435pww/stalux_moved
src/integrations/process-frontmatter.ts
TypeScript
mit
1,758
import { statSync } from 'fs'; import { createHash } from 'crypto'; import { getFileTimestamp, initFileTimestamp, updateFileAbbrlink, loadTimestamps } from './file-timestamps.mjs'; import { relative } from 'path'; /** * 检查 abbrlink 是否已存在于其他文件中 * @param {string} abbrlink 要检查的 abbrlink * @param {string} currentFilePath 当前文件路径 (相对路径) * @param {object} timestamps 时间戳数据对象 * @returns {boolean} 如果存在重复返回 true,否则返回 false */ function isDuplicateAbbrlink(abbrlink, currentFilePath, timestamps) { for (const path in timestamps) { if (path !== currentFilePath && timestamps[path].abbrlink && timestamps[path].abbrlink === abbrlink) { return true; } } return false; } /** * 为文件生成唯一的 abbrlink * @param {string} filepath 文件路径 * @param {string} createdTime 创建时间 * @param {object} timestamps 时间戳数据对象 * @returns {string} 生成的 abbrlink */ function generateUniqueAbbrlink(filepath, createdTime, timestamps) { const relativePath = relative(process.cwd(), filepath).replace(/\\/g, '/'); const timeString = new Date(createdTime).getTime().toString(); const hash = createHash('sha256') .update(relativePath + timeString) .digest('hex'); // 首先尝试使用前8位作为 abbrlink let abbrlink = hash.substring(0, 8); // 检查是否重复 if (isDuplicateAbbrlink(abbrlink, relativePath, timestamps)) { console.log(`警告: 文件 ${relativePath} 生成的 abbrlink: ${abbrlink} 有重复,尝试生成新的...`); // 尝试使用不同位置的哈希值 let found = false; for (let i = 1; i <= hash.length - 8; i++) { const newAbbrlink = hash.substring(i, i + 8); if (!isDuplicateAbbrlink(newAbbrlink, relativePath, timestamps)) { abbrlink = newAbbrlink; found = true; console.log(`为文件 ${relativePath} 生成新的 abbrlink: ${abbrlink}`); break; } } // 如果所有可能的组合都尝试过了还是有重复 if (!found) { const uniqueHash = createHash('sha256') .update(relativePath + timeString + Date.now().toString()) .digest('hex'); abbrlink = uniqueHash.substring(0, 8); console.log(`为文件 ${relativePath} 使用时间戳增强生成新的 abbrlink: ${abbrlink}`); } } return abbrlink; } export function remarkModifiedAbbrlink() { return function (tree, file) { // 获取文件路径 const filepath = file.history[0]; const relativePath = relative(process.cwd(), filepath).replace(/\\/g, '/'); // 尝试从时间戳文件中获取数据 let timestamp = getFileTimestamp(filepath); // 如果找不到时间戳数据,初始化它 if (!timestamp) { console.log(`[remark-abbrlink] 文件 ${relativePath} 没有时间戳记录,初始化...`); initFileTimestamp(filepath); timestamp = getFileTimestamp(filepath); } // 检查时间戳数据中是否已有 abbrlink if (timestamp && timestamp.abbrlink) { // 如果已有 abbrlink,直接使用 const abbrlink = timestamp.abbrlink; //console.log(`[remark-abbrlink] 文件 ${relativePath} 使用现有 abbrlink: ${abbrlink}`); file.data.astro.frontmatter.abbrlink = abbrlink; return; } // 否则,需要生成新的 abbrlink let createdTime; const timestamps = loadTimestamps(); if (timestamp) { // 使用持久化的创建时间来生成稳定的哈希值 createdTime = timestamp.created; } else { // 作为备选方案,使用文件系统时间 const stats = statSync(filepath); createdTime = (stats.birthtime && stats.birthtime.getTime()) ? new Date(stats.birthtime).toISOString() : new Date(stats.ctime).toISOString(); } console.log(`[remark-abbrlink] 为文件 ${relativePath} 生成 abbrlink...`); // 使用统一的 abbrlink 生成函数 let abbrlink = generateUniqueAbbrlink(filepath, createdTime, timestamps); // 在非构建环境下将生成的abbrlink更新到时间戳文件中 if (process.env.NODE_ENV !== 'production' && process.env.VERCEL !== '1') { updateFileAbbrlink(filepath, abbrlink); } else { console.log(`[remark-abbrlink] 构建环境下不写入,仅生成 abbrlink: ${abbrlink}`); } console.log(`[remark-abbrlink] 为文件 ${relativePath} 生成并设置 abbrlink: ${abbrlink}`); // 将生成的abbrlink添加到frontmatter file.data.astro.frontmatter.abbrlink = abbrlink; }; }
2303_806435pww/stalux_moved
src/integrations/remark-modified-abbrlink.mjs
JavaScript
mit
4,927
import { statSync } from 'fs'; import { getFileTimestamp, initFileTimestamp } from './file-timestamps.mjs'; export function remarkModifiedTime() { return function (tree, file) { const filepath = file.history[0]; // 尝试从时间戳文件中获取时间 let timestamp = getFileTimestamp(filepath); // 如果找不到时间戳数据,仅在非构建环境下初始化它 if (!timestamp) { if (process.env.NODE_ENV !== 'production' && process.env.VERCEL !== '1') { // 仅在开发环境下创建新的时间戳 initFileTimestamp(filepath); timestamp = getFileTimestamp(filepath); } else { // 在构建环境下使用文件系统信息,但不保存 const stats = statSync(filepath); const createTime = new Date(Math.min( stats.birthtime.getTime(), stats.ctime.getTime() )); timestamp = { created: createTime.toISOString(), modified: stats.mtime.toISOString() }; } } if (timestamp) { // 使用保存的时间戳,但确保时区信息正确 file.data.astro.frontmatter.date = timestamp.created; file.data.astro.frontmatter.updated = timestamp.modified; if (process.env.NODE_ENV !== 'production') { //console.log(`[remark-modified-time] 文件 ${filepath} 使用时间戳: ${timestamp.created}, ${timestamp.modified}`); } } else { // 作为备选方案,使用文件系统时间 const stats = statSync(filepath); // 使用 ctime 和 birthtime 中较早的时间作为文件创建时间 const createTime = new Date(Math.min( stats.birthtime.getTime(), stats.ctime.getTime() )); file.data.astro.frontmatter.date = createTime.toISOString(); // 使用mtime作为文件修改时间 file.data.astro.frontmatter.updated = stats.mtime.toISOString(); } }; }
2303_806435pww/stalux_moved
src/integrations/remark-modified-time.mjs
JavaScript
mit
2,058
import { loadTimestamps, initFileTimestamp, updateModifiedTimestamp, cleanupDeletedFiles, updateFileAbbrlink } from './file-timestamps.mjs'; import { createHash } from 'crypto'; import { join, relative } from 'path'; import { readdirSync, statSync, watch, existsSync } from 'fs'; function scanContentFiles(dir, rootDir = dir) { let results = []; try { const files = readdirSync(dir); for (const file of files) { const filePath = join(dir, file); try { const stat = statSync(filePath); if (stat.isDirectory()) { if (!file.startsWith('.') && file !== 'node_modules') { results = results.concat(scanContentFiles(filePath, rootDir)); } } else if (/\.(md|mdx)$/.test(file)) { results.push(filePath); } } catch (e) { // ignore } } } catch (e) { // ignore } return results; } function isDuplicateAbbrlink(abbrlink, currentFilePath, timestamps) { for (const path in timestamps) { if (path !== currentFilePath && timestamps[path].abbrlink && timestamps[path].abbrlink === abbrlink) { return true; } } return false; } function generateUniqueAbbrlink(filepath, createdTime, timestamps) { const relativePath = relative(process.cwd(), filepath).replace(/\\/g, '/'); const timeString = new Date(createdTime).getTime().toString(); const hash = createHash('sha256') .update(relativePath + timeString) .digest('hex'); let abbrlink = hash.substring(0, 8); if (isDuplicateAbbrlink(abbrlink, relativePath, timestamps)) { let found = false; for (let i = 1; i <= hash.length - 8; i++) { const newAbbrlink = hash.substring(i, i + 8); if (!isDuplicateAbbrlink(newAbbrlink, relativePath, timestamps)) { abbrlink = newAbbrlink; found = true; break; } } if (!found) { const uniqueHash = createHash('sha256') .update(relativePath + timeString + Date.now().toString()) .digest('hex'); abbrlink = uniqueHash.substring(0, 8); } } return abbrlink; } function validateTimestampConsistency(contentDir) { const timestamps = loadTimestamps(); const contentFiles = scanContentFiles(contentDir); const relativeContentFiles = contentFiles.map(file => relative(process.cwd(), file).replace(/\\/g, '/')); const timestampPaths = Object.keys(timestamps); const nonExistentFiles = timestampPaths.filter(path => !relativeContentFiles.includes(path)); if (nonExistentFiles.length > 0) { cleanupDeletedFiles(nonExistentFiles); } let newFileCount = 0; let abbrlinksAdded = 0; for (const file of contentFiles) { const relativePath = relative(process.cwd(), file).replace(/\\/g, '/'); if (!timestamps[relativePath]) { initFileTimestamp(file); newFileCount++; } } const updatedTimestamps = loadTimestamps(); for (const file of contentFiles) { const relativePath = relative(process.cwd(), file).replace(/\\/g, '/'); if (updatedTimestamps[relativePath] && !updatedTimestamps[relativePath].abbrlink) { const abbrlink = generateUniqueAbbrlink(file, updatedTimestamps[relativePath].created, updatedTimestamps); updateFileAbbrlink(file, abbrlink); abbrlinksAdded++; } } return { nonExistentFiles: nonExistentFiles.length, newFiles: newFileCount, abbrlinksAdded }; } function setupFileWatcher(contentDir) { if (!existsSync(contentDir)) { console.error(`内容目录不存在: ${contentDir}`); return null; } try { const watcher = watch(contentDir, { recursive: true }, (eventType, filename) => { if (!filename || !/\.(md|mdx)$/.test(filename)) return; const fullPath = join(contentDir, filename); if (eventType === 'rename') { try { if (existsSync(fullPath)) { initFileTimestamp(fullPath); const timestamps = loadTimestamps(); const relativePath = relative(process.cwd(), fullPath).replace(/\\/g, '/'); if (timestamps[relativePath] && !timestamps[relativePath].abbrlink) { const abbrlink = generateUniqueAbbrlink(fullPath, timestamps[relativePath].created, timestamps); updateFileAbbrlink(fullPath, abbrlink); } } else { cleanupDeletedFiles([relative(process.cwd(), fullPath).replace(/\\/g, '/')]); } } catch (err) { console.error(`处理文件 ${filename} 时出错:`, err); } } else if (eventType === 'change') { if (existsSync(fullPath)) { updateModifiedTimestamp(fullPath); } } }); return watcher; } catch (error) { console.error(`设置文件监听器时出错: ${error.message}`); return null; } } export default function timestampIntegration() { let fileWatcher = null; return { name: 'stalux-timestamp-integration', hooks: { 'astro:server:start': async () => { const contentDir = join(process.cwd(), 'src', 'content'); try { const contentFiles = scanContentFiles(contentDir); for (const filePath of contentFiles) { initFileTimestamp(filePath); } validateTimestampConsistency(contentDir); fileWatcher = setupFileWatcher(contentDir); } catch (error) { console.error('初始化时间戳和 abbrlink 时出错:', error); } }, 'astro:server:done': () => { if (fileWatcher) { fileWatcher.close(); fileWatcher = null; } }, 'astro:server:update': async ({ file }) => { if (process.env.NODE_ENV === 'production' || process.env.VERCEL === '1') { return; } if (/\.(md|mdx)$/.test(file)) { updateModifiedTimestamp(file); const timestamps = loadTimestamps(); const relativePath = relative(process.cwd(), file).replace(/\\/g, '/'); if (timestamps[relativePath] && !timestamps[relativePath].abbrlink) { const abbrlink = generateUniqueAbbrlink(file, timestamps[relativePath].created, timestamps); updateFileAbbrlink(file, abbrlink); } } }, 'astro:build:start': async () => { try { process.env.NODE_ENV = 'production'; loadTimestamps(); } catch (error) { console.error('加载时间戳数据时出错:', error); } } } }; }
2303_806435pww/stalux_moved
src/integrations/timestamp-integration.mjs
JavaScript
mit
6,691
--- import type { CollectionEntry } from 'astro:content'; import Head from '../components/Head.astro'; import Header from '../components/Header.astro'; import Footer from '../components/Footer.astro'; import WalineComment from '../components/comments/WalineComment.vue'; import { config_site } from '../utils/config-adapter'; import '../styles/global.styl'; import '../styles/blog.styl'; import '../styles/layouts/AboutPage.styl'; interface Props { title?: string; description?: string; noindex?: boolean; } const { title = '关于', description = '关于我', noindex } = Astro.props; // 页面标题 const pageTitle = `${title} | ${config_site.title}`; --- <!DOCTYPE html> <html lang={config_site.lang} class="dark"> <Head title={title + ' | '+ config_site.siteName} description={description || title} author={config_site.author} url={config_site.url + '/about/'} canonical={config_site.url + '/about/'} noindex={noindex} structuredData={{ "@context": "https://schema.org", "@type": "AboutPage", "name": title, "description": description || title, "url": config_site.url + '/about/' }} > <link slot="head" rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.16.9/dist/katex.min.css" integrity="sha384-n8MVd4RsNIU0tAv4ct0nTaAbDJwPJzDEaqSD1odI+WdtXRGWt2kTvGFasHpSy3SV" crossorigin="anonymous" /> </Head> <body> <script> import '../scripts/background.ts'; </script> <Header /> <main class="about-container"> <div class="about-header"> <h1 class="about-title">{title}</h1> <div class="about-content"> <slot /> </div> <WalineComment serverURL={config_site.comment?.waline?.serverURL} path={Astro.url.pathname} title={title} lang={config_site.comment?.waline?.lang || 'zh-CN'} emoji={config_site.comment?.waline?.emoji} requiredFields={config_site.comment?.waline?.requiredFields} reaction={config_site.comment?.waline?.reaction} meta={config_site.comment?.waline?.meta} wordLimit={config_site.comment?.waline?.wordLimit} pageSize={config_site.comment?.waline?.pageSize} client:idle /> </main> <Footer /> </body> </html>
2303_806435pww/stalux_moved
src/layouts/AboutPage.astro
Astro
mit
2,340
--- import Head from "../components/Head.astro"; import Header from "../components/Header.astro"; import Footer from "../components/Footer.astro"; import { config_site } from "../utils/config-adapter"; import "../styles/global.styl"; import "../styles/layouts/ArchivesLayout.styl"; import dayjs from "dayjs"; interface Props { pageTitle: string; description: string; posts: any[]; totalPostsCount: number; noindex?: boolean; } const { pageTitle, description, posts, totalPostsCount, noindex = true, } = Astro.props; // 按年月分组 - This logic now uses the 'posts' prop const archivesByYearMonth: Record<number, Record<number, any[]>> = {}; posts.forEach((post: any) => { if (!post.data.date) return; const date = dayjs(post.data.date); const year = date.year(); const month = date.month() + 1; // dayjs 月份从 0 开始 if (!archivesByYearMonth[year]) { archivesByYearMonth[year] = {}; } if (!archivesByYearMonth[year][month]) { archivesByYearMonth[year][month] = []; } archivesByYearMonth[year][month].push(post); }); // 按年份降序排序 - const sortedYears = Object.keys(archivesByYearMonth) .map(Number) .sort((a: number, b: number) => b - a); --- <!doctype html> <html lang={config_site.lang}> <Head title={pageTitle} titleTemplate={`%s | ${config_site.title}`} description={description} author={config_site.author} url={config_site.url + "/archives/"} canonical={config_site.url + "/archives/"} noindex={noindex} > {/* Allow passing additional head elements if needed */} <slot name="head" /> </Head> <body> <script> import "../scripts/background.ts"; </script> <Header /> <main class="archives-container"> <div class="page-header"> {/* Use a more generic title prop for the H1, description prop for P */} <h1 class="page-title">{pageTitle.split(" | ")[0]}</h1> <p class="page-description">{description}(共 {totalPostsCount} 篇)</p> </div> <div class="timeline-container"> { sortedYears.length > 0 ? ( sortedYears.map((year) => ( <div class="year-section"> <div class="year-header"> <h2 class="year-title">{year}</h2> <div class="year-count"> {Object.values(archivesByYearMonth[year]).flat().length}{" "} 篇文章 </div> </div> {Object.keys(archivesByYearMonth[year]) .map(Number) .sort((a, b) => b - a) // 月份降序排列 .map((month) => ( <div class="month-section"> <h3 class="month-title">{month}月</h3> <ul class="post-list"> {archivesByYearMonth[year][month].map((post) => ( <li class="post-item"> <div class="post-date"> {dayjs(post.data.date).format("YYYY-MM-DD")} </div> <a href={`/posts/${post.data.abbrlink}/`} class="post-link" > {post.data.title} </a> </li> ))} </ul> </div> ))} </div> )) ) : ( <div class="no-posts">暂无文章</div> ) } </div> <!-- 懒加载指示器 --> <div id="lazyload-observer" class="lazyload-observer"> <div class="loading-spinner"> <span class="dot"></span> <span class="dot"></span> <span class="dot"></span> </div> <div class="loading-text">加载更多内容</div> </div> {/* Allow passing additional main content if needed */} <slot name="main" /> </main> <Footer /> <script> // 懒加载实现 (This script is identical to the original page's script) document.addEventListener("DOMContentLoaded", () => { let visibleYears = 2; const yearSections = document.querySelectorAll(".year-section"); const totalYears = yearSections.length; const lazyloadObserver = document.getElementById("lazyload-observer"); const updateLoadingIndicator = ( isLoading: boolean, isComplete: boolean ) => { if (!lazyloadObserver) return; const loadingText = lazyloadObserver.querySelector( ".loading-text" ) as HTMLElement; const loadingSpinner = lazyloadObserver.querySelector( ".loading-spinner" ) as HTMLElement; if (isComplete) { if (loadingText) loadingText.textContent = "已加载全部内容"; if (loadingSpinner) loadingSpinner.style.display = "none"; setTimeout(() => { if (lazyloadObserver) { (lazyloadObserver as HTMLElement).style.opacity = "0"; setTimeout(() => { if (lazyloadObserver) { (lazyloadObserver as HTMLElement).style.display = "none"; } }, 500); } }, 3000); } else { if (loadingText) loadingText.textContent = isLoading ? "正在加载..." : "滚动加载更多"; } }; const showYearSection = (index: number) => { if (index >= 0 && index < totalYears && yearSections[index]) { const section = yearSections[index] as HTMLElement; section.style.display = "block"; section.style.opacity = "0"; setTimeout(() => { section.style.opacity = "1"; section.style.transform = "translateY(0)"; }, 50); } }; if (totalYears > 0) { for (let i = 0; i < totalYears; i++) { if (i < visibleYears) { showYearSection(i); } else { (yearSections[i] as HTMLElement).style.display = "none"; } } if (totalYears <= visibleYears && lazyloadObserver) { updateLoadingIndicator(false, true); } } const observer = new IntersectionObserver( (entries) => { entries.forEach((entry) => { if (entry.isIntersecting && visibleYears < totalYears) { updateLoadingIndicator(true, false); setTimeout(() => { showYearSection(visibleYears); visibleYears++; if (visibleYears >= totalYears) { updateLoadingIndicator(false, true); } else { updateLoadingIndicator(false, false); } }, 300); } }); }, { rootMargin: "300px", threshold: 0.1, } ); if (lazyloadObserver) { observer.observe(lazyloadObserver); } else { console.warn("懒加载指示器元素未找到"); } window.addEventListener("error", (e) => { if ( e.message.includes("lazyload") || e.message.includes("observer") ) { console.error("懒加载功能出现错误:", e); } }); }); </script> </body> </html>
2303_806435pww/stalux_moved
src/layouts/ArchivesLayout.astro
Astro
mit
7,690
--- import type { CollectionEntry } from "astro:content"; import type { MarkdownHeading } from "astro"; import Head from "../components/Head.astro"; import Header from "../components/Header.astro"; import Footer from "../components/Footer.astro"; import WalineComment from "../components/comments/WalineComment.vue"; import "../styles/layouts/BlogPost.styl"; import "../styles/components/PostNavigation.styl"; import { config_site } from "../utils/config-adapter"; import removeMd from "remove-markdown"; // 正确定义Props类型 interface Props { title: string; author?: string; date?: string | Date; updated?: string | Date; tags?: string[]; categories?: string[]; // 改为字符串数组 headings?: MarkdownHeading[]; description?: string; abbrlink?: string; prev?: { title: string; url: string } | null; next?: { title: string; url: string } | null; } const { title, date, updated, tags, categories, headings = [], description, author, abbrlink, prev, next, } = Astro.props; import "../styles/blog.styl"; import "../styles/global.styl"; import LeftSiderbar from "./LeftSiderbar.astro"; import RightSiderbar from "./RightSiderbar.astro"; import CC from "../components/others/CC.astro"; export function description150(description: string): string { const plainText = removeMd(description || "") .replace(/\s+/g, " ") .trim(); if (plainText.length > 150) { return plainText.slice(0, 145) + "..."; } return plainText; } function categoriesToString(categories?: string[]): string { if (!categories || categories.length === 0) { return ""; } // 现在 categories 已经是简单的字符串数组,直接处理即可 return categories .filter((cat) => cat && cat.trim() !== "") // 过滤空字符串 .map((cat) => cat.trim()) // 去除首尾空格 .join(","); // 用逗号连接 } // 将标签和分类合并并去重 const combinedKeywords = new Set<string>(); // 添加所有标签 if (tags && tags.length > 0) { tags.forEach((tag) => combinedKeywords.add(tag)); } // 添加所有分类(已扁平化) const categoryArray = categories ? categoriesToString(categories) .split(",") .filter((cat) => cat.trim() !== "") : []; categoryArray.forEach((category) => { combinedKeywords.add(category.trim()); }); // 转换为逗号分隔的字符串 const keyws = combinedKeywords.size > 0 ? Array.from(combinedKeywords).slice(0, 10).join(",") : ""; const categoryStr = categoriesToString(categories); import "katex/dist/katex.min.css"; --- <html lang={config_site.lang} class="dark"> <Head title={title + " | " + config_site.siteName} description={description150(description || "这是默认的文章描述")} author={author || config_site.author} url={config_site.url + "/posts/" + abbrlink} canonical={config_site.url + "/posts/" + abbrlink} keywords={keyws || "关键字1, 关键字2"} structuredData={{ "@context": "https://schema.org", "@type": "BlogPosting", headline: title, description: description150(description || "这是默认的文章描述"), author: { "@type": "Person", name: author || config_site.author, }, datePublished: date, dateModified: updated || date, mainEntityOfPage: { "@type": "WebPage", "@id": config_site.url + "/posts/" + abbrlink, }, }} > <!-- Vercount统计脚本 --> <script defer src="https://events.vercount.one/js"></script> </Head> <body> <Header /> <main> <div class="main-content"> <LeftSiderbar /> <article class="article-content"> <div class="hero-image"> <!-- 如果有特色图片可以在这里添加 --> </div> <div class="prose fade-in-up delay-200"> <div class="title"> <h1>{title}</h1> <div class="date"> { date && ( <div class="published-on"> 发布时间: <time> {date instanceof Date ? date.toLocaleDateString() : date} </time> </div> ) } { updated && ( <div class="last-updated-on"> 更新时间: <time> {updated instanceof Date ? updated.toLocaleDateString() : updated} </time> </div> ) } </div> <!-- 文章阅读量统计 --> <div class="page-stats"> <span id="vercount_container_page_pv"> 👀 阅读量:<span id="vercount_value_page_pv">Loading...</span> </span> </div> </div> <slot /> </div> <CC title={title} author={config_site.author} url={config_site.url + "/posts/" + abbrlink} /> { prev || next ? ( <nav class="post-navigation" aria-label="文章导航"> <div class="post-navigation-inner"> {prev ? ( <a href={prev.url} class="post-nav-link prev-post" rel="prev" > <span class="post-nav-arrow"> <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" > <path d="M19 12H5M12 19l-7-7 7-7" /> </svg> </span> <div class="post-nav-content"> <span class="post-nav-label"> 上一篇 </span> <span class="post-nav-title"> {prev.title} </span> </div> </a> ) : ( <span class="post-nav-link prev-post disabled"> <span class="post-nav-arrow"> <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" > <path d="M19 12H5M12 19l-7-7 7-7" /> </svg> </span> <div class="post-nav-content"> <span class="post-nav-label"> 上一篇 </span> <span class="post-nav-title"> 没有更早的文章 </span> </div> </span> )} {next ? ( <a href={next.url} class="post-nav-link next-post" rel="next" > <div class="post-nav-content"> <span class="post-nav-label"> 下一篇 </span> <span class="post-nav-title"> {next.title} </span> </div> <span class="post-nav-arrow"> <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" > <path d="M5 12h14M12 5l7 7-7 7" /> </svg> </span> </a> ) : ( <span class="post-nav-link next-post disabled"> <div class="post-nav-content"> <span class="post-nav-label"> 下一篇 </span> <span class="post-nav-title"> 没有更新的文章 </span> </div> <span class="post-nav-arrow"> <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" > <path d="M5 12h14M12 5l7 7-7 7" /> </svg> </span> </span> )} </div> </nav> ) : null } <WalineComment serverURL={config_site.comment?.waline?.serverURL} path={Astro.url.pathname} title={title} lang={config_site.comment?.waline?.lang || "zh-CN"} emoji={config_site.comment?.waline?.emoji} requiredFields={config_site.comment?.waline ?.requiredFields} reaction={config_site.comment?.waline?.reaction} meta={config_site.comment?.waline?.meta} wordLimit={config_site.comment?.waline?.wordLimit} pageSize={config_site.comment?.waline?.pageSize} client:idle /> </article> <RightSiderbar {tags} {categories} {headings} /> </div> </main> <Footer /> </body><script> import "../scripts/background.ts"; import "../scripts/fancybox.ts"; // 为文章内容中的所有图片添加懒加载 document.addEventListener("DOMContentLoaded", () => { const articleImages = document.querySelectorAll( ".article-content img", ); // 为每个图片添加懒加载属性 articleImages.forEach((img) => { // 如果没有loading属性,添加loading="lazy" if (!img.hasAttribute("loading")) { img.setAttribute("loading", "lazy"); } // 添加淡入效果类 img.classList.add("lazy-image"); // 监听图片加载完成事件 img.addEventListener("load", () => { img.classList.add("loaded"); }); // 处理图片加载错误 img.addEventListener("error", () => { console.warn( "图片加载失败:", (img as HTMLImageElement).src, ); // 可以在这里添加一个占位图 // (img as HTMLImageElement).src = '/images/placeholder.svg'; }); }); // 使用 Intersection Observer API 监测图片可见性 if ("IntersectionObserver" in window) { const imageObserver = new IntersectionObserver( (entries) => { entries.forEach((entry) => { if (entry.isIntersecting) { const img = entry.target; // 如果有data-src属性,则加载该图片 const dataSrc = img.getAttribute("data-src"); if (dataSrc) { (img as HTMLImageElement).src = dataSrc; img.removeAttribute("data-src"); } imageObserver.unobserve(img); } }); }, { rootMargin: "200px 0px", // 提前200px加载 threshold: 0.01, }, ); // 观察所有图片 articleImages.forEach((img) => { imageObserver.observe(img); }); } }); </script> <!-- 添加响应式视口设置 --> <style> /* 图片懒加载相关样式 */ .lazy-image { opacity: 0; transition: opacity 0.5s ease; } .lazy-image.loaded { opacity: 1; } /* 文章页面统计样式 */ .page-stats { margin-top: 1rem; padding-top: 0.8rem; border-top: 1px solid rgba(255, 255, 255, 0.1); font-size: 0.9rem; color: rgba(255, 255, 255, 0.7); display: flex; justify-content: center; align-items: center; gap: 1rem; } .page-stats span { display: inline-flex; align-items: center; gap: 0.3rem; } #vercount_value_page_pv { font-weight: 600; color: rgba(255, 255, 255, 0.9); } #vercount_container_page_pv { transition: opacity 0.3s ease; } /* 响应式设计 */ @media (max-width: 768px) { .page-stats { font-size: 0.85rem; margin-top: 0.8rem; padding-top: 0.6rem; } } </style> </html>
2303_806435pww/stalux_moved
src/layouts/BlogPost.astro
Astro
mit
11,507
--- import Head from '../components/Head.astro'; import Header from '../components/Header.astro'; import Footer from '../components/Footer.astro'; import '../../src/styles/global.styl'; import '../styles/layouts/CategoriesLayout.styl'; import '../styles/pages/categories/index-content.styl'; import { config_site } from '../utils/config-adapter'; import type { CategoryNode } from '../utils/category-utils'; export interface Props { title: string; description: string; author: string; url: string; categories: CategoryNode[]; // 扁平化分类数组 noIndex?: boolean; } const { title, description, author, url, categories, noIndex = false } = Astro.props; --- <!DOCTYPE html> <html lang="zh-CN"> <Head title={title} description={description} author={author} url={url} canonical={url} noindex={noIndex} > {noIndex && <meta name="robots" content="noindex, nofollow" slot="robots" />} </Head> <body> <script> import '../scripts/background.ts'; </script> <Header /> <main class="categories-container"> <div class="page-header"> <h1 class="page-title">文章分类</h1> <p class="page-description">按主题分类浏览</p> </div> <!-- 分类卡片网格 - 扁平化展示 --> <div class="categories-grid"> {categories.length > 0 ? ( categories.map((category) => ( <div class="category-card"> <a href={`/categories/${category.path}/`} class="category-header"> <div class="category-icon"> <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"> <path d="M22 19a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5l2 3h9a2 2 0 0 1 2 2z"></path> </svg> </div> <div class="category-content"> <h2 class="category-name">{category.name}</h2> <div class="category-count">{category.count} 篇文章</div> </div> </a> </div> )) ) : ( <div class="no-categories">暂无分类</div> )} </div> <slot /> </main> <Footer /> </body> </html>
2303_806435pww/stalux_moved
src/layouts/CategoriesLayout.astro
Astro
mit
2,346
--- import Head from '../components/Head.astro'; import Header from '../components/Header.astro'; import Footer from '../components/Footer.astro'; import '../../src/styles/global.styl'; import '../styles/layouts/CategoryDetailLayout.styl'; import '../styles/pages/categories/path-content.styl'; export interface Props { title: string; description: string; author: string; url: string; categoryName: string; // 改为单个分类名称 postCount: number; noIndex?: boolean; keywords?: string; structuredData?: any; ogImage?: string; } const { title, description, author, url, categoryName, postCount, noIndex = false, keywords = '', structuredData, ogImage } = Astro.props; --- <!DOCTYPE html> <html lang="zh-CN"> <Head title={title} description={description} author={author} url={url} canonical={url} noindex={noIndex} keywords={keywords} structuredData={structuredData} ogImage={ogImage} > {noIndex && <meta name="robots" content="noindex, nofollow" slot="robots" />} </Head> <body> <script> import '../scripts/background.ts'; </script> <Header /> <main class="category-detail-container" data-pagefind-ignore> <div class="page-header"> <h1 class="page-title"> <span class="category-icon"> <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="28" height="28" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"> <path d="M22 19a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5l2 3h9a2 2 0 0 1 2 2z"></path> </svg> </span> 分类: {categoryName} </h1> <p class="page-description">共找到 {postCount} 篇相关文章</p> <a href="/categories/" class="back-link">返回分类列表</a> </div> <div class="post-list-container"> <slot /> </div> </main> <Footer /> </body> </html>
2303_806435pww/stalux_moved
src/layouts/CategoryDetailLayout.astro
Astro
mit
2,000
--- import { site } from '../consts' import { config_site } from '../utils/config-adapter' import Head from '../components/Head.astro' import Header from '../components/Header.astro' import Footer from '../components/Footer.astro' import { Image } from 'astro:assets'; import avatar from '../images/avatar.webp'; import '../styles/home.styl' import Clock from '../components/others/Clock.vue' import SocialLinks from '../components/others/SocialLinks.astro' import TextTyping from '../components/others/TextTyping.astro' import AuthorCard from '../components/others/AuthorCard.astro' import Postlist from '../components/Postlist.astro' const avatarImage = config_site.avatarPath || avatar --- <!DOCTYPE html> <html lang={config_site.lang}> <Head title={config_site.title} description={config_site.description} url={config_site.url} keywords={config_site.keywords} author={config_site.author} lang={config_site.lang} locale={config_site.locale} siteName={config_site.siteName} favicon={config_site.favicon} titleDefault={config_site.titleDefault} canonical={config_site.canonical} head={config_site.head} /> <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=5.0, minimum-scale=1.0"> <script> import '../scripts/background.ts'; </script> <body> <div class="main-wrapper"> <div class="container"> <div class="Hometitle"><h1>{config_site.title}</h1></div> <Header /> <AuthorCard author={config_site.author} avatarPath={avatarImage} avatarWidth={100} avatarHeight={100} > </AuthorCard> <TextTyping/> <Clock client:idle format="24hour" showDate={true} updateInterval={1000} /> <SocialLinks mediaLinks={config_site.medialinks || []} /> </div> </div> <Postlist /> <Footer/> </body> </html> </html>
2303_806435pww/stalux_moved
src/layouts/Home.astro
Astro
mit
2,121
--- import { config_site } from "../utils/config-adapter"; import avatar from '../images/avatar.webp'; import SocialLinks from "../components/others/SocialLinks.astro"; import RandomPosts from "../components/others/RandomPosts.astro"; import { Image } from 'astro:assets'; const avatarPath = config_site.avatarPath || avatar; // 定义不同设备的图像尺寸 const mobileSizes = 70; // 移动设备图片尺寸 const tabletSizes = 80; // 平板设备图片尺寸 const desktopSizes = 100; // 桌面设备图片尺寸 const { avatarWidth = 100, avatarHeight = 100, author = config_site.author } = Astro.props; import '../styles/layouts/LeftSidebar.styl'; --- <sidebar class="left-sidebar"> <div class="sidebar-container"> <div class="sidebar-section author-card fade-in-left delay-100" id="author-card-container"> <div class="author"> <div class="avatar-container"> {typeof avatarPath === 'string' ? ( <img src={avatarPath} alt={`${author} avatar`} class="avatar" width={avatarWidth} height={avatarHeight} loading="eager" decoding="async" srcset={`${avatarPath}?w=${mobileSizes} ${mobileSizes}w, ${avatarPath}?w=${tabletSizes} ${tabletSizes}w, ${avatarPath}?w=${desktopSizes} ${desktopSizes}w`} sizes="(max-width: 480px) ${mobileSizes}px, (max-width: 768px) ${tabletSizes}px, ${desktopSizes}px" /> ) : ( <Image src={avatarPath} alt={`${author} avatar`} class="avatar" width={avatarWidth} height={avatarHeight} loading="eager" /> )} </div> <div class="author-info"> <h2 class="author-name">{config_site.author}</h2> <p class="author-description">{config_site.short_description||config_site.description.slice(0,20)+"..."}</p> </div> </div> </div> <div class="sidebar-section fade-in-left delay-200"> <SocialLinks mediaLinks={config_site.medialinks?.slice(0, 4) || []} /> <!-- 限制显示数量 --> </div> <!-- 使用解耦的随机文章组件 --> <RandomPosts count={5} delay="delay-300" /> <!-- 文章分类已迁移至右侧边栏 --> </sidebar> <script> // 计算合适的尺寸 function calculateSize(containerWidth:any, maxSize:any, minSize:any, maxWidth = 250, minWidth = 120) { if (!containerWidth) return maxSize; if (containerWidth >= maxWidth) return maxSize; if (containerWidth <= minWidth) return minSize; // 线性插值计算尺寸 const ratio = (containerWidth - minWidth) / (maxWidth - minWidth); return minSize + ratio * (maxSize - minSize); } // 动态调整author-card内元素的大小 function adjustAuthorCardSize(container:any) { // 获取容器的宽度 const containerWidth = container.offsetWidth; // 计算头像大小 const avatarSize = calculateSize(containerWidth, 100, 60); // 计算字体大小 const nameSize = calculateSize(containerWidth, 1.4, 0.9); const descSize = calculateSize(containerWidth, 1, 0.7); // 应用计算后的样式 const avatarContainer = container.querySelector('.avatar-container'); const authorName = container.querySelector('.author-name'); const authorDesc = container.querySelector('.author-description'); if (avatarContainer) { avatarContainer.style.width = `${avatarSize}px`; avatarContainer.style.height = `${avatarSize}px`; } if (authorName) { authorName.style.fontSize = `${nameSize}rem`; authorName.style.marginBottom = `${nameSize * 0.3}rem`; } if (authorDesc) { authorDesc.style.fontSize = `${descSize}rem`; } } // 初始化大小调整 document.addEventListener('DOMContentLoaded', () => { const authorCard = document.getElementById('author-card-container'); if (!authorCard) return; // 初始调整 adjustAuthorCardSize(authorCard); // 使用ResizeObserver监控尺寸变化 if (window.ResizeObserver) { const resizeObserver = new ResizeObserver(entries => { for (const entry of entries) { if (entry.target === authorCard) { adjustAuthorCardSize(authorCard); } } }); resizeObserver.observe(authorCard); } else { // 降级方案:监听窗口大小变化 window.addEventListener('resize', () => { adjustAuthorCardSize(authorCard); }); } }); </script>
2303_806435pww/stalux_moved
src/layouts/LeftSiderbar.astro
Astro
mit
4,824
--- import Head from "../components/Head.astro"; import {site} from "../consts"; import {config_site} from "../utils/config-adapter"; import Footer from "../components/Footer.astro"; import '../styles/global.styl'; import Header from "../components/Header.astro"; import type { FriendLink } from "../types"; type Props = { links: FriendLink[] } const { links } = Astro.props; import '../styles/layouts/Links.styl'; --- <!DOCTYPE html> <html lang={config_site.lang}> <Head title={config_site.friendlinks_title +' | '+ config_site.siteName} description={config_site.friendlinks_description || config_site.description} url={config_site.url + '/links/'} canonical={config_site.url + '/links/'} keywords={config_site.keywords} author={config_site.author} lang={config_site.lang} locale={config_site.locale} siteName={config_site.siteName} favicon={config_site.favicon} structuredData={{ "@context": "https://schema.org", "@type": "CollectionPage", "name": config_site.friendlinks_title, "description": config_site.friendlinks_description || config_site.description, "url": config_site.url + '/links/' }} /> <script> import '../scripts/background.ts'; </script> <body> <div class="main-wrapper"> <Header /> <div class="page-container"> <div class="page-header"> <h1 class="page-title">{config_site.friendlinks_title}</h1> <p class="page-description">{config_site.friendlinks_description}</p> </div> <ul class="friend-links"> {links.map((link) => ( <li class="friend-link"> <a href={link.url} target="_blank" rel="noopener noreferrer"> <div class="friend-avatar"> <img src={link.avatar || '/favicon.ico'} alt={`${link.title}'s avatar`} width="80" height="80" loading="lazy" /> </div> <div class="friend-content"> <h2>{link.title}</h2> <p>{link.description || '暂无描述'}</p> </div> </a> </li> ))} </ul> </div> </div> <Footer /> </body> </html>
2303_806435pww/stalux_moved
src/layouts/Links.astro
Astro
mit
2,301
--- import type { MarkdownHeading } from 'astro'; import Clock from '../components/others/Clock.vue'; import SidebarCategories from '../components/categories/SidebarCategories.astro'; import Tags from '../components/others/Tags.astro'; const { tags = [] as string[], categories = [] as any[], headings = [] as MarkdownHeading[] } = Astro.props; import '../styles/layouts/rightSidebar.styl'; --- <sidebar class="right-sidebar"> <!-- 时钟组件 --> <div class="clock-section fade-in-right delay-100"> <Clock client:idle format="24hour" showDate={true} updateInterval={1000} /> </div> <!-- 文章目录部分 --> <div class="sidebar-section toc-container fade-in-right delay-200"> <div class="section-header"> <h2 class="section-title">文章目录</h2> <button id="toc-toggle" class="section-toggle" aria-label="折叠目录"> <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="18" height="18"> <path fill="currentColor" d="M7 10l5 5 5-5z"></path> </svg> </button> </div> <div id="toc-content" class="section-content"> {headings && headings.length > 0 ? ( <ul class="toc-list"> {headings.map((heading:any) => ( <li class={`toc-item toc-item-h${heading.depth}`}> <a href={`#${heading.slug}`}>{heading.text}</a> </li> ))} </ul> ) : ( <div class="no-content-message"> 暂无目录 </div> )} </div> </div> <!-- 使用新的侧边栏分类组件 --> <SidebarCategories currentCategories={categories} /> <!-- 复用标签组件 --> <Tags tags={tags} /> </sidebar> <script> // 文章目录折叠/展开功能 document.addEventListener('DOMContentLoaded', () => { // 为目录添加事件监听 const tocToggle = document.getElementById('toc-toggle'); const tocContent = document.getElementById('toc-content'); if (tocToggle && tocContent) { tocToggle.addEventListener('click', () => { const isCollapsing = !tocContent.classList.contains('collapsed'); // 与分类和标签组件保持一致的过渡时间 if (isCollapsing) { // 快速折叠 (250ms) tocContent.style.transition = 'max-height 0.25s ease, opacity 0.25s ease'; } else { // 缓慢展开 (600ms) tocContent.style.transition = 'max-height 0.6s ease, opacity 0.6s ease'; } tocContent.classList.toggle('collapsed'); tocToggle.classList.toggle('collapsed'); }); } // 添加平滑滚动功能 const tocLinks = document.querySelectorAll('.toc-item a'); tocLinks.forEach(link => { link.addEventListener('click', (e) => { e.preventDefault(); // 阻止默认行为 const targetId = link.getAttribute('href')?.substring(1); // 去掉 # 号 if (!targetId) return; const targetElement = document.getElementById(targetId); if (!targetElement) return; // 获取目标元素的位置 const targetPosition = targetElement.getBoundingClientRect().top + window.scrollY; // 添加一点偏移量,让标题不会太靠近页面顶部 const offset = 80; // 平滑滚动到目标位置 window.scrollTo({ top: targetPosition - offset, behavior: 'smooth' }); // 更新 URL,但不引起页面跳转 history.pushState(null, '', `#${targetId}`); }); }); }); </script>
2303_806435pww/stalux_moved
src/layouts/RightSiderbar.astro
Astro
mit
3,609
--- import { config_site } from '../utils/config-adapter'; import Head from '../components/Head.astro'; import Header from '../components/Header.astro'; import Footer from '../components/Footer.astro'; import '../../src/styles/global.styl'; import '../styles/layouts/tags.styl'; export interface Props { title: string; description: string; url: string; noindex?: boolean; keywords?: string; structuredData?: any; ogImage?: string; } const { title, description, url, noindex = false, keywords = '', structuredData, ogImage } = Astro.props; --- <!DOCTYPE html> <html lang={config_site.lang}> <Head title={title} description={description} author={config_site.author} url={url} canonical={url} noindex={noindex} keywords={keywords} structuredData={structuredData} ogImage={ogImage} siteName={config_site.siteName} lang={config_site.lang} locale={config_site.locale} > <slot name="head" /> </Head> <body> <script> import '../scripts/background.ts'; </script> <Header /> <main class="tags-layout-container"> <div class="page-header"> <slot name="header" /> </div> <slot name="content" /> </main> <Footer /> </body> </html>
2303_806435pww/stalux_moved
src/layouts/TagsLayout.astro
Astro
mit
1,272
--- import { site } from '../consts' import { config_site } from '../utils/config-adapter' import Head from '../components/Head.astro' import Header from '../components/Header.astro' import Footer from '../components/Footer.astro' import { Image } from 'astro:assets'; import avatar from '../images/avatar.webp'; import '../styles/home.styl' import Clock from '../components/others/Clock.vue' import SocialLinks from '../components/others/SocialLinks.astro' import AuthorCard from '../components/others/AuthorCard.astro' const avatarImage = config_site.avatarPath || avatar --- <!DOCTYPE html> <html lang={config_site.lang}> <Head title="404 - 页面未找到 | {config_site.title}" description="抱歉,您访问的页面不存在。3秒后将自动跳转到首页。" url={config_site.url} keywords={config_site.keywords} author={config_site.author} lang={config_site.lang} locale={config_site.locale} siteName={config_site.siteName} favicon={config_site.favicon} titleDefault={config_site.titleDefault} canonical={config_site.canonical} head={config_site.head} /> <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=5.0, minimum-scale=1.0"> <script> import '../scripts/background.ts'; </script> <body> <div class="main-wrapper"> <div class="container"> <!-- 错误标题 --> <div class="Hometitle"> <h1>404 - 页面走丢了</h1> </div> <Header /> <!-- 404页面专属的AuthorCard变体 --> <div class="glass-card error-author-card"> <div class="author-avatar"> <Image src={avatarImage} alt="404" width={100} height={100} class="avatar-img" /> <div class="error-badge">404</div> </div> <div class="author-info"> <h2>抱歉,页面不存在</h2> <p>您访问的页面可能已被删除、移动或从未存在过...</p> </div> </div> <!-- 倒计时卡片 --> <div class="glass-card countdown-card"> <div class="countdown-content"> <div class="countdown-icon">🚀</div> <div class="countdown-text"> <span id="countdown-number">3</span> 秒后自动返回首页 </div> <div class="countdown-progress"> <div class="progress-bar" id="progress-bar"></div> </div> </div> </div> <!-- 时钟组件 --> <Clock client:idle format="24hour" showDate={true} updateInterval={1000} /> <!-- 导航按钮卡片 --> <div class="glass-card navigation-card"> <div class="nav-buttons"> <a href="/" class="nav-btn primary"> <span class="btn-icon">🏠</span> <span class="btn-text">返回首页</span> </a> <a href="/posts" class="nav-btn secondary"> <span class="btn-icon">📚</span> <span class="btn-text">浏览文章</span> </a> <a href="/archives" class="nav-btn secondary"> <span class="btn-icon">📂</span> <span class="btn-text">文章归档</span> </a> </div> </div> <!-- 社交链接 --> <SocialLinks mediaLinks={config_site.medialinks || []} /> </div> </div> <Footer/> <script> // 3秒倒计时跳转 let countdown = 3; const countdownElement = document.getElementById('countdown-number'); const progressBar = document.getElementById('progress-bar'); let startTime = Date.now(); const timer = setInterval(() => { countdown--; if (countdownElement) { countdownElement.textContent = countdown.toString(); } // 更新进度条 if (progressBar) { const elapsed = Date.now() - startTime; const progress = Math.min(elapsed / 3000 * 100, 100); progressBar.style.width = progress + '%'; } if (countdown <= 0) { clearInterval(timer); window.location.href = '/'; } }, 1000); // 页面加载动画 document.addEventListener('DOMContentLoaded', () => { // 添加动画类 const cards = document.querySelectorAll('.glass-card'); cards.forEach((card, index) => { setTimeout(() => { (card as HTMLElement).style.opacity = '1'; (card as HTMLElement).style.transform = 'translateY(0)'; }, index * 100); }); }); </script> </body> </html> <style> /* 继承首页的样式基础 */ .main-wrapper { min-height: 100vh; display: flex; flex-direction: column; } .container { max-width: 1200px; margin: 0 auto; padding: 0 15px; flex: 1 0 auto; display: flex; flex-direction: column; justify-content: center; } /* 错误页面专属样式 */ .error-author-card { display: flex; align-items: center; padding: 2rem; margin: 1rem 0; gap: 1.5rem; text-align: left; } .author-avatar { position: relative; flex-shrink: 0; } .avatar-img { border-radius: 50%; border: 3px solid rgba(255, 255, 255, 0.3); filter: grayscale(0.3); } .error-badge { position: absolute; top: -10px; right: -10px; background: linear-gradient(45deg, #ff6b6b, #ee5a24); color: white; border-radius: 50%; width: 40px; height: 40px; display: flex; align-items: center; justify-content: center; font-weight: bold; font-size: 0.8rem; box-shadow: 0 4px 15px rgba(255, 107, 107, 0.3); } .author-info h2 { margin: 0 0 0.5rem 0; color: #333; font-size: 1.5rem; } .author-info p { margin: 0; color: #666; line-height: 1.6; } .countdown-card { padding: 2rem; margin: 1rem 0; text-align: center; } .countdown-content { display: flex; flex-direction: column; align-items: center; gap: 1rem; } .countdown-icon { font-size: 3rem; animation: float 2s ease-in-out infinite; } .countdown-text { font-size: 1.2rem; color: #333; } #countdown-number { font-size: 2rem; font-weight: bold; color: #667eea; text-shadow: 0 2px 10px rgba(102, 126, 234, 0.3); } .countdown-progress { width: 100%; height: 6px; background: rgba(102, 126, 234, 0.2); border-radius: 3px; overflow: hidden; margin-top: 1rem; } .progress-bar { height: 100%; background: linear-gradient(90deg, #667eea, #764ba2); border-radius: 3px; width: 0%; transition: width 0.3s ease; } .navigation-card { padding: 2rem; margin: 1rem 0; } .nav-buttons { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 1rem; } .nav-btn { display: flex; flex-direction: column; align-items: center; gap: 0.5rem; padding: 1.5rem 1rem; border-radius: 12px; text-decoration: none; transition: all 0.3s ease; border: 2px solid transparent; background: rgba(255, 255, 255, 0.5); } .nav-btn.primary { background: linear-gradient(45deg, #667eea, #764ba2); color: white; box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3); } .nav-btn.secondary { color: #667eea; border-color: rgba(102, 126, 234, 0.3); } .nav-btn:hover { transform: translateY(-3px); box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1); } .nav-btn.primary:hover { box-shadow: 0 8px 25px rgba(102, 126, 234, 0.4); } .nav-btn.secondary:hover { background: #667eea; color: white; } .btn-icon { font-size: 1.5rem; } .btn-text { font-weight: 600; font-size: 0.9rem; } /* 动画效果 */ @keyframes float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-10px); } } /* 响应式设计 */ @media (max-width: 768px) { .error-author-card { flex-direction: column; text-align: center; padding: 1.5rem; } .nav-buttons { grid-template-columns: 1fr; } .countdown-card { padding: 1.5rem; } .Hometitle h1 { font-size: 1.8rem; } } @media (max-width: 480px) { .container { width: 95%; padding: 0 10px; } .Hometitle h1 { font-size: 1.5rem; } .error-author-card { padding: 1rem; } .countdown-card { padding: 1rem; } .navigation-card { padding: 1rem; } } </style>
2303_806435pww/stalux_moved
src/pages/404.astro
Astro
mit
8,627
--- import { config_site } from '../utils/config-adapter'; import '../styles/pages/about.styl'; import { type CollectionEntry, getCollection } from 'astro:content'; import AboutPage from '../layouts/AboutPage.astro'; import { render } from 'astro:content'; // 获取所有 about 集合内容 const allAboutEntries = await getCollection('about'); // 根据 priority 进行排序,优先级高的排前面 const sortedEntries = allAboutEntries.sort((a, b) => b.data.priority - a.data.priority); // 默认选择:优先选择非 default.md 的文件,如果没有则选择 default.md let selectedEntry; // 查找是否有非 default 的优先级最高条目 const nonDefaultEntry = sortedEntries.find(entry => entry.id !== 'default'); // 如果有非默认条目,选择它;否则选择默认条目或排序后的第一个条目 selectedEntry = nonDefaultEntry || sortedEntries.find(entry => entry.id === 'default') || sortedEntries[0]; // 如果没有任何条目,创建一个基础的占位符 if (!selectedEntry) { throw new Error("未找到关于页面内容。请在 src/content/about/ 目录下创建至少一个 .md 或 .mdx 文件。"); } // 渲染选中的条目内容 type Props = CollectionEntry<'about'>; let about = sortedEntries[0] || Astro.props; const { Content } = await render(about); // 从内容中提取描述(例如取前100个字符作为摘要) const description = about.body?.split('\n').filter(line => line.trim() !== '').slice(0, 2).join(' ').substring(0, 100); --- <AboutPage {...about.data} description={description}> <Content /> </AboutPage>
2303_806435pww/stalux_moved
src/pages/about.astro
Astro
mit
1,595
import { getCollection } from 'astro:content'; import { processFrontmatter } from '../integrations/process-frontmatter.ts'; // 预渲染此页面,确保优先生成 export const prerender = true; export async function GET(context) { let posts = await getCollection('posts'); // 处理frontmatter posts = await Promise.all(posts.map(async (post) => { return await processFrontmatter(post); })); posts = posts.sort((a, b) => new Date(b.data.date) - new Date(a.data.date));// 按日期降序排序 return new Response(JSON.stringify({ Posts: posts.map((post) => ({ title: post.data.title, date: post.data.date, updated: post.data.updated, description: post.data.description, link: `/posts/${post.data.abbrlink}/`, tags: post.data.tags || [], })) }), { headers: { 'Content-Type': 'application/json' } }); }
2303_806435pww/stalux_moved
src/pages/allpost.json.js
JavaScript
mit
967
--- import { getCollection } from 'astro:content'; import { processFrontmatter } from '../../integrations/process-frontmatter'; import ArchivesLayout from '../../layouts/ArchivesLayout.astro'; import { config_site } from '../../utils/config-adapter'; // 获取文章集合 export const allPosts = await getCollection('posts'); export const processedPosts = await Promise.all(allPosts.map(post => processFrontmatter(post))); // 按日期排序 const sortedPosts = processedPosts.sort((a, b) => { const dateA = a.data.date ? new Date(a.data.date).getTime() : 0; const dateB = b.data.date ? new Date(b.data.date).getTime() : 0; return dateB - dateA; }); // 页面标题和描述 const pageTitle = '文章归档 | ' + config_site.siteName; const description = '时间轴上的所有文章'; --- <ArchivesLayout pageTitle={pageTitle} description={description} posts={sortedPosts} totalPostsCount={sortedPosts.length} noindex={false} > <!-- 如果需要向布局组件传递额外内容,可以使用slot --> <!-- <div slot="head">额外的head内容</div> --> <!-- <div slot="main">额外的main内容</div> --> </ArchivesLayout>
2303_806435pww/stalux_moved
src/pages/archives/index.astro
Astro
mit
1,151
import rss from '@astrojs/rss'; import { getCollection } from 'astro:content'; import { config_site } from '../utils/config-adapter'; import { processFrontmatter } from '../integrations/process-frontmatter.ts'; export async function GET(context) { // 获取所有文章 let posts = await getCollection('posts'); // 处理frontmatter posts = await Promise.all(posts.map(async (post) => { return await processFrontmatter(post); })); return rss({ title: config_site.siteName || 'Blog', description: config_site.description || '博客描述', site: context.site, items: posts .sort((a, b) => new Date(b.data.date) - new Date(a.data.date)) .map((post) => ({ title: post.data.title, pubDate: post.data.date, description: post.data.description, link: `/posts/${post.data.abbrlink}/`, })), }); }
2303_806435pww/stalux_moved
src/pages/atom.xml.js
JavaScript
mit
862
--- import { getCollection } from 'astro:content'; import { config_site } from '../../utils/config-adapter'; import { processFrontmatter } from '../../integrations/process-frontmatter'; import dayjs from 'dayjs'; import CategoryDetailLayout from '../../layouts/CategoryDetailLayout.astro'; export async function getStaticPaths() { // 获取所有文章并处理frontmatter const allPosts = await getCollection('posts'); const processedPosts = await Promise.all(allPosts.map(post => processFrontmatter(post))); // 提取所有分类路径 - 扁平化结构,并收集统计信息 const categoryStats = new Map(); processedPosts.forEach(post => { if (post.data.categories && Array.isArray(post.data.categories)) { post.data.categories.forEach((category: string) => { if (typeof category === 'string' && category.trim()) { const categoryName = category.trim(); if (!categoryStats.has(categoryName)) { categoryStats.set(categoryName, { count: 0, posts: [], latestDate: null }); } const stats = categoryStats.get(categoryName); stats.count++; stats.posts.push(post); const postDate = new Date(post.data.date); if (!stats.latestDate || postDate > stats.latestDate) { stats.latestDate = postDate; } } }); } }); // 生成静态路径 return Array.from(categoryStats.entries()).map(([categoryName, stats]) => { return { params: { path: categoryName }, props: { categoryPath: categoryName, categoryStats: stats } }; }); } const { categoryPath, categoryStats } = Astro.props; // 获取所有文章并处理frontmatter const allPosts = await getCollection('posts'); const processedPosts = await Promise.all(allPosts.map(post => processFrontmatter(post))); // 过滤属于当前分类的文章 - 扁平化结构 function isPostInCategory(post: { data: { categories: any; }; }, targetCategory: string) { if (!post.data.categories || !Array.isArray(post.data.categories)) return false; return post.data.categories.some(category => typeof category === 'string' && category.trim() === targetCategory ); } // 过滤和排序文章 const categoryPosts = processedPosts.filter(post => isPostInCategory(post, categoryPath)); // 排序文章 const sortedPosts = categoryPosts.sort((a, b) => { const dateA = a.data.date ? new Date(a.data.date).getTime() : 0; const dateB = b.data.date ? new Date(b.data.date).getTime() : 0; return dateB - dateA; // 降序排序 }); // SEO优化的页面元数据 const pageTitle = `分类: ${categoryPath} | ${config_site.siteName}`; const pageDescription = `浏览 ${categoryPath} 分类下的 ${sortedPosts.length} 篇文章,涵盖相关领域的深度思考与见解。最后更新于 ${dayjs(categoryStats.latestDate).format('YYYY年MM月DD日')}`; const pageUrl = `${config_site.url}/categories/${encodeURIComponent(categoryPath)}/`; const pageKeywords = `${categoryPath}, 分类, 文章, 博客, ${config_site.siteName}, ${sortedPosts.slice(0, 5).map(p => p.data.title).join(', ')}`; // 结构化数据 const structuredData = { "@context": "https://schema.org", "@type": "CollectionPage", "name": pageTitle, "description": pageDescription, "url": pageUrl, "author": { "@type": "Person", "name": config_site.author }, "publisher": { "@type": "Organization", "name": config_site.siteName, "url": config_site.url }, "mainEntity": { "@type": "ItemList", "numberOfItems": sortedPosts.length, "itemListElement": sortedPosts.slice(0, 10).map((post, index) => ({ "@type": "ListItem", "position": index + 1, "item": { "@type": "Article", "name": post.data.title, "url": `${config_site.url}/posts/${post.data.abbrlink}/`, "datePublished": post.data.date, "author": { "@type": "Person", "name": config_site.author } } })) }, "breadcrumb": { "@type": "BreadcrumbList", "itemListElement": [ { "@type": "ListItem", "position": 1, "name": "首页", "item": config_site.url }, { "@type": "ListItem", "position": 2, "name": "分类", "item": `${config_site.url}/categories/` }, { "@type": "ListItem", "position": 3, "name": categoryPath, "item": pageUrl } ] } }; --- <CategoryDetailLayout title={pageTitle} description={pageDescription} author={config_site.author || ''} url={pageUrl} categoryName={categoryPath} postCount={sortedPosts.length} noIndex={false} keywords={pageKeywords} structuredData={structuredData} > noIndex={false} keywords={pageKeywords} structuredData={structuredData} > {sortedPosts.length > 0 ? ( <ul class="post-list"> {sortedPosts.map(post => ( <li class="post-item"> <a href={`/posts/${post.data.abbrlink}/`} class="post-link"> <div class="post-date"> {dayjs(post.data.date).format('YYYY-MM-DD')} </div> <h2 class="post-title">{post.data.title}</h2> <br /> {post.data.description && ( <p class="post-description">{post.data.description.slice(0,50)+ '...'}</p> )} </a> {/* 显示文章的所有分类标签 */} {post.data.categories && post.data.categories.length > 0 && ( <div class="post-categories"> {post.data.categories.map((cat: string) => ( <a href={`/categories/${cat}/`} class={`category-tag ${cat === categoryPath ? 'current' : ''}`}> {cat} </a> ))} </div> )} </li> ))} </ul> ) : ( <div class="no-posts">未找到与分类 "{categoryPath}" 相关的文章</div> )} </CategoryDetailLayout>
2303_806435pww/stalux_moved
src/pages/categories/[...path].astro
Astro
mit
6,075
--- import { getCollection } from 'astro:content'; import { config_site } from '../../utils/config-adapter'; import { processFrontmatter } from '../../integrations/process-frontmatter'; import { extractFlatCategories, sortCategoriesByCount } from '../../utils/category-utils'; import CategoriesLayout from '../../layouts/CategoriesLayout.astro'; // 获取文章集合 const allPosts = await getCollection('posts'); const processedPosts = await Promise.all(allPosts.map(post => processFrontmatter(post))); // 获取所有分类并按文章数量排序 const categories = extractFlatCategories(processedPosts); const sortedCategories = sortCategoriesByCount(categories); // 页面标题 const pageTitle = '文章分类 | ' + config_site.siteName; --- <CategoriesLayout title={pageTitle} description="所有文章分类列表,按主题分类索引" author={config_site.author || ''} url={config_site.url + '/categories/'} categories={sortedCategories} noIndex={false} />
2303_806435pww/stalux_moved
src/pages/categories/index.astro
Astro
mit
987
--- import '../styles/global.styl'; import Home from '../layouts/Home.astro'; --- <Home />
2303_806435pww/stalux_moved
src/pages/index.astro
Astro
mit
91
--- import LinksLayout from "../layouts/Links.astro"; import { config_site } from '../utils/config-adapter' --- <LinksLayout links={config_site.friendlinks || []}> </LinksLayout>
2303_806435pww/stalux_moved
src/pages/links.astro
Astro
mit
180
--- import { type CollectionEntry, getCollection } from 'astro:content'; import BlogPost from '../../layouts/BlogPost.astro'; import { render } from 'astro:content'; import { processFrontmatter } from '../../integrations/process-frontmatter'; export async function getStaticPaths() { const posts = await getCollection('posts'); const processedPosts = await Promise.all( posts.map(async (post) => { const processedPost = await processFrontmatter(post); return processedPost; }) ); // 按日期排序文章,最新的文章在前 const sortedPosts = processedPosts.sort((a, b) => { const dateA = a.data.date ? new Date(a.data.date).getTime() : 0; const dateB = b.data.date ? new Date(b.data.date).getTime() : 0; return dateB - dateA; }); return sortedPosts.map((post, index) => { // 使用官方 API 方式:直接在 props 中提供 prev 和 next const prevPost = index < sortedPosts.length - 1 ? sortedPosts[index + 1] : null; const nextPost = index > 0 ? sortedPosts[index - 1] : null; return { params: { slug: post.data.abbrlink }, props: { post, prev: prevPost ? { title: prevPost.data.title, url: `/posts/${prevPost.data.abbrlink}/` } : null, next: nextPost ? { title: nextPost.data.title, url: `/posts/${nextPost.data.abbrlink}/` } : null }, }; }); } type Props = { post: CollectionEntry<'posts'>; prev: { title: string; url: string } | null; next: { title: string; url: string } | null; }; const { post, prev, next } = Astro.props; const { Content, headings } = await render(post); --- <BlogPost {...post.data} headings={headings} description={post.body} prev={prev} next={next}> <Content /> </BlogPost>
2303_806435pww/stalux_moved
src/pages/posts/[...slug].astro
Astro
mit
1,710
import rss from '@astrojs/rss'; import { getCollection } from 'astro:content'; import { config_site } from '../utils/config-adapter.ts'; import { processFrontmatter } from '../integrations/process-frontmatter.ts'; export async function GET(context) { // 获取所有文章 let posts = await getCollection('posts'); // 处理frontmatter posts = await Promise.all(posts.map(async (post) => { return await processFrontmatter(post); })); return rss({ title: config_site.siteName || 'Blog', description: config_site.description || '博客描述', site: context.site, items: posts .sort((a, b) => new Date(b.data.date) - new Date(a.data.date)) .map((post) => ({ title: post.data.title, pubDate: post.data.date, description: post.data.description, link: `/posts/${post.data.abbrlink}/`, })), }); }
2303_806435pww/stalux_moved
src/pages/rss.xml.js
JavaScript
mit
869
--- import { getCollection } from 'astro:content'; import { config_site } from '../../utils/config-adapter'; import { processFrontmatter } from '../../integrations/process-frontmatter'; import dayjs from 'dayjs'; import TagsLayout from '../../layouts/TagsLayout.astro'; export async function getStaticPaths() { // 获取所有文章并处理frontmatter const allPosts = await getCollection('posts'); const processedPosts = await Promise.all(allPosts.map(post => processFrontmatter(post))); // 提取所有唯一标签及其统计信息 const tagStats = new Map(); processedPosts.forEach(post => { const tags = post.data.tags || []; tags.forEach((tag: String) => { if (tag.trim()) { const tagName = tag.trim(); if (!tagStats.has(tagName)) { tagStats.set(tagName, { count: 0, posts: [], latestDate: null }); } const stats = tagStats.get(tagName); stats.count++; stats.posts.push(post); const postDate = new Date(post.data.date); if (!stats.latestDate || postDate > stats.latestDate) { stats.latestDate = postDate; } } }); }); // 为每个标签创建路径参数 return Array.from(tagStats.entries()).map(([tag, stats]) => ({ params: { tag }, props: { tag, tagStats: stats } })); } const { tag, tagStats } = Astro.props; // 获取所有文章并处理frontmatter const allPosts = await getCollection('posts'); const processedPosts = await Promise.all(allPosts.map(post => processFrontmatter(post))); // 过滤包含特定标签的文章 const taggedPosts = processedPosts.filter(post => (post.data.tags || []).includes(tag) ); // 排序文章 const sortedPosts = taggedPosts.sort((a, b) => { const dateA = a.data.date ? new Date(a.data.date).getTime() : 0; const dateB = b.data.date ? new Date(b.data.date).getTime() : 0; return dateB - dateA; // 降序排序 }); // SEO优化的页面元数据 const pageTitle = `标签: ${tag} | ${config_site.siteName}`; const pageDescription = `探索 ${tag} 相关的 ${sortedPosts.length} 篇文章,包含最新的见解和思考。最后更新于 ${dayjs(tagStats.latestDate).format('YYYY年MM月DD日')}`; const pageUrl = `${config_site.url}/tags/${encodeURIComponent(tag)}/`; const pageKeywords = `${tag}, 标签, 文章, 博客, ${config_site.siteName}, ${sortedPosts.slice(0, 5).map(p => p.data.title).join(', ')}`; // 结构化数据 const structuredData = { "@context": "https://schema.org", "@type": "CollectionPage", "name": pageTitle, "description": pageDescription, "url": pageUrl, "author": { "@type": "Person", "name": config_site.author }, "publisher": { "@type": "Organization", "name": config_site.siteName, "url": config_site.url }, "mainEntity": { "@type": "ItemList", "numberOfItems": sortedPosts.length, "itemListElement": sortedPosts.slice(0, 10).map((post, index) => ({ "@type": "ListItem", "position": index + 1, "item": { "@type": "Article", "name": post.data.title, "url": `${config_site.url}/posts/${post.data.abbrlink}/`, "datePublished": post.data.date, "author": { "@type": "Person", "name": config_site.author } } })) }, "breadcrumb": { "@type": "BreadcrumbList", "itemListElement": [ { "@type": "ListItem", "position": 1, "name": "首页", "item": config_site.url }, { "@type": "ListItem", "position": 2, "name": "标签", "item": `${config_site.url}/tags/` }, { "@type": "ListItem", "position": 3, "name": tag, "item": pageUrl } ] } }; --- <TagsLayout title={pageTitle} description={pageDescription} url={pageUrl} noindex={false} keywords={pageKeywords} structuredData={structuredData} > title={pageTitle} description={`"${tag}" 标签相关的所有文章`} url={config_site.url + '/tags/' + tag} noindex={true} > <Fragment slot="header"> <div data-pagefind-ignore> <h1 class="page-title"> <span class="tag-icon"> <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="28" height="28" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"> <path d="M20.59 13.41l-7.17 7.17a2 2 0 0 1-2.83 0L2 12V2h10l8.59 8.59a2 2 0 0 1 0 2.82z"></path> <line x1="7" y1="7" x2="7.01" y2="7"></line> </svg> </span> {tag} </h1> <p class="page-description">共找到 {sortedPosts.length} 篇相关文章</p> <a href="/tags/" class="back-link">返回标签云</a> </div> </Fragment> <div slot="content" class="post-list-container" data-pagefind-ignore> {sortedPosts.length > 0 ? ( <ul class="post-list"> {sortedPosts.map(post => ( <li class="post-item"> <a href={`/posts/${post.data.abbrlink}/`} class="post-link"> <div class="post-date"> {dayjs(post.data.date).format('YYYY-MM-DD')} </div> <h2 class="post-title">{post.data.title}</h2> <br /> {post.data.description && ( <p class="post-description">{post.data.description.slice(0,50)+ '...'}</p> )} </a> {post.data.tags && post.data.tags.length > 0 && ( <div class="post-tags"> {post.data.tags.map((postTag: unknown) => ( <a href={`/tags/${postTag}/`} class={`post-tag ${postTag === tag ? 'current' : ''}`}> {postTag} </a> ))} </div> )} </li> ))} </ul> ) : ( <div class="no-posts">未找到与标签 "{tag}" 相关的文章</div> )} </div> </TagsLayout>
2303_806435pww/stalux_moved
src/pages/tags/[tag].astro
Astro
mit
5,993
--- import { getCollection } from 'astro:content'; import { config_site } from '../../utils/config-adapter'; import { processFrontmatter } from '../../integrations/process-frontmatter'; import TagsLayout from '../../layouts/TagsLayout.astro'; // 获取文章集合并处理frontmatter const allPosts = await getCollection('posts'); const posts = await Promise.all(allPosts.map(post => processFrontmatter(post))); // 提取所有标签并计算数量 const tagCounts: Record<string, number> = {}; posts.forEach(post => { const tags = post.data.tags || []; tags.forEach((tag: string) => { if (tag.trim()) { tagCounts[tag] = (tagCounts[tag] || 0) + 1; } }); }); // 转换为排序后的数组 const sortedTags = Object.entries(tagCounts) .sort(([, countA], [, countB]) => countB - countA) // 按数量降序排序 .map(([tag, count]) => ({ tag, count })); // 页面标题 const pageTitle = '标签云 | ' + config_site.siteName; --- <TagsLayout title={pageTitle} description="所有文章标签列表" url={config_site.url + '/tags/'} noindex={false} > <Fragment slot="header"> <h1 class="page-title">标签云</h1> <p class="page-description">探索不同主题的文章标签</p> </Fragment> <div slot="content" class="tags-cloud"> {sortedTags.length > 0 ? ( sortedTags.map(({ tag, count }) => ( <a href={`/tags/${tag}/`} class="tag-item" data-count={count}> <span class="tag-name">{tag}</span> <span class="tag-count">{count}</span> </a> )) ) : ( <div class="no-tags">暂无标签</div> )} </div> </TagsLayout>
2303_806435pww/stalux_moved
src/pages/tags/index.astro
Astro
mit
1,634
/** * 随机背景图片实现 * 每次加载页面时随机选择一张背景图片进行平铺 * 使用额外的DOM元素实现背景淡入效果,提高性能 */ // 背景图片总数 // 预加载所有背景图片 const backgroundImages = Array.from({ length: 42 }, (_, i) => { const index = i + 1; return { id: index, url: new URL(`../images/background/pattern-${index}.min.svg`, import.meta.url).href }; }); // 使用backgroundImages的长度来确定总数量 // 随机选择一个背景图案 function selectRandomBackground(): void { // 生成1到backgroundImages.length的随机整数 const randomIndex = Math.floor(Math.random() * backgroundImages.length); // 获取随机选择的背景图片URL const selectedBackground = backgroundImages[randomIndex]; // 创建背景容器元素 const bgContainer = document.createElement('div'); bgContainer.id = 'background-container'; bgContainer.style.cssText = ` position: fixed; top: 0; left: 0; width: 100%; height: 100%; z-index: -10; background-image: url('${selectedBackground.url}'); background-repeat: repeat; background-size: auto; background-position: center; opacity: 0; transition: opacity 1.2s ease; `; // 添加到body的最前面 if (document.body.firstChild) { document.body.insertBefore(bgContainer, document.body.firstChild); } else { document.body.appendChild(bgContainer); } // 延迟一点点再显示,确保DOM插入后再执行动画 setTimeout(() => { bgContainer.style.opacity = '1'; }, 100); } // 页面加载完成后执行 document.addEventListener('DOMContentLoaded', selectRandomBackground); // 导出函数,以便可以在其他地方手动调用 export { selectRandomBackground };
2303_806435pww/stalux_moved
src/scripts/background.ts
TypeScript
mit
1,795
import { Fancybox } from "@fancyapps/ui"; import "@fancyapps/ui/dist/fancybox/fancybox.css"; const imgboxs = document.querySelectorAll(".article-content img"); imgboxs.forEach((img) => { img.setAttribute("data-fancybox", "gallery"); }) Fancybox.bind("[data-fancybox]", { hideScrollbar: true, })
2303_806435pww/stalux_moved
src/scripts/fancybox.ts
TypeScript
mit
305
import { config_site } from "../utils/config-adapter"; document.addEventListener("DOMContentLoaded", () => { const textTypingElement = document.getElementById("textyping"); if(!textTypingElement) return; const texts = config_site.textyping; let currentTextIndex = Math.floor(Math.random() * texts.length); let currentCharIndex = 0; let isDeleting = false; let typingDelay = 40; // 打印速度 let deletingDelay = 80; // 删除速度 let pauseDelay = 1000; // 暂停时间 function typeText(){ const currentText = texts[currentTextIndex]; if(!textTypingElement) return; if(isDeleting){ textTypingElement.textContent = currentText.slice(0, currentCharIndex--); typingDelay = deletingDelay; if(currentCharIndex < 0){ isDeleting = false; let newIndex; do { newIndex = Math.floor(Math.random() * texts.length); } while (newIndex === currentTextIndex && texts.length > 1); currentTextIndex = newIndex; setTimeout(typeText, pauseDelay); return; } } else { textTypingElement.textContent = currentText.substring(0, currentCharIndex++); typingDelay = 80; if(currentCharIndex > currentText.length){ isDeleting = true; currentCharIndex = currentText.length; setTimeout(typeText, pauseDelay); return; } } setTimeout(typeText, typingDelay); } // 开始打字效果 typeText(); });
2303_806435pww/stalux_moved
src/scripts/textyping.ts
TypeScript
mit
1,714
/** * 脚本用于更新现有文件的 abbrlink 到 timestamps 文件中 */ import { readdirSync, statSync } from 'fs'; import { join, relative } from 'path'; import { createHash } from 'crypto'; import { loadTimestamps, saveTimestamps } from '../integrations/file-timestamps.mjs'; // 递归扫描目录找出所有 .md 和 .mdx 文件 function scanContentFiles(dir, rootDir = dir) { let results = []; try { const files = readdirSync(dir); for (const file of files) { const filePath = join(dir, file); try { const stat = statSync(filePath); if (stat.isDirectory()) { // 忽略 node_modules 和 .git 等目录 if (!file.startsWith('.') && file !== 'node_modules') { results = results.concat(scanContentFiles(filePath, rootDir)); } } else if (/\.(md|mdx)$/.test(file)) { results.push(filePath); } } catch (e) { // ignore } } } catch (e) { // ignore } return results; } /** * 检查 abbrlink 是否已存在于其他文件中 * @param {string} abbrlink 要检查的 abbrlink * @param {string} currentFilePath 当前文件路径 (相对路径) * @returns {boolean} 如果存在重复返回 true,否则返回 false */ function isDuplicateAbbrlink(abbrlink, currentFilePath, timestamps) { for (const path in timestamps) { if (path !== currentFilePath && timestamps[path].abbrlink && timestamps[path].abbrlink === abbrlink) { return true; } } return false; } /** * 为文件生成唯一的 abbrlink * @param {string} filepath 文件路径 * @param {string} createdTime 创建时间 * @param {object} timestamps 时间戳数据对象 * @returns {string} 生成的 abbrlink */ function generateUniqueAbbrlink(filepath, createdTime, timestamps) { const relativePath = relative(process.cwd(), filepath).replace(/\\/g, '/'); const timeString = new Date(createdTime).getTime().toString(); const hash = createHash('sha256') .update(relativePath + timeString) .digest('hex'); // 首先尝试使用前8位作为 abbrlink let abbrlink = hash.substring(0, 8); // 检查是否重复 if (isDuplicateAbbrlink(abbrlink, relativePath, timestamps)) { // 尝试使用不同位置的哈希值 let found = false; for (let i = 1; i <= hash.length - 8; i++) { const newAbbrlink = hash.substring(i, i + 8); if (!isDuplicateAbbrlink(newAbbrlink, relativePath, timestamps)) { abbrlink = newAbbrlink; found = true; break; } } // 如果所有可能的组合都尝试过了还是有重复 if (!found) { const uniqueHash = createHash('sha256') .update(relativePath + timeString + Date.now().toString()) .digest('hex'); abbrlink = uniqueHash.substring(0, 8); } } return abbrlink; } // 更新所有文件的 abbrlink async function updateAllAbbrlinks() { // 加载时间戳数据 const timestamps = loadTimestamps(); // 扫描内容目录 const contentDir = join(process.cwd(), 'src', 'content'); const contentFiles = scanContentFiles(contentDir); // 记录各种统计 let updated = 0; let added = 0; let unchanged = 0; let duplicates = 0; // 为每个文件处理 abbrlink for (const filepath of contentFiles) { const relativePath = relative(process.cwd(), filepath).replace(/\\/g, '/'); // 如果文件没有时间戳记录,跳过 if (!timestamps[relativePath]) { continue; } // 检查是否已有 abbrlink if (timestamps[relativePath].abbrlink) { unchanged++; continue; } // 使用统一的函数生成新的 abbrlink let abbrlink = generateUniqueAbbrlink(filepath, timestamps[relativePath].created, timestamps); // 检查是否与简单哈希不同(表示发生了重复处理) const simpleHash = createHash('sha256') .update(relativePath + new Date(timestamps[relativePath].created).getTime().toString()) .digest('hex').substring(0, 8); if (abbrlink !== simpleHash) { duplicates++; } // 更新 abbrlink timestamps[relativePath].abbrlink = abbrlink; added++; } // 保存时间戳数据 saveTimestamps(timestamps); } // 执行更新 updateAllAbbrlinks().catch(error => { console.error('更新 abbrlink 时出错:', error); process.exit(1); });
2303_806435pww/stalux_moved
src/scripts/update-abbrlinks.mjs
JavaScript
mit
4,464
// 博客页面样式 // 主内容区样式 main { width: 100% margin: 0 auto padding: 0 1rem } // 三栏布局 .main-content { display: flex min-height: 100vh gap: 5rem position: relative margin: 1rem auto } // 文章内容区 .article-content { flex: 1 min-width: 0 // 解决Flexbox内容溢出问题 box-shadow: 0 4px 6px rgba(0, 0, 0, 0.753) background-color: rgba(0, 0, 0, 0.1) border-radius: 12px animation: fadeInUp 0.8s ease-in-out forwards opacity: 0 } // 侧边栏共同样式 .left-sidebar, .right-sidebar { flex: 0.3 min-width: 0 // 防止溢出 } // 左侧边栏特定动画 .left-sidebar { animation: fadeInLeft 0.8s ease-in-out forwards opacity: 0 animation-delay: 0.2s } // 右侧边栏特定动画 .right-sidebar { animation: fadeInRight 0.8s ease-in-out forwards opacity: 0 animation-delay: 0.2s } // 头图样式 .hero-image { width: 100% margin-bottom: 1rem animation: fadeIn 1s ease-in-out forwards opacity: 0 img { display: block margin: 0 auto border-radius: 12px box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2) max-height: 400px object-fit: cover } } // 文章内容区 .prose { padding: 2rem border-radius: 12px box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1) // 文章排版增强 p { line-height: 1.7 margin-bottom: 1.5rem } h2, h3, h4 { margin-top: 2.5rem margin-bottom: 1.2rem position: relative } h2 { font-size: 1.8rem border-bottom: 1px solid rgba(255, 255, 255, 0.2) padding-bottom: 0.5rem } h3 { font-size: 1.5rem } h4 { font-size: 1.3rem } ul, ol { padding-left: 1.5rem margin-bottom: 1.5rem } li { margin-bottom: 0.5rem } blockquote { border-left: 4px solid rgba(1, 162, 190, 0.8) padding-left: 1rem margin-left: 0 color: rgba(255, 255, 255, 0.8) font-style: italic margin-bottom: 1.5rem } a { color: rgba(41, 182, 246, 1) text-decoration: none transition: all 0.3s ease position: relative &:not(:has(img)) { &:after { content: " 🔗" font-size: 0.85em opacity: 0.7 } } &:hover { color: rgba(3, 218, 198, 1) text-shadow: 0 0 8px rgba(3, 218, 198, 0.4) } &:active { color: rgba(0, 229, 255, 1) } } img { max-width: 100% height: auto border-radius: 8px display: block margin: 2rem auto } table { width: 100% border-collapse: collapse margin: 2rem 0 overflow-x: auto display: block th, td { border: 1px solid rgba(255, 255, 255, 0.2) padding: 0.75rem text-align: left } th { background-color: rgba(255, 255, 255, 0.1) } tr:nth-child(even) { background-color: rgba(255, 255, 255, 0.05) } } code { color:rgba(255, 121, 198, .95); } strong { color:rgba(255, 217, 102, .95); } del { text-decoration: line-through color: rgba(255, 99, 132, 0.85) background-color: rgba(255, 99, 132, 0.1) padding: 0 4px border-radius: 3px position: relative } u { text-decoration: none position: relative color: rgba(102, 217, 255, 0.95) &::after { content: '' position: absolute left: 0 bottom: -2px width: 100% height: 2px background: linear-gradient(90deg, rgba(102, 217, 255, 0.7), rgba(3, 218, 198, 0.7)) border-radius: 1px box-shadow: 0 0 4px rgba(3, 218, 198, 0.4) } } em { font-style: italic color: rgba(142, 220, 230, 0.95) position: relative padding: 0 2px } } // 标题样式 .title { margin-bottom: 2rem text-align: center line-height: 1.3 animation: fadeInUp 0.8s ease-in-out forwards opacity: 0 animation-delay: 0.1s h1 { margin: 0 0 1rem 0 font-size: 2.5rem background: linear-gradient(90deg, rgba(255, 255, 255, 0.9), rgba(1, 162, 190, 0.9)) -webkit-background-clip: text -webkit-text-fill-color: transparent background-clip: text } } // 日期样式 .date { display: flex justify-content: center gap: 2rem flex-wrap: wrap margin: 1rem 0 color: rgba(255, 255, 255, 0.7) font-size: 0.9rem animation: fadeInUp 0.8s ease-in-out forwards opacity: 0 animation-delay: 0.2s } // 更新日期样式 .last-updated-on { font-style: italic } // 代码块样式增强 .expressive-code { margin: 2rem 0 .frame { border-radius: 8px } } // 响应式调整 @media (max-width: 1200px) { .prose { padding: 1.5rem } .title h1 { font-size: 2.2rem } } @media (max-width: 768px) { .main-content { flex-direction: column gap: 2rem } .prose { padding: 1.2rem } .title h1 { font-size: 2rem } .date { flex-direction: column gap: 0.5rem align-items: center } } @media (max-width: 480px) { main { padding: 0 0.5rem } .prose { padding: 1rem } .title h1 { font-size: 1.8rem } }
2303_806435pww/stalux_moved
src/styles/blog.styl
Stylus
mit
5,075
// 导航容器样式 .nav { width: 100% max-width: 1200px margin: 20px auto padding: 10px 20px position: relative // 导航列表样式 ul { display: flex justify-content: center align-items: center list-style: none padding: 0 margin: 0 flex-wrap: wrap gap: 8px } // 列表项样式 li { margin: 4px 8px flex-shrink: 0 } // 搜索按钮特殊样式 .search-toggle { position: relative cursor: pointer transition: all 0.3s ease &:hover { color: var(--color-primary) } } } // 导航链接样式 .nav-link { display: flex align-items: center text-decoration: none font-size: 1.1rem color: inherit padding: 8px 12px transition: all 0.3s ease text-shadow: 0.1rem 0.1rem 0.2rem rgb(1, 162, 190) border-radius: 6px white-space: nowrap &:hover { transform: translateY(-2px) background-color: rgba(255, 255, 255, 0.1) } } // 导航图标容器样式 .nav-icon-container { display: inline-flex margin-right: 6px } // 导航图标样式 .nav-icon { stroke: currentColor stroke-width: 2 } // 移动端菜单切换按钮样式 .mobile-menu-toggle { display: none background: transparent !important backdrop-filter: none border: none !important color: white cursor: pointer position: fixed top: 20px right: 20px z-index: 101 padding: 12px border-radius: 12px transition: all 0.3s ease box-shadow: none !important .menu-icon-wrapper { position: relative display: block width: 24px height: 24px } .menu-icon { position: absolute top: 0 left: 0 stroke: white stroke-width: 2 transition: all 0.3s ease filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3)) &:hover { filter: drop-shadow(0 0 8px rgba(1, 162, 190, 0.6)) } &.menu-open { opacity: 1 transform: rotate(0deg) } &.menu-close { opacity: 0 transform: rotate(90deg) } } &:hover { transform: scale(1.05) background: transparent !important border: none !important box-shadow: none !important } &:active { transform: scale(0.95) background: transparent !important } &[aria-expanded="true"] { background: transparent !important border: none !important .menu-open { opacity: 0 transform: rotate(-90deg) } .menu-close { opacity: 1 transform: rotate(0deg) } } } // 针对导航项过多的情况进行优化 @media (min-width: 901px) { .nav { ul { // 当导航项过多时,允许换行 flex-wrap: wrap max-width: 100% // 确保至少有两行时的垂直间距 row-gap: 10px } } } @media (max-width: 1024px) { .nav { max-width: 100% padding: 10px 15px ul { gap: 6px } li { margin: 3px 6px } } .nav-link { font-size: 1rem padding: 6px 10px } } @media (max-width: 900px) { .nav { ul { gap: 4px } li { margin: 2px 4px } } .nav-link { font-size: 0.95rem padding: 6px 8px span:last-child { display: none } } .nav-icon-container { margin-right: 0 } // 在900px断点及以上不显示移动端菜单按钮 .mobile-menu-toggle { display: none !important } } // 确保在768px-900px区间内也不显示移动菜单切换按钮 @media (min-width: 769px) and (max-width: 900px) { .mobile-menu-toggle { display: none !important } } // 在768px以下才完全隐藏原导航栏,显示移动端菜单 @media (max-width: 768px) { .nav { width: 100% margin: 10px auto // 完全隐藏原导航栏 ul { display: none flex-direction: column position: fixed top: 70px left: 50% transform: translateX(-50%) width: 95% max-width: 420px background: linear-gradient(135deg, rgba(0, 0, 0, 0.15) 0%, rgba(0, 0, 0, 0.25) 30%, rgba(0, 0, 0, 0.35) 70%, rgba(0, 0, 0, 0.25) 100%) backdrop-filter: blur(20px) border: 1px solid rgba(1, 162, 190, 0.15) border-radius: 20px padding: 24px 0 box-shadow: 0 20px 50px rgba(0, 0, 0, 0.3), 0 8px 20px rgba(1, 162, 190, 0.05), inset 0 1px 0 rgba(255, 255, 255, 0.08), inset 0 -1px 0 rgba(1, 162, 190, 0.1) z-index: 99 gap: 6px opacity: 0 transform: translateX(-50%) translateY(-15px) scale(0.9) transition: all 0.4s cubic-bezier(0.25, 0.8, 0.25, 1) &.active { display: flex !important opacity: 1 transform: translateX(-50%) translateY(0) scale(1) animation: mobileMenuBounceIn 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards } &::before { content: "" position: absolute top: -9px left: 50% transform: translateX(-50%) width: 18px height: 18px background: linear-gradient(135deg, rgba(0, 0, 0, 0.25) 0%, rgba(0, 0, 0, 0.35) 100%) border: 1px solid rgba(1, 162, 190, 0.15) border-bottom: none border-right: none transform: translateX(-50%) rotate(45deg) border-radius: 3px 0 0 0 z-index: 1 } &::after { content: "" position: absolute top: 0 left: 0 right: 0 bottom: 0 background: linear-gradient(45deg, rgba(1, 162, 190, 0.03) 0%, transparent 30%, transparent 70%, rgba(1, 162, 190, 0.03) 100%) border-radius: 20px pointer-events: none } } li { margin: 8px 20px text-align: center position: relative opacity: 0 transform: translateY(15px) animation: mobileMenuItemSlideIn 0.3s ease-out forwards &:nth-child(1) { animation-delay: 0.1s } &:nth-child(2) { animation-delay: 0.15s } &:nth-child(3) { animation-delay: 0.2s } &:nth-child(4) { animation-delay: 0.25s } &:nth-child(5) { animation-delay: 0.3s } &:nth-child(6) { animation-delay: 0.35s } &:nth-child(7) { animation-delay: 0.4s } &:nth-child(8) { animation-delay: 0.45s } &:not(:last-child)::after { content: "" position: absolute bottom: -4px left: 15% right: 15% height: 1px background: linear-gradient(90deg, transparent, rgba(1, 162, 190, 0.2), rgba(1, 162, 190, 0.4), rgba(1, 162, 190, 0.2), transparent) opacity: 0.6 } } } .nav-link { justify-content: center align-items: center padding: 16px 24px font-size: 1.1rem border-radius: 14px transition: all 0.4s cubic-bezier(0.25, 0.8, 0.25, 1) position: relative overflow: hidden background: rgba(255, 255, 255, 0.01) border: 1px solid rgba(255, 255, 255, 0.03) &::before { content: "" position: absolute top: 0 left: -100% width: 100% height: 100% background: linear-gradient(90deg, transparent, rgba(1, 162, 190, 0.1), transparent) transition: left 0.6s ease z-index: 0 } &::after { content: "" position: absolute top: 50% left: 50% width: 0 height: 0 background: radial-gradient(circle, rgba(1, 162, 190, 0.2) 0%, transparent 70%) border-radius: 50% transition: all 0.4s ease transform: translate(-50%, -50%) z-index: 0 } &:hover { background: linear-gradient(135deg, rgba(1, 162, 190, 0.12) 0%, rgba(1, 162, 190, 0.08) 50%, rgba(1, 162, 190, 0.04) 100%) border-color: rgba(1, 162, 190, 0.3) transform: translateY(-3px) scale(1.02) box-shadow: 0 8px 20px rgba(1, 162, 190, 0.1), 0 4px 10px rgba(0, 0, 0, 0.15), inset 0 1px 0 rgba(255, 255, 255, 0.08) text-shadow: 0 0 8px rgba(1, 162, 190, 0.4) &::before { left: 100% } &::after { width: 120px height: 120px } } &:active { transform: translateY(-1px) scale(0.98) transition: all 0.1s ease } span:last-child { display: inline font-weight: 600 position: relative z-index: 1 letter-spacing: 0.5px } } .nav-icon-container { margin-right: 10px transition: all 0.4s cubic-bezier(0.25, 0.8, 0.25, 1) position: relative z-index: 1 .nav-link:hover & { transform: scale(1.15) rotate(8deg) filter: drop-shadow(0 0 8px rgba(1, 162, 190, 0.6)) } .nav-icon { filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3)) } } .mobile-menu-toggle { display: block !important position: fixed top: 20px right: 20px z-index: 101 background: transparent !important backdrop-filter: none border: none !important border-radius: 12px padding: 12px transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1) box-shadow: none !important &:hover { transform: scale(1.05) background: rgba(1, 162, 190, 0.1) !important border: none !important box-shadow: none !important } &:active { transform: scale(0.95) transition: all 0.1s ease } .menu-icon { stroke: white transition: all 0.3s ease filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.5)) &:hover { filter: drop-shadow(0 0 8px rgba(1, 162, 190, 0.8)) } } } // 搜索按钮特殊样式 .search-toggle { background: linear-gradient(135deg, rgba(1, 162, 190, 0.25), rgba(1, 162, 190, 0.15)) border: 1px solid rgba(1, 162, 190, 0.4) box-shadow: 0 4px 12px rgba(1, 162, 190, 0.1), inset 0 1px 0 rgba(255, 255, 255, 0.1) &:hover { background: linear-gradient(135deg, rgba(1, 162, 190, 0.35), rgba(1, 162, 190, 0.25)) border-color: rgba(1, 162, 190, 0.6) box-shadow: 0 6px 16px rgba(1, 162, 190, 0.2), 0 0 20px rgba(1, 162, 190, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.15) } } } @media (max-width: 480px) { .nav { ul { width: 98% max-width: 380px padding: 20px 0 border-radius: 18px &::before { width: 14px height: 14px top: -7px } } li { margin: 6px 16px } } .nav-link { font-size: 1rem padding: 14px 20px border-radius: 12px } } // 新增动画关键帧 @keyframes mobileMenuBounceIn { 0% { opacity: 0 transform: translateX(-50%) translateY(-20px) scale(0.8) } 60% { opacity: 1 transform: translateX(-50%) translateY(2px) scale(1.05) } 100% { opacity: 1 transform: translateX(-50%) translateY(0) scale(1) } } @keyframes mobileMenuItemSlideIn { 0% { opacity: 0 transform: translateY(15px) } 100% { opacity: 1 transform: translateY(0) } } // 为移动端菜单添加渐入动画 @keyframes mobileMenuSlideIn { from { opacity: 0 transform: translateX(-50%) translateY(-20px) scale(0.9) } to { opacity: 1 transform: translateX(-50%) translateY(0) scale(1) } } @keyframes mobileMenuSlideOut { from { opacity: 1 transform: translateX(-50%) translateY(0) scale(1) } to { opacity: 0 transform: translateX(-50%) translateY(-20px) scale(0.9) } } // 移动端菜单项逐个显示动画 - 更新版本 @media (max-width: 768px) { .nav ul.active li { animation: fadeInUp 0.4s cubic-bezier(0.25, 0.8, 0.25, 1) forwards opacity: 0 &:nth-child(1) { animation-delay: 0.08s } &:nth-child(2) { animation-delay: 0.12s } &:nth-child(3) { animation-delay: 0.16s } &:nth-child(4) { animation-delay: 0.2s } &:nth-child(5) { animation-delay: 0.24s } &:nth-child(6) { animation-delay: 0.28s } &:nth-child(7) { animation-delay: 0.32s } &:nth-child(8) { animation-delay: 0.36s } } } @keyframes fadeInUp { from { opacity: 0 transform: translateY(25px) scale(0.95) } to { opacity: 1 transform: translateY(0) scale(1) } } // 移动端菜单遮罩层优化 .mobile-menu-backdrop { position: fixed top: 0 left: 0 width: 100% height: 100% background: linear-gradient(45deg, rgba(0, 0, 0, 0.4) 0%, rgba(0, 0, 0, 0.3) 50%, rgba(1, 162, 190, 0.1) 100%) backdrop-filter: blur(4px) z-index: 98 opacity: 0 visibility: hidden transition: all 0.4s cubic-bezier(0.25, 0.8, 0.25, 1) &.active { opacity: 1 visibility: visible } } @media (min-width: 769px) { .mobile-menu-backdrop { display: none } }
2303_806435pww/stalux_moved
src/styles/components/Header.styl
Stylus
mit
12,859
// 文章导航样式 .post-navigation { width: 100% margin: 3rem 0 1.5rem border-top: 1px solid rgba(255, 255, 255, 0.1) padding-top: 2rem .post-navigation-inner { display: flex justify-content: space-between gap: 1rem } .post-nav-link { display: flex align-items: center gap: 0.75rem padding: 1rem background: rgba(255, 255, 255, 0.05) border-radius: 0.5rem color: #fff text-decoration: none transition: all 0.3s ease border: 1px solid rgba(255, 255, 255, 0.1) flex: 1 1 0 min-width: 0 // 确保flex项可以缩小 position: relative overflow: hidden &::before { content: "" position: absolute top: 0 left: -100% width: 100% height: 100% background: linear-gradient(120deg, rgba(255, 255, 255, 0), rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0)) transition: all 0.8s ease } &:hover { background: rgba(1, 162, 190, 0.1) border-color: rgba(1, 162, 190, 0.3) transform: translateY(-3px) box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2) &::before { left: 100% } .post-nav-arrow { color: rgba(1, 162, 190, 0.9) } } &.disabled { opacity: 0.5 pointer-events: none cursor: not-allowed background: rgba(255, 255, 255, 0.02) } &.prev-post { text-align: left margin-left: 10px; } &.next-post { text-align: right justify-content: flex-end margin-right: 10px; } } .post-nav-content { display: flex flex-direction: column min-width: 0 // 为了文本过长时的省略 overflow: hidden } .post-nav-arrow { flex-shrink: 0 color: rgba(255, 255, 255, 0.7) transition: color 0.2s ease } .post-nav-label { font-size: 0.85rem color: rgba(1, 162, 190, 0.9) margin-bottom: 0.3rem } .post-nav-title { font-size: 1rem white-space: nowrap overflow: hidden text-overflow: ellipsis max-width: 100% } } // 响应式样式 @media (max-width: 768px) { .post-navigation { margin: 2rem 0 1rem .post-navigation-inner { gap: 0.75rem } .post-nav-link { padding: 0.8rem &.prev-post .post-nav-arrow { transform: scale(0.85) } &.next-post .post-nav-arrow { transform: scale(0.85) } } .post-nav-label { font-size: 0.8rem margin-bottom: 0.2rem } .post-nav-title { font-size: 0.9rem } } } // 移动端适配 @media (max-width: 576px) { .post-navigation { margin: 1.5rem 0 1rem .post-navigation-inner { flex-direction: column gap: 0.75rem } .post-nav-link { width: 100% padding: 0.7rem } } }
2303_806435pww/stalux_moved
src/styles/components/PostNavigation.styl
Stylus
mit
2,906
// 随机文章组件样式 .random-posts { // 使用与其他侧边栏组件一致的样式 background-color: rgba(0, 0, 0, 0.192) border-radius: 8px padding: 1rem box-shadow: 0 4px 6px rgba(0, 0, 0, 0.753) background-color: rgba(0, 0, 0, 0.1) margin-bottom: 1.5rem transition: all 0.3s ease &:hover { box-shadow: 0 6px 12px rgba(0, 0, 0, 0.8) } } .random-posts-header { display: flex justify-content: space-between align-items: center margin-bottom: 0.8rem padding-bottom: 0.5rem border-bottom: 1px solid rgba(255, 255, 255, 0.2) h3 { margin: 0 font-size: 1.2rem color: rgba(255, 255, 255, 0.9) } .refresh-button { background: none border: none color: rgba(255, 255, 255, 0.7) cursor: pointer padding: 0 display: flex align-items: center justify-content: center transition: all 0.3s ease &:hover { color: rgba(1, 162, 190, 0.9) transform: rotate(45deg) } &.rotating { animation: rotate360 0.6s ease } svg { width: 16px height: 16px } } } .random-posts-list { list-style: none padding: 0 margin: 0 // 滚动条样式 max-height: 300px overflow-y: auto scrollbar-width: thin scrollbar-color: rgba(255, 255, 255, 0.3) transparent &::-webkit-scrollbar { width: 4px } &::-webkit-scrollbar-track { background: transparent } &::-webkit-scrollbar-thumb { background-color: rgba(255, 255, 255, 0.3) border-radius: 3px } // 淡入淡出过渡效果 &.fade-out { opacity: 0 transition: opacity 0.3s ease } &.fade-in { opacity: 1 animation: fadeIn 0.5s ease forwards } } .random-post-item { margin-bottom: 0.5rem padding: 0.3rem 0 border-bottom: 1px dashed rgba(255, 255, 255, 0.1) transition: transform 0.2s ease &:last-child { border-bottom: none margin-bottom: 0 } &:hover { transform: translateX(3px) } } .random-post-link { text-decoration: none color: rgba(255, 255, 255, 0.8) transition: all 0.2s ease font-size: 0.95rem display: block white-space: nowrap overflow: hidden text-overflow: ellipsis &:hover { color: rgba(1, 162, 190, 0.9) text-decoration: none } } .no-posts { color: rgba(255, 255, 255, 0.6) font-style: italic font-size: 0.9rem padding: 0.5rem text-align: center } // 旋转动画 @keyframes rotate360 { from { transform: rotate(0deg) } to { transform: rotate(360deg) } } // 响应式样式 @media (max-width: 1200px) { .random-posts { padding: 0.9rem } .random-post-link { font-size: 0.9rem } } @media (max-width: 1024px) { .random-posts { padding: 0.8rem } .random-posts-header { h3 { font-size: 1.1rem } } .random-post-link { font-size: 0.85rem } .random-posts-list { max-height: 250px } } @media (max-width: 900px) { .random-posts { padding: 0.7rem } .random-posts-header { margin-bottom: 0.6rem h3 { font-size: 1rem } .refresh-button svg { width: 14px height: 14px } } .random-post-item { padding: 0.25rem 0 } } // 移动设备适配 (虽然左右侧边栏在移动设备上通常被隐藏,但保留这些样式以防需要) @media (max-width: 768px) { .random-posts { margin-bottom: 1rem } .random-posts-list { max-height: 200px } }
2303_806435pww/stalux_moved
src/styles/components/RandomPosts.styl
Stylus
mit
3,476
// 自定义Pagefind UI样式 .pagefind-ui { width: 100%; max-width: 100%; font-family: inherit; color: white !important; // 搜索输入框 .pagefind-ui__search-input { border: 2px solid var(--color-border); border-radius: 8px; padding: 0.8rem 1rem; font-size: 1rem; width: 100%; background-color: var(--color-bg); color: var(--color-text); transition: all 0.3s ease; &:focus { outline: none; border-color: var(--color-primary); box-shadow: 0 0 5px var(--color-primary-shadow); } &::placeholder { color: var(--color-text-light); } } // 结果容器 .pagefind-ui__results { margin-top: 1rem; } // 结果项 .pagefind-ui__result { padding: 2rem; border-radius: 8px; margin-bottom: 1rem; background-color: var(--color-card-bg); transition: transform 0.2s ease; border: 2px solid rgba(255, 255, 255, 0.1) !important; &:hover { transform: translateY(-2px); box-shadow: 0 5px 10px rgba(0, 0, 0, 0.05); } } // 结果标题 .pagefind-ui__result-title { font-size: 1.2rem; font-weight: 600; margin-bottom: 0.5rem; color: var(--color-heading); text-decoration: none; &:hover { color: var(--color-primary); } } // 结果摘要 .pagefind-ui__result-excerpt { font-size: 0.9rem; color: var(--color-text); line-height: 1.6; margin-bottom: 0.5rem; } // 高亮文本 mark { background-color: var(--color-primary-light); color: var(--color-primary); padding: 0 0.2rem; border-radius: 2px; } // 消息提示 .pagefind-ui__message { padding: 1rem; background-color: var(--color-card-bg); border-radius: 8px; text-align: center; color: var(--color-text-light); } // 加载指示器 .pagefind-ui__button { background-color: var(--color-primary); color: rgba(255, 255, 255, 0.171); border: none; border-radius: 6px; padding: 0.5rem 1rem; font-size: 0.9rem; cursor: pointer; transition: background-color 0.2s ease; &:hover { background-color: var(--color-primary-dark); } } } // 修改搜索悬浮框样式 .search-container { position: fixed; top: 0; left: 0; width: 100%; height: 100%; z-index: 1000; display: flex; align-items: center; justify-content: center; visibility: hidden; opacity: 0; transition: visibility 0s linear 0.3s, opacity 0.3s ease; &.active { visibility: visible; opacity: 1; transition-delay: 0s; } .search-backdrop { position: absolute; top: 0; left: 0; width: 100%; height: 100%; background-color: rgba(0, 0, 0, 0.5); backdrop-filter: blur(5px); } .search-box { position: relative; width: 90%; max-width: 700px; max-height: 80vh; background-color: var(--color-card-bg); border-radius: 12px; box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15); overflow: hidden; z-index: 1001; animation: search-appear 0.3s ease; display: flex; flex-direction: column; .search-header { padding: 1rem 1.5rem; border-bottom: 1px solid var(--color-border); display: flex; align-items: center; justify-content: space-between; h2 { margin: 0; font-size: 1.25rem; color: var(--color-heading); } .search-close { background: none; border: none; cursor: pointer; color: var(--color-text-light); transition: color 0.2s ease; padding: 0.5rem; margin: -0.5rem; line-height: 0; &:hover { color: var(--color-primary); } } } .search-content { padding: 1.5rem; overflow-y: auto; flex: 1; } } } @keyframes search-appear { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } } // 响应式样式 @media (max-width: 768px) { .search-container { .search-box { width: 95%; max-width: 95%; max-height: 90vh; } } } .pagefind-ui__search-clear { background-color: rgba(255, 255, 255, 0) !important; text-color: var(--color-text-light) !important; border: none; border-radius: 6px; padding: 0.5rem 1rem; font-size: 0.9rem; cursor: pointer; transition: background-color 0.2s ease; &:hover { background-color: } } .pagefind-ui__result-link{ background-image: linear-gradient(90deg, rgba(255,255,255,0.9), rgba(1, 162, 190, 0.9)) !important; -webkit-background-clip: text !important; -webkit-text-fill-color: transparent !important; background-clip: text !important; } mark{ background-color: rgba(42, 246, 253, 0.5) !important; } .pagefind-ui__result-inner{ margin-left: 2rem; }
2303_806435pww/stalux_moved
src/styles/components/Search.styl
Stylus
mit
4,879
.sidebar-section { background-color: rgba(0, 0, 0, 0.192) border-radius: 8px padding: 1rem box-shadow: 0 4px 6px rgba(0, 0, 0, 0.753) background-color: rgba(0, 0, 0, 0.1) margin-bottom: 1.5rem .section-header { display: flex justify-content: space-between align-items: center margin-bottom: 0.8rem padding-bottom: 0.5rem h3 { margin: 0 font-size: 1.2rem color: rgba(255, 255, 255, 0.9) } } .section-toggle { background: none border: none color: rgba(255, 255, 255, 0.7) cursor: pointer padding: 0 display: flex align-items: center justify-content: center transition: transform 0.3s ease &:hover { color: rgba(255, 255, 255, 1) } &.collapsed { transform: rotate(-90deg) } } } .section-content { max-height: 500px overflow-y: auto opacity: 1 transition: max-height 0.3s ease, opacity 0.3s ease scrollbar-width: thin scrollbar-color: rgba(255, 255, 255, 0.3) transparent &::-webkit-scrollbar { width: 6px } &::-webkit-scrollbar-track { background: transparent } &::-webkit-scrollbar-thumb { background-color: rgba(255, 255, 255, 0.3) border-radius: 3px } &.collapsed { max-height: 0 opacity: 0 overflow: hidden } } .category-list { display: flex flex-wrap: wrap gap: 0.5rem padding: 0.2rem } .category-tag { border-radius: 4px padding: 0.2rem 0.5rem font-size: 0.85rem color: rgba(255, 255, 255, 0.9) text-decoration: none transition: all 0.2s ease background-color: rgba(255, 255, 255, 0.1) display: flex align-items: center .category-name { margin-right: 0.3rem } .category-count { font-size: 0.75rem color: rgba(255, 255, 255, 0.6) font-weight: normal } &:hover { background-color: rgba(255, 255, 255, 0.25) transform: translateY(-2px) .category-count { color: rgba(255, 255, 255, 0.8) } } } .no-categories { color: rgba(255, 255, 255, 0.6) font-style: italic font-size: 0.9rem padding: 0.5rem text-align: center } @keyframes shine { 0% { transform: translateX(-100%) } 100% { transform: translateX(100%) } }
2303_806435pww/stalux_moved
src/styles/components/categories/SidebarCategories.styl
Stylus
mit
2,248
.card { width: 100% margin: 20px auto max-width: 500px } .author { display: flex justify-content: center align-items: center flex-wrap: wrap gap: 15px } .author-info { display: flex flex-direction: column } .name { font-size: 1.5rem margin-bottom: 5px text-shadow: 0.25rem 0.25rem 0.5rem rgb(1, 162, 190) h2 { margin: 0 line-height: 1.2 } } .avatar-container { width: 100px height: 100px border-radius: 50% overflow: hidden border: 2px solid rgba(1, 162, 190, 0.5) box-shadow: 0 0 15px rgba(1, 162, 190, 0.2) flex-shrink: 0 } .avatar { display: block width: 100% height: 100% object-fit: cover transition: transform 0.6s ease } .avatar-container:hover .avatar { transform: rotate(360deg) scale(1.05) box-shadow: 0 0 20px rgba(1, 162, 190, 0.4) } .avatar-container:not(:hover) .avatar { transition: transform 0.8s ease transform: rotate(0deg) } /* 响应式样式调整 */ @media (max-width: 1024px) { .card { max-width: 450px } .avatar-container { width: 90px height: 90px } .name { font-size: 1.4rem } } @media (max-width: 900px) { .card { max-width: 400px } .avatar-container { width: 80px height: 80px } } @media (max-width: 768px) { .card { margin: 15px auto max-width: 350px } .author { justify-content: center } .name { font-size: 1.3rem } } /* 确保在小屏幕上也能显示 */ @media (max-width: 480px) { .card { max-width: 100% margin: 10px auto } .author { flex-direction: row justify-content: center text-align: center gap: 10px } .avatar-container { width: 70px height: 70px } .name { font-size: 1.2rem } } /* 处理超窄屏幕,确保内容能完全展示 */ @media (max-width: 360px) { .author { flex-direction: column align-items: center } .author-info { align-items: center text-align: center } }
2303_806435pww/stalux_moved
src/styles/components/others/AuthorCard.styl
Stylus
mit
1,979
.social-links { display: flex justify-content: center align-items: center margin: 25px auto width: 90% max-width: 800px ul { display: flex flex-wrap: wrap justify-content: center list-style: none padding: 0 margin: 0 gap: 10px } li { margin: 5px } a { display: flex align-items: center justify-content: center width: 48px height: 48px border-radius: 50% transition: all 0.3s ease color: #ffffff text-decoration: none background-color: rgba(255, 255, 255, 0.1) &:hover { transform: translateY(-3px) background-color: rgba(255, 255, 255, 0.2) } } i { font-size: 1.5rem } } /* 为bilibili自定义图标 */ .custom-icon { font-style: normal font-weight: bold font-size: 1.3rem } .sr-only { position: absolute width: 1px height: 1px padding: 0 margin: -1px overflow: hidden clip: rect(0, 0, 0, 0) white-space: nowrap } /* 添加svg图标的样式 */ .icon-container { svg { width: 24px height: 24px font-size: 1.5rem } } /* 响应式调整 */ @media (max-width: 768px) { .social-links { margin: 20px auto ul { gap: 5px } a { width: 44px height: 44px } } } @media (max-width: 480px) { .social-links { a { width: 40px height: 40px } i, .icon-container svg { font-size: 1.2rem } } }
2303_806435pww/stalux_moved
src/styles/components/others/SocialLinks.styl
Stylus
mit
1,454
.sidebar-section { background-color: rgba(0, 0, 0, 0.192) border-radius: 8px padding: 1rem box-shadow: 0 4px 6px rgba(0, 0, 0, 0.753) background-color: rgba(0, 0, 0, 0.1) margin-bottom: 1.5rem .section-header { display: flex justify-content: space-between align-items: center margin-bottom: 0.8rem border-bottom: 1px solid rgba(255, 255, 255, 0.2) padding-bottom: 0.5rem h3 { margin: 0 font-size: 1.2rem color: rgba(255, 255, 255, 0.9) } } .section-toggle { background: none border: none color: rgba(255, 255, 255, 0.7) cursor: pointer padding: 0 display: flex align-items: center justify-content: center transition: transform 0.3s ease &:hover { color: rgba(255, 255, 255, 1) } &.collapsed { transform: rotate(-90deg) } } } .section-content { max-height: 500px overflow-y: auto opacity: 1 &.collapsed { max-height: 0 opacity: 0 overflow: hidden } } /* 标签云样式 */ .tag-cloud { display: flex flex-wrap: wrap gap: 0.5rem } .tag { border-radius: 4px padding: 0.2rem 0.5rem font-size: 0.85rem color: rgba(255, 255, 255, 0.9) text-decoration: none transition: all 0.2s ease background-color: rgba(255, 255, 255, 0.1) &:hover { background-color: rgba(255, 255, 255, 0.25) transform: translateY(-2px) } } .no-tags { color: rgba(255, 255, 255, 0.6) font-style: italic font-size: 0.9rem }
2303_806435pww/stalux_moved
src/styles/components/others/Tags.styl
Stylus
mit
1,512
.cc-by-nc-sa-box { background-color: rgba(0, 0, 0, 0.1); padding: 1.5rem; border-radius: 0.5rem; border: 1px solid rgba(255, 255, 255, 0.20); max-width: 80%; margin: 1.5rem auto; position: relative; overflow: hidden; .cc-content { position: relative; z-index: 2; } .cc-title { margin-top: 0; margin-bottom: 0.5rem; font-size: 1.2rem; } .cc-author, .cc-url, .cc-license { margin: 0.5rem 0; font-size: 0.9rem; } a { color: #58a6ff; text-decoration: none; position: relative; transition: all 0.3s ease; border-bottom: 1px dashed rgba(88, 166, 255, 0.5); padding-bottom: 1px; &:hover { color: #79bcff; border-bottom: 1px solid #79bcff; } &:active { color: #2188ff; } } .cc-watermark { position: absolute; bottom: 1rem; right: 1rem; opacity: 0.15; z-index: 1; transition: opacity 0.3s ease; .tool-icons { display: flex; gap: 8px; align-items: center; } .cc-icon { display: inline-block; width: 48px; height: 48px; svg { width: 100%; height: 100%; display: block; } } } }
2303_806435pww/stalux_moved
src/styles/components/others/cc.styl
Stylus
mit
1,517
// 全局样式 - 使用 Stylus 嵌套语法 // 基础重置样式 * { margin: 0 padding: 0 box-sizing: border-box //text-shadow: 0.25rem 0.25rem 0.5rem rgb(1, 162, 190) } // 自定义滚动条样式 ::-webkit-scrollbar { width: 8px height: 8px } ::-webkit-scrollbar-track { background: #2a2a2a border-radius: 4px } ::-webkit-scrollbar-thumb { background: #4a4a4a border-radius: 4px transition: background 0.3s &:hover { background: #5a5a5a } } ::-webkit-scrollbar-corner { background: #2a2a2a } // Firefox 滚动条样式 html { scrollbar-width: thin scrollbar-color: #4a4a4a #2a2a2a } // 移除列表样式 ul, ol { list-style: none } // 其他样式清除 address, article, aside, canvas, details, figcaption, figure, footer, header, hgroup, main, nav, section, summary { display: block } blockquote, q { quotes: none &::before, &::after { content: "" content: none } } table { border-collapse: collapse border-spacing: 0 } // 基础页面样式 body { color: #fff background-color: #202020 position: relative min-height: 100vh overflow-x: hidden font-size: 16px // 基础字体大小 } // 响应式文字大小 @media (max-width: 768px) { body { font-size: 14px } } @media (max-width: 480px) { body { font-size: 12px } } // 背景容器样式 #background-container { pointer-events: none // 确保背景不会拦截鼠标事件 } // 链接样式 a { text-decoration: none } // 淡入动画 @keyframes fadeIn { from { opacity: 0 } to { opacity: 1 } } // 添加从下向上淡入动画 @keyframes fadeInUp { from { opacity: 0 transform: translateY(20px) } to { opacity: 1 transform: translateY(0) } } // 添加从左向右淡入动画 @keyframes fadeInLeft { from { opacity: 0 transform: translateX(-20px) } to { opacity: 1 transform: translateX(0) } } // 添加从右向左淡入动画 @keyframes fadeInRight { from { opacity: 0 transform: translateX(20px) } to { opacity: 1 transform: translateX(0) } } // 基础动画类 .fade-in { animation: fadeIn 0.8s ease-in-out forwards opacity: 0 } .fade-in-up { animation: fadeInUp 0.8s ease-in-out forwards opacity: 0 } .fade-in-left { animation: fadeInLeft 0.8s ease-in-out forwards opacity: 0 } .fade-in-right { animation: fadeInRight 0.8s ease-in-out forwards opacity: 0 } // 动画延迟类 .delay-100 { animation-delay: 0.1s } .delay-200 { animation-delay: 0.2s } .delay-300 { animation-delay: 0.3s } .delay-400 { animation-delay: 0.4s } .delay-500 { animation-delay: 0.5s } .delay-600 { animation-delay: 0.6s } // 响应式容器 .container { width: 90% max-width: 1200px margin: 0 auto padding: 0 15px } // 响应式网格系统 .row { display: flex flex-wrap: wrap margin: 0 -15px } .col { flex: 1 padding: 0 15px } // 媒体查询断点 @media (max-width: 992px) { .row { flex-direction: column } .col { width: 100% margin-bottom: 20px } } // 移动端触摸优化 @media (max-width: 768px) { a, button { min-height: 44px // 提供足够大的触摸区域 min-width: 44px display: inline-flex align-items: center justify-content: center } } // 主页面包装器 .main-wrapper { min-height: 100vh display: flex flex-direction: column position: relative }
2303_806435pww/stalux_moved
src/styles/global.styl
Stylus
mit
3,417
// 此文件只包含全局样式或共享的基础样式 // 组件特定的样式已迁移到各自的组件中 // 共享的卡片样式属性 .glass-card { background-color: rgba(0, 0, 0, 0.021); backdrop-filter: blur(25px); border-radius: 10px; border: 1px solid rgba(255, 255, 255, 0.3); box-shadow: 0 10px 35px rgba(0, 0, 0, 0.226); animation: fadeInUp 0.8s ease-in-out forwards; opacity: 0; } // 为不同的卡片设置不同的延迟 .glass-card:nth-child(1) { animation-delay: 0.1s; } .glass-card:nth-child(2) { animation-delay: 0.2s; } .glass-card:nth-child(3) { animation-delay: 0.3s; } .glass-card:nth-child(4) { animation-delay: 0.4s; } .glass-card:nth-child(5) { animation-delay: 0.5s; } .glass-card:nth-child(n+6) { animation-delay: 0.6s; } // 全局动画效果 @keyframes float { 0% { transform: translateY(0); } 50% { transform: translateY(-10px); } 100% { transform: translateY(0); } } .float-animation { animation: float 6s ease-in-out infinite; } // Home布局样式 html, body { height: 100%; margin: 0; padding: 0; overflow-x: hidden; } .container { width: 90%; max-width: 1200px; margin: 0 auto; padding: 0 15px; flex: 1 0 auto; display: flex; flex-direction: column; justify-content: center; } .Hometitle { font-size: 2.0rem; display: flex; justify-content: center; text-shadow: 0.25rem 0.25rem 0.5rem rgb(1, 162, 190); animation: fadeInUp 0.8s ease-in-out forwards; opacity: 0; animation-delay: 0.1s; } @media (max-width: 768px) { .Hometitle h1 { font-size: 1.8rem; } } @media (max-width: 480px) { .container { width: 95%; padding: 0 10px; } .HometitleS h1 { font-size: 1.5rem; } }
2303_806435pww/stalux_moved
src/styles/home.styl
Stylus
mit
1,725
// AboutPage.styl - 关于页面样式 // 参考了博客文章和友链页面的样式,保持整体风格一致性 // 主要容器样式 .about-container { max-width: 900px margin: 0 auto padding: 2rem 1.5rem } // 页面标题区域 .about-header { text-align: center margin-bottom: 2rem .about-title { font-size: 2.5rem margin-bottom: 1rem background: linear-gradient(90deg, rgba(255,255,255,0.9), rgba(1, 162, 190, 0.9)) -webkit-background-clip: text -webkit-text-fill-color: transparent background-clip: text animation: fadeInDown 0.8s ease-out forwards } } // 内容区域 .about-content { background: rgba(0, 0, 0, 0.2) border-radius: 12px padding: 2rem box-shadow: 0 6px 12px rgba(0, 0, 0, 0.3) animation: fadeInUp 0.8s ease-out forwards animation-delay: 0.2s opacity: 0 // 内容排版样式 p { margin-bottom: 1.2rem line-height: 1.8 color: rgba(255, 255, 255, 0.85) font-size: 1.05rem } h2 { margin-top: 2rem margin-bottom: 1rem font-size: 1.7rem color: rgba(255, 255, 255, 0.95) border-bottom: 1px solid rgba(255, 255, 255, 0.15) padding-bottom: 0.5rem } h3 { margin-top: 1.5rem margin-bottom: 0.8rem font-size: 1.4rem color: rgba(255, 255, 255, 0.9) } ul, ol { margin-bottom: 1.2rem padding-left: 1.5rem li { margin-bottom: 0.5rem color: rgba(255, 255, 255, 0.8) } } a { color: rgba(45, 165, 206, 0.9) text-decoration: none transition: color 0.2s ease &:hover { color: rgba(45, 165, 206, 1) text-decoration: underline } } img { max-width: 100% border-radius: 8px box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2) margin: 1.5rem 0 display: block } blockquote { border-left: 4px solid rgba(45, 165, 206, 0.7) padding: 0.8rem 1.2rem margin: 1.5rem 0 background: rgba(0, 0, 0, 0.2) border-radius: 0 8px 8px 0 p { margin-bottom: 0.5rem font-style: italic color: rgba(255, 255, 255, 0.75) &:last-child { margin-bottom: 0 } } } pre { background: rgba(0, 0, 0, 0.3) padding: 1rem border-radius: 8px overflow-x: auto margin: 1.5rem 0 code { color: rgba(255, 255, 255, 0.8) font-family: monospace } } code { background: rgba(0, 0, 0, 0.25) padding: 0.2rem 0.4rem border-radius: 4px font-size: 0.9em } hr { border: none height: 1px background: rgba(255, 255, 255, 0.15) margin: 2rem 0 } // 表格样式 table { width: 100% border-collapse: collapse margin: 1.5rem 0 th, td { padding: 0.8rem border-bottom: 1px solid rgba(255, 255, 255, 0.1) text-align: left } th { background: rgba(0, 0, 0, 0.2) color: rgba(255, 255, 255, 0.9) } tr:nth-child(even) { background: rgba(255, 255, 255, 0.05) } } } // Waline评论区样式调整 .waline-comment-container { margin-top: 3rem animation: fadeInUp 0.8s ease-out forwards animation-delay: 0.4s opacity: 0 } // 动画定义 @keyframes fadeInDown { from { opacity: 0 transform: translateY(-20px) } to { opacity: 1 transform: translateY(0) } } @keyframes fadeInUp { from { opacity: 0 transform: translateY(20px) } to { opacity: 1 transform: translateY(0) } } // 响应式调整 @media (max-width: 768px) { .about-container { padding: 1.5rem 1rem } .about-header { .about-title { font-size: 2rem } } .about-content { padding: 1.5rem p { font-size: 1rem } h2 { font-size: 1.5rem } h3 { font-size: 1.3rem } } } @media (max-width: 480px) { .about-container { padding: 1rem 0.8rem } .about-header { .about-title { font-size: 1.8rem } } .about-content { padding: 1rem border-radius: 8px p { font-size: 0.95rem line-height: 1.7 } h2 { font-size: 1.4rem margin-top: 1.8rem } h3 { font-size: 1.2rem margin-top: 1.3rem } } }
2303_806435pww/stalux_moved
src/styles/layouts/AboutPage.styl
Stylus
mit
4,255
.archives-container { max-width: 1000px margin: 0 auto padding: 2rem 1rem min-height: calc(100vh - 200px) } .page-header { text-align: center margin-bottom: 3rem .page-title { font-size: 2.5rem margin-bottom: 1rem background: linear-gradient(90deg, rgba(255,255,255,0.9), rgba(1, 162, 190, 0.9)) -webkit-background-clip: text -webkit-text-fill-color: transparent background-clip: text } .page-description { font-size: 1.1rem color: rgba(255, 255, 255, 0.8) max-width: 600px margin: 0 auto } } .timeline-container { position: relative padding-left: 2rem &::before { content: "" position: absolute left: 0 top: 0 width: 4px height: 100% background: linear-gradient(to bottom, rgba(255, 255, 255, 0.2), rgba(1, 162, 190, 0.4), rgba(255, 255, 255, 0.2)) border-radius: 2px } } .year-section { margin-bottom: 3rem position: relative animation: fadeIn 0.6s ease forwards opacity: 0 &::before { content: "" position: absolute width: 16px height: 16px border-radius: 50% background-color: rgba(1, 162, 190, 0.8) border: 3px solid rgba(255, 255, 255, 0.3) left: -2.5rem top: 0.5rem z-index: 2 } } .year-header { display: flex align-items: center margin-bottom: 1.5rem } .year-title { font-size: 1.8rem margin: 0 color: rgba(1, 162, 190, 0.9) } .year-count { margin-left: 1rem font-size: 0.9rem padding: 0.3rem 0.8rem background-color: rgba(1, 162, 190, 0.2) border-radius: 1rem color: rgba(255, 255, 255, 0.9) } .month-section { margin-bottom: 2rem position: relative &::before { content: "" position: absolute width: 10px height: 10px border-radius: 50% background-color: rgba(255, 255, 255, 0.6) left: -2.25rem top: 0.5rem z-index: 1 } } .month-title { font-size: 1.4rem margin: 0 0 1rem 0 border-bottom: 1px dashed rgba(255, 255, 255, 0.2) padding-bottom: 0.5rem color: rgba(255, 255, 255, 0.9) } .post-list { list-style: none padding: 0 margin: 0 } .post-item { margin-bottom: 1rem position: relative display: flex align-items: baseline &::before { content: "" position: absolute width: 6px height: 6px border-radius: 50% background-color: rgba(1, 162, 190, 0.6) left: -2rem top: 0.6rem z-index: 1 } } .post-date { min-width: 100px font-size: 0.9rem color: rgba(255, 255, 255, 0.6) margin-right: 1rem } .post-link { color: rgba(255, 255, 255, 0.9) text-decoration: none transition: all 0.2s ease position: relative overflow: hidden display: inline-block &::after { content: "" position: absolute bottom: 0 left: 0 width: 100% height: 1px background-color: rgba(1, 162, 190, 0.5) transform: translateX(-100%) transition: transform 0.3s ease } &:hover { color: rgba(1, 162, 190, 0.9) &::after { transform: translateX(0) } } } .no-posts { text-align: center padding: 3rem 1rem color: rgba(255, 255, 255, 0.7) font-size: 1.2rem background-color: rgba(0, 0, 0, 0.1) border-radius: 0.5rem width: 100% } // 懒加载指示器样式 .lazyload-observer { display: flex flex-direction: column align-items: center padding: 2rem 0 opacity: 0.8 transition: opacity 0.3s ease &:hover { opacity: 1 } } .loading-spinner { display: flex justify-content: center margin-bottom: 0.5rem .dot { display: inline-block width: 10px height: 10px margin: 0 3px border-radius: 50% background-color: rgba(1, 162, 190, 0.8) animation: dotPulse 1.4s infinite ease-in-out both &:nth-child(1) { animation-delay: -0.32s } &:nth-child(2) { animation-delay: -0.16s } &:nth-child(3) { animation-delay: 0s } } } .loading-text { font-size: 0.9rem color: rgba(255, 255, 255, 0.7) } @keyframes dotPulse { 0%, 80%, 100% { transform: scale(0.3) } 40% { transform: scale(1.0) } } @keyframes fadeIn { from { opacity: 0 transform: translateY(20px) } to { opacity: 1 transform: translateY(0) } } @media (max-width: 768px) { .archives-container { padding: 1.5rem 0.5rem 2rem 1.5rem } .page-header { margin-bottom: 2rem .page-title { font-size: 2rem } .page-description { font-size: 1rem } } .timeline-container { padding-left: 1.5rem } .year-section { margin-bottom: 2rem &::before { left: -2rem width: 14px height: 14px } } .year-title { font-size: 1.6rem } .month-section { &::before { left: -1.75rem width: 8px height: 8px } } .month-title { font-size: 1.2rem } .post-item { flex-direction: column &::before { left: -1.6rem width: 5px height: 5px } } .post-date { min-width: auto margin-bottom: 0.2rem margin-right: 0 } } @media (max-width: 480px) { .archives-container { padding: 1.5rem 0.5rem 2rem 1.2rem } .page-header { .page-title { font-size: 1.8rem } } .timeline-container { padding-left: 1.2rem &::before { width: 3px } } .year-section { &::before { left: -1.6rem width: 12px height: 12px } } .year-title { font-size: 1.4rem } .month-title { font-size: 1.1rem } .post-item { margin-bottom: 0.8rem &::before { left: -1.35rem width: 4px height: 4px } } }
2303_806435pww/stalux_moved
src/styles/layouts/ArchivesLayout.styl
Stylus
mit
5,710
// 博客文章布局样式 // 响应式视口设置 @media (max-width: 768px) { html { font-size: 95%; } } @media (max-width: 480px) { html { font-size: 90%; } }
2303_806435pww/stalux_moved
src/styles/layouts/BlogPost.styl
Stylus
mit
180
// CategoriesLayout.styl - 分类列表布局的样式 // 容器样式 .categories-container { max-width: 1200px margin: 0 auto padding: 2rem 1rem min-height: calc(100vh - 200px) } // 页面标题部分 .page-header { text-align: center margin-bottom: 3rem .page-title { font-size: 2.5rem margin-bottom: 1rem background: linear-gradient(90deg, rgba(255,255,255,0.9), rgba(1, 162, 190, 0.9)) -webkit-background-clip: text -webkit-text-fill-color: transparent background-clip: text } .page-description { font-size: 1.1rem color: rgba(255, 255, 255, 0.8) max-width: 600px margin: 0 auto } } // 分类网格布局 .categories-grid { display: grid grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)) gap: 1.8rem padding: 1rem max-width: 1200px margin: 0 auto } // 响应式布局 @media (max-width: 768px) { .page-header { margin-bottom: 2rem .page-title { font-size: 2rem } .page-description { font-size: 1rem } } .categories-grid { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)) gap: 1rem } } @media (max-width: 480px) { .categories-container { padding: 1.5rem 0.8rem } .page-header { .page-title { font-size: 1.8rem } } .categories-grid { grid-template-columns: 1fr padding: 0.5rem } }
2303_806435pww/stalux_moved
src/styles/layouts/CategoriesLayout.styl
Stylus
mit
1,395
// CategoryDetailLayout.styl - 分类详情页布局的样式 // 容器样式 .category-detail-container { max-width: 1200px margin: 0 auto padding: 2rem 1rem min-height: calc(100vh - 200px) } // 页面标题部分 .page-header { margin-bottom: 2.5rem position: relative padding-bottom: 1rem border-bottom: 1px solid rgba(255, 255, 255, 0.1) .page-title { font-size: 1.8rem margin-bottom: 0.5rem display: flex align-items: center color: #ffffff .category-icon { margin-right: 0.8rem color: rgba(1, 162, 190, 0.8) } .category-name { color: rgba(1, 162, 190, 0.9) font-weight: 500 } } .page-description { font-size: 1rem color: rgba(255, 255, 255, 0.7) margin-bottom: 0.5rem } .back-link { font-size: 0.9rem color: rgba(255, 255, 255, 0.6) text-decoration: none display: inline-block transition: all 0.2s ease &:hover { color: rgba(1, 162, 190, 0.9) text-decoration: underline } } } // 文章列表容器 .post-list-container { position: relative } // 响应式布局 @media (max-width: 768px) { .category-detail-container { padding: 1.5rem 1rem } .page-header { margin-bottom: 2rem .page-title { font-size: 1.6rem } } } @media (max-width: 480px) { .category-detail-container { padding: 1.2rem 0.8rem } .page-header { .page-title { font-size: 1.4rem flex-wrap: wrap } } }
2303_806435pww/stalux_moved
src/styles/layouts/CategoryDetailLayout.styl
Stylus
mit
1,513
// 左侧边栏布局样式 .left-sidebar { width: 250px padding: 1.5rem 0.5rem position: sticky top: 20px height: fit-content max-height: calc(100vh - 40px) overflow-y: auto /* 隐藏滚动条但保留滚动功能 */ scrollbar-width: none /* Firefox */ -ms-overflow-style: none /* IE and Edge */ /* 为 Webkit 浏览器(Chrome, Safari)隐藏滚动条 */ &::-webkit-scrollbar { display: none } } .sidebar-container { display: flex flex-direction: column gap: 1.5rem } .sidebar-section { border-radius: 8px padding: 1rem box-shadow: 0 4px 6px rgba(0, 0, 0, 0.753) background-color: rgba(0, 0, 0, 0.1) animation: fade-in-left 0.5s ease forwards h3 { margin-top: 0 margin-bottom: 0.8rem font-size: 1.2rem border-bottom: 1px solid rgba(255, 255, 255, 0.2) padding-bottom: 0.5rem color: rgba(255, 255, 255, 0.9) } } .recent-posts { ul { list-style: none padding: 0 margin: 0 } li { margin-bottom: 0.5rem padding: 0.3rem 0 border-bottom: 1px dashed rgba(255, 255, 255, 0.1) &:last-child { border-bottom: none } } a { text-decoration: none color: rgba(255, 255, 255, 0.8) transition: all 0.2s ease font-size: 0.95rem &:hover { color: rgba(255, 255, 255, 1) text-decoration: underline } } } @media (max-width: 1200px) { .left-sidebar { width: 230px } .author-info { .author-name { font-size: 1.3rem } .author-description { font-size: 0.9rem } } } @media (max-width: 1024px) { .left-sidebar { width: 200px padding: 1rem 0.4rem } .sidebar-section { padding: 0.8rem } .avatar-container { width: 80px height: 80px } .author-info { .author-name { font-size: 1.2rem margin: 0.5rem 0 0.3rem } .author-description { font-size: 0.85rem margin: 0.3rem 0 } } } /* 在页面宽度较小但仍显示左侧边栏时的样式优化 */ @media (max-width: 900px) { .left-sidebar { width: 180px padding: 0.8rem 0.3rem } .sidebar-container { gap: 1rem } .sidebar-section { padding: 0.7rem } .avatar-container { width: 70px height: 70px } .author-info { .author-name { font-size: 1.1rem margin: 0.4rem 0 0.2rem } .author-description { font-size: 0.8rem } } .recent-posts { li { margin-bottom: 0.3rem padding: 0.2rem 0 } a { font-size: 0.85rem } } } @media (max-width: 768px) { .left-sidebar { display: none /* 在移动设备上隐藏左侧边栏 */ } } .avatar { display: block width: 100% height: 100% object-fit: cover border-radius: 50% transition: transform 0.6s ease } .avatar-container { width: 100px height: 100px margin: 0 auto overflow: hidden border-radius: 50% &:hover .avatar { transform: rotate(360deg) scale(1.05) box-shadow: 0 0 20px rgba(1, 162, 190, 0.4) } &:not(:hover) .avatar { transition: transform 0.8s ease transform: rotate(0deg) } } .author { display: flex flex-direction: column align-items: center text-align: center } .author-info { margin-top: 0.6rem .author-name { font-size: 1.4rem font-weight: 600 margin: 0.6rem 0 0.4rem color: rgba(255, 255, 255, 0.95) } .author-description { font-size: 1rem color: rgba(255, 255, 255, 0.8) margin: 0.4rem 0 line-height: 1.4 word-wrap: break-word } } @keyframes fade-in-left { from { opacity: 0 transform: translateX(-20px) } to { opacity: 1 transform: translateX(0) } } .fade-in-left { animation: fade-in-left 0.5s ease forwards } .delay-100 { animation-delay: 0.1s } .delay-200 { animation-delay: 0.2s } .delay-300 { animation-delay: 0.3s }
2303_806435pww/stalux_moved
src/styles/layouts/LeftSidebar.styl
Stylus
mit
3,918
// 友链页面的样式,针对暗色背景优化 // 页面容器样式 .page-container { max-width: 1200px margin: 0 auto padding: 20px } // 页面头部样式 .page-header { text-align: center margin-bottom: 30px padding: 20px 0 .page-title { font-size: 2.5rem margin-bottom: 15px background: linear-gradient(90deg, rgba(255,255,255,0.9), rgba(1, 162, 190, 0.9)) -webkit-background-clip: text -webkit-text-fill-color: transparent background-clip: text } .page-description { max-width: 700px margin: 0 auto line-height: 1.6 font-size: 1.1rem color: rgba(255, 255, 255, 0.8) } } // 友链列表样式 .friend-links { display: grid grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)) gap: 20px margin: 30px auto list-style: none padding: 0 max-width: 1200px .friend-link { background: rgba(255, 255, 255, 0.1) border-radius: 8px overflow: hidden transition: all 0.3s ease animation: fadeInUp 0.5s ease forwards opacity: 0 a { display: block padding: 15px color: #fff text-decoration: none } .friend-avatar { display: flex justify-content: center margin-bottom: 15px img { width: 80px height: 80px border-radius: 50% object-fit: cover border: 2px solid rgba(1, 162, 190, 0.5) transition: all 0.3s ease } } .friend-content { text-align: center h2 { font-size: 1.2rem margin-bottom: 8px color: rgba(255, 255, 255, 0.9) } p { font-size: 0.9rem color: rgba(255, 255, 255, 0.7) line-height: 1.4 } } &:hover { transform: translateY(-5px) box-shadow: 0 10px 20px rgba(0, 0, 0, 0.3) background: rgba(255, 255, 255, 0.15) .friend-avatar img { transform: rotate(360deg) scale(1.05) border-color: rgba(1, 162, 190, 0.8) box-shadow: 0 0 15px rgba(1, 162, 190, 0.5) } } } } // 添加进入动画效果 @keyframes fadeInUp { from { opacity: 0 transform: translateY(20px) } to { opacity: 1 transform: translateY(0) } } // 为每个项目设置不同的延迟 .friend-link:nth-child(1) { animation-delay: 0.1s } .friend-link:nth-child(2) { animation-delay: 0.15s } .friend-link:nth-child(3) { animation-delay: 0.2s } .friend-link:nth-child(4) { animation-delay: 0.25s } .friend-link:nth-child(5) { animation-delay: 0.3s } .friend-link:nth-child(n+6) { animation-delay: 0.35s } // 大屏幕:5个卡片一行 @media (min-width: 1400px) { .friend-links { grid-template-columns: repeat(5, 1fr) } } // 中等屏幕:4个卡片一行 @media (max-width: 1399px) and (min-width: 1100px) { .friend-links { grid-template-columns: repeat(4, 1fr) } } // 小屏幕:3个卡片一行 @media (max-width: 1099px) and (min-width: 768px) { .friend-links { grid-template-columns: repeat(3, 1fr) } } // 平板:2个卡片一行 @media (max-width: 767px) and (min-width: 480px) { .page-header { padding: 15px 0 .page-title { font-size: 2rem } .page-description { font-size: 1rem } } .friend-links { grid-template-columns: repeat(2, 1fr) } } // 移动设备:1个卡片一行 @media (max-width: 479px) { .page-header { padding: 10px 0 .page-title { font-size: 1.8rem } .page-description { font-size: 0.9rem } } .friend-links { grid-template-columns: 1fr } }
2303_806435pww/stalux_moved
src/styles/layouts/Links.styl
Stylus
mit
3,631
// 右侧边栏布局样式 .right-sidebar { width: 250px padding: 1.5rem 0.5rem position: sticky top: 20px height: fit-content max-height: calc(100vh - 40px) overflow-y: auto /* 隐藏滚动条但保留滚动功能 */ scrollbar-width: none /* Firefox */ -ms-overflow-style: none /* IE and Edge */ /* 为 Webkit 浏览器(Chrome, Safari)隐藏滚动条 */ &::-webkit-scrollbar { display: none } } /* 时钟部分样式 */ .clock-section { background-color: rgba(0, 0, 0, 0.192) border-radius: 8px padding: 0.5rem box-shadow: 0 4px 6px rgba(0, 0, 0, 0.753) background-color: rgba(0, 0, 0, 0.1) margin-bottom: 1.5rem text-align: center } /* 侧边栏通用部分样式 - 与Categories.astro组件保持一致 */ .sidebar-section { background-color: rgba(0, 0, 0, 0.192) border-radius: 8px padding: 1rem box-shadow: 0 4px 6px rgba(0, 0, 0, 0.753) background-color: rgba(0, 0, 0, 0.1) margin-bottom: 1.5rem } /* 标题和折叠按钮样式 - 与Categories.astro组件保持一致 */ .section-header { display: flex justify-content: space-between align-items: center margin-bottom: 0.8rem border-bottom: 1px solid rgba(255, 255, 255, 0.2) padding-bottom: 0.5rem .section-title { margin: 0 font-size: 1.2rem color: rgba(255, 255, 255, 0.9) } } .section-toggle { background: none border: none color: rgba(255, 255, 255, 0.7) cursor: pointer padding: 0 display: flex align-items: center justify-content: center transition: transform 0.3s ease &:hover { color: rgba(255, 255, 255, 1) } &.collapsed { transform: rotate(-90deg) } } /* 可折叠内容的通用样式 - 与Categories.astro组件保持一致 */ .section-content { max-height: 500px overflow-y: auto opacity: 1 scrollbar-width: thin scrollbar-color: rgba(255, 255, 255, 0.3) transparent &::-webkit-scrollbar { width: 6px } &::-webkit-scrollbar-track { background: transparent } &::-webkit-scrollbar-thumb { background-color: rgba(255, 255, 255, 0.3) border-radius: 3px } &.collapsed { max-height: 0 opacity: 0 overflow: hidden } } /* 无内容时的提示样式 */ .no-content-message { color: rgba(255, 255, 255, 0.6) font-style: italic font-size: 0.9rem padding: 0.5rem text-align: center } /* 目录列表样式 */ .toc-list { list-style: none padding: 0 margin: 0 } .toc-item { margin-bottom: 0.5rem border-radius: 4px transition: background-color 0.2s ease &:hover { background-color: rgba(255, 255, 255, 0.15) } a { color: rgba(255, 255, 255, 0.85) text-decoration: none font-size: 0.95rem transition: color 0.2s ease display: block overflow: hidden text-overflow: ellipsis white-space: nowrap padding: 0.2rem 0.4rem &:hover { color: rgba(255, 255, 255, 1) text-decoration: none } } } /* 不同级别标题的缩进 */ .toc-item-h1 { margin-left: 0 } .toc-item-h2 { margin-left: 0.75rem } .toc-item-h3 { margin-left: 1.5rem } .toc-item-h4 { margin-left: 2.25rem; font-size: 0.9em } .toc-item-h5 { margin-left: 3rem; font-size: 0.85em } .toc-item-h6 { margin-left: 3.75rem; font-size: 0.8em } @keyframes fade-in-right { from { opacity: 0 transform: translateX(20px) } to { opacity: 1 transform: translateX(0) } } .fade-in-right { animation: fade-in-right 0.8s ease forwards opacity: 0 } .delay-100 { animation-delay: 0.1s } .delay-200 { animation-delay: 0.2s } .delay-300 { animation-delay: 0.3s } .delay-400 { animation-delay: 0.4s } @media (max-width: 1024px) { .right-sidebar { width: 200px } } @media (max-width: 768px) { .right-sidebar { display: none /* 在移动设备上隐藏右侧边栏 */ } }
2303_806435pww/stalux_moved
src/styles/layouts/rightSidebar.styl
Stylus
mit
3,832
// 标签布局公共样式 .tags-layout-container { max-width: 1200px margin: 0 auto padding: 2rem 1rem min-height: calc(100vh - 200px) } .page-header { text-align: center margin-bottom: 3rem .page-title { display: flex align-items: center justify-content: center font-size: 2.5rem margin-bottom: 1rem background: linear-gradient(90deg, rgba(255,255,255,0.9), rgba(1, 162, 190, 0.9)) -webkit-background-clip: text -webkit-text-fill-color: transparent background-clip: text } .page-description { font-size: 1.1rem color: rgba(255, 255, 255, 0.8) max-width: 600px margin: 0 auto 1rem } .tag-icon { display: inline-flex margin-right: 0.5rem color: rgba(1, 162, 190, 0.9) stroke: currentColor } .back-link { display: inline-block padding: 0.4rem 1rem border-radius: 2rem background-color: rgba(255, 255, 255, 0.1) color: #ffffff text-decoration: none transition: all 0.3s ease font-size: 0.9rem &:hover { background-color: rgba(1, 162, 190, 0.2) transform: translateY(-2px) } } } // 标签云样式 .tags-cloud { display: flex flex-wrap: wrap gap: 1rem justify-content: center padding: 1rem max-width: 900px margin: 0 auto } .tag-item { position: relative display: flex align-items: center padding: 0.5rem 1rem border-radius: 2rem background-color: rgba(255, 255, 255, 0.1) color: #ffffff text-decoration: none transition: all 0.3s ease border: 1px solid rgba(255, 255, 255, 0.2) overflow: hidden &::before { content: "" position: absolute top: 0 left: 0 width: 100% height: 100% background: linear-gradient(120deg, rgba(255,255,255,0), rgba(255,255,255,0.1), rgba(255,255,255,0)) transform: translateX(-100%) transition: transform 0.6s z-index: 1 } &:hover { transform: translateY(-3px) background-color: rgba(1, 162, 190, 0.2) box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2) border-color: rgba(1, 162, 190, 0.5) &::before { transform: translateX(100%) } } // 根据标签数量调整大小 &[data-count="1"] { font-size: 0.9rem padding: 0.3rem 0.8rem } &[data-count="2"] { font-size: 1rem padding: 0.4rem 0.9rem } &[data-count="3"] { font-size: 1.1rem padding: 0.5rem 1rem } &[data-count^="4"], &[data-count^="5"] { font-size: 1.2rem padding: 0.6rem 1.1rem } &[data-count^="6"], &[data-count^="7"], &[data-count^="8"], &[data-count^="9"] { font-size: 1.3rem padding: 0.7rem 1.2rem } .tag-name { margin-right: 0.5rem z-index: 2 } .tag-count { background-color: rgba(255, 255, 255, 0.2) border-radius: 1rem padding: 0.1rem 0.4rem font-size: 0.8rem min-width: 1.5rem text-align: center z-index: 2 } } .no-tags { font-size: 1.2rem color: rgba(255, 255, 255, 0.6) text-align: center padding: 2rem width: 100% } // 标签详情页样式 .post-list-container { max-width: 1200px margin: 0 auto padding: 1rem } .post-list { list-style: none padding: 0 margin: 0 display: grid grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)) gap: 1.5rem } .post-item { padding: 1.5rem background-color: rgba(255, 255, 255, 0.05) border-radius: 0.5rem transition: all 0.3s ease display: flex flex-direction: column height: fit-content &:hover { background-color: rgba(255, 255, 255, 0.1) transform: translateY(-3px) box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2) } } .post-link { display: block text-decoration: none color: #ffffff margin-bottom: 0.8rem } .post-date { color: rgba(1, 162, 190, 0.9) font-size: 0.9rem margin-bottom: 0.5rem } .post-title { font-size: 1.4rem margin: 0 line-height: 1.3 transition: color 0.2s &:hover { color: rgba(1, 162, 190, 0.9) } } .post-tags { display: flex flex-wrap: wrap gap: 0.5rem margin-top: 1rem } .post-tag { font-size: 0.8rem padding: 0.2rem 0.6rem border-radius: 1rem background-color: rgba(255, 255, 255, 0.1) color: rgba(255, 255, 255, 0.8) text-decoration: none transition: all 0.2s ease &:hover { background-color: rgba(1, 162, 190, 0.2) } &.current { background-color: rgba(1, 162, 190, 0.3) border: 1px solid rgba(1, 162, 190, 0.5) } } .no-posts { font-size: 1.2rem color: rgba(255, 255, 255, 0.6) text-align: center padding: 2rem grid-column: 1 / -1 } // 响应式网格布局 @media (max-width: 1200px) { .post-list-container { max-width: 1000px } .post-list { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)) gap: 1.2rem } } @media (max-width: 1024px) { .post-list-container { max-width: 900px } .post-list { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)) gap: 1rem } .post-item { padding: 1.2rem } .post-title { font-size: 1.2rem } } @media (max-width: 768px) { .post-list { grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)) gap: 1rem } .post-item { padding: 1rem } .post-title { font-size: 1.1rem } .post-date { font-size: 0.8rem } } @media (max-width: 480px) { .post-list { grid-template-columns: 1fr gap: 0.8rem } .post-item { padding: 0.8rem } .post-title { font-size: 1rem } .tags-layout-container { padding: 1rem 0.5rem } }
2303_806435pww/stalux_moved
src/styles/layouts/tags.styl
Stylus
mit
5,540
// About 页面样式 .about-container { max-width: 1000px margin: 0 auto padding: 2rem 1rem min-height: calc(100vh - 200px) animation: fadeIn 0.8s ease-in-out forwards } .about-header { text-align: center margin-bottom: 3rem .about-title { font-size: 2.5rem margin-bottom: 1rem background: linear-gradient(90deg, rgba(255,255,255,0.9), rgba(1, 162, 190, 0.9)) -webkit-background-clip: text -webkit-text-fill-color: transparent background-clip: text } .about-description { font-size: 1.2rem color: rgba(255, 255, 255, 0.8) max-width: 700px margin: 0 auto 1rem line-height: 1.6 } .about-date { font-size: 0.9rem color: rgba(255, 255, 255, 0.7) font-style: italic } } .about-hero-image { margin: 2rem auto text-align: center img { max-width: 100% height: auto border-radius: 8px box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3) border: 1px solid rgba(255, 255, 255, 0.1) } } .about-content { background-color: rgba(0, 0, 0, 0.1) border-radius: 12px padding: 2rem margin-bottom: 2rem box-shadow: 0 4px 6px rgba(0, 0, 0, 0.753) /* 内容排版增强 */ p { line-height: 1.7 margin-bottom: 1.5rem color: rgba(255, 255, 255, 0.9) } h2, h3, h4 { margin-top: 2rem margin-bottom: 1.2rem color: rgba(255, 255, 255, 0.95) } h2 { font-size: 1.8rem padding-bottom: 0.5rem border-bottom: 1px solid rgba(255, 255, 255, 0.2) } h3 { font-size: 1.5rem } h4 { font-size: 1.3rem } ul, ol { padding-left: 1.5rem margin-bottom: 1.5rem line-height: 1.6 } li { margin-bottom: 0.5rem color: rgba(255, 255, 255, 0.9) } blockquote { border-left: 4px solid rgba(1, 162, 190, 0.8) padding: 0.5rem 0 0.5rem 1.5rem margin: 1.5rem 0 color: rgba(255, 255, 255, 0.8) font-style: italic background: rgba(1, 162, 190, 0.1) border-radius: 0 4px 4px 0 } a { color: rgba(1, 162, 190, 1) text-decoration: none transition: all 0.2s ease border-bottom: 1px dashed rgba(1, 162, 190, 0.5) &:hover { border-bottom-style: solid color: rgba(1, 162, 190, 0.8) } } img { max-width: 100% height: auto border-radius: 8px display: block margin: 1.5rem auto } code { background-color: rgba(0, 0, 0, 0.2) padding: 0.2em 0.4em border-radius: 3px font-family: Consolas, Monaco, 'Andale Mono', monospace font-size: 0.9em } pre { background-color: rgba(0, 0, 0, 0.2) padding: 1rem border-radius: 5px overflow-x: auto margin: 1.5rem 0 code { background: none padding: 0 } } table { width: 100% border-collapse: collapse margin: 2rem 0 overflow-x: auto display: block th, td { border: 1px solid rgba(255, 255, 255, 0.2) padding: 0.75rem text-align: left } th { background-color: rgba(255, 255, 255, 0.1) } tr:nth-child(even) { background-color: rgba(255, 255, 255, 0.05) } } /* 特殊样式类 */ .highlight { background: linear-gradient(90deg, rgba(1, 162, 190, 0.2), rgba(1, 162, 190, 0.1)) padding: 1rem border-radius: 5px margin: 1.5rem 0 border-left: 3px solid rgba(1, 162, 190, 0.8) } .card { background: rgba(255, 255, 255, 0.05) border-radius: 8px padding: 1.5rem margin: 1.5rem 0 border: 1px solid rgba(255, 255, 255, 0.1) transition: all 0.3s ease &:hover { transform: translateY(-5px) box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2) background: rgba(255, 255, 255, 0.08) } } .timeline { position: relative padding-left: 2rem margin: 2rem 0 &::before { content: "" position: absolute left: 0 top: 0 width: 4px height: 100% background: linear-gradient(to bottom, rgba(255, 255, 255, 0.2), rgba(1, 162, 190, 0.4), rgba(255, 255, 255, 0.2)) border-radius: 2px } .timeline-item { position: relative margin-bottom: 2rem &::before { content: "" position: absolute width: 12px height: 12px border-radius: 50% background-color: rgba(1, 162, 190, 0.8) border: 2px solid rgba(255, 255, 255, 0.3) left: -2.3rem top: 0.3rem } } } } /* 响应式样式调整 */ @media (max-width: 768px) { .about-header { .about-title { font-size: 2rem } .about-description { font-size: 1.1rem } } .about-content { padding: 1.5rem h2 { font-size: 1.6rem } h3 { font-size: 1.4rem } } } @media (max-width: 480px) { .about-container { padding: 1.5rem 0.8rem } .about-header { margin-bottom: 2rem .about-title { font-size: 1.8rem } .about-description { font-size: 1rem } } .about-content { padding: 1.2rem h2 { font-size: 1.5rem } h3 { font-size: 1.3rem } p { font-size: 0.95rem } } }
2303_806435pww/stalux_moved
src/styles/pages/about.styl
Stylus
mit
5,249
// index.styl - 分类列表页面的特定样式(扁平化展示) // 分类卡片(扁平化展示) .category-card { position: relative display: flex flex-direction: column padding: 1.5rem background-color: rgba(255, 255, 255, 0.05) border-radius: 0.8rem border: 1px solid rgba(255, 255, 255, 0.1) color: #ffffff transition: all 0.3s ease overflow: hidden height: fit-content &::before { content: "" position: absolute top: 0 left: 0 width: 100% height: 100% background: linear-gradient(120deg, rgba(255,255,255,0), rgba(255,255,255,0.05), rgba(255,255,255,0)) transform: translateX(-100%) transition: transform 0.6s z-index: 1 } &:hover { transform: translateY(-3px) background-color: rgba(255, 255, 255, 0.08) border-color: rgba(1, 162, 190, 0.5) box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3) &::before { transform: translateX(100%) } .category-icon { transform: rotate(-15deg) translateY(-3px) background: rgba(1, 162, 190, 0.3) color: rgba(255, 255, 255, 0.9) box-shadow: 0 3px 8px rgba(1, 162, 190, 0.3) opacity: 1 } } } .category-header { display: flex text-decoration: none color: #ffffff position: relative align-items: center width: 100% height: 100% } .category-icon { position: absolute top: 10px right: 10px width: 28px height: 28px color: rgba(255, 255, 255, 0.5) transition: all 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) z-index: 2 transform-origin: center center background: rgba(0, 0, 0, 0.15) padding: 5px border-radius: 6px box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1) opacity: 0.8 svg { width: 100% height: 100% } } .category-content { flex: 1 padding-right: 40px } .category-name { font-size: 1.5rem margin: 0 0 0.5rem 0 position: relative z-index: 2 background: linear-gradient(45deg, #fff, #fff) -webkit-background-clip: text -webkit-text-fill-color: transparent background-clip: text font-weight: 500 } .category-count { font-size: 0.9rem color: rgba(255, 255, 255, 0.8) position: relative z-index: 2 } // 无分类提示 .no-categories { text-align: center grid-column: 1 / -1 padding: 3rem 1rem color: rgba(255, 255, 255, 0.7) font-size: 1.2rem background-color: rgba(0, 0, 0, 0.1) border-radius: 0.5rem } // 响应式样式 @media (max-width: 768px) { .category-card { padding: 1.2rem } .category-name { font-size: 1.3rem } .category-content { padding-right: 35px } } @media (max-width: 480px) { .category-card { padding: 1rem } .category-name { font-size: 1.2rem } .category-content { padding-right: 30px } .category-icon { width: 24px height: 24px } }
2303_806435pww/stalux_moved
src/styles/pages/categories/index-content.styl
Stylus
mit
2,822
// path-content.styl - 分类详情页面的特定样式 // 文章列表样式 - 网格布局 .post-list { list-style: none padding: 0 margin: 0 display: grid grid-template-columns: repeat(auto-fill, minmax(350px, 1fr)) gap: 1.5rem } .post-item { background: rgba(255, 255, 255, 0.03) border-radius: 0.5rem padding: 1.2rem transition: all 0.3s ease position: relative border-left: 2px solid rgba(1, 162, 190, 0.4) height: fit-content &:hover { background: rgba(255, 255, 255, 0.05) transform: translateY(-2px) border-left-color: rgba(1, 162, 190, 0.8) box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2) } } .post-link { text-decoration: none color: #ffffff display: block margin-bottom: 0.6rem } .post-date { font-size: 0.85rem color: rgba(255, 255, 255, 0.6) margin-bottom: 0.3rem } .post-title { margin: 0 font-size: 1.4rem font-weight: normal color: rgba(255, 255, 255, 0.9) line-height: 1.4 transition: color 0.2s ease &:hover { color: rgba(1, 162, 190, 0.9) } } // 文章分类标签样式 .post-categories { margin-top: 0.5rem display: flex flex-wrap: wrap gap: 0.4rem } .category-tag { display: inline-block padding: 0.2rem 0.6rem font-size: 0.75rem background: rgba(1, 162, 190, 0.2) color: rgba(1, 162, 190, 0.9) border-radius: 1rem text-decoration: none transition: all 0.2s ease border: 1px solid rgba(1, 162, 190, 0.3) &:hover { background: rgba(1, 162, 190, 0.3) color: rgba(1, 162, 190, 1) border-color: rgba(1, 162, 190, 0.5) transform: translateY(-1px) } // 当前分类高亮 &.current { background: rgba(1, 162, 190, 0.8) color: #ffffff border-color: rgba(1, 162, 190, 1) font-weight: 500 } } // 无文章提示 .no-posts { grid-column: 1 / -1 text-align: center padding: 3rem 1rem color: rgba(255, 255, 255, 0.7) font-size: 1.1rem background-color: rgba(0, 0, 0, 0.1) border-radius: 0.5rem } // 响应式样式 @media (max-width: 768px) { .post-list { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)) gap: 1rem } .post-item { padding: 1rem } .post-title { font-size: 1.1rem } } @media (max-width: 480px) { .post-list { grid-template-columns: 1fr gap: 0.8rem } .post-item { padding: 0.9rem } .post-title { font-size: 1rem } }
2303_806435pww/stalux_moved
src/styles/pages/categories/path-content.styl
Stylus
mit
2,399
// 文章列表页样式 .posts-container { width: 90% max-width: 1000px margin: 2rem auto 4rem padding: 0 1rem } .page-header { text-align: center margin-bottom: 3rem animation: fadeInDown 0.8s ease forwards .page-title { font-size: 2.5rem margin-bottom: 1rem color: #fff font-weight: 600 text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3) } .page-description { font-size: 1.1rem color: rgba(255, 255, 255, 0.8) max-width: 600px margin: 0 auto } } .posts-list-container { .posts-list { list-style: none padding: 0 margin: 0 display: flex flex-direction: column gap: 1.5rem } .post-item { animation: fadeInUp 0.6s ease forwards opacity: 0 &:nth-child(1) { animation-delay: 0.1s } &:nth-child(2) { animation-delay: 0.15s } &:nth-child(3) { animation-delay: 0.2s } &:nth-child(4) { animation-delay: 0.25s } &:nth-child(5) { animation-delay: 0.3s } &:nth-child(6) { animation-delay: 0.35s } &:nth-child(7) { animation-delay: 0.4s } &:nth-child(8) { animation-delay: 0.45s } &:nth-child(9) { animation-delay: 0.5s } &:nth-child(10) { animation-delay: 0.55s } } .post-card { background: rgba(255, 255, 255, 0.05) border-radius: 0.8rem padding: 1.5rem border: 1px solid rgba(255, 255, 255, 0.1) transition: all 0.3s ease position: relative overflow: hidden &::before { content: "" position: absolute top: 0 left: -100% width: 100% height: 100% background: linear-gradient(120deg, rgba(255, 255, 255, 0), rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0)) transition: all 0.8s ease } &:hover { transform: translateY(-5px) background: rgba(1, 162, 190, 0.1) border-color: rgba(1, 162, 190, 0.3) box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3) &::before { left: 100% } } } .post-meta { display: flex justify-content: space-between align-items: center margin-bottom: 1rem .post-date { color: rgba(1, 162, 190, 0.9) font-size: 0.9rem } .post-tags { display: flex flex-wrap: wrap gap: 0.5rem .post-tag { background: rgba(1, 162, 190, 0.2) color: rgba(255, 255, 255, 0.9) font-size: 0.8rem padding: 0.2rem 0.6rem border-radius: 2rem text-decoration: none border: 1px solid rgba(1, 162, 190, 0.3) transition: all 0.2s ease &:hover { background: rgba(1, 162, 190, 0.3) transform: translateY(-2px) } } .more-tags { color: rgba(255, 255, 255, 0.7) font-size: 0.8rem } } } .post-title { font-size: 1.4rem margin: 0.5rem 0 1rem line-height: 1.4 a { color: #ffffff text-decoration: none transition: color 0.2s ease &:hover { color: rgba(1, 162, 190, 1) } } } .post-footer { display: flex justify-content: flex-end margin-top: 1rem .read-more { display: flex align-items: center gap: 0.3rem color: rgba(1, 162, 190, 0.9) text-decoration: none font-size: 0.9rem transition: all 0.2s ease svg { transition: transform 0.2s ease } &:hover { color: rgba(1, 162, 190, 1) svg { transform: translateX(3px) } } } } } .no-posts { text-align: center margin: 3rem 0 color: rgba(255, 255, 255, 0.7) font-size: 1.2rem } @keyframes fadeInUp { from { opacity: 0 transform: translateY(20px) } to { opacity: 1 transform: translateY(0) } } @keyframes fadeInDown { from { opacity: 0 transform: translateY(-20px) } to { opacity: 1 transform: translateY(0) } } // 响应式样式 @media (max-width: 768px) { .posts-container { width: 95% } .page-header { margin-bottom: 2rem .page-title { font-size: 2rem } .page-description { font-size: 1rem } } .posts-list-container { .post-card { padding: 1.2rem } .post-title { font-size: 1.2rem } .post-meta { flex-direction: column align-items: flex-start gap: 0.8rem } } } // 移动设备优化 @media (max-width: 480px) { .page-header { margin-bottom: 1.5rem .page-title { font-size: 1.8rem } .page-description { font-size: 0.9rem } } .posts-list-container { .posts-list { gap: 1rem } .post-card { padding: 1rem } .post-title { font-size: 1.1rem margin: 0.3rem 0 0.8rem } } }
2303_806435pww/stalux_moved
src/styles/pages/posts/index.styl
Stylus
mit
4,881
/** * 简化的类型定义 - 只保留实际使用的配置 */ /** * 站点配置类型定义 - 清理后只保留实际使用的配置 */ export interface SiteConfig { // 核心基础信息 title: string; description: string; short_description?: string; url: string; author?: string; siteName?: string; // SEO 基础配置 titleDefault?: string; lang?: string; locale?: string; keywords?: string; canonical?: string; // 资源配置 favicon?: string; avatarPath?: string; head?: string; // 导航配置 nav?: NavItem[]; // 特效配置 textyping?: string[]; // 社交媒体链接 medialinks?: MediaLink[]; // 友情链接 friendlinks_title?: string; friendlinks_description?: string; friendlinks?: FriendLink[]; // 评论系统配置 comment?: CommentConfig; // 页脚配置 footer?: FooterConfig; } /** * 页脚配置类型定义 */ export interface FooterConfig { // 站点构建时间 buildtime?: string | Date; // 版权信息 copyright?: { enabled?: boolean; startYear?: number; customText?: string; }; // 主题信息显示 theme?: { showPoweredBy?: boolean; showThemeInfo?: boolean; }; // 备案信息 beian?: { // ICP备案 icp?: { enabled?: boolean; number?: string; }; // 公安备案 security?: { enabled?: boolean; text?: string; number?: string; }; }; // 徽章 badges?: BadgeOptions[]; } /** * 导航项类型 */ export interface NavItem { title: string; path: string; icon?: string; } /** * 社交媒体链接类型 */ export interface MediaLink { title: string; url: string; icon?: string; } /** * 友情链接类型 */ export interface FriendLink { title: string; url: string; avatar?: string; description?: string; } /** * 徽章链接类型 */ export interface BadgeLink { src: string; alt: string; href?: string; } /** * 徽章选项类型 */ export interface BadgeOptions { label: string; message: string; color?: string; style?: 'plastic' | 'flat' | 'flat-square' | 'for-the-badge' | 'social'; labelColor?: string; logo?: string; logoWidth?: number; alt?: string; href?: string; } /** * 评论系统配置类型 */ export interface CommentConfig { waline?: WalineConfig; } /** * Waline配置类型 */ export interface WalineConfig { serverURL: string; path?: string; lang?: string; emoji?: string[]; requiredFields?: string[]; reaction?: boolean; meta?: string[]; wordLimit?: number; pageSize?: number; }
2303_806435pww/stalux_moved
src/types.ts
TypeScript
mit
2,624
/** * 徽章生成器工具 * 基于 badge-maker 库生成徽章 */ import { makeBadge } from 'badge-maker'; import type { BadgeOptions } from '../types'; /** * 生成徽章SVG * @param options 徽章选项 * @returns 返回徽章SVG字符串 */ export function generateBadge(options: BadgeOptions): string { try { const format = { label: options.label, message: options.message, color: options.color || 'blue', style: options.style || 'flat', labelColor: options.labelColor, logo: options.logo, logoWidth: options.logoWidth, }; // 过滤掉未定义的属性 Object.keys(format).forEach(key => { const typedKey = key as keyof typeof format; if (format[typedKey] === undefined) { delete format[typedKey]; } }); return makeBadge(format); } catch (error) { return ''; } } /** * 将SVG字符串转为Data URL * @param svg SVG字符串 * @returns data URL */ export function svgToDataUrl(svg: string): string { if (!svg) return ''; const encoded = encodeURIComponent(svg) .replace(/'/g, '%27') .replace(/"/g, '%22'); return `data:image/svg+xml,${encoded}`; }
2303_806435pww/stalux_moved
src/utils/badge-generator.ts
TypeScript
mit
1,193
/** * 分类工具函数集合 * * 概念区分: * - 分类(Categories): 用于内容的主题组织,具有明确的分类目录结构 * - 标签(Tags): 用于内容的关键词标记,扁平化的标签云形式 * * 本博客中的分类采用扁平化展示模式,但在语义上仍属于分类系统 */ // 定义分类节点的接口 - 扁平化分类结构 export interface CategoryNode { name: string; path: string; count: number; // 属于该分类的文章数量 posts: Array<{ slug: string; title: string }>; // 存储该分类直接关联的文章 } // 定义分类列表类型 - 扁平化结构,便于展示 export type CategoryList = CategoryNode[]; // 提取并组织所有分类,构建扁平化分类结构 export function extractFlatCategories(posts: any[]): CategoryList { const categoryMap = new Map<string, CategoryNode>(); // 处理每篇文章的分类 posts.forEach(post => { if (post.data.categories && Array.isArray(post.data.categories)) { post.data.categories.forEach((categoryName: string) => { if (typeof categoryName === 'string' && categoryName.trim()) { const trimmedName = categoryName.trim(); if (!categoryMap.has(trimmedName)) { categoryMap.set(trimmedName, { name: trimmedName, path: trimmedName, count: 0, posts: [] }); } const category = categoryMap.get(trimmedName)!; category.count++; category.posts.push({ slug: post.slug, title: post.data.title || post.slug }); } }); } }); // 转换为数组并按文章数量排序 return Array.from(categoryMap.values()).sort((a, b) => b.count - a.count); } // 排序函数,将分类按文章数量降序排列 export function sortCategoriesByCount(categories: CategoryList): CategoryList { return categories.sort((a, b) => b.count - a.count); }
2303_806435pww/stalux_moved
src/utils/category-utils.ts
TypeScript
mit
2,004
// 导入默认配置 import type { SiteConfig } from '../types'; import { site as defaultConfig } from '../consts'; // 创建一个Promise来处理异步配置加载 let configPromise: Promise<SiteConfig> | null = null; // 更现代化的配置加载函数 async function loadConfig(): Promise<SiteConfig> { try { // 动态导入用户配置 const userConfigModule = await import('../_config').catch(() => null); // 类型守卫检查 if (userConfigModule && typeof userConfigModule === 'object' && userConfigModule.useConfig === true) { // 合并配置,用户配置优先 return deepMerge(defaultConfig, userConfigModule.siteConfig); } } catch (error) { // 如果导入失败,这表示用户没有创建配置文件,这是正常的 console.debug('未找到用户配置文件或配置文件有误,使用默认配置'); } // 返回默认配置 return defaultConfig; } // 深度合并函数,用于合并默认配置和用户配置 function deepMerge<T extends Record<string, any>>(defaultObj: T, userObj: Partial<T>): T { const result = { ...defaultObj } as T; for (const key in userObj) { if (userObj.hasOwnProperty(key)) { const userValue = userObj[key]; const defaultValue = result[key]; if (userValue !== undefined) { if (isObject(defaultValue) && isObject(userValue)) { result[key] = deepMerge(defaultValue, userValue); } else { result[key] = userValue; } } } } return result; } // 类型守卫函数 function isObject(item: any): item is Record<string, any> { return item !== null && typeof item === 'object' && !Array.isArray(item); } // 导出配置Promise,供应用其他部分使用 export function getConfig(): Promise<SiteConfig> { if (!configPromise) { configPromise = loadConfig(); } return configPromise; } // 也导出一个同步获取配置的方法(如果已经加载完成) export let config_site: SiteConfig = defaultConfig; // 立即执行的异步函数来更新配置 (async () => { try { config_site = await getConfig(); } catch (error) { console.warn('配置加载失败,使用默认配置:', error); } })();
2303_806435pww/stalux_moved
src/utils/config-adapter.ts
TypeScript
mit
2,239
using Godot; using System; public partial class Killzone : Area2D { // Called when the node enters the scene tree for the first time. public override void _Ready() { } // Called every frame. 'delta' is the elapsed time since the previous frame. public override void _Process(double delta) { } private void _on_body_entered(Node body) { GD.Print("wocaonima"); } }
2303_806435pww/my-first-godot-game
testgame/Killzone.cs
C#
cc0-1.0
382
using Godot; using System; public partial class Coin : Area2D { // Called when the node enters the scene tree for the first time. public override void _Ready() { GD.Print("youshit"); } // Connect("body_entered", this, nameof(_on_body_entered)); // 处理 'body_entered' 信号的方法 private void _on_body_entered(Node body) { GD.Print(body.Name+"获得了金币"); QueueFree(); } // Called every frame. 'delta' is the elapsed time since the previous frame. public override void _Process(double delta) { } }
2303_806435pww/my-first-godot-game
testgame/scene/Coin.cs
C#
cc0-1.0
559
using Godot; using System; public partial class Player : CharacterBody2D { public const float Speed = 250.0f; public const float JumpVelocity = -375.0f; public override void _PhysicsProcess(double delta) { Vector2 velocity = Velocity; // Add the gravity. if (!IsOnFloor()) { velocity += GetGravity() * (float)delta; } // Handle Jump. if (Input.IsActionJustPressed("ui_accept") && IsOnFloor()) { velocity.Y = JumpVelocity; } // Get the input direction and handle the movement/deceleration. // As good practice, you should replace UI actions with custom gameplay actions. Vector2 direction = Input.GetVector("ui_left", "ui_right", "ui_up", "ui_down"); if (direction != Vector2.Zero) { velocity.X = direction.X * Speed; } else { velocity.X = Mathf.MoveToward(Velocity.X, 0, Speed); } Velocity = velocity; MoveAndSlide(); } }
2303_806435pww/my-first-godot-game
testgame/scene/Player.cs
C#
cc0-1.0
885
extends Area2D @onready var game_manager: Node = %gameManager @onready var animation_player: AnimationPlayer = $AnimationPlayer # Called when the node enters the scene tree for the first time. func _ready() -> void: pass # Replace with function body. # Called every frame. 'delta' is the elapsed time since the previous frame. func _process(delta: float) -> void: pass func _on_body_entered(body: Node2D) -> void: pass # Replace with function body. print("shabi"); animation_player.play("getcoin"); game_manager.add_point();
2303_806435pww/my-first-godot-game
testgame/scene/coin.gd
GDScript
cc0-1.0
540
extends Node @onready var scorelabel: Label = $scorelabel var score=0; # Called when the node enters the scene tree for the first time. func add_point(): score+=1 scorelabel.text="you have get "+str(score)+" coins."
2303_806435pww/my-first-godot-game
testgame/scene/game_manager.gd
GDScript
cc0-1.0
225
extends Area2D @onready var timer: Timer = $Timer # Called when the node enters the scene tree for the first time. func _ready() -> void: pass # Replace with function body. # Called every frame. 'delta' is the elapsed time since the previous frame. func _process(delta: float) -> void: pass func _on_body_entered(body: Node2D) -> void: pass # Replace with function body. print("死了"); Engine.time_scale=0.5; body.get_node("player").queue_free(); body.character_body_2d.flip_v=1; body.velocity.y=-100; timer.start(); func _on_timer_timeout() -> void: pass # Replace with function body. Engine.time_scale=1; get_tree().reload_current_scene();
2303_806435pww/my-first-godot-game
testgame/scene/killzone.gd
GDScript
cc0-1.0
666
extends AnimatableBody2D @onready var ray_castright: RayCast2D = $RayCastright @onready var ray_castleft: RayCast2D = $RayCastleft var direction =1; const SPEED=30; # Called when the node enters the scene tree for the first time. func _ready() -> void: pass # Replace with function body. # Called every frame. 'delta' is the elapsed time since the previous frame. func _process(delta: float) -> void: if ray_castleft.is_colliding(): direction=1; elif ray_castright.is_colliding(): direction=-1; if direction: position.x+= direction * SPEED*delta; else: position.x+=direction*SPEED*delta;
2303_806435pww/my-first-godot-game
testgame/scene/platform lr.gd
GDScript
cc0-1.0
603
extends CharacterBody2D const SPEED = 250.0 const JUMP_VELOCITY = -350.0 @onready var character_body_2d: AnimatedSprite2D = $CharacterBody2D func _physics_process(delta: float) -> void: # Add the gravity. if not is_on_floor(): velocity += get_gravity() * delta # Handle jump. if Input.is_action_just_pressed("jump") and is_on_floor(): velocity.y = JUMP_VELOCITY # Get the input direction and handle the movement/deceleration. # As good practice, you should replace UI actions with custom gameplay actions. var direction := Input.get_axis("left_move", "right_move") # return -1,0,1,i forgget it!! if direction>0: character_body_2d.flip_h=0 elif direction<0: character_body_2d.flip_h=1 if is_on_floor(): if direction==0: character_body_2d.play("move"); elif direction!=0: character_body_2d.play("run"); else: character_body_2d.play("jump"); if direction: velocity.x = direction * SPEED else: velocity.x = move_toward(velocity.x, 0, SPEED) move_and_slide()
2303_806435pww/my-first-godot-game
testgame/scene/player.gd
GDScript
cc0-1.0
1,012
extends Node2D @onready var ray_cast_left: RayCast2D = $RayCastLeft @onready var ray_cast_right: RayCast2D = $RayCastRight @onready var animated_sprite_2d: AnimatedSprite2D = $AnimatedSprite2D const SPEED=30; var direction=1; # Called when the node enters the scene tree for the first time. func _ready() -> void: pass # Replace with function body. # Called every frame. 'delta' is the elap sed time since the previous frame. func _process(delta: float) -> void: if ray_cast_left.is_colliding()||ray_cast_right.is_colliding(): direction*=-1 animated_sprite_2d.flip_h=!animated_sprite_2d.flip_h position.x+=SPEED*delta*direction;
2303_806435pww/my-first-godot-game
testgame/scene/slime.gd
GDScript
cc0-1.0
639
extends Sprite2D # Called when the node enters the scene tree for the first time. func _ready() -> void: pass # Replace with function body. # Called every frame. 'delta' is the elapsed time since the previous frame. func _process(delta: float) -> void: pass
2303_806435pww/my-first-godot-game
testgame/scene/sprite_2d.gd
GDScript
cc0-1.0
266
import { defineConfig } from "vitepress"; import AutoSidebar from "vite-plugin-vitepress-auto-sidebar"; // https://vitepress.dev/reference/site-config export const en_US = defineConfig({ title: "Travellings", description: "Friend Link Relation Project", themeConfig: { // https://vitepress.dev/reference/default-theme-config nav: [ { text: "Home", link: "/en_US/" }, { text: "Docs", link: "/en_US/docs/", activeMatch: "/en_US/docs/" }, { text: "Blog", link: "/en_US/blog/", activeMatch: "/en_US/blog/" }, { text: "Announcement", link: "/en_US/announcements/", activeMatch: "/en_US/announcements/" }, { text: "Sponsor", link: "https://afdian.com/a/travellings" }, { text: "Member List", link: "https://list.travellings.cn" }, { text: "Travellings GO", link: "/go.html", target: "_blank" }, ], socialLinks: [ { icon: "github", link: "https://github.com/travellings-link/travellings", }, { icon: "twitter", link: "https://twitter.com/travellings_cn" }, { icon: { svg: '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 496 512"><!--!Font Awesome Free 6.5.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2024 Fonticons, Inc.--><path d="M248 8C111 8 0 119 0 256S111 504 248 504 496 393 496 256 385 8 248 8zM363 176.7c-3.7 39.2-19.9 134.4-28.1 178.3-3.5 18.6-10.3 24.8-16.9 25.4-14.4 1.3-25.3-9.5-39.3-18.7-21.8-14.3-34.2-23.2-55.3-37.2-24.5-16.1-8.6-25 5.3-39.5 3.7-3.8 67.1-61.5 68.3-66.7 .2-.7 .3-3.1-1.2-4.4s-3.6-.8-5.1-.5q-3.3 .7-104.6 69.1-14.8 10.2-26.9 9.9c-8.9-.2-25.9-5-38.6-9.1-15.5-5-27.9-7.7-26.8-16.3q.8-6.7 18.5-13.7 108.4-47.2 144.6-62.3c68.9-28.6 83.2-33.6 92.5-33.8 2.1 0 6.6 .5 9.6 2.9a10.5 10.5 0 0 1 3.5 6.7A43.8 43.8 0 0 1 363 176.7z"/></svg>' }, link: "https://t.me/TravellingsCN" }, ], editLink: { pattern: "https://github.com/travellings-link/travellings/edit/master/:path", text: "Edit this page on GitHub", }, logo: { dark: "/assets/light.png", light: "/assets/dark.png", }, siteTitle: false, footer: { copyright: "Copyright © 2020-2024 Travellings Project.", message: 'Released under the GPL License.<br /><a href="https://beian.miit.gov.cn/">闽 ICP 备 2023011626 号 - 1</a><br /><a href="http://www.beian.gov.cn/portal/registerSystemInfo?recordcode=35059102000048">闽公网安备 35059102000048 号</a>', }, docFooter: { prev: "Previous Page", next: "Next Page", }, darkModeSwitchLabel: "Theme", darkModeSwitchTitle: "Switch to dark mode", lightModeSwitchTitle: "Switch to light mode", sidebarMenuLabel: "Menu", returnToTopLabel: "Return to top", externalLinkIcon: true, }, cleanUrls: true, locales: { root: { label: '简体中文', lang: 'zh-CN' }, zh_TW: { label: '繁體中文', lang: 'zh-TW', }, en_US: { label: 'English', lang: 'en-US', }, }, head: [ ["link", { rel: "icon", href: "/assets/favicon.png" }], [ "script", { type: "application/ld+json", innerHTML: JSON.stringify({ '@context': 'https://schema.org/', '@type': 'Organization', name: '开往 Travellings', url: 'https://www.travellings.cn/', sameAs: 'https://github.com/travellings-link', logo: 'https://www.travellings.cn/assets/light.png', email: 'contact@travellings.cn', slogan: 'We hope to make the Internet open through the Friend Link Relation Project.', }), }, ], ], markdown: { lineNumbers: true, theme: { light: "material-theme-lighter", dark: "material-theme-darker", }, image: { lazyLoading: true, }, }, sitemap: { hostname: "https://www.travellings.cn", }, vite: { plugins: [ AutoSidebar({ titleFromFile: true, path: "./", ignoreList: [ "README.md", "public", ".vitepress", "node_modules", "package.json", "pnpm-lock.yaml", ".gitignore", ".git", ".github", "/blog/authors.yml", ], }), ], }, lastUpdated: true, });
2303_806435pww/travellings
.vitepress/config/en_US.mts
TypeScript
agpl-3.0
4,363
import { defineConfig } from 'vitepress' import AutoSidebar from "vite-plugin-vitepress-auto-sidebar"; import { zh_CN } from './zh_CN.mts' import { zh_TW } from './zh_TW.mts' import { en_US } from './en_US.mts' export default defineConfig({ locales: { root: { label: '简体中文', ...zh_CN }, zh_TW: { label: '繁體中文', ...zh_TW }, en_US: { label: 'English', ...en_US }, }, vite: { plugins: [ AutoSidebar({ titleFromFile: true, path: "./", ignoreList: [ "README.md", "public", ".vitepress", "node_modules", "package.json", "pnpm-lock.yaml", ".gitignore", ".git", ".github", "/blog/authors.yml", ], }), ], }, })
2303_806435pww/travellings
.vitepress/config/index.mts
TypeScript
agpl-3.0
790
import { defineConfig } from "vitepress"; import AutoSidebar from "vite-plugin-vitepress-auto-sidebar"; // https://vitepress.dev/reference/site-config export const zh_CN = defineConfig({ title: "开往", description: "友链接力", themeConfig: { // https://vitepress.dev/reference/default-theme-config nav: [ { text: "主页", link: "/" }, { text: "文档", link: "/docs/", activeMatch: "/docs/" }, { text: "博客", link: "/blog/", activeMatch: "/blog/" }, { text: "公告", link: "/announcements/", activeMatch: "/announcements/" }, { text: "赞助", link: "https://afdian.com/a/travellings" }, { text: "成员列表", link: "https://list.travellings.cn" }, { text: "开往", link: "/go.html", target: "_blank" }, ], socialLinks: [ { icon: "github", link: "https://github.com/travellings-link/travellings", }, { icon: "twitter", link: "https://twitter.com/travellings_cn" }, { icon: { svg: '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 496 512"><!--!Font Awesome Free 6.5.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2024 Fonticons, Inc.--><path d="M248 8C111 8 0 119 0 256S111 504 248 504 496 393 496 256 385 8 248 8zM363 176.7c-3.7 39.2-19.9 134.4-28.1 178.3-3.5 18.6-10.3 24.8-16.9 25.4-14.4 1.3-25.3-9.5-39.3-18.7-21.8-14.3-34.2-23.2-55.3-37.2-24.5-16.1-8.6-25 5.3-39.5 3.7-3.8 67.1-61.5 68.3-66.7 .2-.7 .3-3.1-1.2-4.4s-3.6-.8-5.1-.5q-3.3 .7-104.6 69.1-14.8 10.2-26.9 9.9c-8.9-.2-25.9-5-38.6-9.1-15.5-5-27.9-7.7-26.8-16.3q.8-6.7 18.5-13.7 108.4-47.2 144.6-62.3c68.9-28.6 83.2-33.6 92.5-33.8 2.1 0 6.6 .5 9.6 2.9a10.5 10.5 0 0 1 3.5 6.7A43.8 43.8 0 0 1 363 176.7z"/></svg>' }, link: "https://t.me/TravellingsCN" }, ], editLink: { pattern: "https://github.com/travellings-link/travellings/edit/master/:path", text: "在 GitHub 上编辑此页", }, logo: { dark: "/assets/light.png", light: "/assets/dark.png", }, siteTitle: false, footer: { copyright: "Copyright © 2020-2024 Travellings Project.", message: 'Released under the GPL License.<br /><a href="https://beian.miit.gov.cn/">闽 ICP 备 2023011626 号 - 1</a><br /><a href="http://www.beian.gov.cn/portal/registerSystemInfo?recordcode=35059102000048">闽公网安备 35059102000048 号</a>', }, docFooter: { prev: "上一页", next: "下一页", }, darkModeSwitchLabel: "外观", darkModeSwitchTitle: "切换到深色模式", lightModeSwitchTitle: "切换到浅色模式", sidebarMenuLabel: "目录", returnToTopLabel: "返回顶部", externalLinkIcon: true, }, cleanUrls: true, locales: { root: { label: '简体中文', lang: 'zh-CN' }, zh_TW: { label: '繁體中文', lang: 'zh-TW', }, en_US: { label: 'English', lang: 'en-US', }, }, head: [ ["link", { rel: "icon", href: "/assets/favicon.png" }], [ "script", { type: "application/ld+json", innerHTML: JSON.stringify({ '@context': 'https://schema.org/', '@type': 'Organization', name: '开往 Travellings', url: 'https://www.travellings.cn/', sameAs: 'https://github.com/travellings-link', logo: 'https://www.travellings.cn/assets/light.png', email: 'contact@travellings.cn', slogan: '我们期望通过友链接力来让互联网流量变得开放。', }), }, ], ], markdown: { lineNumbers: true, theme: { light: "material-theme-lighter", dark: "material-theme-darker", }, image: { lazyLoading: true, }, }, sitemap: { hostname: "https://www.travellings.cn", }, vite: { plugins: [ AutoSidebar({ titleFromFile: true, path: "./", ignoreList: [ "README.md", "public", ".vitepress", "node_modules", "package.json", "pnpm-lock.yaml", ".gitignore", ".git", ".github", "/blog/authors.yml", ], }), ], }, lastUpdated: true, });
2303_806435pww/travellings
.vitepress/config/zh_CN.mts
TypeScript
agpl-3.0
4,286
import { defineConfig } from "vitepress"; import AutoSidebar from "vite-plugin-vitepress-auto-sidebar"; // https://vitepress.dev/reference/site-config export const zh_TW = defineConfig({ title: "開往", description: "友鏈接力", themeConfig: { // https://vitepress.dev/reference/default-theme-config nav: [ { text: "首頁", link: "/zh_TW/" }, { text: "檔案", link: "/zh_TW/docs/", activeMatch: "/zh_TW/docs/" }, { text: "部落格", link: "/zh_TW/blog/", activeMatch: "/zh_TW/blog/" }, { text: "公告", link: "/zh_TW/announcements/", activeMatch: "/zh_TW/announcements/" }, { text: "贊助", link: "https://afdian.com/a/travellings" }, { text: "成員列表", link: "https://list.travellings.cn" }, { text: "開往GO", link: "/go.html", target: "_blank" }, ], socialLinks: [ { icon: "github", link: "https://github.com/travellings-link/travellings", }, { icon: "twitter", link: "https://twitter.com/travellings_cn" }, { icon: { svg: '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 496 512"><!--!Font Awesome Free 6.5.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2024 Fonticons, Inc.--><path d="M248 8C111 8 0 119 0 256S111 504 248 504 496 393 496 256 385 8 248 8zM363 176.7c-3.7 39.2-19.9 134.4-28.1 178.3-3.5 18.6-10.3 24.8-16.9 25.4-14.4 1.3-25.3-9.5-39.3-18.7-21.8-14.3-34.2-23.2-55.3-37.2-24.5-16.1-8.6-25 5.3-39.5 3.7-3.8 67.1-61.5 68.3-66.7 .2-.7 .3-3.1-1.2-4.4s-3.6-.8-5.1-.5q-3.3 .7-104.6 69.1-14.8 10.2-26.9 9.9c-8.9-.2-25.9-5-38.6-9.1-15.5-5-27.9-7.7-26.8-16.3q.8-6.7 18.5-13.7 108.4-47.2 144.6-62.3c68.9-28.6 83.2-33.6 92.5-33.8 2.1 0 6.6 .5 9.6 2.9a10.5 10.5 0 0 1 3.5 6.7A43.8 43.8 0 0 1 363 176.7z"/></svg>' }, link: "https://t.me/TravellingsCN" }, ], editLink: { pattern: "https://github.com/travellings-link/travellings/edit/master/:path", text: "在 GitHub 上編輯此頁", }, logo: { dark: "/assets/light.png", light: "/assets/dark.png", }, siteTitle: false, footer: { copyright: "Copyright © 2020-2024 Travellings Project.", message: 'Released under the GPL License.<br /><a href="https://beian.miit.gov.cn/">闽 ICP 备 2023011626 号 - 1</a><br /><a href="http://www.beian.gov.cn/portal/registerSystemInfo?recordcode=35059102000048">闽公网安备 35059102000048 号</a>', }, docFooter: { prev: "上一頁", next: "下一頁", }, darkModeSwitchLabel: "外觀", darkModeSwitchTitle: "切換到深色模式", lightModeSwitchTitle: "切換到淺色模式", sidebarMenuLabel: "目錄", returnToTopLabel: "回到頂部", externalLinkIcon: true, }, cleanUrls: true, locales: { root: { label: '简体中文', lang: 'zh-CN' }, zh_TW: { label: '繁體中文', lang: 'zh-TW', }, en_US: { label: 'English', lang: 'en-US', }, }, head: [ ["link", { rel: "icon", href: "/assets/favicon.png" }], [ "script", { type: "application/ld+json", innerHTML: JSON.stringify({ '@context': 'https://schema.org/', '@type': 'Organization', name: '开往 Travellings', url: 'https://www.travellings.cn/', sameAs: 'https://github.com/travellings-link', logo: 'https://www.travellings.cn/assets/light.png', email: 'contact@travellings.cn', slogan: '我們期望透過友鏈接力讓網路流量變得開放。', }), }, ], ], markdown: { lineNumbers: true, theme: { light: "material-theme-lighter", dark: "material-theme-darker", }, image: { lazyLoading: true, }, }, sitemap: { hostname: "https://www.travellings.cn", }, vite: { plugins: [ AutoSidebar({ titleFromFile: true, path: "./", ignoreList: [ "README.md", "public", ".vitepress", "node_modules", "package.json", "pnpm-lock.yaml", ".gitignore", ".git", ".github", "/blog/authors.yml", ], }), ], }, lastUpdated: true, });
2303_806435pww/travellings
.vitepress/config/zh_TW.mts
TypeScript
agpl-3.0
4,327
<!-- .vitepress/theme/Layout.vue --> <script setup lang="ts"> import { useData } from 'vitepress' import DefaultTheme from 'vitepress/theme' import { nextTick, provide } from 'vue' const { isDark } = useData() const enableTransitions = () => 'startViewTransition' in document && window.matchMedia('(prefers-reduced-motion: no-preference)').matches provide('toggle-appearance', async ({ clientX: x, clientY: y }: MouseEvent) => { if (!enableTransitions()) { isDark.value = !isDark.value return } const clipPath = [ `circle(0px at ${x}px ${y}px)`, `circle(${Math.hypot( Math.max(x, innerWidth - x), Math.max(y, innerHeight - y) )}px at ${x}px ${y}px)` ] await document.startViewTransition(async () => { isDark.value = !isDark.value await nextTick() }).ready document.documentElement.animate( { clipPath: isDark.value ? clipPath.reverse() : clipPath }, { duration: 300, easing: 'ease-in', pseudoElement: `::view-transition-${isDark.value ? 'old' : 'new'}(root)` } ) }) </script> <template> <DefaultTheme.Layout /> </template> <style> ::view-transition-old(root), ::view-transition-new(root) { animation: none; mix-blend-mode: normal; } ::view-transition-old(root), .dark::view-transition-new(root) { z-index: 1; } ::view-transition-new(root), .dark::view-transition-old(root) { z-index: 9999; } .VPSwitchAppearance { width: 22px !important; } .VPSwitchAppearance .check { transform: none !important; } </style>
2303_806435pww/travellings
.vitepress/theme/Layout.vue
Vue
agpl-3.0
1,524
<script setup lang="ts"> import { useData } from "vitepress" import { computed } from "vue" const defaultAuthor = "开往" const { frontmatter } = useData() const contributors = computed(() => { return [ frontmatter.value?.author, ...(frontmatter.value.contributors || []), ].filter((x) => x) }) function getAvatarUrl(name: string) { return `https://github.com/${name}.png` } function getGitHubLink(name: string) { return `https://github.com/${name}` } function isNotEmpty(arr: string | string[]) { return Array.isArray(arr) && arr.length } </script> <template> <p v-if="isNotEmpty(contributors)" class="vp-main-color con">本文贡献者:</p> <div v-if="isNotEmpty(contributors)" class="flex flex-wrap gap-4"> <div v-for="contributor of contributors" :key="contributor" class="flex gap-2 items-center vp-main-color"> <a :href="getGitHubLink(contributor)" rel="noreferrer" target="_blank" class="flex items-center gap-2"> <img :src="getAvatarUrl(contributor)" class="w-8 h-8 rounded-full" loading="lazy" /> <p class="vp-main-color">{{ contributor }}</p> </a> </div> </div> </template> <style scoped> .flex { display: flex; } .flex-wrap { flex-wrap: wrap; } .gap-2 { grid-gap: 0.5rem; gap: 0.5rem; } .gap-4 { grid-gap: 1rem; gap: 1rem; } .items-center { align-items: center; } .w-8 { width: 2rem; } .h-8 { width: 2rem; } .rounded-full { border-radius: 9999px; } img { display: block; border: 0.1px solid var(--vp-c-brand); } p { line-height: 24px; /* font-size: 14px; */ font-weight: 500; color: var(--vp-c-brand); } .con { margin-bottom: 5px; } </style>
2303_806435pww/travellings
.vitepress/theme/components/Author.vue
Vue
agpl-3.0
1,714
<script setup lang="ts"> import { ref, Ref, onMounted, onUnmounted, watch, computed } from 'vue'; const loading = ref(false); interface Changelog { date: string; message: string; author: string; } const changelogs: Ref<Changelog[]> = ref([]); const ISOToTime = (ISO: string): string => { return new Date(ISO).toLocaleString(); }; onMounted(async () => { loading.value = true; const timestamp = new Date().getTime(); const res = await fetch("https://api.github.com/repos/travellings-link/travellings/commits?per_page=100&_t=" + timestamp); changelogs.value = (await res.json()).map((item: any) => { return { date: ISOToTime(item.commit.author.date), message: item.commit.message, author: item.commit.author.name }; }); loading.value = false; }); </script> <template> <table> <thead> <th> <slot name="date"></slot> </th> <th> <slot name="message"></slot> </th> <th> <slot name="author"></slot> </th> </thead> <tbody> <template v-if="loading"> <tr> <td colspan="3"> <slot name="loading"></slot> </td> </tr> </template> <template v-else> <tr v-for="item in changelogs"> <td>{{ item.date }}</td> <td>{{ item.message }}</td> <td>{{ item.author }}</td> </tr> </template> </tbody> </table> <a href="https://github.com/travellings-link/travellings/commits/main/" target="_blank"> <slot name="more"></slot> </a> </template>
2303_806435pww/travellings
.vitepress/theme/components/Changelog.vue
Vue
agpl-3.0
1,829
<script setup lang="ts"> // by xuanzhi33 import { ref } from 'vue' import MaintainersTable from './MaintainersTable.vue'; import maintainersData from "./maintainers"; const maintainers = ref(maintainersData); </script> <template> <slot name="active"></slot> <MaintainersTable :maintainers="maintainers" :isActive="true" /> <slot name="inactive"></slot> <MaintainersTable :maintainers="maintainers" :isActive="false" /> </template>
2303_806435pww/travellings
.vitepress/theme/components/Maintainers.vue
Vue
agpl-3.0
443
<script setup lang="ts"> // by xuanzhi33 defineProps<{ maintainers: Record<string, { title: string, active: boolean }>, isActive: boolean }>(); const getGithubUrl = (name: string) => { return `https://github.com/${name}` } const getGithubAvatar = (name: string) => { return `https://github.com/${name}.png` } </script> <template> <table> <template v-for="(maintainer, name) in maintainers" :key="name"> <tr v-if="maintainer.active === isActive"> <td> <img :src="getGithubAvatar(name)" alt="avatar" width="40" /> </td> <td> <a :href="getGithubUrl(name)">{{ name }}</a> </td> <td>{{ maintainer.title }}</td> </tr> </template> </table> </template>
2303_806435pww/travellings
.vitepress/theme/components/MaintainersTable.vue
Vue
agpl-3.0
765
<template> <ClientOnly> <div class="container"> <div class="main"> <h2>分类跳转</h2> <div> 仅跳转到指定类型的网站(当前网站分类尚未完成,设置此项后可跳转的网站可能较少)<br /> 杂项网站指导航、论坛、个人主页、维基文档、在线游戏等不方便加以细分的成员网站,杂项网站与博客一样具有访问的价值。 </div> <select class="form-control" v-model="settings.tag"> <option value="">不使用分类跳转</option> <option value="blog">博客网站</option> <option value="normal">杂项</option> <option value="tech">技术类网站(博客或维基)</option> <option value="site">网站分享类博客</option> <option value="life">生活类博客</option> <option value="hybrid">综合类博客</option> </select> <h2>跳转延时</h2> <div>在跳转页的停留时间,单位:毫秒</div> <input class="form-control" type="number" v-model="settings.timeout" placeholder="不填写则取默认值“1500”" /> <h2>自定义跳转页</h2> <div> 默认样式看腻了?可以在此选择使用其他样式的跳转页面(<a href="/docs/pages">跳转页面一览</a>),您也可以<a href="/docs/join#%E5%8F%82%E4%B8%8E%E9%A1%B9%E7%9B%AE">制作新的跳转页</a> </div> <select class="form-control" v-model="settings.page"> <option value="">使用默认跳转页</option> <!-- 以下为自定义跳转页 --> <option>plain.html</option> <option>coder-1024.html</option> <option>go-by-clouds.html</option> <!-- 以上为自定义跳转页 --> </select> <br> <a href="/go.html" class="go-travelling" target="_self">设置好了,继续开往吧~</a> </div> </div> </ClientOnly> </template> <script> const prefix = "t_preference_"; export default { data: () => ({ settings: { tag: '', timeout: '', page: '' } }), mounted() { for (let key in this.settings) { const value = this.getSettings(key); if (value) { this.settings[key] = value; } } }, watch: { settings: { handler(val) { for (let key in val) { if (val[key]) { this.setSettings(key, val[key]); } else { this.removeSettings(key); } } }, deep: true } }, methods: { getSettings(key) { return localStorage.getItem(prefix + key); }, removeSettings(key) { localStorage.removeItem(prefix + key); }, setSettings(key, value) { localStorage.setItem(prefix + key, value); } } } </script> <style scoped> .go-travelling { margin-top: 2rem; display: inline-block; text-decoration: none; background-color: #333; color: white; padding: 10px 20px; border-radius: 5px; transition: all 0.3s; } .go-travelling:hover { background-color: #555; color: white; } .form-control { width: 100%; padding: 10px 20px; margin-top: 1rem; border: 1px solid #ccc; border-radius: 5px; font-size: 1.1rem } </style>
2303_806435pww/travellings
.vitepress/theme/components/Preferences.vue
Vue
agpl-3.0
3,607
export default { Luochancy: { title: "开往负责人", active: true }, xuanzhi33: { title: "前端开发 / 运维", active: true }, BLxcwg666: { title: "后端开发 / 运维", active: true }, "Big-Cake-jpg": { title: "维护组成员", active: true }, NanamiNakano: { title: "英文翻译", active: true }, ScaredCube: { title: "繁体中文翻译", active: true }, vicevolf: { title: "开往创始人", active: false }, Cubik65536: { title: "维护组成员", active: false }, jiangyangcreate: { title: "前任前后端开发", active: false }, imjason: { title: "前开往负责人", active: false }, rabbitxuanxuan: { title: "维护组成员", active: false }, baipin: { title: "维护组成员", active: true }, BCTX2010: { title: "维护组成员", active: false }, Jiaocz: { title: "维护组成员", active: false }, gtxykn0504: { title: "原文案编辑", active: false }, gxres042: { title: "维护组成员", active: true }, MengZeMC: { title: "公共关系", active: true }, linlinzzo: { title: "维护组成员", active: false } };
2303_806435pww/travellings
.vitepress/theme/components/maintainers.ts
TypeScript
agpl-3.0
1,478
// https://vitepress.dev/guide/custom-theme import { h } from 'vue' import Theme from 'vitepress/theme' import './style.css' // import Layout from "./Layout.vue" disable for a while by author component import Authors from "./components/Author.vue" export default { extends: Theme, Layout: () => { return h(Theme.Layout, null, { // https://vitepress.dev/guide/extending-default-theme#layout-slots "doc-footer-before": () => h(Authors), }) }, enhanceApp({ app, router, siteData }) { // ... } }
2303_806435pww/travellings
.vitepress/theme/index.ts
TypeScript
agpl-3.0
527
/** * Customize default theme styling by overriding CSS variables: * https://github.com/vuejs/vitepress/blob/main/src/client/theme-default/styles/vars.css */ /** * Colors * * Each colors have exact same color scale system with 3 levels of solid * colors with different brightness, and 1 soft color. * * - `XXX-1`: The most solid color used mainly for colored text. It must * satisfy the contrast ratio against when used on top of `XXX-soft`. * * - `XXX-2`: The color used mainly for hover state of the button. * * - `XXX-3`: The color for solid background, such as bg color of the button. * It must satisfy the contrast ratio with pure white (#ffffff) text on * top of it. * * - `XXX-soft`: The color used for subtle background such as custom container * or badges. It must satisfy the contrast ratio when putting `XXX-1` colors * on top of it. * * The soft color must be semi transparent alpha channel. This is crucial * because it allows adding multiple "soft" colors on top of each other * to create a accent, such as when having inline code block inside * custom containers. * * - `default`: The color used purely for subtle indication without any * special meanings attched to it such as bg color for menu hover state. * * - `brand`: Used for primary brand colors, such as link text, button with * brand theme, etc. * * - `tip`: Used to indicate useful information. The default theme uses the * brand color for this by default. * * - `warning`: Used to indicate warning to the users. Used in custom * container, badges, etc. * * - `danger`: Used to show error, or dangerous message to the users. Used * in custom container, badges, etc. * -------------------------------------------------------------------------- */ :root { --vp-c-default-1: var(--vp-c-gray-1); --vp-c-default-2: var(--vp-c-gray-2); --vp-c-default-3: var(--vp-c-gray-3); --vp-c-default-soft: var(--vp-c-gray-soft); --vp-c-brand-1: #8eb4b6; --vp-c-brand-2: #7d9c9d; --vp-c-brand-3: #8cb1b3; --vp-c-brand-soft: var(--vp-c-indigo-soft); --vp-c-tip-1: var(--vp-c-brand-1); --vp-c-tip-2: var(--vp-c-brand-2); --vp-c-tip-3: var(--vp-c-brand-3); --vp-c-tip-soft: var(--vp-c-brand-soft); --vp-c-warning-1: var(--vp-c-yellow-1); --vp-c-warning-2: var(--vp-c-yellow-2); --vp-c-warning-3: var(--vp-c-yellow-3); --vp-c-warning-soft: var(--vp-c-yellow-soft); --vp-c-danger-1: var(--vp-c-red-1); --vp-c-danger-2: var(--vp-c-red-2); --vp-c-danger-3: var(--vp-c-red-3); --vp-c-danger-soft: var(--vp-c-red-soft); } /** * Component: Button * -------------------------------------------------------------------------- */ :root { --vp-button-brand-border: transparent; --vp-button-brand-text: var(--vp-c-white); --vp-button-brand-bg: var(--vp-c-brand-3); --vp-button-brand-hover-border: transparent; --vp-button-brand-hover-text: var(--vp-c-white); --vp-button-brand-hover-bg: var(--vp-c-brand-2); --vp-button-brand-active-border: transparent; --vp-button-brand-active-text: var(--vp-c-white); --vp-button-brand-active-bg: var(--vp-c-brand-1); } /** * Component: Home * -------------------------------------------------------------------------- */ :root { --vp-home-hero-name-color: transparent; --vp-home-hero-name-background: -webkit-linear-gradient( 120deg, #a1ccce 30%, #faf7f0 ); --vp-home-hero-image-background-image: linear-gradient( -45deg, #a1ccce 50%, #faf7f0 50% ); --vp-home-hero-image-filter: blur(44px); } @media (min-width: 640px) { :root { --vp-home-hero-image-filter: blur(56px); } } @media (min-width: 960px) { :root { --vp-home-hero-image-filter: blur(68px); } } /** * Component: Custom Block * -------------------------------------------------------------------------- */ :root { --vp-custom-block-tip-border: transparent; --vp-custom-block-tip-text: var(--vp-c-text-1); --vp-custom-block-tip-bg: var(--vp-c-brand-soft); --vp-custom-block-tip-code-bg: var(--vp-c-brand-soft); } /** * Component: Algolia * -------------------------------------------------------------------------- */ .DocSearch { --docsearch-primary-color: var(--vp-c-brand-1) !important; }
2303_806435pww/travellings
.vitepress/theme/style.css
CSS
agpl-3.0
4,247
/* _____ _ _ _ _____ _ _ __ ______ |_ _| __ __ ___ _____| | (_)_ __ __ _ ___ | ___| __ ___ _ __ | |_ ___ _ __ __| | \ \ / /___ \ | || '__/ _` \ \ / / _ \ | | | '_ \ / _` / __| | |_ | '__/ _ \| '_ \| __/ _ \ '_ \ / _` | \ \ / / __) | | || | | (_| |\ V / __/ | | | | | | (_| \__ \ | _|| | | (_) | | | | || __/ | | | (_| | \ V / / __/ |_||_| \__,_| \_/ \___|_|_|_|_| |_|\__, |___/ |_| |_| \___/|_| |_|\__\___|_| |_|\__,_| \_/ |_____| |___/ 🚇 开往·友链接力! 一群狼走得远 https://github.com/travellings-link/travellings */ @charset "UTF-8"; html { background-image: url("/assets/img/kw-bg-2560.png"); background-repeat: no-repeat; background-position: center; background-size: cover; background-attachment: fixed; } .box { max-width: 50%; margin: 25px auto; } nav { box-shadow: 0px 5px 10px #e2e2e2; } div.title { margin-top: 25px; } iframe.afdian { height: 200px; position: relative; width: 100%; }
2303_806435pww/travellings
public/assets/css/index.css
CSS
agpl-3.0
1,163
/* _____ _ _ _ _____ _ _ __ ______ |_ _| __ __ ___ _____| | (_)_ __ __ _ ___ | ___| __ ___ _ __ | |_ ___ _ __ __| | \ \ / /___ \ | || '__/ _` \ \ / / _ \ | | | '_ \ / _` / __| | |_ | '__/ _ \| '_ \| __/ _ \ '_ \ / _` | \ \ / / __) | | || | | (_| |\ V / __/ | | | | | | (_| \__ \ | _|| | | (_) | | | | || __/ | | | (_| | \ V / / __/ |_||_| \__,_| \_/ \___|_|_|_|_| |_|\__, |___/ |_| |_| \___/|_| |_|\__\___|_| |_|\__,_| \_/ |_____| |___/ 🚇 开往·友链接力! 一群狼走得远 https://github.com/travellings-link/travellings */ @charset "UTF-8"; html { background-image: url("/assets/img/kw-bg-2560.png"); background-repeat: no-repeat; background-position: center; background-size: cover; background-attachment: fixed; } .box { max-width: 90%; margin: 25px auto; } nav { box-shadow: 0px 5px 10px #e2e2e2; } div.title { margin-top: 25px; } iframe.afdian { height: 200px; position: relative; width: 100%; }
2303_806435pww/travellings
public/assets/css/index.mobile.css
CSS
agpl-3.0
1,163
const prefix = "t_preference_"; const getSetting = key => localStorage.getItem(prefix + key); const preferredTag = getSetting("tag"); const travellingTimeout = getSetting("timeout") || 1500; let apiUrl = "https://api.travellings.cn/random"; if (preferredTag) apiUrl += "?tag=" + preferredTag; let go = async () => { let res = await fetch(apiUrl); res = await res.json(); if (!res.success) { alert("非常抱歉,后端服务器出现了问题,请稍后再试~") return; } location.href = res.data[0].url; } setTimeout(go, travellingTimeout);
2303_806435pww/travellings
public/assets/js/go.js
JavaScript
agpl-3.0
585
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>Travellings CLI</title> <script async src="https://umami.luochancy.com/script.js" data-website-id="23ac5682-b5b5-4013-8a32-5ceb3e598df2"></script> <style> body { background-color: black; color: white; font-family: Consolas, monospace; margin: 0; padding: 0; overflow: hidden; } #terminal { width: 100%; height: 100%; position: relative; display: flex; flex-direction: column; } #output-container { flex-grow: 1; overflow: auto; padding: 10px; box-sizing: border-box; font-size: 16px; white-space: nowrap; } #output { /* Output content goes here */ } #input-container { display: flex; align-items: center; padding: 5px; } #prompt { font-size: 16px; margin-right: 5px; } #input { background-color: transparent; color: white; border: none; outline: none; font-size: 16px; flex-grow: 1; white-space: nowrap; } </style> </head> <body> <div id="terminal"> <div id="output-container"> <div id="output"> <pre>________ _______________ ___ __/____________ ___ _________ /__ /__(_)_____________ ________ __ / __ ___/ __ `/_ | / / _ \_ /__ /__ /__ __ \_ __ `/_ ___/ _ / _ / / /_/ /__ |/ // __/ / _ / _ / _ / / / /_/ /_(__ ) /_/ /_/ \__,_/ _____/ \___//_/ /_/ /_/ /_/ /_/_\__, / /____/ /____/ <br>Travellings CLI [Version 1.49]<br>(C) Travellings-link Project. All rights reserved. Made by BLxcwg666 with love.<br>Enter 'help' to get the commands.</pre> </div> </div> <div id="input-container"> <span id="prompt" contenteditable="false">C:\Travellings ></span> <span id="input" contenteditable="true" autofocus></span> </div> </div> <script> const terminal = document.getElementById("terminal"); const input = document.getElementById("input"); const output = document.getElementById("output"); const prompt = document.getElementById("prompt"); let isTravellingMode = false; let selectedDestination = null; const history = []; // Array to store command history let historyIndex = -1; // Index to keep track of the current position in history input.addEventListener("keydown", function (event) { if (event.key === "Enter") { event.preventDefault(); const command = input.textContent.trim(); if (isTravellingMode) { handleTravellingInput(command); } else { if (command !== "") { history.push(command); // Store the command in history historyIndex = history.length; // Reset history index handleRegularInput(command); } else { // If no command is entered, display the prompt only appendToTerminal(prompt.textContent); input.textContent = ""; input.focus(); } } } else if (event.key === "ArrowUp") { // Handle the "Arrow Up" key to navigate command history if (historyIndex > 0) { historyIndex--; input.textContent = history[historyIndex]; } } else if (event.key === "ArrowDown") { // Handle the "Arrow Down" key to navigate command history if (historyIndex < history.length - 1) { historyIndex++; input.textContent = history[historyIndex]; } else if (historyIndex === history.length - 1) { // Clear the input if we're at the latest history entry input.textContent = ""; } } }); function handleRegularInput(command) { if (command.toLowerCase() === "clear") { output.innerHTML = ""; output.scrollTop = 0; } else if (command.toLowerCase() === "travellings" || command.toLowerCase() === "t") { isTravellingMode = true; fetchNewDestination(); } else if (command.toLowerCase() === "date") { const currentDate = new Date().toLocaleString("zh-CN", { timeZone: "Asia/Shanghai" }); appendToTerminal("C:\\Travellings > " + command); appendToTerminal(currentDate); } else if (command.toLowerCase() === "help") { appendToTerminal("C:\\Travellings > " + command); appendToTerminal("Commands:<br>t 开始穿梭!<br>cmd 输出版权信息<br>help 输出帮助菜单<br>echo 输出文字<br>date 输出当前时间<br>clear 清空历史记录<br>settings 前往开往偏好设置<br>travellings 开始穿梭吧!"); } else if (command.toLowerCase() === "cmd") { // Print the title appendToTerminal("Travellings CLI [Version 1.49]<br>(C) Travellings-link Project. All rights reserved."); } else if (command.toLowerCase().startsWith("echo ")) { const text = command.slice(5); appendToTerminal("C:\\Travellings > " + command); appendToTerminal(text); } else if (command.toLowerCase() === "settings") { appendToTerminal("C:\\Travelling > " + command); appendToTerminal("正在前往开往偏好设置...") location.href = "./preference"; } else { appendToTerminal("C:\\Travellings > " + command); appendToTerminal("Command not found: " + command); } input.textContent = ""; input.focus(); } function handleTravellingInput(choice) { choice = choice.toLowerCase(); if (choice === "y") { if (selectedDestination && selectedDestination.url) { window.open(selectedDestination.url, "_blank"); appendToTerminal("请做出你的选择 > Y"); appendToTerminal("即将发车..."); } isTravellingMode = false; // Reset the prompt prompt.textContent = "C:\\Travellings >"; input.textContent = ""; input.focus(); } else if (choice === "n") { fetchNewDestination(); } else if (choice === "e") { isTravellingMode = false; // Reset the prompt prompt.textContent = "C:\\Travellings >"; input.textContent = ""; input.focus(); appendToTerminal("请做出你的选择 > E"); appendToTerminal("已取消本次穿梭"); } else { appendToTerminal("C:\\Travellings > " + choice); appendToTerminal("无效的选择"); // Change the prompt prompt.textContent = "请做出你的选择 >"; input.textContent = ""; input.focus(); } } function fetchNewDestination() { const tag = localStorage.getItem("t_preference_tag") || "tech"; fetch("https://api.travellings.cn/random?tag=" + tag) .then(response => response.json()) .then(data => { if (data.success && data.data.length > 0) { selectedDestination = data.data[0]; // Clear previous destination information output.innerHTML = ""; // Display new destination information appendToTerminal("Go to Travel!"); appendToTerminal(`即将开往:${selectedDestination.name}(${selectedDestination.url})`); appendToTerminal("输入 'Y' 出发,输入 'N' 重新选择目的地,输入 'E' 退出。"); // Change the prompt prompt.textContent = "请做出你的选择 >"; input.textContent = ""; input.focus(); } else { // Handle the case where the request was not successful console.error("出错了呜呜呜~ 从API获取数据时发生错误:", data); } }) .catch(error => { console.error("出错了呜呜呜~ 请求API时发生错误:", error); }); } function appendToTerminal(text) { const pre = document.createElement("pre"); pre.innerHTML = text; output.appendChild(pre); output.scrollTop = output.scrollHeight; } </script> </body> </html>
2303_806435pww/travellings
public/coder-1024.html
HTML
agpl-3.0
8,300
<!-- BY KARLUKLE @ WWW.KARLUKLE.SITE --> <!DOCTYPE html> <html lang="en"> <!-- Document type declaration and language --> <head> <link href="https://fonts.googleapis.com/css2?family=Orbitron&family=VT323&family=Roboto+Mono&display=swap" rel="stylesheet"> <!-- Font links --> <meta charset="utf-8" /> <meta http-equiv="content-language" content="en" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <meta http-equiv="X-UA-Compatible" content="ie=edge" /> <!-- Meta tags definition and settings --> <title>开往-友链接力</title> <!-- Page title --> <meta name="title" content="开往-友链接力" /> <!-- Website icons --> <link rel="icon" href="./assets/favicon.png" /> <style> body, html { height: 100%; margin: 0; overflow: hidden; font-family: Orbitron; background-color: #333; /* Set default background color to dark grey */ transition: background-color 1s ease; /* Set transition effect, lasting 1 second, easing is ease */ } #particles-js { position: absolute; width: 100%; height: 100%; background-color: #000; } #content { position: fixed; top: 56%; left: 50%; transform: translate(-50%, -50%); text-align: center; color: #050826cf; font-size: clamp(15px, 2vw, 50px); opacity: 0; transition: opacity 1s ease; /* Set transition effect, lasting 1 second, easing is ease */ } #clouds { opacity: 0; transition: opacity 1s ease; /* Set transition effect, lasting 1 second, easing is ease */ } /* Basic link styles */ a { color: #000000cf; /* Set link color */ text-decoration: none; /* Remove underline */ transition: color 0.3s ease; /* Color change transition effect */ } /* Color change on hover */ a:hover { color: #0056b3; /* Hover color */ } /* Provide distinct style for active links for better readability and accessibility */ a:active { color: #ff0000; /* Active link color */ } /* Highlight links with background color */ a.highlight { background-color: #ffc107; /* Highlight background color */ padding: 2px 4px; /* Add some padding */ border-radius: 3px; /* Rounded border */ } .botCenter { position: fixed; width: 100%; height: 50px; bottom: 10px; line-height: 20px; font-size: 12px; text-align: center; color: #000000cf; font-family: Roboto Mono; } @keyframes botCenter { 0% { opacity: 0; } 40% { opacity: 0.3; } 100% { opacity: 1; } } @-webkit-keyframes botCenter { 0% { opacity: 0; } 40% { opacity: 0.3; } 100% { opacity: 1; } } @-moz-keyframes botCenter { 0% { opacity: 0; } 40% { opacity: 0.3; } 100% { opacity: 1; } } @-ms-keyframes botCenter { 0% { opacity: 0; } 40% { opacity: 0.3; } 100% { opacity: 1; } } @-o-keyframes botCenter { 0% { opacity: 0; } 40% { opacity: 0.3; } 100% { opacity: 1; } } </style> <!-- Inline style sheet --> </head> <body id="clouds" onload="fadeIn()"> <!-- Page body --> <div id="content">TRAVELLING INTO ANOTHER SPACE<br/><div id="arrive">WE WILL ARRIVE IN <span id="count">10</span>s</div></div> <!-- Main content area --> <script src="https://lf3-cdn-tos.bytecdntp.com/cdn/expire-1-M/three.js/110/three.min.js"></script> <script src="https://lf3-cdn-tos.bytecdntp.com/cdn/expire-1-M/vanta/0.5.21/vanta.clouds.min.js"></script> <script src="https://lf6-cdn-tos.bytecdntp.com/cdn/expire-1-M/gsap/3.9.1/gsap.min.js"></script> <!-- Script references --> <script> var cloudsEffect = VANTA.CLOUDS({ el: "#clouds", mouseControls: true, touchControls: true, gyroControls: false, minHeight: 200.00, minWidth: 200.00 }); var speedUpLink = document.getElementById("speedUpLink"); speedUpLink.addEventListener("click", function() { // Modify cloud speed using TweenMax library gsap.to(cloudsEffect.uniforms.speed, { value: 1.1, duration: 20, ease: "linear" }); // Change speed from default (0.5) to 0.8, lasting 2 seconds }); </script> <!-- Inline script --> <div class="botCenter"> ↩️ Tips: <b>后退</b>网页可再次开往 | <a href="./preference" class="links">⚙️ 开往偏好设置</a> | <a href="https://www.travellings.cn/docs/join" class="links" target="_blank">🚇 加入</a> <br /> <a href="https://beian.miit.gov.cn/" target="_blank">🇨🇳 闽ICP备2023011626号-1</a> | <a target="_blank" href="http://www.beian.gov.cn/portal/registerSystemInfo?recordcode=35059102000048">闽公网安备35059102000048号</a> <script> const prefix = "t_preference_"; const getSetting = key => localStorage.getItem(prefix + key); const preferredTag = getSetting("tag"); var countElement = document.getElementById("count"); const travellingTimeout = getSetting("timeout") || 5000; var count = Math.round(travellingTimeout/1000)+1; var currentPageUrl = window.location.pathname; function updateCount() { count--; // 每次调用减少倒计时 countElement.textContent = count; // 更新倒计时显示 if (count > 0) { setTimeout(updateCount, 1000); // 每秒更新一次倒计时 }; if (count == 3) { gsap.to(cloudsEffect.uniforms.speed, { value: 1.1, duration: 20, ease: "linear" }); // 将速度从默认值(0.5)更改为0.8,持续2秒 } if (count == 1) { gsap.to(cloudsEffect.uniforms.speed, { value: 1.4, duration: 20, ease: "linear" }); let apiUrl = "https://api.travellings.cn/random"; if (preferredTag) apiUrl += "?tag=" + preferredTag; let go = async () => { let res = await fetch(apiUrl); res = await res.json(); if (!res.success) { alert("非常抱歉,后端服务器出现了问题,请稍后再试~") return; } location.href = res.data[0].url; } setTimeout(go, 0); } if (count == 0) { document.getElementById("arrive").style.display = "none"; gsap.to(cloudsEffect.uniforms.speed, { value: 1.1, duration: 20, ease: "linear" }); document.getElementById("content").style.display = "none"; } } function fadeIn() { var clouds = document.getElementById("clouds"); clouds.style.opacity = 1; setTimeout(function() { var content = document.getElementById("content"); content.style.opacity = 1; }, 600); updateCount(); } var cloudsEffect = VANTA.CLOUDS({ el: "#clouds", mouseControls: true, touchControls: true, gyroControls: false, minHeight: 200.00, minWidth: 200.00 }); var speedUpLink = document.getElementById("speedUpLink"); speedUpLink.addEventListener("click", function() { gsap.to(cloudsEffect.uniforms.speed, { value: 1.1, duration: 20, ease: "linear" }); }); </script> </body> </html>
2303_806435pww/travellings
public/go-by-clouds.html
HTML
agpl-3.0
8,633
<!-- _____ _ _ _ __ _______ |_ _| __ __ ___ _____| | (_)_ __ __ _ ___ \ \ / /___ / | || '__/ _` \ \ / / _ \ | | | '_ \ / _` / __| \ \ / / |_ \ | || | | (_| |\ V / __/ | | | | | | (_| \__ \ \ V / ___) | |_||_| \__,_| \_/ \___|_|_|_|_| |_|\__, |___/ \_/ |____/ |___/ 🚇 开往·友链接力! 一群狼走得远 https://github.com/travellings-link/travellings --> <!DOCTYPE html> <html lang="zh"> <head> <meta charset="UTF-8" /> <meta http-equiv="X-UA-Compatible" content="IE=edge" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <title>开往-友链接力</title> <script> const customPage = localStorage.getItem("t_preference_page"); if (customPage) { location.href = "./" + customPage; } </script> <link rel="icon" href="./assets/favicon.png" /> <script async src="https://umami.luochancy.com/script.js" data-website-id="23ac5682-b5b5-4013-8a32-5ceb3e598df2"></script> <style> * { color: #111827; } a { text-decoration: none; } body { transition: background-color 0.5s; } @media (prefers-color-scheme: dark) { * { color: #f9fafb; } body { background: #111111; } } .blink { position: fixed; height: 100%; width: 100%; text-align: center; display: flex; display: -webkit-flex; align-items: center; justify-content: center; animation: blink 3s linear infinite; -webkit-animation: blink 3s linear infinite; -moz-animation: blink 3s linear infinite; -ms-animation: blink 3s linear infinite; -o-animation: blink 3s linear infinite; } @keyframes blink { 0% { opacity: 0; transform: scale(1); } 40% { opacity: 0.3; transform: scale(1); } 80% { opacity: 1; transform: scale(0.98); } 100% { opacity: 0.2; transform: scale(1.2); } } @-webkit-keyframes blink { 0% { opacity: 0; transform: scale(1); } 40% { opacity: 0.3; transform: scale(1); } 80% { opacity: 1; transform: scale(0.98); } 100% { opacity: 0.2; transform: scale(1.2); } } @-moz-keyframes blink { 0% { opacity: 0; transform: scale(1); } 40% { opacity: 0.3; transform: scale(1); } 80% { opacity: 1; transform: scale(0.98); } 100% { opacity: 0.2; transform: scale(1.2); } } @-ms-keyframes blink { 0% { opacity: 0; transform: scale(1); } 40% { opacity: 0.3; transform: scale(1); } 80% { opacity: 1; transform: scale(0.98); } 100% { opacity: 0.2; transform: scale(1.2); } } @-o-keyframes blink { 0% { opacity: 0; transform: scale(1); } 40% { opacity: 0.3; transform: scale(1); } 80% { opacity: 1; transform: scale(0.98); } 100% { opacity: 0.2; transform: scale(1.2); } } .botCenter { position: fixed; width: 100%; height: 50px; bottom: 10px; line-height: 20px; font-size: 12px; text-align: center; animation: botCenter 3s linear; -webkit-animation: botCenter 3s linear; -moz-animation: botCenter 3s linear; -ms-animation: botCenter 3s linear; -o-animation: botCenter 3s linear; } @keyframes botCenter { 0% { opacity: 0; } 40% { opacity: 0.3; } 100% { opacity: 1; } } @-webkit-keyframes botCenter { 0% { opacity: 0; } 40% { opacity: 0.3; } 100% { opacity: 1; } } @-moz-keyframes botCenter { 0% { opacity: 0; } 40% { opacity: 0.3; } 100% { opacity: 1; } } @-ms-keyframes botCenter { 0% { opacity: 0; } 40% { opacity: 0.3; } 100% { opacity: 1; } } @-o-keyframes botCenter { 0% { opacity: 0; } 40% { opacity: 0.3; } 100% { opacity: 1; } } .links { --link-color: #5372b4; color: var(--link-color); } .links:hover { border-bottom: 2px solid var(--link-color); } @media (prefers-color-scheme: dark) { .links { --link-color: #9ca3af; } } </style> </head> <body> <div class="blink"> <a href="https://www.travellings.cn/" target="_blank" title="点击前往“开往”官网 :-)">欢迎回来,正在<b>&nbsp开往&nbsp</b>下一个世界…<br />Welcome back, travelling to the next world…</a> </div> <div class="botCenter"> ↩️ Tips: <b>后退</b>网页可再次开往 | <a href="./preference" class="links">⚙️ 开往偏好设置</a> | <a href="https://www.travellings.cn/docs/join" class="links" target="_blank">🚇 加入</a> <br /> <!--<a href="https://status.travellings.link/status/index" target="_blank">♻️ 状态</a><br />--> <a href="https://beian.miit.gov.cn/" target="_blank">🇨🇳 闽ICP备2023011626号-1</a> | <a target="_blank" href="http://www.beian.gov.cn/portal/registerSystemInfo?recordcode=35059102000048">闽公网安备 35059102000048号</a><!--<br />本网站由<a href="https://www.upyun.com/?utm_source=lianmeng&utm_medium=referral" target="_blank">🆙 又拍云</a>提供CDN加速服务<br />--> <!--<a href="https://github.com/travellings-link/travellings/stargazers"><img alt="GitHub stars" src="https://img.shields.io/github/stars/travellings-link/travellings?style=social" height="18px"></a>--> </div> <style> #notice { position: fixed; width: 100%; top: 0; left: 0; text-align: center; padding: 0.75rem; background-color: #eee; font-size: 0.8rem; transform: translateY(-100%); transition: transform 0.5s; } @media (prefers-color-scheme: dark) { #notice { background-color: #222; } } </style> <div id="notice"> Hi,这里是我们的 <a class="links" href="http://qm.qq.com/cgi-bin/qm/qr?_wv=1027&k=q8CdLceaQzVFRhXPL7aSydV0a-rOXrHX&authKey=rxWesNE7V2fHv1PdX%2FfNTPGI9ntA87m3O8XYpgT8me0w8JGm1bB1VcHetBm9T3Yl&noverify=0&group_code=186690715" target="_blank">QQ群</a> 和 <a href="https://t.me/TravellingsCN" class="links" target="_blank">TG群</a> ,欢迎加入 </div> <script src="./assets/js/go.js"></script> <script> setTimeout(() => { document.querySelector("#notice").style.transform = "translateY(0)"; }, 0); </script> </body> </html>
2303_806435pww/travellings
public/go.html
HTML
agpl-3.0
8,599
<!DOCTYPE html> <html lang="zh"> <head> <meta charset="UTF-8" /> <meta http-equiv="X-UA-Compatible" content="IE=edge" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <script async src="https://umami.luochancy.com/script.js" data-website-id="23ac5682-b5b5-4013-8a32-5ceb3e598df2"></script> <title>开往 - 友链接力</title> <meta name="description" content="欢迎回来,正在开往下一个世界。https://github.com/travellings-link/travellings" /> <link rel="shortcut icon" href="./assets/favicon-fluent-emoji.svg" /> <style> /* 色板:https://www.materialui.co/colors */ * { box-sizing: border-box; margin: 0; padding: 0; } body { font-family: Inter, -apple-system, HarmonyOS Sans SC, MiSans, Source Han Sans SC, Noto Sans SC, system-ui, Roboto, emoji, sans-serif; color: black; background: white; font-weight: 400; font-size: 1rem; min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; } main { padding: 2rem; flex: 1; display: flex; gap: 2rem; flex-direction: column; align-items: center; justify-content: center; } main h1 { margin-top: 4rem; font-size: 1.75rem; font-weight: 700; line-height: 1.75; text-align: center; } main h1 span { white-space: nowrap; } footer { width: 100%; display: flex; flex-wrap: wrap; gap: 0.5rem 1.5rem; align-items: center; justify-content: center; padding: 1.75rem 2rem; } footer a { font-size: 0.875rem; text-decoration: none; color: #757575; transition: all 0.2s; } footer span { flex: 1; } footer a:hover { color: #3f51b5; text-decoration: underline; text-underline-offset: 0.25rem; } @media (prefers-color-scheme: dark) { body { color: #eeeeee; background: #212121; } footer a { color: #bdbdbd; transition: all 0.2s; } footer a:hover { color: #5c6bc0; } } @media screen and (max-width: 768px) { main { margin-top: 4.5rem; } main h1 { font-size: 1.5rem; } footer { gap: 0.5rem 1rem; } footer span { display: none; } } /* Material Design 风格的加载动画 https://codepen.io/mrrocks/pen/ExLovj */ .spinner { -webkit-animation: rotator 1.4s linear infinite; animation: rotator 1.4s linear infinite; } @-webkit-keyframes rotator { 0% { transform: rotate(0deg); } 100% { transform: rotate(270deg); } } @keyframes rotator { 0% { transform: rotate(0deg); } 100% { transform: rotate(270deg); } } .path { stroke-dasharray: 187; stroke-dashoffset: 0; transform-origin: center; -webkit-animation: dash 1.4s ease-in-out infinite, colors 5.6s ease-in-out infinite; animation: dash 1.4s ease-in-out infinite, colors 5.6s ease-in-out infinite; } @-webkit-keyframes colors { 0% { stroke: #4285f4; } 25% { stroke: #de3e35; } 50% { stroke: #f7c223; } 75% { stroke: #1b9a59; } 100% { stroke: #4285f4; } } @keyframes colors { 0% { stroke: #4285f4; } 25% { stroke: #de3e35; } 50% { stroke: #f7c223; } 75% { stroke: #1b9a59; } 100% { stroke: #4285f4; } } @-webkit-keyframes dash { 0% { stroke-dashoffset: 187; } 50% { stroke-dashoffset: 46.75; transform: rotate(135deg); } 100% { stroke-dashoffset: 187; transform: rotate(450deg); } } @keyframes dash { 0% { stroke-dashoffset: 187; } 50% { stroke-dashoffset: 46.75; transform: rotate(135deg); } 100% { stroke-dashoffset: 187; transform: rotate(450deg); } } </style> </head> <body> <main> <h1><span>欢迎回来,正在开往</span><span>下一个世界</span></h1> <!-- Material Design 风格的加载动画 https://codepen.io/mrrocks/pen/ExLovj --> <svg class="spinner" width="32px" height="32px" viewBox="0 0 66 66" xmlns="http://www.w3.org/2000/svg" > <circle class="path" fill="none" stroke-width="6" stroke-linecap="round" cx="33" cy="33" r="30" ></circle> </svg> </main> <footer> <a href="https://www.travellings.cn/" target="_blank" rel="noopener noreferrer" > 主页 </a> <a href="https://github.com/travellings-link/travellings" target="_blank" rel="noopener noreferrer" > GitHub </a> <a href="https://www.travellings.cn/docs/join" target="_blank" rel="noopener noreferrer" > 加入 </a> <a href="https://afdian.com/a/travellings" target="_blank" rel="noopener noreferrer" > 赞助 </a> <a href="./preference"> 偏好设置 </a> <span></span> <a href="https://beian.miit.gov.cn/" target="_blank" rel="noopener noreferrer" > 闽ICP备2023011626号-1 </a> <a href="http://www.beian.gov.cn/portal/registerSystemInfo?recordcode=35059102000048" target="_blank" rel="noopener noreferrer" > 闽公网安备 35059102000048号 </a> </footer> <script src="./assets/js/go.js"></script> </body> </html>
2303_806435pww/travellings
public/plain.html
HTML
agpl-3.0
6,467
<html> <head> <style> .butten { border-radius: 1em; padding: 0.2em; color: #5285ac } .foru { width: "90%"; justify-content: space-between; } </style> </head> <body> <div class="foru"> <span>测试阶段-为你推荐</span> <span class="butten"> 换一批</span> </div> <iframe src="https://www.jiangmiemie.com" width="49%" height="95%" frameborder="0" allowfullscreen="" sandbox=""> <p><a href="https://www.jiangmiemie.com">点击打开嵌入页面</a></p> </iframe> <iframe src="https://blog.travellings.cn" width="49%" height="95%" frameborder="0" allowfullscreen="" sandbox=""> <p><a href="https://blog.travellings.cn">点击打开嵌入页面</a></p> </iframe> </body> </html>
2303_806435pww/travellings
public/rss.html
HTML
agpl-3.0
762
package fun.xingwangzhe.webmapview.client; import com.sun.net.httpserver.HttpServer; import com.sun.net.httpserver.HttpHandler; import com.sun.net.httpserver.HttpExchange; import java.io.OutputStream; import java.net.InetSocketAddress; import java.util.List; import java.util.ArrayList; import java.util.concurrent.Executors; import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.TimeUnit; import net.minecraft.client.MinecraftClient; public class API { private static HttpServer server; private static List<PlayerInformation> localPlayers; private static ScheduledExecutorService scheduler; public static void startLocalHttpServer(int port, List<PlayerInformation> players) { try { // 如果没有提供玩家列表,则创建一个新的列表 if (players == null) { localPlayers = new ArrayList<>(); } else { localPlayers = new ArrayList<>(players); } // 检查是否需要添加当前玩家信息 addCurrentPlayerInfo(); server = HttpServer.create(new InetSocketAddress(port), 0); server.createContext("/local-players.json", new HttpHandler() { @Override public void handle(HttpExchange exchange) { try { String response = PlayerInformation.generatePlayerJson(localPlayers, 100, true); exchange.getResponseHeaders().set("Content-Type", "application/json"); exchange.sendResponseHeaders(200, response.getBytes().length); OutputStream os = exchange.getResponseBody(); os.write(response.getBytes()); os.close(); } catch (Exception e) { e.printStackTrace(); } } }); server.start(); // 启动定时更新任务,每200毫秒更新一次玩家信息 startPlayerInfoUpdater(); System.out.println("Local HTTP server started on port " + port); } catch (Exception e) { e.printStackTrace(); } } public static void stopLocalHttpServer() { if (server != null) { server.stop(0); System.out.println("Local HTTP server stopped."); } // 停止定时更新任务 if (scheduler != null && !scheduler.isShutdown()) { scheduler.shutdown(); try { if (!scheduler.awaitTermination(1, TimeUnit.SECONDS)) { scheduler.shutdownNow(); } } catch (InterruptedException e) { scheduler.shutdownNow(); Thread.currentThread().interrupt(); } System.out.println("Player info updater stopped."); } } public static void updateLocalPlayers(List<PlayerInformation> players) { if (players == null) { localPlayers = new ArrayList<>(); } else { localPlayers = new ArrayList<>(players); } addCurrentPlayerInfo(); } /** * 添加当前玩家信息到本地玩家列表(如果列表中还没有当前玩家) */ private static void addCurrentPlayerInfo() { try { MinecraftClient client = MinecraftClient.getInstance(); if (client.player != null && client.world != null) { String currentPlayerName = client.player.getName().getString(); // 检查当前玩家是否已经在列表中 boolean playerExists = localPlayers.stream() .anyMatch(player -> player.getName().equals(currentPlayerName)); // 如果当前玩家不在列表中,则添加 if (!playerExists) { PlayerInformation currentPlayer = new PlayerInformation( client.player.getUuid().toString(), currentPlayerName, "[fp]"+client.player.getDisplayName().getString(), client.player.getX(), client.player.getZ(), client.world.getRegistryKey().getValue().toString().replace(":", "_"), client.player.getYaw(), (int) client.player.getHealth(), (int) client.player.getArmor(), "", // headUrl false, // isVirtual "" // icon ); localPlayers.add(currentPlayer); System.out.println("Added current player to local player list: " + currentPlayerName); } } } catch (Exception e) { System.err.println("Failed to add current player info: " + e.getMessage()); } } /** * 启动定时更新玩家信息的任务 */ private static void startPlayerInfoUpdater() { scheduler = Executors.newSingleThreadScheduledExecutor(); scheduler.scheduleAtFixedRate(() -> { try { updateCurrentPlayerInfo(); } catch (Exception e) { System.err.println("Error updating player info: " + e.getMessage()); e.printStackTrace(); } }, 0, 200, TimeUnit.MILLISECONDS); // 每200毫秒更新一次 } /** * 更新当前玩家信息 */ private static void updateCurrentPlayerInfo() { try { MinecraftClient client = MinecraftClient.getInstance(); if (client.player != null && client.world != null) { String currentPlayerName = client.player.getName().getString(); // 查找并更新当前玩家信息 for (PlayerInformation player : localPlayers) { if (player.getName().equals(currentPlayerName) && !player.isVirtual()) { player.setX(client.player.getX()); player.setZ(client.player.getZ()); player.setYaw(client.player.getYaw()); player.setHealth((int) client.player.getHealth()); player.setArmor((int) client.player.getArmor()); player.setWorld(client.world.getRegistryKey().getValue().toString().replace(":", "_")); break; } } } } catch (Exception e) { System.err.println("Failed to update current player info: " + e.getMessage()); } } }
2303_806435pww/webmapview_moved
src/client/java/fun/xingwangzhe/webmapview/client/API.java
Java
mit
6,845
package fun.xingwangzhe.webmapview.client; import com.cinemamod.mcef.MCEF; import com.cinemamod.mcef.MCEFBrowser; import com.mojang.blaze3d.systems.RenderSystem; import net.minecraft.client.MinecraftClient; import net.minecraft.client.gui.DrawContext; import net.minecraft.client.gui.screen.Screen; import net.minecraft.client.render.*; import net.minecraft.text.Text; import org.cef.CefSettings; import org.cef.browser.CefBrowser; import org.cef.handler.CefDisplayHandler; import org.cef.handler.CefLoadHandler; import org.cef.network.CefRequest; import org.cef.browser.CefFrame; import java.util.List; import java.util.concurrent.CompletableFuture; import static fun.xingwangzhe.webmapview.client.UrlManager.sendFeedback; //copy from https://github.com/CinemaMod/mcef-fabric-example-mod and change by xingwangzhe public class BasicBrowser extends Screen { private static final int BROWSER_DRAW_OFFSET = 20; private MCEFBrowser browser; private boolean isInitializing = false; private boolean initializationFailed = false; // 添加资源包状态检测 private boolean resourcesReloading = false; private long lastResourceReloadTime = 0; // 添加自动恢复机制 private static int retryCount = 0; private static final int MAX_RETRY_COUNT = 2; private boolean isAutoRecovering = false; // 添加定期注入控制标志 private volatile boolean shouldStopInjection = false; private volatile boolean injectionSuccessful = false; private final MinecraftClient minecraft = MinecraftClient.getInstance(); public BasicBrowser(Text title) { super(title); } @Override protected void init() { super.init(); if (browser == null && !isInitializing) { // 启动本地 HTTP 服务 API.startLocalHttpServer(8080, List.of()); // 初始玩家列表为空 // 检测资源包状态后再初始化浏览器 if (isResourcePackReady()) { initializeBrowserAsync(); } else { // 如果资源包未准备好,延迟初始化 waitForResourcePackAndInitialize(); } } } /** * 检测资源包是否已完全加载 */ private boolean isResourcePackReady() { try { // 检查基本资源管理器状态 if (minecraft.getResourceManager() == null) { return false; } // 检查纹理管理器状态 if (minecraft.getTextureManager() == null) { return false; } // 检查字体管理器状态 if (minecraft.textRenderer == null) { return false; } // 检��窗口�����态 if (minecraft.getWindow() == null || minecraft.getWindow().getHandle() == 0) { return false; } // 检查最近是否发生过资源重新加载 long currentTime = System.currentTimeMillis(); if (currentTime - lastResourceReloadTime < 2000) { // 增加等待时间到2秒 return false; } // 检查资源包是否正在重新加载 if (resourcesReloading) { return false; } return true; } catch (Exception e) { System.err.println(Text.translatable("debug.resource_pack.check_failed", e.getMessage()).getString()); return false; } } // 统一的 JavaScript 注入方法 private void injectJavaScriptContent() { if (browser != null) { try { String jsCode = """ (function() { console.log('JavaScript注入成功: ' + new Date().toISOString()); // 劫持 fetch 方法 const originalFetch = window.fetch; window.fetch = async function(...args) { const [url] = args; //console.log('fetch 被调用,URL:', url); if (typeof url === 'string' && url.includes('/players.json')) { //console.log('拦截到 /players.json 请求'); try { // 获取本地API节点数据 (使用硬编码地址) const localResponse = await originalFetch("http://localhost:8080/local-players.json"); const localData = await localResponse.json(); //console.log('本地API数据:', localData); // 获取服务器原始数据 const serverResponse = await originalFetch.apply(this, args); const serverData = await serverResponse.json(); //console.log('服务器原始数据:', serverData); // 合并数据 - 优先使用本地API节点的数据 const mergedData = { ...serverData, ...localData, players: [ ...(serverData.players || []), ...(localData.players || []).filter(localPlayer => !(serverData.players || []).some(serverPlayer => serverPlayer.name === localPlayer.name ) ) ] }; //console.log('合并后数据:', mergedData); // 打印完整的title/players.json数据 //console.log('完整的合并后title/players.json数据:', JSON.stringify(mergedData, null, 2)); // 返回合并后的数据 const updatedResponse = new Response(JSON.stringify(mergedData), { status: serverResponse.status, statusText: serverResponse.statusText, headers: serverResponse.headers }); return updatedResponse; } catch (error) { //console.error('数据合并失败:', error); // 如果合并失败,返回原始服务器数据 return originalFetch.apply(this, args); } } return originalFetch.apply(this, args); }; //console.log('fetch 方法已劫持'); })(); """; // 启动定期注入任务直到成功 startPeriodicJavaScriptInjection(jsCode); } catch (Exception e) { System.err.println("[BasicBrowser] JavaScript注入失败: " + e.getMessage()); } } } /** * 启动定期JavaScript注入任务 */ private void startPeriodicJavaScriptInjection(String jsCode) { // 如果已有任务在运行,先停止它 shouldStopInjection = true; injectionSuccessful = false; shouldStopInjection = false; // 启动新的定期注入任务 CompletableFuture.runAsync(() -> { int attempts = 0; while (!shouldStopInjection && !injectionSuccessful && attempts < 30) { // 最多尝试30次 attempts++; int finalAttempts = attempts; minecraft.execute(() -> { if (!shouldStopInjection && browser != null) { try { browser.executeJavaScript(jsCode, browser.getURL(), 0); System.out.println("[BasicBrowser] JavaScript已注入 (尝试 #" + finalAttempts+ ")"); } catch (Exception e) { System.err.println("[BasicBrowser] JavaScript注入异常 (尝试 #" + finalAttempts + "): " + e.getMessage()); } } }); try { Thread.sleep(1000); // 每秒尝试一次 } catch (InterruptedException e) { Thread.currentThread().interrupt(); break; } } if (injectionSuccessful) { System.out.println("[BasicBrowser] JavaScript注入成功完成"); } else if (attempts >= 30) { System.err.println("[BasicBrowser] JavaScript注入超时"); } }); } /** * 等待资源包完全加载后初始化浏览器 */ private void waitForResourcePackAndInitialize() { resourcesReloading = true; System.out.println(Text.translatable("debug.resource_pack.waiting").getString()); CompletableFuture.runAsync(() -> { try { int maxRetries = 30; // 最多等待15秒 (30 * 500ms) int retryCount = 0; while (retryCount < maxRetries && !isResourcePackReady()) { try { Thread.sleep(500); } catch (InterruptedException e) { Thread.currentThread().interrupt(); break; } retryCount++; } // 额外等待确保稳定 if (!Thread.currentThread().isInterrupted()) { try { Thread.sleep(1000); // 额外等待1秒确保完全稳定 } catch (InterruptedException e) { Thread.currentThread().interrupt(); } } minecraft.execute(() -> { resourcesReloading = false; lastResourceReloadTime = System.currentTimeMillis(); if (isResourcePackReady()) { System.out.println(Text.translatable("debug.resource_pack.loaded").getString()); initializeBrowserAsync(); } else { System.err.println(Text.translatable("debug.resource_pack.timeout").getString()); initializationFailed = true; } }); } catch (Exception e) { resourcesReloading = false; initializationFailed = true; System.err.println(Text.translatable("debug.resource_pack.error", e.getMessage()).getString()); } }); } private void initializeBrowserAsync() { isInitializing = true; initializationFailed = false; // 异步初始化浏览器 - 移除所有光标操作 CompletableFuture.runAsync(() -> { try { // 添加延迟,确保窗口完全初始化 Thread.sleep(100); String url = UrlManager.fullUrl(UrlManager.defaultUrl); sendFeedback(url); boolean transparent = false; // 在主线程中创建浏览器 - 不操作光标 minecraft.execute(() -> { try { browser = MCEF.createBrowser(url, transparent); if (browser != null) { resizeBrowser(); isInitializing = false; retryCount = 0; System.out.println(Text.translatable("debug.browser.initialization.success").getString()); // 注册 ConsoleMessageHandler browser.getClient().addDisplayHandler(new ConsoleMessageHandler()); // 在浏览器初始化时注入 JavaScript injectJavaScriptContent(); } else { System.err.println(Text.translatable("debug.browser.mcef_null").getString()); handleInitializationFailure(); } } catch (Exception e) { System.err.println(Text.translatable("debug.browser.init_failed_main", e.getMessage()).getString()); handleInitializationFailure(); } }); } catch (Exception e) { System.err.println(Text.translatable("debug.browser.init_failed_async", e.getMessage()).getString()); minecraft.execute(this::handleInitializationFailure); } }); } /** * 处理初始化失败,决定是否进行自��恢复 */ private void handleInitializationFailure() { isInitializing = false; // 立即尝试自动恢复,不管是第几次失败 if (retryCount < MAX_RETRY_COUNT && !isAutoRecovering) { retryCount++; System.out.println(Text.translatable("debug.browser.auto_recovery_starting", retryCount, MAX_RETRY_COUNT).getString()); // 发送提示消息给玩家 if (minecraft.player != null) { minecraft.player.sendMessage(Text.translatable("browser.initialization.failed.auto_recovery", retryCount, MAX_RETRY_COUNT), false); } // 立即开始自动恢复���不等待 startAutoRecovery(); } else { // 达到最大重试次数或已经在恢复中,标记为最终失败 initializationFailed = true; isAutoRecovering = false; if (retryCount >= MAX_RETRY_COUNT) { System.err.println(Text.translatable("debug.browser.max_retries", MAX_RETRY_COUNT).getString()); if (minecraft.player != null) { minecraft.player.sendMessage(Text.translatable("browser.initialization.final_failure", MAX_RETRY_COUNT), false); minecraft.player.sendMessage(Text.translatable("browser.initialization.manual_fix_required"), false); } } else { System.err.println(Text.translatable("debug.browser.initialization.failed").getString()); if (minecraft.player != null) { minecraft.player.sendMessage(Text.translatable("browser.initialization.mcef_check"), false); } } } } /** * 开始自动恢复流程:模拟按下F3+T来刷新资源包 */ private void startAutoRecovery() { isAutoRecovering = true; System.out.println(Text.translatable("debug.browser.auto_recovery_begin").getString()); CompletableFuture.runAsync(() -> { try { // 等待一小段时间确保状态稳定 Thread.sleep(500); minecraft.execute(() -> { try { // 模拟按下F3+T组合键来重新加载资源包 triggerResourcePackReload(); // 等待资源包重新加载完成后重试初始化 waitForRecoveryAndRetry(); } catch (Exception e) { System.err.println(Text.translatable("debug.browser.auto_recovery_failed", e.getMessage()).getString()); isAutoRecovering = false; initializationFailed = true; } }); } catch (InterruptedException e) { Thread.currentThread().interrupt(); isAutoRecovering = false; initializationFailed = true; } }); } /** * 触发资源包重新加载 (模拟F3+T) */ private void triggerResourcePackReload() { try { System.out.println(Text.translatable("debug.browser.resource_reload_trigger").getString()); // 设置资源包重新加载状态 resourcesReloading = true; lastResourceReloadTime = System.currentTimeMillis(); // 调用Minecraft的资源包重新加载方法 if (minecraft.getResourcePackManager() != null) { minecraft.reloadResources(); System.out.println(Text.translatable("debug.browser.resource_reload_success").getString()); } else { System.err.println(Text.translatable("debug.browser.resource_manager_unavailable").getString()); throw new RuntimeException("资源包管理器不可用"); } } catch (Exception e) { System.err.println(Text.translatable("debug.browser.resource_reload_failed", e.getMessage()).getString()); throw e; } } /** * 等待恢复完成后重新尝试初始化���览器 */ private void waitForRecoveryAndRetry() { CompletableFuture.runAsync(() -> { try { System.out.println(Text.translatable("debug.browser.waiting_recovery").getString()); // 等待资源包重新加载完成 int maxWaitTime = 60; // 最多等待30秒 (60 * 500ms) int waitCount = 0; while (waitCount < maxWaitTime && (resourcesReloading || !isResourcePackReady())) { try { Thread.sleep(500); waitCount++; } catch (InterruptedException e) { Thread.currentThread().interrupt(); break; } } // 额外等待确保稳定 if (!Thread.currentThread().isInterrupted()) { Thread.sleep(1000); } minecraft.execute(() -> { isAutoRecovering = false; resourcesReloading = false; lastResourceReloadTime = System.currentTimeMillis(); if (isResourcePackReady()) { System.out.println(Text.translatable("debug.browser.recovery_completed").getString()); if (minecraft.player != null) { minecraft.player.sendMessage(Text.translatable("browser.auto_recovery.completed"), false); } // 清理之前失败的状态 initializationFailed = false; // 重新尝试初始化 initializeBrowserAsync(); } else { System.err.println(Text.translatable("debug.browser.recovery_still_failed").getString()); initializationFailed = true; if (minecraft.player != null) { minecraft.player.sendMessage(Text.translatable("browser.auto_recovery.failed"), false); } } }); } catch (Exception e) { System.err.println(Text.translatable("debug.browser.recovery_error", e.getMessage()).getString()); minecraft.execute(() -> { isAutoRecovering = false; initializationFailed = true; }); } }); } private int mouseX(double x) { return (int) ((x - BROWSER_DRAW_OFFSET) * minecraft.getWindow().getScaleFactor()); } private int mouseY(double y) { return (int) ((y - BROWSER_DRAW_OFFSET) * minecraft.getWindow().getScaleFactor()); } private int scaleX(double x) { return (int) ((x - BROWSER_DRAW_OFFSET * 2) * minecraft.getWindow().getScaleFactor()); } private int scaleY(double y) { return (int) ((y - BROWSER_DRAW_OFFSET * 2) * minecraft.getWindow().getScaleFactor()); } private void resizeBrowser() { if (browser != null && width > 100 && height > 100) { browser.resize(scaleX(width), scaleY(height)); } } @Override public void resize(MinecraftClient minecraft, int i, int j) { super.resize(minecraft, i, j); if (browser != null) { resizeBrowser(); } } @Override public void close() { // 停止本地 HTTP 服务 API.stopLocalHttpServer(); // 完全移除光标恢复操作 // restoreCursorState(); if (browser != null) { try { browser.close(); } catch (Exception e) { System.err.println(Text.translatable("debug.browser.close_failed", e.getMessage()).getString()); } } super.close(); } @Override public void render(DrawContext guiGraphics, int i, int j, float f) { super.render(guiGraphics, i, j, f); // 如果正在自动恢复,显示恢复状态 if (isAutoRecovering) { guiGraphics.fill(BROWSER_DRAW_OFFSET, BROWSER_DRAW_OFFSET, width - BROWSER_DRAW_OFFSET, height - BROWSER_DRAW_OFFSET, 0xFF004400); guiGraphics.drawCenteredTextWithShadow(textRenderer, Text.translatable("browser.auto_recovery.starting").getString(), width / 2, height / 2 - 30, 0xFFFFFF); guiGraphics.drawCenteredTextWithShadow(textRenderer, Text.translatable("browser.auto_recovery.reloading_resources").getString(), width / 2, height / 2 - 10, 0xFFFFFF); guiGraphics.drawCenteredTextWithShadow(textRenderer, Text.translatable("browser.auto_recovery.attempt", retryCount, MAX_RETRY_COUNT).getString(), width / 2, height / 2 + 10, 0xFFAAAA); guiGraphics.drawCenteredTextWithShadow(textRenderer, Text.translatable("browser.auto_recovery.please_wait").getString(), width / 2, height / 2 + 30, 0xFFAAAA); return; } // 如果资源包正在重新加载,显示���待信息 if (resourcesReloading) { guiGraphics.fill(BROWSER_DRAW_OFFSET, BROWSER_DRAW_OFFSET, width - BROWSER_DRAW_OFFSET, height - BROWSER_DRAW_OFFSET, 0xFF444444); guiGraphics.drawCenteredTextWithShadow(textRenderer, Text.translatable("browser.waiting_resource_pack").getString(), width / 2, height / 2 - 10, 0xFFFFFF); guiGraphics.drawCenteredTextWithShadow(textRenderer, Text.translatable("browser.waiting_resource_pack.then_init").getString(), width / 2, height / 2 + 10, 0xFFAAAA); return; } // 如果正在初始化,显示加载信息 if (isInitializing) { guiGraphics.fill(BROWSER_DRAW_OFFSET, BROWSER_DRAW_OFFSET, width - BROWSER_DRAW_OFFSET, height - BROWSER_DRAW_OFFSET, 0xFF333333); guiGraphics.drawCenteredTextWithShadow(textRenderer, Text.translatable("browser.initializing").getString(), width / 2, height / 2, 0xFFFFFF); return; } // 如果初始化失败,显示错误信息 if (initializationFailed) { guiGraphics.fill(BROWSER_DRAW_OFFSET, BROWSER_DRAW_OFFSET, width - BROWSER_DRAW_OFFSET, height - BROWSER_DRAW_OFFSET, 0xFF333333); guiGraphics.drawCenteredTextWithShadow(textRenderer, Text.translatable("browser.failed.title").getString(), width / 2, height / 2 - 20, 0xFF0000); if (retryCount >= MAX_RETRY_COUNT) { guiGraphics.drawCenteredTextWithShadow(textRenderer, Text.translatable("browser.failed.tried_times", MAX_RETRY_COUNT).getString(), width / 2, height / 2, 0xFFFF00); guiGraphics.drawCenteredTextWithShadow(textRenderer, Text.translatable("browser.failed.manual_f3t").getString(), width / 2, height / 2 + 20, 0xFFFFFF); } else { guiGraphics.drawCenteredTextWithShadow(textRenderer, Text.translatable("browser.failed.check_config").getString(), width / 2, height / 2 + 10, 0xFFFF00); } return; } // 确保浏览器已初始化 if (browser == null || browser.getRenderer() == null) { guiGraphics.drawCenteredTextWithShadow(textRenderer, Text.translatable("browser.not_initialized").getString(), width / 2, height / 2, 0xFF0000); return; } // 获取纹理ID int textureId = browser.getRenderer().getTextureID(); if (textureId <= 0) { // 显示加载提示和调试信息 guiGraphics.fill(BROWSER_DRAW_OFFSET, BROWSER_DRAW_OFFSET, width - BROWSER_DRAW_OFFSET, height - BROWSER_DRAW_OFFSET, 0xFF333333); guiGraphics.drawCenteredTextWithShadow(textRenderer, Text.translatable("browser.loading").getString(), width / 2, height / 2 - 10, 0xFFFFFF); guiGraphics.drawCenteredTextWithShadow(textRenderer, Text.translatable("browser.texture_id", textureId).getString(), width / 2, height / 2 + 10, 0xFFFF00); return; } // 显示调试信息 guiGraphics.drawTextWithShadow(textRenderer, Text.translatable("browser.texture_id", textureId).getString(), 10, 10, 0xFFFFFF); // 使用原始MCEF示例的渲染方式 RenderSystem.setShaderTexture(0, textureId); RenderSystem.setShaderColor(1.0f, 1.0f, 1.0f, 1.0f); Tessellator tessellator = Tessellator.getInstance(); BufferBuilder buffer = tessellator.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_TEXTURE_COLOR); var matrix = guiGraphics.getMatrices().peek().getPositionMatrix(); float x1 = BROWSER_DRAW_OFFSET; float y1 = BROWSER_DRAW_OFFSET; float x2 = width - BROWSER_DRAW_OFFSET; float y2 = height - BROWSER_DRAW_OFFSET; // 使用原始MCEF示例的纹理坐标和颜色 buffer.vertex(matrix, x1, y2, 0).texture(0.0f, 1.0f).color(255, 255, 255, 255); buffer.vertex(matrix, x2, y2, 0).texture(1.0f, 1.0f).color(255, 255, 255, 255); buffer.vertex(matrix, x2, y1, 0).texture(1.0f, 0.0f).color(255, 255, 255, 255); buffer.vertex(matrix, x1, y1, 0).texture(0.0f, 0.0f).color(255, 255, 255, 255); BufferRenderer.drawWithGlobalProgram(buffer.end()); } /** * 向页面注入玩家数据 */ public void injectPlayerData(String playerDataJson) { // 删除所有JavaScript注入相关代码 } /** * 拦截并注入本地生成的玩家数据到指定的 URL。 */ private void interceptAndInjectPlayerData() { // 删除所有JavaScript注入相关代码 } /** * 生成用于注入的玩家数据的 JSON 脚本。 * @return JavaScript 格式的 JSON 数据 */ private String generatePlayerJsonScript() { // 删除所有JavaScript注入相关代码 return ""; } /** * 调用 PlayerInformation 的本地 JSON 生成方法,并注入到浏览器。 */ /** * 添加 JavaScript 到 Java 的日志桥接 */ private void addJavaScriptToJavaLogging() { // 删除所有JavaScript注入相关代码 } @Override public boolean mouseClicked(double mouseX, double mouseY, int button) { if (browser == null || browser.getRenderer() == null) { return super.mouseClicked(mouseX, mouseY, button); } try { browser.sendMousePress(mouseX(mouseX), mouseY(mouseY), button); browser.setFocus(true); } catch (Exception e) { // 忽略浏览器交互错误,避免崩��� } return super.mouseClicked(mouseX, mouseY, button); } @Override public boolean mouseReleased(double mouseX, double mouseY, int button) { if (browser == null || browser.getRenderer() == null) { return super.mouseReleased(mouseX, mouseY, button); } try { browser.sendMouseRelease(mouseX(mouseX), mouseY(mouseY), button); browser.setFocus(true); } catch (Exception e) { // 忽略浏览器交互错误,避免崩溃 } return super.mouseReleased(mouseX, mouseY, button); } @Override public void mouseMoved(double mouseX, double mouseY) { if (browser != null && browser.getRenderer() != null) { try { browser.sendMouseMove(mouseX(mouseX), mouseY(mouseY)); } catch (Exception e) { // 忽略浏览器交互错误,避免崩溃 } } super.mouseMoved(mouseX, mouseY); } @Override public boolean mouseDragged(double mouseX, double mouseY, int button, double dragX, double dragY) { if (browser != null && browser.getRenderer() != null) { try { browser.sendMouseMove(mouseX(mouseX), mouseY(mouseY)); } catch (Exception e) { // 忽略浏览器交互错误,避免崩溃 } } return super.mouseDragged(mouseX, mouseY, button, dragX, dragY); } @Override public boolean mouseScrolled(double mouseX, double Y, double horizontalAmount, double verticalAmount) { if (browser != null && browser.getRenderer() != null) { try { browser.sendMouseWheel(mouseX(mouseX), mouseY(Y), verticalAmount, 0); } catch (Exception e) { // 忽略浏览器交互错误,避免崩溃 } } return super.mouseScrolled(mouseX, Y, horizontalAmount, verticalAmount); } @Override public boolean keyPressed(int keyCode, int scanCode, int modifiers) { // ��理ESC键关闭浏览器 if (keyCode == 256) { // GLFW.GLFW_KEY_ESCAPE = 256 this.close(); return true; } // 动态检测切换按键关闭浏览器(支持玩家自定义按键绑定) if (WebmapviewClient.isToggleKey(keyCode)) { System.out.println("[DEBUG] Toggle key detected in BasicBrowser, closing..."); this.close(); return true; } // 其他所有按键都不处理,直接让游戏系统处理 return super.keyPressed(keyCode, scanCode, modifiers); } @Override public boolean keyReleased(int keyCode, int scanCode, int modifiers) { // 不处理任何按键释放事件,让游戏系统处理 return super.keyReleased(keyCode, scanCode, modifiers); } @Override public boolean charTyped(char codePoint, int modifiers) { // 不处理任何字符输入,让游戏系统处理 return super.charTyped(codePoint, modifiers); } private void addLoadHandlerForJavaScriptInjection() { // 删除所有JavaScript注入相关代码 } // 在 BasicBrowser 类中添加一个内部类实现 CefDisplayHandler private static class ConsoleMessageHandler implements CefDisplayHandler { @Override public boolean onConsoleMessage(CefBrowser browser, CefSettings.LogSeverity level, String message, String source, int line) { System.out.printf("[Browser Console] Level: %s, Message: %s, Source: %s, Line: %d%n", level, message, source, line); return false; // 返回 false 表示消息仍会显示在浏览器控制台中 } @Override public void onAddressChange(CefBrowser browser, CefFrame frame, String url) {} @Override public void onTitleChange(CefBrowser browser, String title) {} @Override public boolean onTooltip(CefBrowser browser, String text) { return false; } @Override public void onStatusMessage(CefBrowser browser, String value) {} @Override public boolean onCursorChange(CefBrowser browser, int cursorType) { return false; } } }
2303_806435pww/webmapview_moved
src/client/java/fun/xingwangzhe/webmapview/client/BasicBrowser.java
Java
mit
33,362
package fun.xingwangzhe.webmapview.client; import com.google.gson.Gson; import com.google.gson.JsonObject; import com.google.gson.JsonArray; import java.util.List; public class PlayerInformation { private String uuid; private String name; private String displayName; private double x; private double z; private String world; private double yaw; private int health; private int armor; private String headUrl; private boolean isVirtual; private String icon; public PlayerInformation(String uuid, String name, String displayName, double x, double z, String world, double yaw, int health, int armor, String headUrl, boolean isVirtual, String icon) { this.uuid = uuid; this.name = name; this.displayName = displayName; this.x = x; this.z = z; this.world = world; this.yaw = yaw; this.health = health; this.armor = armor; this.headUrl = headUrl; this.isVirtual = isVirtual; this.icon = icon; } public String getUuid() { return uuid; } public void setUuid(String uuid) { this.uuid = uuid; } public String getName() { return name; } public void setName(String name) { this.name = name; } public String getDisplayName() { return displayName; } public void setDisplayName(String displayName) { this.displayName = displayName; } public double getX() { return x; } public void setX(double x) { this.x = x; } public double getZ() { return z; } public void setZ(double z) { this.z = z; } public String getWorld() { return world; } public void setWorld(String world) { this.world = world; } public double getYaw() { return yaw; } public void setYaw(double yaw) { this.yaw = yaw; } public int getHealth() { return health; } public void setHealth(int health) { this.health = health; } public int getArmor() { return armor; } public void setArmor(int armor) { this.armor = armor; } public String getHeadUrl() { return headUrl; } public void setHeadUrl(String headUrl) { this.headUrl = headUrl; } public boolean isVirtual() { return isVirtual; } public void setVirtual(boolean virtual) { isVirtual = virtual; } public String getIcon() { return icon; } public void setIcon(String icon) { this.icon = icon; } public static String generatePlayerJson(List<PlayerInformation> players, int maxPlayers, boolean includeVirtual) { Gson gson = new Gson(); JsonObject root = new JsonObject(); root.addProperty("max", maxPlayers); JsonArray playersArray = new JsonArray(); for (PlayerInformation player : players) { if (!includeVirtual && player.isVirtual()) { continue; } JsonObject playerJson = new JsonObject(); playerJson.addProperty("uuid", player.getUuid()); playerJson.addProperty("name", player.getName()); playerJson.addProperty("display_name", player.getDisplayName()); playerJson.addProperty("x", player.getX()); playerJson.addProperty("y", 66); playerJson.addProperty("z", player.getZ()); playerJson.addProperty("world", player.getWorld()); playerJson.addProperty("yaw", player.getYaw()); playerJson.addProperty("health", player.getHealth()); playerJson.addProperty("armor", player.getArmor()); playerJson.addProperty("is_virtual", player.isVirtual()); playersArray.add(playerJson); } root.add("players", playersArray); return gson.toJson(root); } }
2303_806435pww/webmapview_moved
src/client/java/fun/xingwangzhe/webmapview/client/PlayerInformation.java
Java
mit
3,966
package fun.xingwangzhe.webmapview.client; import net.fabricmc.loader.api.FabricLoader; import net.minecraft.text.Text; import net.minecraft.client.MinecraftClient; import java.io.*; import java.nio.file.Files; import java.nio.file.Path; import java.util.ArrayList; import java.util.List; import java.util.Objects; public class UrlManager { private static final String URL_FILE_NAME = "urls.txt"; // 存储URL列表的文件名 private static final String DEFAULT_URL_FILE_NAME = "default_url.txt"; // 默认URL文件名 private static List<String> urlList = new ArrayList<>(); // 存储URL的列表 public static String defaultUrl="squaremap-demo.jpenilla.xyz"; // 默认URL public static boolean webmapview=true; static { loadUrls(); loadDefaultUrl(); } /** * 添加一个URL到列表中并保存到文件。 * @param url 要添加的URL字符串 */ public static void addUrl(String url) { if (!urlList.contains(url)) { // 确保不重��添加相同的URL urlList.add(url); saveUrls(); // 保存更新后的URL列表到文件 sendFeedback(Text.translatable("feedback.url.added", url)); // 向玩家发送反馈 } else { sendFeedback(Text.translatable("feedback.url.exists", url)); // 如果URL已存在,则通知玩家 } } /** * 设置默认URL。 * @param url 要设置为默认的URL字符串 */ public static void setDefaultUrl(String url) { if (urlList.contains(url)) { // 确保URL已经存在于列表中 defaultUrl = url; saveDefaultUrl(); // 更新默认URL到文件 sendFeedback(Text.translatable("feedback.default.url.updated", url)); // 向玩家发送反馈 } else { sendFeedback(Text.translatable("feedback.url.not_found", url)); // 如果URL不存在于列表中,则通知玩家 } } /** * 获取当前的URL列表。 * @return 包含所有URL的列表 */ public static List<String> getUrlList() { return urlList; } /** * 获取默认URL。 * @return 默认URL字符串 */ public static String getDefaultUrl() { return defaultUrl; } /** * 将当前的URL列表保存到文件���。 */ private static void saveUrls() { Path configPath = getConfigDirectory().resolve(URL_FILE_NAME); // 获取配置文件路径 try (BufferedWriter writer = Files.newBufferedWriter(configPath)) { // 使用try-with-resources确保资源关闭 for (String url : urlList) { writer.write(url); // 写入单个URL writer.newLine(); // 换行以便每个URL占一行 } } catch (IOException e) { e.printStackTrace(); // 打印异常信息 } } /** * 从文件加载URL列表。 */ private static void loadUrls() { Path configPath = getConfigDirectory().resolve(URL_FILE_NAME); // 获取配置文件路径 urlList.clear(); // 清空现有列表以准备加载新数据 if (Files.exists(configPath)) { // 如果文件存在,则读取它 try (BufferedReader reader = Files.newBufferedReader(configPath)) { // 使用try-with-resources确保资源关闭 String line; while ((line = reader.readLine()) != null) { // 循环读取每一行 urlList.add(line); // 将每行作为一个URL添加到列表中 } } catch (IOException e) { e.printStackTrace(); // 打印异常信息 } } } /** * 保存默认URL到文件。 */ private static void saveDefaultUrl() { Path defaultUrlPath = getConfigDirectory().resolve(DEFAULT_URL_FILE_NAME); // 获取默认URL文件路径 try (BufferedWriter writer = Files.newBufferedWriter(defaultUrlPath)) { // 使用try-with-resources确保资源关闭 if (defaultUrl != null && !defaultUrl.trim().isEmpty()) { writer.write(defaultUrl); // 写入默认URL } else { // 如果没有有效的默认URL,则删除默认URL文件(如果存在) Files.deleteIfExists(defaultUrlPath); } } catch (IOException e) { e.printStackTrace(); // 打印异常信息 } } /** * 从文件加载默认URL。 */ private static void loadDefaultUrl() { Path defaultUrlPath = getConfigDirectory().resolve(DEFAULT_URL_FILE_NAME); // 获取默认URL文件路径 if (Files.exists(defaultUrlPath)) { // 如果文件存在,则读取它 try (BufferedReader reader = Files.newBufferedReader(defaultUrlPath)) { // 使用try-with-resources确保资源关闭 String line; if ((line = reader.readLine()) != null) { // 只读取第一行 defaultUrl = line; // 设置默认URL } } catch (IOException e) { e.printStackTrace(); // 打印异常信息 } } } /** * 获取配置目录路径。 * @return Minecraft配置目录下的路径 */ private static Path getConfigDirectory() { Path configDir = FabricLoader.getInstance().getConfigDir(); try { Files.createDirectories(configDir); // 如果目录不存在,则创建之 } catch (IOException e) { e.printStackTrace(); } return configDir; } /** * 发送反馈信息到聊天栏。 * @param message 要发送的消息 */ public static void sendFeedback(String message) { if (MinecraftClient.getInstance().player != null) { MinecraftClient.getInstance().player.sendMessage(Text.of(message), false); } } public static void sendFeedback(Text textMessage) { if (MinecraftClient.getInstance().player != null) { MinecraftClient.getInstance().player.sendMessage(textMessage, false); } } public static void removeUrl(String url) { if (urlList.remove(url)) { // 如果成功移除URL saveUrls(); // 保存更新后的URL列表到文件 // 如果被删除的URL是默认URL,则清除默认URL设置 if (defaultUrl != null && defaultUrl.equals(url)) { clearDefaultUrl(); } sendFeedback(Text.translatable("feedback.url.removed", url)); // 向玩家发送反馈 } else { sendFeedback(Text.translatable("feedback.url.not_found", url)); // 如果URL不存在,则通知玩家 } } /** * 清除默认URL设置。 */ private static void clearDefaultUrl() { defaultUrl = null; Path defaultUrlPath = getConfigDirectory().resolve(DEFAULT_URL_FILE_NAME); // 获取默认URL文件路径 try { Files.deleteIfExists(defaultUrlPath); // 删除默认URL文件(如果存在) } catch (IOException e) { e.printStackTrace(); // 打印异常信息 } } public static String fullUrl(String baseUrl) { MinecraftClient client = MinecraftClient.getInstance(); if (client.player == null || client.world == null|| webmapview==false ) { sendFeedback(Text.translatable("feedback.player_or_world_not_available")); // 使用翻译文本 return baseUrl; // 如果无法获取玩家或世界信息,则返回原始URL } // 获取玩家坐标并转换为整数 int playerX = (int) client.player.getX(); int playerZ = (int) client.player.getZ(); // 获取玩家所在的世界名称 String worldName = client.world.getRegistryKey().getValue().toString(); if(Objects.equals(worldName, "minecraft:overworld")){ worldName = "world"; } else if (Objects.equals(worldName, "minecraft:the_nether")){ worldName = "world_nether"; } else if (Objects.equals(worldName, "minecraft:the_end")){ worldName = "world_the_end"; } // 构建完整的URL StringBuilder fullUrlBuilder = new StringBuilder(); if (!baseUrl.startsWith("http://") && !baseUrl.startsWith("https://")) { fullUrlBuilder.append("https://"); } fullUrlBuilder.append(baseUrl).append("/"); if (!baseUrl.contains("?")) { // 检查是否已有参数 fullUrlBuilder.append("?"); } else { fullUrlBuilder.append("&"); // 如果已经有参数,则使用&连接 } fullUrlBuilder.append("x=").append(playerX) .append("&z=").append(playerZ) .append("&zoom=").append("4") .append("&world=").append(worldName); return fullUrlBuilder.toString(); } }
2303_806435pww/webmapview_moved
src/client/java/fun/xingwangzhe/webmapview/client/UrlManager.java
Java
mit
8,953
package fun.xingwangzhe.webmapview.client; import com.mojang.brigadier.arguments.StringArgumentType; import com.mojang.brigadier.context.CommandContext; import com.mojang.brigadier.suggestion.Suggestions; import com.mojang.brigadier.suggestion.SuggestionsBuilder; import net.fabricmc.api.ClientModInitializer; import net.fabricmc.fabric.api.client.command.v2.ClientCommandManager; import net.fabricmc.fabric.api.client.command.v2.ClientCommandRegistrationCallback; import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents; import net.fabricmc.fabric.api.client.keybinding.v1.KeyBindingHelper; import net.minecraft.client.MinecraftClient; import net.minecraft.client.option.KeyBinding; import net.minecraft.text.Text; import org.lwjgl.glfw.GLFW; import java.util.List; import java.util.concurrent.CompletableFuture; import static fun.xingwangzhe.webmapview.client.UrlManager.sendFeedback; public class WebmapviewClient implements ClientModInitializer { private static CompletableFuture<Suggestions> suggestUrls(CommandContext<?> context, SuggestionsBuilder builder) { List<String> urls = UrlManager.getUrlList(); urls.forEach(builder::suggest); return builder.buildFuture(); } private KeyBinding keyBinding; private static WebmapviewClient instance; private static long lastResourcePackCheckTime = 0; public static KeyBinding getToggleKeyBinding() { return instance != null ? instance.keyBinding : null; } public static boolean isToggleKey(int keyCode) { KeyBinding binding = getToggleKeyBinding(); if (binding != null) { return binding.matchesKey(keyCode, 0); } return false; } private static boolean isResourcePackFullyLoaded() { try { MinecraftClient minecraft = MinecraftClient.getInstance(); if (minecraft.getResourceManager() == null) { return false; } if (minecraft.getTextureManager() == null) { return false; } if (minecraft.textRenderer == null) { return false; } if (minecraft.getWindow() == null || minecraft.getWindow().getHandle() == 0) { return false; } long currentTime = System.currentTimeMillis(); if (currentTime - lastResourcePackCheckTime < 3000) { return false; } lastResourcePackCheckTime = currentTime; return true; } catch (Exception e) { System.err.println(Text.translatable("debug.resource_pack.check_failed", e.getMessage()).getString()); return false; } } @Override public void onInitializeClient() { instance = this; ClientCommandRegistrationCallback.EVENT.register((dispatcher, registryAccess) -> { dispatcher.register( ClientCommandManager.literal("urladd") .then(ClientCommandManager.argument("url", StringArgumentType.string()) .executes(context -> { String url = StringArgumentType.getString(context, "url"); UrlManager.addUrl(url); return 1; }) ) ); dispatcher.register( ClientCommandManager.literal("urlremove") .then(ClientCommandManager.argument("url", StringArgumentType.string()).suggests(WebmapviewClient::suggestUrls) .executes(context -> { String url = StringArgumentType.getString(context, "url"); UrlManager.removeUrl(url); return 1; }) ) ); dispatcher.register( ClientCommandManager.literal("urllist") .executes(context -> { List<String> urls = UrlManager.getUrlList(); StringBuilder listMessage = new StringBuilder("Available URLs:\n"); for (int i = 0; i < urls.size(); i++) { listMessage.append(i + 1).append(": ").append(urls.get(i)).append("\n"); } context.getSource().sendFeedback(Text.of(listMessage.toString())); return 1; }) ); dispatcher.register( ClientCommandManager.literal("urlset") .then(ClientCommandManager.argument("url", StringArgumentType.string()).suggests(WebmapviewClient::suggestUrls) .executes(context -> { String url = StringArgumentType.getString(context, "url"); UrlManager.setDefaultUrl(url); return 1; }) ) ); dispatcher.register( ClientCommandManager.literal("webmapviewoption") .then(ClientCommandManager.argument("url", StringArgumentType.string()) .executes(context -> { UrlManager.webmapview = !UrlManager.webmapview; if (UrlManager.webmapview) { sendFeedback("webmapview is enabled"); } else { sendFeedback("webmapview is not enabled"); } return 1; }) ) ); dispatcher.register( ClientCommandManager.literal("webmapview") .then(ClientCommandManager.literal("help") .executes(context -> { String helpMessage = "/urladd: " + Text.translatable("command.urladd.description").getString() + "\n" + "/urlremove: " + Text.translatable("command.urlremove.description").getString() + "\n" + "/urllist: " + Text.translatable("command.urllist.description").getString() + "\n" + "/urlset: " + Text.translatable("command.urlset.description").getString() + "\n" + "/webmapviewoption: " + Text.translatable("command.webmapviewoption.description").getString() + "\n"; sendFeedback(helpMessage); return 1; }) ) ); }); keyBinding = new KeyBinding( "key.webmapview.open_basic_browser", GLFW.GLFW_KEY_H, "category.webmapview" ); KeyBindingHelper.registerKeyBinding(keyBinding); final MinecraftClient minecraft = MinecraftClient.getInstance(); ClientTickEvents.END_CLIENT_TICK.register(client -> { if (keyBinding.wasPressed()) { System.out.println("[DEBUG] KeyBinding detected! Current screen: " + (minecraft.currentScreen == null ? "null" : minecraft.currentScreen.getClass().getSimpleName())); if(minecraft.currentScreen instanceof BasicBrowser) { System.out.println("[DEBUG] Closing BasicBrowser"); minecraft.setScreen(null); } else { System.out.println("[DEBUG] Opening BasicBrowser"); if (!isResourcePackFullyLoaded()) { if (minecraft.player != null) { minecraft.player.sendMessage(Text.translatable("browser.resource_pack.not_loaded"), false); } System.out.println(Text.translatable("debug.key_handler.resource_not_ready").getString()); return; } try { System.out.println(Text.translatable("browser.resource_pack.ready").getString()); minecraft.setScreen(new BasicBrowser(Text.translatable("browser.title"))); } catch (Exception e) { System.err.println(Text.translatable("debug.key_handler.creation_failed", e.getMessage()).getString()); if (minecraft.player != null) { minecraft.player.sendMessage(Text.translatable("browser.creation.failed"), false); } } } } }); } }
2303_806435pww/webmapview_moved
src/client/java/fun/xingwangzhe/webmapview/client/WebmapviewClient.java
Java
mit
9,270
package fun.xingwangzhe.webmapview; import net.fabricmc.api.ModInitializer; public class Webmapview implements ModInitializer { @Override public void onInitialize() { } }
2303_806435pww/webmapview_moved
src/main/java/fun/xingwangzhe/webmapview/Webmapview.java
Java
mit
186
extends Button # Called when the node enters the scene tree for the first time. func _ready() -> void: pass # Replace with function body. # Called every frame. 'delta' is the elapsed time since the previous frame. func _process(delta: float) -> void: pass func _on_pressed() -> void: $"../../Window".visible=true
2303_806435pww/turing_machine_moved
about.gd
GDScript
mit
322
extends Button # Called when the node enters the scene tree for the first time. func _ready() -> void: pass # Replace with function body. # Called every frame. 'delta' is the elapsed time since the previous frame. func _process(delta: float) -> void: pass func _on_pressed() -> void: $"../../RichTextLabel".text=$"..".text
2303_806435pww/turing_machine_moved
button.gd
GDScript
mit
332
extends Button ## Called every frame. 'delta' is the elapsed time since the previous frame. #func _process(delta: float) -> void: #pass func _on_pressed() -> void: #pass # Replace with function body. $"../../VBoxContainer/Label1".text='niaho' $"../../modelimg".texture=load("res://model1.png") func _on_model_2_pressed() -> void: pass # Replace with function body.
2303_806435pww/turing_machine_moved
model_1.gd
GDScript
mit
379