mirror of
https://github.com/infinilabs/coco-app.git
synced 2025-12-16 11:37:47 +01:00
feat: add auto collapse delay for compact mode (#981)
* feat: add auto collapse delay for compact mode * refactor: change i18n * docs: update changelog
This commit is contained in:
@@ -26,7 +26,7 @@ feat(extension compatibility): minimum_coco_version #946
|
|||||||
feat: add compact mode for window #947
|
feat: add compact mode for window #947
|
||||||
feat: advanced settings search debounce & local query source weight #950
|
feat: advanced settings search debounce & local query source weight #950
|
||||||
feat: add window opacity configuration option #963
|
feat: add window opacity configuration option #963
|
||||||
|
feat: add auto collapse delay for compact mode #981
|
||||||
|
|
||||||
### 🐛 Bug fix
|
### 🐛 Bug fix
|
||||||
|
|
||||||
|
|||||||
@@ -103,8 +103,13 @@ function SearchChat({
|
|||||||
const [hideMiddleBorder, setHideMiddleBorder] = useState(false);
|
const [hideMiddleBorder, setHideMiddleBorder] = useState(false);
|
||||||
|
|
||||||
const setSuppressErrors = useAppStore((state) => state.setSuppressErrors);
|
const setSuppressErrors = useAppStore((state) => state.setSuppressErrors);
|
||||||
|
let collapseWindowTimer = useRef<ReturnType<typeof setTimeout>>();
|
||||||
|
|
||||||
const setWindowSize = useCallback(() => {
|
const setWindowSize = useCallback(() => {
|
||||||
|
if (collapseWindowTimer.current) {
|
||||||
|
clearTimeout(collapseWindowTimer.current);
|
||||||
|
}
|
||||||
|
|
||||||
const width = 680;
|
const width = 680;
|
||||||
let height = 590;
|
let height = 590;
|
||||||
|
|
||||||
@@ -128,12 +133,22 @@ function SearchChat({
|
|||||||
if (windowMode === "compact") {
|
if (windowMode === "compact") {
|
||||||
height = 84;
|
height = 84;
|
||||||
}
|
}
|
||||||
|
|
||||||
setHideMiddleBorder(height < 590);
|
|
||||||
setSuppressErrors(height < 590);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
platformAdapter.setWindowSize(width, height);
|
if (height < 590) {
|
||||||
|
const { compactModeAutoCollapseDelay } = useConnectStore.getState();
|
||||||
|
|
||||||
|
console.log("compactModeAutoCollapseDelay", compactModeAutoCollapseDelay);
|
||||||
|
|
||||||
|
collapseWindowTimer.current = setTimeout(() => {
|
||||||
|
setHideMiddleBorder(true);
|
||||||
|
setSuppressErrors(true);
|
||||||
|
|
||||||
|
platformAdapter.setWindowSize(width, height);
|
||||||
|
}, compactModeAutoCollapseDelay * 1000);
|
||||||
|
} else {
|
||||||
|
platformAdapter.setWindowSize(width, height);
|
||||||
|
}
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const debouncedSetWindowSize = debounce(setWindowSize, 50);
|
const debouncedSetWindowSize = debounce(setWindowSize, 50);
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import {
|
|||||||
AppWindowMac,
|
AppWindowMac,
|
||||||
ArrowUpWideNarrow,
|
ArrowUpWideNarrow,
|
||||||
MessageSquareMore,
|
MessageSquareMore,
|
||||||
|
PanelTopClose,
|
||||||
Search,
|
Search,
|
||||||
ShieldCheck,
|
ShieldCheck,
|
||||||
Unplug,
|
Unplug,
|
||||||
@@ -59,7 +60,12 @@ const Advanced = () => {
|
|||||||
const setAllowSelfSignature = useConnectStore((state) => {
|
const setAllowSelfSignature = useConnectStore((state) => {
|
||||||
return state.setAllowSelfSignature;
|
return state.setAllowSelfSignature;
|
||||||
});
|
});
|
||||||
const { searchDelay, setSearchDelay } = useConnectStore();
|
const {
|
||||||
|
searchDelay,
|
||||||
|
setSearchDelay,
|
||||||
|
compactModeAutoCollapseDelay,
|
||||||
|
setCompactModeAutoCollapseDelay,
|
||||||
|
} = useConnectStore();
|
||||||
|
|
||||||
const [localSearchResultWeight, setLocalSearchResultWeight] = useState(1);
|
const [localSearchResultWeight, setLocalSearchResultWeight] = useState(1);
|
||||||
|
|
||||||
@@ -296,6 +302,25 @@ const Advanced = () => {
|
|||||||
</option>
|
</option>
|
||||||
</select>
|
</select>
|
||||||
</SettingsItem>
|
</SettingsItem>
|
||||||
|
|
||||||
|
<SettingsItem
|
||||||
|
icon={PanelTopClose}
|
||||||
|
title={t(
|
||||||
|
"settings.advanced.other.compactModeAutoCollapseDelay.title"
|
||||||
|
)}
|
||||||
|
description={t(
|
||||||
|
"settings.advanced.other.compactModeAutoCollapseDelay.description"
|
||||||
|
)}
|
||||||
|
>
|
||||||
|
<SettingsInput
|
||||||
|
type="number"
|
||||||
|
min={0}
|
||||||
|
value={compactModeAutoCollapseDelay}
|
||||||
|
onChange={(value) => {
|
||||||
|
setCompactModeAutoCollapseDelay(!value ? 0 : Number(value));
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</SettingsItem>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -159,8 +159,6 @@ export function useSearch() {
|
|||||||
|
|
||||||
const performSearch = useCallback(
|
const performSearch = useCallback(
|
||||||
async (searchInput: string) => {
|
async (searchInput: string) => {
|
||||||
console.log(123);
|
|
||||||
|
|
||||||
if (!searchInput) {
|
if (!searchInput) {
|
||||||
setSearchState((prev) => ({ ...prev, suggests: [] }));
|
setSearchState((prev) => ({ ...prev, suggests: [] }));
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -118,7 +118,7 @@ export const useSyncStore = () => {
|
|||||||
const setEndpoint = useAppStore((state) => state.setEndpoint);
|
const setEndpoint = useAppStore((state) => state.setEndpoint);
|
||||||
const setLanguage = useAppStore((state) => state.setLanguage);
|
const setLanguage = useAppStore((state) => state.setLanguage);
|
||||||
const { setWindowMode } = useAppearanceStore();
|
const { setWindowMode } = useAppearanceStore();
|
||||||
const { setSearchDelay } = useConnectStore();
|
const { setSearchDelay, setCompactModeAutoCollapseDelay } = useConnectStore();
|
||||||
|
|
||||||
const setServerListSilently = useConnectStore(
|
const setServerListSilently = useConnectStore(
|
||||||
(state) => state.setServerListSilently
|
(state) => state.setServerListSilently
|
||||||
@@ -191,6 +191,7 @@ export const useSyncStore = () => {
|
|||||||
querySourceTimeout,
|
querySourceTimeout,
|
||||||
searchDelay,
|
searchDelay,
|
||||||
allowSelfSignature,
|
allowSelfSignature,
|
||||||
|
compactModeAutoCollapseDelay,
|
||||||
} = payload;
|
} = payload;
|
||||||
if (isNumber(connectionTimeout)) {
|
if (isNumber(connectionTimeout)) {
|
||||||
setConnectionTimeout(connectionTimeout);
|
setConnectionTimeout(connectionTimeout);
|
||||||
@@ -200,6 +201,7 @@ export const useSyncStore = () => {
|
|||||||
}
|
}
|
||||||
setSearchDelay(searchDelay);
|
setSearchDelay(searchDelay);
|
||||||
setAllowSelfSignature(allowSelfSignature);
|
setAllowSelfSignature(allowSelfSignature);
|
||||||
|
setCompactModeAutoCollapseDelay(compactModeAutoCollapseDelay);
|
||||||
}),
|
}),
|
||||||
|
|
||||||
platformAdapter.listenEvent("change-appearance-store", ({ payload }) => {
|
platformAdapter.listenEvent("change-appearance-store", ({ payload }) => {
|
||||||
|
|||||||
@@ -208,6 +208,10 @@
|
|||||||
"medium": "Medium",
|
"medium": "Medium",
|
||||||
"low": "Low"
|
"low": "Low"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"compactModeAutoCollapseDelay": {
|
||||||
|
"title": "Compact Mode Auto-Collapse Delay",
|
||||||
|
"description": "Adds a delay before collapsing in Compact Mode to avoid sudden size changes when typing or clearing input. Default: 10s."
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -208,6 +208,10 @@
|
|||||||
"medium": "中",
|
"medium": "中",
|
||||||
"low": "低"
|
"low": "低"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"compactModeAutoCollapseDelay": {
|
||||||
|
"title": "紧凑模式自动收起延迟",
|
||||||
|
"description": "为紧凑模式的自动收起添加延迟,避免输入或清空内容时窗口突然缩小。默认: 10s。"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -40,6 +40,10 @@ export type IConnectStore = {
|
|||||||
setAllowSelfSignature: (allowSelfSignature: boolean) => void;
|
setAllowSelfSignature: (allowSelfSignature: boolean) => void;
|
||||||
searchDelay: number;
|
searchDelay: number;
|
||||||
setSearchDelay: (searchDelay: number) => void;
|
setSearchDelay: (searchDelay: number) => void;
|
||||||
|
compactModeAutoCollapseDelay: number;
|
||||||
|
setCompactModeAutoCollapseDelay: (
|
||||||
|
compactModeAutoCollapseDelay: number
|
||||||
|
) => void;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const useConnectStore = create<IConnectStore>()(
|
export const useConnectStore = create<IConnectStore>()(
|
||||||
@@ -149,6 +153,10 @@ export const useConnectStore = create<IConnectStore>()(
|
|||||||
setSearchDelay(searchDelay) {
|
setSearchDelay(searchDelay) {
|
||||||
return set(() => ({ searchDelay }));
|
return set(() => ({ searchDelay }));
|
||||||
},
|
},
|
||||||
|
compactModeAutoCollapseDelay: 10,
|
||||||
|
setCompactModeAutoCollapseDelay(compactModeAutoCollapseDelay) {
|
||||||
|
return set(() => ({ compactModeAutoCollapseDelay }));
|
||||||
|
},
|
||||||
}),
|
}),
|
||||||
{
|
{
|
||||||
name: "connect-store",
|
name: "connect-store",
|
||||||
|
|||||||
Reference in New Issue
Block a user