perf: git star

This commit is contained in:
archer
2023-08-07 13:26:53 +08:00
parent c26be2e885
commit 89036f8aec
6 changed files with 37 additions and 28 deletions

View File

@@ -1,6 +1,7 @@
import { create } from 'zustand';
import { devtools } from 'zustand/middleware';
import { immer } from 'zustand/middleware/immer';
import axios from 'axios';
type State = {
loading: boolean;
@@ -9,6 +10,8 @@ type State = {
setScreenWidth: (val: number) => void;
isPc?: boolean;
initIsPc(val: boolean): void;
gitStar: number;
loadGitStar: () => Promise<void>;
};
export const useGlobalStore = create<State>()(
@@ -35,6 +38,16 @@ export const useGlobalStore = create<State>()(
set((state) => {
state.isPc = val;
});
},
gitStar: 2700,
async loadGitStar() {
try {
const { data: git } = await axios.get('https://api.github.com/repos/labring/FastGPT');
set((state) => {
state.gitStar = git.stargazers_count;
});
} catch (error) {}
}
}))
)