-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
feat: 插件有新版本时置顶显示(可开关) #7665
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
zouyonghe
merged 7 commits into
AstrBotDevs:master
from
Blueteemo:fix/issue-7577-plugin-update-pin
Apr 21, 2026
Merged
feat: 插件有新版本时置顶显示(可开关) #7665
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
901d64d
feat: add pinUpdatesOnTop option to always show plugin updates at top
607b382
fix: add missing pinUpdatesOnTop destructuring in InstalledPluginsTab
a9b4e2f
fix: address AI review suggestions - add localStorage persistence and…
66195be
fix: harden extension preference storage
zouyonghe 2feeb55
fix: refine extension preference sorting
zouyonghe 767ebf9
fix: simplify extension preference sorting
zouyonghe f858539
refactor: simplify extension preference storage access
zouyonghe File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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
84 changes: 84 additions & 0 deletions
84
dashboard/src/views/extension/extensionPreferenceStorage.mjs
This file contains hidden or 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,84 @@ | ||
| export const SHOW_RESERVED_PLUGINS_STORAGE_KEY = "showReservedPlugins"; | ||
| export const PLUGIN_LIST_VIEW_MODE_STORAGE_KEY = "pluginListViewMode"; | ||
| export const PIN_UPDATES_ON_TOP_STORAGE_KEY = "pinUpdatesOnTop"; | ||
|
|
||
| /** | ||
| * Resolve the storage backend for reading preferences. | ||
| * Pass `null` to explicitly disable storage access in callers/tests. | ||
| */ | ||
| const getStorageForRead = (storageOverride) => { | ||
| if (storageOverride === null) { | ||
| return null; | ||
| } | ||
| if (storageOverride !== undefined) { | ||
| return typeof storageOverride?.getItem === "function" | ||
| ? storageOverride | ||
| : null; | ||
| } | ||
| if (typeof window === "undefined") { | ||
| return null; | ||
| } | ||
| try { | ||
| const localStorage = window.localStorage ?? null; | ||
| return typeof localStorage?.getItem === "function" ? localStorage : null; | ||
| } catch { | ||
| return null; | ||
| } | ||
| }; | ||
|
|
||
| /** | ||
| * Resolve the storage backend for writing preferences. | ||
| * Pass `null` to explicitly disable storage access in callers/tests. | ||
| */ | ||
| const getStorageForWrite = (storageOverride) => { | ||
| if (storageOverride === null) { | ||
| return null; | ||
| } | ||
| if (storageOverride !== undefined) { | ||
| return typeof storageOverride?.setItem === "function" | ||
| ? storageOverride | ||
| : null; | ||
| } | ||
| if (typeof window === "undefined") { | ||
| return null; | ||
| } | ||
| try { | ||
| const localStorage = window.localStorage ?? null; | ||
| return typeof localStorage?.setItem === "function" ? localStorage : null; | ||
| } catch { | ||
| return null; | ||
| } | ||
| }; | ||
|
|
||
| export const readBooleanPreference = (key, fallback, storage) => { | ||
| const targetStorage = getStorageForRead(storage); | ||
| if (!targetStorage) { | ||
| return fallback; | ||
| } | ||
|
|
||
| try { | ||
| const saved = targetStorage.getItem(key); | ||
| if (saved === "true") { | ||
| return true; | ||
| } | ||
| if (saved === "false") { | ||
| return false; | ||
| } | ||
| return fallback; | ||
| } catch { | ||
| return fallback; | ||
| } | ||
| }; | ||
|
|
||
| export const writeBooleanPreference = (key, value, storage) => { | ||
| const targetStorage = getStorageForWrite(storage); | ||
| if (!targetStorage) { | ||
| return; | ||
| } | ||
|
|
||
| try { | ||
| targetStorage.setItem(key, String(value)); | ||
| } catch { | ||
| // Ignore restricted storage environments. | ||
| } | ||
| }; | ||
This file contains hidden or 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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.