Skip to content

Commit 550e1d2

Browse files
authored
fix(settings): create window twice not work (#51)
1 parent 68264fe commit 550e1d2

File tree

4 files changed

+45
-7
lines changed

4 files changed

+45
-7
lines changed

src/main/main.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,9 @@ const initializeApp = async () => {
100100

101101
logger.info('createMainWindow');
102102
const mainWindow = createMainWindow();
103-
const settingsWindow = createSettingsWindow();
103+
const settingsWindow = createSettingsWindow({
104+
showInBackground: true,
105+
});
104106

105107
// Remove this if your app does not use auto updates
106108
// eslint-disable-next-line

src/main/store/types.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@ export type AppState = {
5252

5353
export enum VlmProvider {
5454
// Ollama = 'ollama',
55-
Huggingface = 'huggingface',
55+
Huggingface = 'Hugging Face',
56+
vLLM = 'vLLM',
5657
}
5758

5859
export type LocalStore = {

src/main/window/index.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,11 +78,13 @@ export function createMainWindow() {
7878
export function createSettingsWindow(
7979
config: {
8080
childPath?: string;
81+
showInBackground?: boolean;
8182
} = {
8283
childPath: '',
84+
showInBackground: false,
8385
},
8486
) {
85-
const { childPath = '' } = config;
87+
const { childPath = '', showInBackground = false } = config;
8688
if (settingsWindow) {
8789
settingsWindow.show();
8890
return settingsWindow;
@@ -108,8 +110,8 @@ export function createSettingsWindow(
108110
height,
109111
resizable: false,
110112
movable: true,
111-
alwaysOnTop: false,
112-
showInBackground: true,
113+
alwaysOnTop: true,
114+
showInBackground,
113115
});
114116

115117
settingsWindow.on('closed', () => {

src/renderer/src/pages/settings/index.tsx

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,15 @@ const Settings = () => {
5454
title: 'Settings saved successfully',
5555
position: 'top',
5656
status: 'success',
57-
duration: 2000,
57+
duration: 1500,
5858
isClosable: true,
5959
variant: 'ui-tars-success',
60+
onCloseComplete: () => {
61+
dispatch({
62+
type: 'CLOSE_SETTINGS_WINDOW',
63+
payload: null,
64+
});
65+
},
6066
});
6167
};
6268

@@ -90,7 +96,7 @@ const Settings = () => {
9096
<VStack spacing={8} align="stretch">
9197
{settings ? (
9298
<Formik initialValues={settings} onSubmit={handleSubmit}>
93-
{({ values = {} }) => (
99+
{({ values = {}, setFieldValue }) => (
94100
<Form>
95101
<VStack spacing={4} align="stretch">
96102
<FormControl>
@@ -129,6 +135,33 @@ const Settings = () => {
129135
borderColor: 'gray.400',
130136
boxShadow: 'none',
131137
}}
138+
onChange={(e) => {
139+
const newValue = e.target.value;
140+
setFieldValue('vlmProvider', newValue);
141+
142+
if (!settings.vlmBaseUrl) {
143+
setFieldValue('vlmProvider', newValue);
144+
if (newValue === VlmProvider.vLLM) {
145+
setFieldValue(
146+
'vlmBaseUrl',
147+
'http://localhost:8000/v1',
148+
);
149+
setFieldValue('vlmModelName', 'ui-tars');
150+
} else if (
151+
newValue === VlmProvider.Huggingface
152+
) {
153+
setFieldValue(
154+
'vlmBaseUrl',
155+
'https://<your_service>.us-east-1.aws.endpoints.huggingface.cloud/v1',
156+
);
157+
setFieldValue('vlmApiKey', 'your_api_key');
158+
setFieldValue(
159+
'vlmModelName',
160+
'your_model_name',
161+
);
162+
}
163+
}
164+
}}
132165
>
133166
{Object.values(VlmProvider).map((item) => (
134167
<option key={item} value={item}>

0 commit comments

Comments
 (0)