-
Notifications
You must be signed in to change notification settings - Fork 167
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
139 additions
and
99 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { noop } from "lodash-es"; | ||
import { subscribe } from "valtio"; | ||
|
||
export const useImmediate = (...args: Parameters<typeof subscribe>) => { | ||
const state = useReactive({ | ||
unsubscribe: noop, | ||
}); | ||
|
||
useMount(async () => { | ||
const [, callback] = args; | ||
|
||
callback([]); | ||
|
||
state.unsubscribe = subscribe(...args); | ||
}); | ||
|
||
useUnmount(state.unsubscribe); | ||
}; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import ProListItem from "@/components/ProListItem"; | ||
import { InputNumber } from "antd"; | ||
import { useSnapshot } from "valtio"; | ||
|
||
const Duration = () => { | ||
const { history } = useSnapshot(clipboardStore); | ||
const { t } = useTranslation(); | ||
|
||
return ( | ||
<ProListItem | ||
title={t("preference.history.history.label.duration")} | ||
description={t("preference.history.history.hints.duration")} | ||
> | ||
<InputNumber | ||
value={history.duration} | ||
min={0} | ||
addonAfter={t("preference.history.history.label.duration_unit")} | ||
className="w-120" | ||
onChange={(value) => { | ||
clipboardStore.history.duration = value ?? 0; | ||
}} | ||
/> | ||
</ProListItem> | ||
); | ||
}; | ||
|
||
export default Duration; |
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,27 @@ | ||
import ProListItem from "@/components/ProListItem"; | ||
import { InputNumber } from "antd"; | ||
import { useSnapshot } from "valtio"; | ||
|
||
const MaxCount = () => { | ||
const { history } = useSnapshot(clipboardStore); | ||
const { t } = useTranslation(); | ||
|
||
return ( | ||
<ProListItem | ||
title={t("preference.history.history.label.max_count")} | ||
description={t("preference.history.history.hints.max_count")} | ||
> | ||
<InputNumber | ||
value={history.maxCount} | ||
min={0} | ||
addonAfter={t("preference.history.history.label.max_count_unit")} | ||
className="w-120" | ||
onChange={(value) => { | ||
clipboardStore.history.maxCount = value ?? 0; | ||
}} | ||
/> | ||
</ProListItem> | ||
); | ||
}; | ||
|
||
export default MaxCount; |
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 |
---|---|---|
|
@@ -32,5 +32,6 @@ export const clipboardStore = proxy<ClipboardStore>({ | |
history: { | ||
duration: 0, | ||
unit: 1, | ||
maxCount: 0, | ||
}, | ||
}); |
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,3 @@ | ||
export type Interval = ReturnType<typeof setInterval>; | ||
|
||
export type Timeout = ReturnType<typeof setTimeout>; |
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 |
---|---|---|
|
@@ -95,5 +95,6 @@ export interface ClipboardStore { | |
history: { | ||
duration: number; | ||
unit: number; | ||
maxCount: number; | ||
}; | ||
} |
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