generated from halo-dev/plugin-starter
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: only query the necessary applications when checking updates (…
…#13) 重构检测插件或者主题更新时的逻辑,修改为仅查询已安装的应用信息。 /kind improvement Fixes #8 ```release-note 重构检测插件或者主题更新时的逻辑,修改为仅查询已安装的应用信息。 ```
- Loading branch information
Showing
9 changed files
with
78 additions
and
32 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,20 @@ | ||
import { STORE_APP_ID } from "@/constant"; | ||
import { apiClient } from "@/utils/api-client"; | ||
import type { Plugin } from "@halo-dev/api-client"; | ||
import { useQuery } from "@tanstack/vue-query"; | ||
import type { Ref } from "vue"; | ||
|
||
export function useFetchInstalledPlugins(enabled: Ref<boolean>) { | ||
const { data: installedPlugins } = useQuery<Plugin[]>({ | ||
queryKey: ["store-installed-plugins"], | ||
queryFn: async () => { | ||
const { data } = await apiClient.plugin.listPlugins(); | ||
return data.items.filter((plugin) => { | ||
return !!plugin.metadata.annotations?.[STORE_APP_ID]; | ||
}); | ||
}, | ||
enabled, | ||
staleTime: 1000, | ||
}); | ||
return { installedPlugins }; | ||
} |
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,21 @@ | ||
import { STORE_APP_ID } from "@/constant"; | ||
import { apiClient } from "@/utils/api-client"; | ||
import type { Theme } from "@halo-dev/api-client"; | ||
import { useQuery } from "@tanstack/vue-query"; | ||
import type { Ref } from "vue"; | ||
|
||
export function useFetchInstalledThemes(enabled: Ref<boolean>) { | ||
const { data: installedThemes } = useQuery<Theme[]>({ | ||
queryKey: ["store-installed-themes"], | ||
queryFn: async () => { | ||
const { data } = await apiClient.theme.listThemes({ | ||
uninstalled: false, | ||
}); | ||
return data.items.filter((theme) => { | ||
return !!theme.metadata.annotations?.[STORE_APP_ID]; | ||
}); | ||
}, | ||
enabled, | ||
}); | ||
return { installedThemes }; | ||
} |
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 |
---|---|---|
@@ -1,7 +1,11 @@ | ||
import axios from "axios"; | ||
import qs from "qs"; | ||
|
||
const storeApiClient = axios.create({ | ||
baseURL: import.meta.env.VITE_APP_STORE_BACKEND, | ||
paramsSerializer: (params) => { | ||
return qs.stringify(params, { arrayFormat: "repeat" }); | ||
}, | ||
}); | ||
|
||
export default storeApiClient; |