Skip to content

Commit

Permalink
🐛 HeadBar的标题显示@verkfi/core
Browse files Browse the repository at this point in the history
  • Loading branch information
neila-a committed Apr 19, 2024
1 parent a4626d8 commit 77ecde7
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 29 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ bower_components
# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release
out
public/service-worker.js
service-worker.js
next.config.js
*.vxt

Expand Down
2 changes: 1 addition & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@verkfi/core",
"version": "1.7.0",
"devVersion": "866",
"devVersion": "871",
"dev": true,
"description": "Platform for Neila's something useless tools.",
"private": true,
Expand Down
2 changes: 1 addition & 1 deletion packages/core/public/index.webmanifest
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
"url": "/handle?handle=%s"
}
],
"id": "verkfi",
"id": "@verkfi/core",
"display_override": [
"window-controls-overlay",
"fullscreen",
Expand Down
19 changes: 0 additions & 19 deletions packages/core/public/service-worker.js

This file was deleted.

3 changes: 2 additions & 1 deletion packages/core/src/app/components/HeadBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import {
import Link from 'next/link';
import {
forkMeOnGitHub as forkMeOnGitHubContext,
repoInfo,
share as shareContext,
showSidebar
} from 'layout/layoutClient';
Expand All @@ -53,7 +54,7 @@ export interface HeadBarOption {
export default function HeadBar(props: HeadBarOption): JSX.Element {
const forkMeOnGithub = useContext(forkMeOnGitHubContext),
router = useRouter(),
upper = pack.name.charAt(0).toUpperCase() + pack.name.slice(1),
upper = useContext(repoInfo).name.charAt(0).toUpperCase() + useContext(repoInfo).name.slice(1),
share = useContext(shareContext).value,
noDrag: CSSProperties = {
// @ts-ignore React的CSSProperties中明明有WebkitAppRegion,但是类型中没有
Expand Down
9 changes: 5 additions & 4 deletions packages/core/src/app/components/getRepoInfo.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import pack from "../../../package.json";
export interface repoInfo {
name: string;
description: string;
};
export async function getRepoInfo() {
const repoInfo: {
name: string;
description: string;
} = await (await fetch(`https://api.github.com/repos/${pack.repository.replace("github:", "")}`)).json();
const repoInfo: repoInfo = await (await fetch(`https://api.github.com/repos/${pack.repository.replace("github:", "")}`)).json();
return repoInfo;
}
3 changes: 2 additions & 1 deletion packages/core/src/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ import {
export default async function Layout({
children
}) {
const repoInfo = await getRepoInfo();
return (
<html lang="zh-cmn-Hans-CN">
<body style={{
Expand Down Expand Up @@ -109,7 +110,7 @@ export default async function Layout({
minHeight: "100vh"
}}>
<Suspense fallback={<Loading />}>
<BaseLayout>
<BaseLayout repoInfo={repoInfo}>
{children}
</BaseLayout>
</Suspense>
Expand Down
7 changes: 6 additions & 1 deletion packages/core/src/app/layout/layoutClient.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ import useExtensions, {
extensionsDispatch
} from "./useExtensions";
import composeProviders from "./providerCompose";
import {
repoInfo as repoInfoType
} from "components/getRepoInfo";
export const showSidebar = createContext<{
show: boolean;
set: Dispatch<boolean>;
Expand Down Expand Up @@ -154,8 +157,10 @@ export const extensions = createContext<{
value: single[];
set: Dispatch<extensionsDispatch>;
}>(null);
export const repoInfo = createContext<repoInfoType>(null);
export default function ModifiedApp(props: {
children: ReactNode;
repoInfo: repoInfoType;
}) {
const [mode, setMode] = useStoragedState<PaletteMode | "system">("darkmode", "暗色模式", "system"),
[realWindows, setRealWindows] = useState<WindowOptions[]>([]),
Expand Down Expand Up @@ -195,7 +200,7 @@ export default function ModifiedApp(props: {
[forkMeOnGitHubState, setForkMeOnGithub] = useStoragedState<boolean>("fork-me-on-github", "Fork me on GitHub", false),
[shareState, setShare] = useStoragedState<boolean>("share", "分享", isBrowser() ? "share" in navigator : false),
[colorModeState, setColorModeState] = useStoragedState<boolean>("color", "多彩主页", true),
Provider = composeProviders([first, {
Provider = composeProviders([repoInfo, props.repoInfo],[first, {
value: firstState,
set: setFirst
}], [forkMeOnGitHub, {
Expand Down

0 comments on commit 77ecde7

Please sign in to comment.