krinlove commited on
Commit
9b60369
·
verified ·
1 Parent(s): 612a132

Update src/lib/stores/index.ts

Browse files
Files changed (1) hide show
  1. src/lib/stores/index.ts +7 -6
src/lib/stores/index.ts CHANGED
@@ -1,5 +1,5 @@
1
  import { APP_NAME } from '$lib/constants';
2
- import { type Writable, writable } from 'svelte/store';
3
  import type { GlobalModelConfig, ModelConfig } from '$lib/apis';
4
  import type { Banner } from '$lib/types';
5
  import type { Socket } from 'socket.io-client';
@@ -15,11 +15,12 @@ export const MODEL_DOWNLOAD_POOL = writable({});
15
  export const mobile = writable(false);
16
 
17
  export const socket: Writable<null | Socket> = writable(null);
18
- export const activeUserCount: Writable<null | number> = writable(null);
19
- function updateRandomUserCountInRange() {
20
- const randomCount = Math.floor(Math.random() * (200 - 150 + 1) + 150);
21
- activeUserCount.set(randomCount);
22
- }
 
23
  updateRandomUserCountInRange();
24
  export const USAGE_POOL: Writable<null | string[]> = writable(null);
25
 
 
1
  import { APP_NAME } from '$lib/constants';
2
+ import { type Writable, writable,derived } from 'svelte/store';
3
  import type { GlobalModelConfig, ModelConfig } from '$lib/apis';
4
  import type { Banner } from '$lib/types';
5
  import type { Socket } from 'socket.io-client';
 
15
  export const mobile = writable(false);
16
 
17
  export const socket: Writable<null | Socket> = writable(null);
18
+ export const activeUserCount = derived(
19
+ null, //这里不需要依赖任何其他存储
20
+ ($) => {
21
+ return Math.floor(Math.random() * (200 -150 +1) +150);
22
+ }
23
+ );
24
  updateRandomUserCountInRange();
25
  export const USAGE_POOL: Writable<null | string[]> = writable(null);
26