Skip to content

Commit 2d681ee

Browse files
committed
1.3.9.02
【优化】 - 移除部分死代码 - README 中弃用的 HTML 特性
1 parent b2038fc commit 2d681ee

61 files changed

Lines changed: 147 additions & 1946 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

README.md

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
1-
<h1 align="center">
2-
<em>Repo-Viewer</em>
3-
</h1>
4-
5-
<p align="center">
6-
<strong>基于 Material Design 3设计风格的 GitHub仓库浏览应用</strong>
7-
&nbsp;&nbsp;
8-
<a href="https://deepwiki.com/UE-DND/Repo-Viewer">
9-
<img src="https://deepwiki.com/badge.svg" alt="Ask DeepWiki">
10-
</a>
11-
</p>
1+
<div style="text-align: center;">
2+
<h1><em>Repo-Viewer</em></h1>
3+
</div>
4+
5+
<div style="text-align: center;">
6+
<p>
7+
<strong>基于 Material Design 3设计风格的 GitHub仓库浏览应用</strong>
8+
&nbsp;&nbsp;
9+
<a href="https://deepwiki.com/UE-DND/Repo-Viewer">
10+
<img src="https://deepwiki.com/badge.svg" alt="Ask DeepWiki">
11+
</a>
12+
</p>
13+
</div>
1214

1315
![Preview Dark](docs/image/dark.png)
1416

scripts/generateDocfindIndex.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,7 @@ const resolveBranchRef = async (repoPath: string, branch: string): Promise<strin
402402
await runCommandText("git", ["rev-parse", "--verify", candidate], repoPath);
403403
return candidate;
404404
} catch {
405-
continue;
405+
406406
}
407407
}
408408
return null;

scripts/generateInitialContent.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ const fetchJson = async <T>(url: string): Promise<T> => {
7878
if (!response.ok) {
7979
throw new Error(`Request failed: ${response.status} ${response.statusText}`);
8080
}
81-
return response.json() as Promise<T>;
81+
return (await response.json()) as T;
8282
};
8383

8484
const fetchText = async (url: string): Promise<string> => {
@@ -139,7 +139,9 @@ const run = async (): Promise<void> => {
139139
const contents = await fetchJson<unknown>(contentsUrl);
140140

141141
if (!Array.isArray(contents)) {
142-
throw new Error("Unexpected contents response");
142+
console.warn("[hydration] Unexpected contents response, writing null payload.");
143+
await writeOutput(null);
144+
return;
143145
}
144146

145147
const contentItems = contents.filter(isRecord);
Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1 @@
1-
import type { InitialContentHydrationPayload } from "@/types";
2-
3-
export const initialContentPayload: InitialContentHydrationPayload | null = null;
1+
export {};

src/components/file/FileListItem.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ import {
1717
Download as DownloadIcon,
1818
Cancel as CancelIcon,
1919
} from "@mui/icons-material";
20-
import { file, logger, theme as themeUtils } from "@/utils";
20+
import { logger, theme as themeUtils } from "@/utils";
21+
import { fileExtensionIcons } from "@/utils/files/fileHelpers";
2122
import type { GitHubContent } from "@/types";
2223
import { getFeaturesConfig } from "@/config";
2324
import { useI18n } from "@/contexts/I18nContext";
@@ -143,7 +144,7 @@ const FileListItem = memo<FileListItemProps>(
143144

144145
const extension = item.name.split('.').pop()?.toLowerCase();
145146
if (typeof extension === "string" && extension.length > 0) {
146-
const icon = file.fileExtensionIcons[extension];
147+
const icon = fileExtensionIcons[extension];
147148
if (icon !== undefined) {
148149
return icon;
149150
}

src/components/file/FileListRow.tsx

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import React, { useEffect, useRef, useState } from "react";
2-
import type { ReactElement } from "react";
1+
import { useEffect, useRef, useState } from "react";
2+
import type { CSSProperties, ReactElement } from "react";
33
import { motion } from "framer-motion";
44
import type { MotionStyle } from "framer-motion";
55
import type { RowComponentProps } from "react-window";
@@ -75,7 +75,7 @@ const RowComponent = ({
7575

7676
const isHighlighted = highlightedIndex === index;
7777

78-
const adjustedStyle: React.CSSProperties = {
78+
const adjustedStyle: CSSProperties = {
7979
...style,
8080
boxSizing: "border-box",
8181
alignItems: "flex-start",
@@ -130,10 +130,4 @@ const RowComponent = ({
130130
);
131131
};
132132

133-
const Row = React.memo(RowComponent);
134-
135-
Row.displayName = "FileListRow";
136-
137133
export { RowComponent };
138-
139-
export default Row;

src/components/interactions/SearchDrawer/FallbackDialog.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {
66
DialogTitle,
77
Typography
88
} from "@mui/material";
9+
import React from "react";
910

1011
interface FallbackDialogProps {
1112
open: boolean;

src/components/interactions/SearchDrawer/FilterSection.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import {
1717
} from "@mui/icons-material";
1818
import { g3BorderRadius, G3_PRESETS } from "@/theme/g3Curves";
1919
import { useI18n } from "@/contexts/I18nContext";
20+
import React from "react";
2021

2122
interface FilterSectionProps {
2223
expanded: boolean;

src/components/interactions/SearchDrawer/IndexStatus.tsx

Lines changed: 45 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { useMemo } from "react";
1+
import React, { useMemo } from "react";
22
import {
33
Alert,
44
Box,
@@ -13,13 +13,14 @@ import { Refresh as RefreshIcon } from "@mui/icons-material";
1313
import { g3BorderRadius, G3_PRESETS } from "@/theme/g3Curves";
1414
import { useI18n } from "@/contexts/I18nContext";
1515
import type { InterpolationOptions } from "@/utils/i18n/types";
16+
import { SearchIndexErrorCode } from "@/services/github/core/searchIndex/errors";
1617

1718
const FALLBACK_INDEX_TIME = Date.now();
1819

1920
interface IndexStatusProps {
2021
enabled: boolean;
2122
loading: boolean;
22-
error: { message: string; code?: string } | null;
23+
error: { message: string; code?: SearchIndexErrorCode } | null;
2324
ready: boolean;
2425
indexedBranches: string[];
2526
lastUpdatedAt: number | undefined;
@@ -32,50 +33,52 @@ interface ErrorScenario {
3233
}
3334

3435
const getErrorScenario = (
35-
error: { message: string; code?: string } | null,
36+
error: { message: string; code?: SearchIndexErrorCode } | null,
3637
ready: boolean,
3738
t: (key: string, options?: InterpolationOptions) => string
3839
): ErrorScenario | null => {
39-
if (error?.code !== undefined) {
40-
switch (error.code) {
41-
case 'SEARCH_INDEX_MANIFEST_NOT_FOUND':
42-
return {
43-
title: t('search.index.errors.manifestNotFound.title'),
44-
description: [
45-
t('search.index.errors.manifestNotFound.description1'),
46-
t('search.index.errors.manifestNotFound.description2'),
47-
],
48-
};
49-
case 'SEARCH_INDEX_MANIFEST_INVALID':
50-
return {
51-
title: t('search.index.errors.manifestInvalid.title'),
52-
description: [t('search.index.errors.manifestInvalid.description1')],
53-
};
54-
case 'SEARCH_INDEX_FILE_NOT_FOUND':
55-
return {
56-
title: t('search.index.errors.fileNotFound.title'),
57-
description: [
58-
t('search.index.errors.fileNotFound.description1'),
59-
t('search.index.errors.fileNotFound.description2'),
60-
],
61-
};
62-
case 'SEARCH_INDEX_DOCUMENT_INVALID':
63-
return {
64-
title: t('search.index.errors.documentInvalid.title'),
65-
description: [
66-
t('search.index.errors.documentInvalid.description1'),
67-
t('search.index.errors.documentInvalid.description2'),
68-
],
69-
};
70-
default:
71-
return {
72-
title: t('search.index.errors.default.title'),
73-
description: [
74-
t('search.index.errors.default.description1', { message: error.message }),
75-
t('search.index.errors.default.description2'),
76-
],
77-
};
40+
if (error !== null) {
41+
const code = error.code;
42+
if (code === SearchIndexErrorCode.MANIFEST_NOT_FOUND) {
43+
return {
44+
title: t('search.index.errors.manifestNotFound.title'),
45+
description: [
46+
t('search.index.errors.manifestNotFound.description1'),
47+
t('search.index.errors.manifestNotFound.description2'),
48+
],
49+
};
7850
}
51+
if (code === SearchIndexErrorCode.MANIFEST_INVALID) {
52+
return {
53+
title: t('search.index.errors.manifestInvalid.title'),
54+
description: [t('search.index.errors.manifestInvalid.description1')],
55+
};
56+
}
57+
if (code === SearchIndexErrorCode.INDEX_FILE_NOT_FOUND) {
58+
return {
59+
title: t('search.index.errors.fileNotFound.title'),
60+
description: [
61+
t('search.index.errors.fileNotFound.description1'),
62+
t('search.index.errors.fileNotFound.description2'),
63+
],
64+
};
65+
}
66+
if (code === SearchIndexErrorCode.INDEX_DOCUMENT_INVALID) {
67+
return {
68+
title: t('search.index.errors.documentInvalid.title'),
69+
description: [
70+
t('search.index.errors.documentInvalid.description1'),
71+
t('search.index.errors.documentInvalid.description2'),
72+
],
73+
};
74+
}
75+
return {
76+
title: t('search.index.errors.default.title'),
77+
description: [
78+
t('search.index.errors.default.description1', { message: error.message }),
79+
t('search.index.errors.default.description2'),
80+
],
81+
};
7982
}
8083

8184
if (!ready) {

src/components/interactions/SearchDrawer/SearchInput.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import {
1010
import { Clear as ClearIcon } from "@mui/icons-material";
1111
import { g3BorderRadius, G3_PRESETS } from "@/theme/g3Curves";
1212
import { useI18n } from "@/contexts/I18nContext";
13+
import React from "react";
1314

1415
interface SearchInputProps {
1516
value: string;

0 commit comments

Comments
 (0)