Skip to content

Commit 093ec32

Browse files
committed
test: 测试修改路径
1 parent a2997c8 commit 093ec32

File tree

6 files changed

+88
-83
lines changed

6 files changed

+88
-83
lines changed

components/code-block/index.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import React, { useState } from "react";
22
import styles from "./index.module.css";
3+
import { useRouter } from "next/router";
34

45
interface CodeBlockProps {
56
type: "maven" | "gradle";
@@ -25,6 +26,7 @@ const gradleCodeHighlight = `<span style="color: #6DFF1C">implementation</span>
2526

2627
export const CodeBlock: React.FC<CodeBlockProps> = ({ type }) => {
2728
const [copied, setCopied] = useState(false);
29+
const { basePath } = useRouter();
2830
const highlightCode =
2931
type === "maven" ? mavenCodeHighlight : gradleCodeHighlight;
3032

@@ -43,7 +45,7 @@ export const CodeBlock: React.FC<CodeBlockProps> = ({ type }) => {
4345
<div className={styles.wrapper}>
4446
<div className={styles.logo}>
4547
<img
46-
src={`/fastexcel/images/${type}.png`}
48+
src={`${basePath}/images/${type}.png`}
4749
alt="FastExcel"
4850
width={136}
4951
height={40}

components/contributors/index.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import React from "react";
22
import styles from "./index.module.css";
33
import { useTranslation } from "../../hooks/useTranslation";
44
import Link from "next/link";
5+
import { useRouter } from "next/router";
56

67
interface Contributor {
78
name: string;
@@ -49,6 +50,7 @@ const contributors: Contributor[] = [
4950

5051
export const Contributors: React.FC = () => {
5152
const { t } = useTranslation();
53+
const { basePath } = useRouter();
5254
return (
5355
<div className={styles.container}>
5456
<h2 className={styles.title}>{t("contributors.title")}</h2>
@@ -58,7 +60,7 @@ export const Contributors: React.FC = () => {
5860
{contributors.map((contributor, index) => (
5961
<div key={index} className={styles.contributorItem}>
6062
<img
61-
src={`/fastexcel${contributor.avatar}`}
63+
src={`${basePath}${contributor.avatar}`}
6264
alt={contributor.name}
6365
className={styles.avatar}
6466
/>

components/features/index.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import React, { useMemo } from "react";
22
import Image from "next/image";
33
import styles from "./index.module.css";
44
import { useTranslation } from "../../hooks/useTranslation";
5+
import { useRouter } from "next/router";
56

67
interface Feature {
78
title: string;
@@ -11,6 +12,7 @@ interface Feature {
1112

1213
export const Features: React.FC = () => {
1314
const { t } = useTranslation();
15+
const { basePath } = useRouter();
1416
const features: Feature[] = useMemo(
1517
() => [
1618
{
@@ -41,7 +43,7 @@ export const Features: React.FC = () => {
4143
{features.map((feature, index) => (
4244
<div key={index} className={styles.featureCard}>
4345
<Image
44-
src={`/fastexcel${feature.icon}`}
46+
src={`${basePath}${feature.icon}`}
4547
alt={feature.title}
4648
width={40}
4749
height={40}

components/testimonials/index.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import React from 'react';
22
import styles from './index.module.css';
33
import { useTranslation } from '../../hooks/useTranslation';
4+
import { useRouter } from 'next/router';
45

56
interface Testimonial {
67
author: string;
@@ -114,7 +115,7 @@ const extendedTestimonials = [...testimonials, ...testimonials, ...testimonials]
114115

115116
export const Testimonials: React.FC = () => {
116117
const { t } = useTranslation();
117-
118+
const { basePath } = useRouter();
118119
// 提取卡片组件以提高可复用性
119120
const TestimonialCard = React.memo(({ testimonial, index, rowId }: {
120121
testimonial: Testimonial;
@@ -124,7 +125,7 @@ export const Testimonials: React.FC = () => {
124125
<div key={`${rowId}-${index}`} className={styles.testimonialCard}>
125126
<div className={styles.testimonialHeader}>
126127
<img
127-
src={`/fastexcel${testimonial.avatar}`}
128+
src={`${basePath}${testimonial.avatar}`}
128129
alt={testimonial.author}
129130
className={styles.avatar}
130131
loading="lazy" // 添加懒加载

next.config.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ const withNextra = nextra({
77
});
88

99
export default withNextra({
10-
basePath: '/fastexcel',
11-
assetPrefix: '/fastexcel',
1210
i18n: {
1311
locales: ["zh-CN", "zh-TW", "en-US", "ja-JP"],
1412
defaultLocale: "zh-CN",

0 commit comments

Comments
 (0)