style: 完成所有文件的lint

This commit is contained in:
claude-code-best
2026-05-01 21:39:30 +08:00
parent d136872cc9
commit 6182015005
1333 changed files with 68255 additions and 77882 deletions

View File

@@ -1,18 +1,13 @@
import React, {
createContext,
useContext,
useState,
useSyncExternalStore,
} from 'react'
import { createStore, type Store } from '../state/store.js'
import React, { createContext, useContext, useState, useSyncExternalStore } from 'react';
import { createStore, type Store } from '../state/store.js';
export type VoiceState = {
voiceState: 'idle' | 'recording' | 'processing'
voiceError: string | null
voiceInterimTranscript: string
voiceAudioLevels: number[]
voiceWarmingUp: boolean
}
voiceState: 'idle' | 'recording' | 'processing';
voiceError: string | null;
voiceInterimTranscript: string;
voiceAudioLevels: number[];
voiceWarmingUp: boolean;
};
const DEFAULT_STATE: VoiceState = {
voiceState: 'idle',
@@ -20,29 +15,29 @@ const DEFAULT_STATE: VoiceState = {
voiceInterimTranscript: '',
voiceAudioLevels: [],
voiceWarmingUp: false,
}
};
type VoiceStore = Store<VoiceState>
type VoiceStore = Store<VoiceState>;
const VoiceContext = createContext<VoiceStore | null>(null)
const VoiceContext = createContext<VoiceStore | null>(null);
type Props = {
children: React.ReactNode
}
children: React.ReactNode;
};
export function VoiceProvider({ children }: Props): React.ReactNode {
// Store is created once — stable context value means the provider never
// triggers re-renders. Consumers subscribe to slices via useVoiceState.
const [store] = useState(() => createStore<VoiceState>(DEFAULT_STATE))
return <VoiceContext.Provider value={store}>{children}</VoiceContext.Provider>
const [store] = useState(() => createStore<VoiceState>(DEFAULT_STATE));
return <VoiceContext.Provider value={store}>{children}</VoiceContext.Provider>;
}
function useVoiceStore(): VoiceStore {
const store = useContext(VoiceContext)
const store = useContext(VoiceContext);
if (!store) {
throw new Error('useVoiceState must be used within a VoiceProvider')
throw new Error('useVoiceState must be used within a VoiceProvider');
}
return store
return store;
}
/**
@@ -50,9 +45,9 @@ function useVoiceStore(): VoiceStore {
* value changes (compared via Object.is).
*/
export function useVoiceState<T>(selector: (state: VoiceState) => T): T {
const store = useVoiceStore()
const get = () => selector(store.getState())
return useSyncExternalStore(store.subscribe, get, get)
const store = useVoiceStore();
const get = () => selector(store.getState());
return useSyncExternalStore(store.subscribe, get, get);
}
/**
@@ -60,10 +55,8 @@ export function useVoiceState<T>(selector: (state: VoiceState) => T): T {
* store.setState is synchronous: callers can read getVoiceState() immediately
* after to observe the new value (VoiceKeybindingHandler relies on this).
*/
export function useSetVoiceState(): (
updater: (prev: VoiceState) => VoiceState,
) => void {
return useVoiceStore().setState
export function useSetVoiceState(): (updater: (prev: VoiceState) => VoiceState) => void {
return useVoiceStore().setState;
}
/**
@@ -72,5 +65,5 @@ export function useSetVoiceState(): (
* inside event handlers that need to read state set earlier in the same tick.
*/
export function useGetVoiceState(): () => VoiceState {
return useVoiceStore().getState
return useVoiceStore().getState;
}