{ // 获取包含Hugging Face文本的span元素 const spans = link.querySelectorAll('span.whitespace-nowrap, span.hidden.whitespace-nowrap'); spans.forEach(span => { if (span.textContent && span.textContent.trim().match(/Hugging\s*Face/i)) { span.textContent = 'AI快站'; } }); }); // 替换logo图片的alt属性 document.querySelectorAll('img[alt*="Hugging"], img[alt*="Face"]').forEach(img => { if (img.alt.match(/Hugging\s*Face/i)) { img.alt = 'AI快站 logo'; } }); } // 替换导航栏中的链接 function replaceNavigationLinks() { // 已替换标记,防止重复运行 if (window._navLinksReplaced) { return; } // 已经替换过的链接集合,防止重复替换 const replacedLinks = new Set(); // 只在导航栏区域查找和替换链接 const headerArea = document.querySelector('header') || document.querySelector('nav'); if (!headerArea) { return; } // 在导航区域内查找链接 const navLinks = headerArea.querySelectorAll('a'); navLinks.forEach(link => { // 如果已经替换过,跳过 if (replacedLinks.has(link)) return; const linkText = link.textContent.trim(); const linkHref = link.getAttribute('href') || ''; // 替换Spaces链接 - 仅替换一次 if ( (linkHref.includes('/spaces') || linkHref === '/spaces' || linkText === 'Spaces' || linkText.match(/^s*Spacess*$/i)) && linkText !== 'OCR模型免费转Markdown' && linkText !== 'OCR模型免费转Markdown' ) { link.textContent = 'OCR模型免费转Markdown'; link.href = 'https://fast360.xyz'; link.setAttribute('target', '_blank'); link.setAttribute('rel', 'noopener noreferrer'); replacedLinks.add(link); } // 删除Posts链接 else if ( (linkHref.includes('/posts') || linkHref === '/posts' || linkText === 'Posts' || linkText.match(/^s*Postss*$/i)) ) { if (link.parentNode) { link.parentNode.removeChild(link); } replacedLinks.add(link); } // 替换Docs链接 - 仅替换一次 else if ( (linkHref.includes('/docs') || linkHref === '/docs' || linkText === 'Docs' || linkText.match(/^s*Docss*$/i)) && linkText !== '模型下载攻略' ) { link.textContent = '模型下载攻略'; link.href = '/'; replacedLinks.add(link); } // 删除Enterprise链接 else if ( (linkHref.includes('/enterprise') || linkHref === '/enterprise' || linkText === 'Enterprise' || linkText.match(/^s*Enterprises*$/i)) ) { if (link.parentNode) { link.parentNode.removeChild(link); } replacedLinks.add(link); } }); // 查找可能嵌套的Spaces和Posts文本 const textNodes = []; function findTextNodes(element) { if (element.nodeType === Node.TEXT_NODE) { const text = element.textContent.trim(); if (text === 'Spaces' || text === 'Posts' || text === 'Enterprise') { textNodes.push(element); } } else { for (const child of element.childNodes) { findTextNodes(child); } } } // 只在导航区域内查找文本节点 findTextNodes(headerArea); // 替换找到的文本节点 textNodes.forEach(node => { const text = node.textContent.trim(); if (text === 'Spaces') { node.textContent = node.textContent.replace(/Spaces/g, 'OCR模型免费转Markdown'); } else if (text === 'Posts') { // 删除Posts文本节点 if (node.parentNode) { node.parentNode.removeChild(node); } } else if (text === 'Enterprise') { // 删除Enterprise文本节点 if (node.parentNode) { node.parentNode.removeChild(node); } } }); // 标记已替换完成 window._navLinksReplaced = true; } // 替换代码区域中的域名 function replaceCodeDomains() { // 特别处理span.hljs-string和span.njs-string元素 document.querySelectorAll('span.hljs-string, span.njs-string, span[class*="hljs-string"], span[class*="njs-string"]').forEach(span => { if (span.textContent && span.textContent.includes('huggingface.co')) { span.textContent = span.textContent.replace(/huggingface.co/g, 'aifasthub.com'); } }); // 替换hljs-string类的span中的域名(移除多余的转义符号) document.querySelectorAll('span.hljs-string, span[class*="hljs-string"]').forEach(span => { if (span.textContent && span.textContent.includes('huggingface.co')) { span.textContent = span.textContent.replace(/huggingface.co/g, 'aifasthub.com'); } }); // 替换pre和code标签中包含git clone命令的域名 document.querySelectorAll('pre, code').forEach(element => { if (element.textContent && element.textContent.includes('git clone')) { const text = element.innerHTML; if (text.includes('huggingface.co')) { element.innerHTML = text.replace(/huggingface.co/g, 'aifasthub.com'); } } }); // 处理特定的命令行示例 document.querySelectorAll('pre, code').forEach(element => { const text = element.innerHTML; if (text.includes('huggingface.co')) { // 针对git clone命令的专门处理 if (text.includes('git clone') || text.includes('GIT_LFS_SKIP_SMUDGE=1')) { element.innerHTML = text.replace(/huggingface.co/g, 'aifasthub.com'); } } }); // 特别处理模型下载页面上的代码片段 document.querySelectorAll('.flex.border-t, .svelte_hydrator, .inline-block').forEach(container => { const content = container.innerHTML; if (content && content.includes('huggingface.co')) { container.innerHTML = content.replace(/huggingface.co/g, 'aifasthub.com'); } }); // 特别处理模型仓库克隆对话框中的代码片段 try { // 查找包含"Clone this model repository"标题的对话框 const cloneDialog = document.querySelector('.svelte_hydration_boundary, [data-target="MainHeader"]'); if (cloneDialog) { // 查找对话框中所有的代码片段和命令示例 const codeElements = cloneDialog.querySelectorAll('pre, code, span'); codeElements.forEach(element => { if (element.textContent && element.textContent.includes('huggingface.co')) { if (element.innerHTML.includes('huggingface.co')) { element.innerHTML = element.innerHTML.replace(/huggingface.co/g, 'aifasthub.com'); } else { element.textContent = element.textContent.replace(/huggingface.co/g, 'aifasthub.com'); } } }); } // 更精确地定位克隆命令中的域名 document.querySelectorAll('[data-target]').forEach(container => { const codeBlocks = container.querySelectorAll('pre, code, span.hljs-string'); codeBlocks.forEach(block => { if (block.textContent && block.textContent.includes('huggingface.co')) { if (block.innerHTML.includes('huggingface.co')) { block.innerHTML = block.innerHTML.replace(/huggingface.co/g, 'aifasthub.com'); } else { block.textContent = block.textContent.replace(/huggingface.co/g, 'aifasthub.com'); } } }); }); } catch (e) { // 错误处理但不打印日志 } } // 当DOM加载完成后执行替换 if (document.readyState === 'loading') { document.addEventListener('DOMContentLoaded', () => { replaceHeaderBranding(); replaceNavigationLinks(); replaceCodeDomains(); // 只在必要时执行替换 - 3秒后再次检查 setTimeout(() => { if (!window._navLinksReplaced) { console.log('[Client] 3秒后重新检查导航链接'); replaceNavigationLinks(); } }, 3000); }); } else { replaceHeaderBranding(); replaceNavigationLinks(); replaceCodeDomains(); // 只在必要时执行替换 - 3秒后再次检查 setTimeout(() => { if (!window._navLinksReplaced) { console.log('[Client] 3秒后重新检查导航链接'); replaceNavigationLinks(); } }, 3000); } // 增加一个MutationObserver来处理可能的动态元素加载 const observer = new MutationObserver(mutations => { // 检查是否导航区域有变化 const hasNavChanges = mutations.some(mutation => { // 检查是否存在header或nav元素变化 return Array.from(mutation.addedNodes).some(node => { if (node.nodeType === Node.ELEMENT_NODE) { // 检查是否是导航元素或其子元素 if (node.tagName === 'HEADER' || node.tagName === 'NAV' || node.querySelector('header, nav')) { return true; } // 检查是否在导航元素内部 let parent = node.parentElement; while (parent) { if (parent.tagName === 'HEADER' || parent.tagName === 'NAV') { return true; } parent = parent.parentElement; } } return false; }); }); // 只在导航区域有变化时执行替换 if (hasNavChanges) { // 重置替换状态,允许再次替换 window._navLinksReplaced = false; replaceHeaderBranding(); replaceNavigationLinks(); } }); // 开始观察document.body的变化,包括子节点 if (document.body) { observer.observe(document.body, { childList: true, subtree: true }); } else { document.addEventListener('DOMContentLoaded', () => { observer.observe(document.body, { childList: true, subtree: true }); }); } })(); \n \n )\n }\n\nFinally, create a home page `app/page.tsx` with some initial content:\n\napp/page.tsx\n\nTypeScript\n\nJavaScriptTypeScript\n\n export default function Page() {\n return

Hello, Next.js!

\n }\n\n> **Good to know**: If you forget to create `layout.tsx`, Next.js will automatically create this file when running the development server with `next dev`.\n\nLearn more about [using the App Router](/docs/app/building-your-application/routing/defining-routes).\n\n#### [The `pages` directory (optional)](#the-pages-directory-optional)\n\nIf you prefer to use the Pages Router instead of the App Router, you can create a `pages/` directory at the root of your project.\n\nThen, add an `index.tsx` file inside your `pages` folder. This will be your home page (`/`):\n\npages/index.tsx\n\nTypeScript\n\nJavaScriptTypeScript\n\n export default function Page() {\n return

Hello, Next.js!

\n }\n\nNext, add an `_app.tsx` file inside `pages/` to define the global layout. Learn more about the [custom App file](/docs/pages/building-your-application/routing/custom-app).\n\npages/\\_app.tsx\n\nTypeScript\n\nJavaScriptTypeScript\n\n import type { AppProps } from 'next/app'\n \n export default function App({ Component, pageProps }: AppProps) {\n return \n }\n\nFinally, add a `_document.tsx` file inside `pages/` to control the initial response from the server. Learn more about the [custom Document file](/docs/pages/building-your-application/routing/custom-document).\n\npages/\\_document.tsx\n\nTypeScript\n\nJavaScriptTypeScript\n\n import { Html, Head, Main, NextScript } from 'next/document'\n \n export default function Document() {\n return (\n \n \n \n
\n \n \n \n )\n }\n\nLearn more about [using the Pages Router](/docs/pages/building-your-application/routing/pages-and-layouts).\n\n> **Good to know**: Although you can use both routers in the same project, routes in `app` will be prioritized over `pages`. We recommend using only one router in your new project to avoid confusion.\n\n#### [The `public` folder (optional)](#the-public-folder-optional)\n\nCreate a `public` folder to store static assets such as images, fonts, etc. Files inside `public` directory can then be referenced by your code starting from the base URL (`/`).\n\n[Run the Development Server](#run-the-development-server)\n---------------------------------------------------------\n\n1. Run `npm run dev` to start the development server.\n2. Visit `http://localhost:3000` to view your application.\n3. Edit `app/page.tsx` (or `pages/index.tsx`) file and save it to see the updated result in your browser.\n\nNext Steps\n----------\n\nLearn about the files and folders in your Next.js project.\n\n[\n\nGetting Started\n\n### Project Structure\n\nA list of folders and files conventions in a Next.js project\n\n](/docs/getting-started/project-structure)\n\n[Previous\n\nIntroduction\n\n](/docs)\n\n[Next\n\nProject Structure\n\n](/docs/getting-started/project-structure)\n\nWas this helpful?\n\nsupported.\n\nSend"}}},{"rowIdx":16,"cells":{"metadata":{"kind":"string","value":"{\n \"contentLength\": null,\n \"etag\": \"W/\\\"eb6f40af3dfcab15488fec496a01b7a5\\\"\",\n \"lastModifiedHeader\": null,\n \"lastModifiedHtml\": null\n}"},"url":{"kind":"string","value":"https://nextjs.org/docs/app/building-your-application/rendering/client-components"},"markdown":{"kind":"string","value":"Menu\n\nUsing App Router\n\nFeatures available in /app\n\n* [Getting Started](/docs/getting-started)\n \n * [Installation](/docs/getting-started/installation)\n * [Project Structure](/docs/getting-started/project-structure)\n \n\n* [Building Your Application](/docs/app/building-your-application)\n \n * [Routing](/docs/app/building-your-application/routing)\n \n * [Defining Routes](/docs/app/building-your-application/routing/defining-routes)\n * [Pages and Layouts](/docs/app/building-your-application/routing/pages-and-layouts)\n * [Linking and Navigating](/docs/app/building-your-application/routing/linking-and-navigating)\n * [Loading UI and Streaming](/docs/app/building-your-application/routing/loading-ui-and-streaming)\n * [Error Handling](/docs/app/building-your-application/routing/error-handling)\n * [Redirecting](/docs/app/building-your-application/routing/redirecting)\n * [Route Groups](/docs/app/building-your-application/routing/route-groups)\n * [Project Organization](/docs/app/building-your-application/routing/colocation)\n * [Dynamic Routes](/docs/app/building-your-application/routing/dynamic-routes)\n * [Parallel Routes](/docs/app/building-your-application/routing/parallel-routes)\n * [Intercepting Routes](/docs/app/building-your-application/routing/intercepting-routes)\n * [Route Handlers](/docs/app/building-your-application/routing/route-handlers)\n * [Middleware](/docs/app/building-your-application/routing/middleware)\n * [Internationalization](/docs/app/building-your-application/routing/internationalization)\n \n * [Data Fetching](/docs/app/building-your-application/data-fetching)\n \n * [Fetching, Caching, and Revalidating](/docs/app/building-your-application/data-fetching/fetching-caching-and-revalidating)\n * [Server Actions and Mutations](/docs/app/building-your-application/data-fetching/server-actions-and-mutations)\n * [Data Fetching Patterns and Best Practices](/docs/app/building-your-application/data-fetching/patterns)\n \n * [Rendering](/docs/app/building-your-application/rendering)\n \n * [Server Components](/docs/app/building-your-application/rendering/server-components)\n * [\n \n Client Components](/docs/app/building-your-application/rendering/client-components)\n * [Composition Patterns](/docs/app/building-your-application/rendering/composition-patterns)\n * [Edge and Node.js Runtimes](/docs/app/building-your-application/rendering/edge-and-nodejs-runtimes)\n \n * [Caching](/docs/app/building-your-application/caching)\n * [Styling](/docs/app/building-your-application/styling)\n \n * [CSS Modules](/docs/app/building-your-application/styling/css-modules)\n * [Tailwind CSS](/docs/app/building-your-application/styling/tailwind-css)\n * [CSS-in-JS](/docs/app/building-your-application/styling/css-in-js)\n * [Sass](/docs/app/building-your-application/styling/sass)\n \n * [Optimizing](/docs/app/building-your-application/optimizing)\n \n * [Images](/docs/app/building-your-application/optimizing/images)\n * [Videos](/docs/app/building-your-application/optimizing/videos)\n * [Fonts](/docs/app/building-your-application/optimizing/fonts)\n * [Metadata](/docs/app/building-your-application/optimizing/metadata)\n * [Scripts](/docs/app/building-your-application/optimizing/scripts)\n * [Bundle Analyzer](/docs/app/building-your-application/optimizing/bundle-analyzer)\n * [Lazy Loading](/docs/app/building-your-application/optimizing/lazy-loading)\n * [Analytics](/docs/app/building-your-application/optimizing/analytics)\n * [Instrumentation](/docs/app/building-your-application/optimizing/instrumentation)\n * [OpenTelemetry](/docs/app/building-your-application/optimizing/open-telemetry)\n * [Static Assets](/docs/app/building-your-application/optimizing/static-assets)\n * [Third Party Libraries](/docs/app/building-your-application/optimizing/third-party-libraries)\n * [Memory Usage](/docs/app/building-your-application/optimizing/memory-usage)\n \n * [Configuring](/docs/app/building-your-application/configuring)\n \n * [TypeScript](/docs/app/building-your-application/configuring/typescript)\n * [ESLint](/docs/app/building-your-application/configuring/eslint)\n * [Environment Variables](/docs/app/building-your-application/configuring/environment-variables)\n * [Absolute Imports and Module Path Aliases](/docs/app/building-your-application/configuring/absolute-imports-and-module-aliases)\n * [MDX](/docs/app/building-your-application/configuring/mdx)\n * [src Directory](/docs/app/building-your-application/configuring/src-directory)\n * [Draft Mode](/docs/app/building-your-application/configuring/draft-mode)\n * [Content Security Policy](/docs/app/building-your-application/configuring/content-security-policy)\n \n * [Testing](/docs/app/building-your-application/testing)\n \n * [Vitest](/docs/app/building-your-application/testing/vitest)\n * [Jest](/docs/app/building-your-application/testing/jest)\n * [Playwright](/docs/app/building-your-application/testing/playwright)\n * [Cypress](/docs/app/building-your-application/testing/cypress)\n \n * [Authentication](/docs/app/building-your-application/authentication)\n * [Deploying](/docs/app/building-your-application/deploying)\n \n * [Production Checklist](/docs/app/building-your-application/deploying/production-checklist)\n * [Static Exports](/docs/app/building-your-application/deploying/static-exports)\n \n * [Upgrading](/docs/app/building-your-application/upgrading)\n \n * [Codemods](/docs/app/building-your-application/upgrading/codemods)\n * [App Router Migration](/docs/app/building-your-application/upgrading/app-router-migration)\n * [Version 14](/docs/app/building-your-application/upgrading/version-14)\n * [Migrating from Vite](/docs/app/building-your-application/upgrading/from-vite)\n * [Migrating from Create React App](/docs/app/building-your-application/upgrading/from-create-react-app)\n \n \n\n* [API Reference](/docs/app/api-reference)\n \n * [Components](/docs/app/api-reference/components)\n \n * [Font](/docs/app/api-reference/components/font)\n * [](/docs/app/api-reference/components/image)\n * [](/docs/app/api-reference/components/link)\n * [\n\nOr by using the `dangerouslySetInnerHTML` property:\n\n \n\n> **Warning**: An `id` property must be assigned for inline scripts in order for Next.js to track and optimize the script.\n\n### [Executing Additional Code](#executing-additional-code)\n\nEvent handlers can be used with the Script component to execute additional code after a certain event occurs:\n\n* `onLoad`: Execute code after the script has finished loading.\n* `onReady`: Execute code after the script has finished loading and every time the component is mounted.\n* `onError`: Execute code if the script fails to load.\n\nThese handlers will only work when `next/script` is imported and used inside of a [Client Component](/docs/app/building-your-application/rendering/client-components) where `\"use client\"` is defined as the first line of code:\n\napp/page.tsx\n\nTypeScript\n\nJavaScriptTypeScript\n\n 'use client'\n \n import Script from 'next/script'\n \n export default function Page() {\n return (\n <>\n {\n console.log('Script has loaded')\n }}\n />\n \n )\n }\n\nRefer to the [`next/script`](/docs/app/api-reference/components/script#onload) API reference to learn more about each event handler and view examples.\n\n### [Additional Attributes](#additional-attributes)\n\nThere are many DOM attributes that can be assigned to a `