mirror of
https://github.com/labring/FastGPT.git
synced 2025-08-04 05:56:08 +00:00
perf: git star
This commit is contained in:
@@ -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) {}
|
||||
}
|
||||
}))
|
||||
)
|
||||
|
Reference in New Issue
Block a user