-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
⚡️ 在atomWithStorage中使用初始值让渲染挂起以获得异步值
- Loading branch information
Showing
54 changed files
with
288 additions
and
223 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
"use client"; | ||
import { | ||
PaletteMode | ||
} from "@mui/material"; | ||
import { | ||
WindowOptions | ||
} from "components/window/Window"; | ||
import { | ||
viewMode as viewModeType | ||
} from "index/consts"; | ||
import { | ||
lists as listsType | ||
} from "index/sidebar"; | ||
import { | ||
atom | ||
} from "jotai"; | ||
import defaultPalette from "setting/appearance/defaultPalette"; | ||
import atomWithStorage from "setting/reader/atomWithStorage"; | ||
import isBrowser from "layout/isBrowser"; | ||
interface mostUsedMarks { | ||
[key: string]: number; | ||
} | ||
export const sidebarMode = atomWithStorage<"menu" | "sidebar">("sidebarmode", "边栏模式", "menu"), | ||
showSidebar = atomWithStorage<boolean>("sidebar", "边栏", false), | ||
forkMeOnGitHub = atomWithStorage<boolean>("fork-me-on-github", "Fork me on GitHub", false), | ||
share = atomWithStorage<boolean>("share", "分享", isBrowser() ? "share" in navigator : false), | ||
paletteColors = atomWithStorage<typeof defaultPalette>("palette", "调色板", defaultPalette), | ||
viewMode = atomWithStorage<viewModeType>("viewmode", "列表模式", "list"), | ||
darkMode = atomWithStorage<PaletteMode | "system">("darkmode", "暗色模式", "system"), | ||
booleanifyDarkMode = atom(async get => { | ||
const [gotAtom] = await get(darkMode); | ||
let value = true; | ||
switch (gotAtom) { | ||
case "dark": | ||
value = false; | ||
break; | ||
case "system": | ||
if (isBrowser()) { | ||
value = !(window.matchMedia("(prefers-color-scheme: dark)").matches); | ||
} | ||
break; | ||
} | ||
return value; | ||
}), gradientTool = atomWithStorage<boolean>("gradient-tool", "工具渐变", false), | ||
recentlyUsed = atomWithStorage<string[]>("recently-tools", "最近使用的工具", []), | ||
mostUsed = atomWithStorage<mostUsedMarks>("most-tools", "最常使用的工具", { | ||
}), | ||
lists = atomWithStorage<listsType>("lists", "分类列表", []), | ||
windows = atom<WindowOptions[]>([]); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 7 additions & 8 deletions
15
...pp/index/sidebar/selects/toolsListAtom.ts → packages/core/src/app/atoms/toolsList.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.