mirror of
https://github.com/lencx/ChatGPT.git
synced 2024-10-01 01:06:13 -04:00
feat: set window size (#405)
This commit is contained in:
parent
5ec9bb5656
commit
5426a711e9
@ -62,7 +62,7 @@ pub fn init(app: &mut App) -> std::result::Result<(), Box<dyn std::error::Error>
|
|||||||
.title("ChatGPT")
|
.title("ChatGPT")
|
||||||
.resizable(true)
|
.resizable(true)
|
||||||
.fullscreen(false)
|
.fullscreen(false)
|
||||||
.inner_size(800.0, 600.0)
|
.inner_size(app_conf2.main_width, app_conf2.main_height)
|
||||||
.theme(Some(theme))
|
.theme(Some(theme))
|
||||||
.always_on_top(app_conf2.stay_on_top)
|
.always_on_top(app_conf2.stay_on_top)
|
||||||
.initialization_script(&utils::user_script())
|
.initialization_script(&utils::user_script())
|
||||||
|
@ -18,7 +18,7 @@ pub fn tray_window(handle: &tauri::AppHandle) {
|
|||||||
.title("ChatGPT")
|
.title("ChatGPT")
|
||||||
.resizable(false)
|
.resizable(false)
|
||||||
.fullscreen(false)
|
.fullscreen(false)
|
||||||
.inner_size(360.0, 540.0)
|
.inner_size(app_conf.tray_width, app_conf.tray_height)
|
||||||
.decorations(false)
|
.decorations(false)
|
||||||
.always_on_top(true)
|
.always_on_top(true)
|
||||||
.theme(Some(theme))
|
.theme(Some(theme))
|
||||||
|
@ -34,20 +34,29 @@ pub_struct!(AppConf {
|
|||||||
// macOS and Windows: light / dark / system
|
// macOS and Windows: light / dark / system
|
||||||
theme: String,
|
theme: String,
|
||||||
// auto update policy: prompt / silent / disable
|
// auto update policy: prompt / silent / disable
|
||||||
isinit: bool,
|
|
||||||
main_close: bool,
|
|
||||||
auto_update: String,
|
auto_update: String,
|
||||||
tray: bool,
|
|
||||||
popup_search: bool,
|
|
||||||
stay_on_top: bool,
|
stay_on_top: bool,
|
||||||
main_dashboard: bool,
|
save_window_state: bool,
|
||||||
tray_dashboard: bool,
|
|
||||||
main_origin: String,
|
|
||||||
tray_origin: String,
|
|
||||||
default_origin: String,
|
|
||||||
ua_window: String,
|
|
||||||
ua_tray: String,
|
|
||||||
global_shortcut: Option<String>,
|
global_shortcut: Option<String>,
|
||||||
|
default_origin: String,
|
||||||
|
|
||||||
|
// Main Window
|
||||||
|
isinit: bool,
|
||||||
|
popup_search: bool,
|
||||||
|
main_close: bool,
|
||||||
|
main_dashboard: bool,
|
||||||
|
main_origin: String,
|
||||||
|
ua_window: String,
|
||||||
|
main_width: f64,
|
||||||
|
main_height: f64,
|
||||||
|
|
||||||
|
// Tray Window
|
||||||
|
tray_width: f64,
|
||||||
|
tray_height: f64,
|
||||||
|
tray: bool,
|
||||||
|
tray_dashboard: bool,
|
||||||
|
tray_origin: String,
|
||||||
|
ua_tray: String,
|
||||||
});
|
});
|
||||||
|
|
||||||
impl AppConf {
|
impl AppConf {
|
||||||
@ -56,6 +65,7 @@ impl AppConf {
|
|||||||
Self {
|
Self {
|
||||||
titlebar: !cfg!(target_os = "macos"),
|
titlebar: !cfg!(target_os = "macos"),
|
||||||
hide_dock_icon: false,
|
hide_dock_icon: false,
|
||||||
|
save_window_state: false,
|
||||||
theme: "light".into(),
|
theme: "light".into(),
|
||||||
auto_update: "prompt".into(),
|
auto_update: "prompt".into(),
|
||||||
tray: true,
|
tray: true,
|
||||||
@ -65,6 +75,10 @@ impl AppConf {
|
|||||||
stay_on_top: false,
|
stay_on_top: false,
|
||||||
main_dashboard: false,
|
main_dashboard: false,
|
||||||
tray_dashboard: false,
|
tray_dashboard: false,
|
||||||
|
main_width: 800.0,
|
||||||
|
main_height: 600.0,
|
||||||
|
tray_width: 360.0,
|
||||||
|
tray_height: 540.0,
|
||||||
main_origin: CHATGPT_URL.into(),
|
main_origin: CHATGPT_URL.into(),
|
||||||
tray_origin: CHATGPT_URL.into(),
|
tray_origin: CHATGPT_URL.into(),
|
||||||
default_origin: CHATGPT_URL.into(),
|
default_origin: CHATGPT_URL.into(),
|
||||||
|
@ -52,7 +52,6 @@ async fn main() {
|
|||||||
MacosLauncher::LaunchAgent,
|
MacosLauncher::LaunchAgent,
|
||||||
None,
|
None,
|
||||||
))
|
))
|
||||||
.plugin(tauri_plugin_window_state::Builder::default().build())
|
|
||||||
.invoke_handler(tauri::generate_handler![
|
.invoke_handler(tauri::generate_handler![
|
||||||
cmd::drag_window,
|
cmd::drag_window,
|
||||||
cmd::fullscreen,
|
cmd::fullscreen,
|
||||||
@ -88,6 +87,10 @@ async fn main() {
|
|||||||
builder = builder.system_tray(menu::tray_menu());
|
builder = builder.system_tray(menu::tray_menu());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if app_conf.save_window_state {
|
||||||
|
builder = builder.plugin(tauri_plugin_window_state::Builder::default().build());
|
||||||
|
}
|
||||||
|
|
||||||
builder
|
builder
|
||||||
.on_menu_event(menu::menu_handler)
|
.on_menu_event(menu::menu_handler)
|
||||||
.on_system_tray_event(menu::tray_handler)
|
.on_system_tray_event(menu::tray_handler)
|
||||||
|
4
src/hooks/useTable.tsx
vendored
4
src/hooks/useTable.tsx
vendored
@ -8,8 +8,8 @@ type rowSelectionOptions = {
|
|||||||
key: 'id' | string;
|
key: 'id' | string;
|
||||||
rowType: 'id' | 'row' | 'all';
|
rowType: 'id' | 'row' | 'all';
|
||||||
};
|
};
|
||||||
export function useTableRowSelection(options: Partial<rowSelectionOptions> = {}) {
|
export function useTableRowSelection(options?: Partial<rowSelectionOptions>) {
|
||||||
const { key = 'id', rowType = 'id' } = options;
|
const { key = 'id', rowType = 'id' } = options || {};
|
||||||
const [selectedRowKeys, setSelectedRowKeys] = useState<React.Key[]>([]);
|
const [selectedRowKeys, setSelectedRowKeys] = useState<React.Key[]>([]);
|
||||||
const [selectedRowIDs, setSelectedRowIDs] = useState<string[]>([]);
|
const [selectedRowIDs, setSelectedRowIDs] = useState<string[]>([]);
|
||||||
const [selectedRows, setSelectedRows] = useState<Record<string | symbol, any>[]>([]);
|
const [selectedRows, setSelectedRows] = useState<Record<string | symbol, any>[]>([]);
|
||||||
|
3
src/view/settings/General.tsx
vendored
3
src/view/settings/General.tsx
vendored
@ -18,6 +18,9 @@ export default function General() {
|
|||||||
<Form.Item label="Stay On Top" name="stay_on_top" valuePropName="checked">
|
<Form.Item label="Stay On Top" name="stay_on_top" valuePropName="checked">
|
||||||
<Switch />
|
<Switch />
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
|
<Form.Item label="Save Window State" name="save_window_state" valuePropName="checked">
|
||||||
|
<Switch />
|
||||||
|
</Form.Item>
|
||||||
{platformInfo === 'darwin' && (
|
{platformInfo === 'darwin' && (
|
||||||
<Form.Item label="Titlebar" name="titlebar" valuePropName="checked">
|
<Form.Item label="Titlebar" name="titlebar" valuePropName="checked">
|
||||||
<Switch />
|
<Switch />
|
||||||
|
8
src/view/settings/MainWindow.tsx
vendored
8
src/view/settings/MainWindow.tsx
vendored
@ -1,4 +1,4 @@
|
|||||||
import { Form, Switch, Input, Tooltip } from 'antd';
|
import { Form, Switch, Input, InputNumber, Tooltip } from 'antd';
|
||||||
import { QuestionCircleOutlined } from '@ant-design/icons';
|
import { QuestionCircleOutlined } from '@ant-design/icons';
|
||||||
|
|
||||||
import SwitchOrigin from '@/components/SwitchOrigin';
|
import SwitchOrigin from '@/components/SwitchOrigin';
|
||||||
@ -50,6 +50,12 @@ export default function MainWindow() {
|
|||||||
<Form.Item label={<MainCloseLabel />} name="main_close" valuePropName="checked">
|
<Form.Item label={<MainCloseLabel />} name="main_close" valuePropName="checked">
|
||||||
<Switch />
|
<Switch />
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
|
<Form.Item label="Default Width" name="main_width">
|
||||||
|
<InputNumber />
|
||||||
|
</Form.Item>
|
||||||
|
<Form.Item label="Default Height" name="main_height">
|
||||||
|
<InputNumber />
|
||||||
|
</Form.Item>
|
||||||
<SwitchOrigin name="main" />
|
<SwitchOrigin name="main" />
|
||||||
<Form.Item label="User Agent (Main)" name="ua_window">
|
<Form.Item label="User Agent (Main)" name="ua_window">
|
||||||
<Input.TextArea
|
<Input.TextArea
|
||||||
|
8
src/view/settings/TrayWindow.tsx
vendored
8
src/view/settings/TrayWindow.tsx
vendored
@ -1,4 +1,4 @@
|
|||||||
import { Form, Switch, Input, Tooltip } from 'antd';
|
import { Form, Switch, Input, InputNumber, Tooltip } from 'antd';
|
||||||
import { QuestionCircleOutlined } from '@ant-design/icons';
|
import { QuestionCircleOutlined } from '@ant-design/icons';
|
||||||
|
|
||||||
import { DISABLE_AUTO_COMPLETE } from '@/utils';
|
import { DISABLE_AUTO_COMPLETE } from '@/utils';
|
||||||
@ -23,6 +23,12 @@ export default function TrayWindow() {
|
|||||||
<Form.Item label="Enable SystemTray" name="tray" valuePropName="checked">
|
<Form.Item label="Enable SystemTray" name="tray" valuePropName="checked">
|
||||||
<Switch />
|
<Switch />
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
|
<Form.Item label="Default Width" name="tray_width">
|
||||||
|
<InputNumber />
|
||||||
|
</Form.Item>
|
||||||
|
<Form.Item label="Default Height" name="tray_height">
|
||||||
|
<InputNumber />
|
||||||
|
</Form.Item>
|
||||||
<SwitchOrigin name="tray" />
|
<SwitchOrigin name="tray" />
|
||||||
<Form.Item label={<UALabel />} name="ua_tray">
|
<Form.Item label={<UALabel />} name="ua_tray">
|
||||||
<Input.TextArea
|
<Input.TextArea
|
||||||
|
Loading…
Reference in New Issue
Block a user