1
0
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:
lencx 2023-02-16 22:02:12 +08:00
parent 5ec9bb5656
commit 5426a711e9
8 changed files with 50 additions and 18 deletions

View File

@ -62,7 +62,7 @@ pub fn init(app: &mut App) -> std::result::Result<(), Box<dyn std::error::Error>
.title("ChatGPT")
.resizable(true)
.fullscreen(false)
.inner_size(800.0, 600.0)
.inner_size(app_conf2.main_width, app_conf2.main_height)
.theme(Some(theme))
.always_on_top(app_conf2.stay_on_top)
.initialization_script(&utils::user_script())

View File

@ -18,7 +18,7 @@ pub fn tray_window(handle: &tauri::AppHandle) {
.title("ChatGPT")
.resizable(false)
.fullscreen(false)
.inner_size(360.0, 540.0)
.inner_size(app_conf.tray_width, app_conf.tray_height)
.decorations(false)
.always_on_top(true)
.theme(Some(theme))

View File

@ -34,20 +34,29 @@ pub_struct!(AppConf {
// macOS and Windows: light / dark / system
theme: String,
// auto update policy: prompt / silent / disable
isinit: bool,
main_close: bool,
auto_update: String,
tray: bool,
popup_search: bool,
stay_on_top: bool,
main_dashboard: bool,
tray_dashboard: bool,
main_origin: String,
tray_origin: String,
default_origin: String,
ua_window: String,
ua_tray: String,
save_window_state: bool,
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 {
@ -56,6 +65,7 @@ impl AppConf {
Self {
titlebar: !cfg!(target_os = "macos"),
hide_dock_icon: false,
save_window_state: false,
theme: "light".into(),
auto_update: "prompt".into(),
tray: true,
@ -65,6 +75,10 @@ impl AppConf {
stay_on_top: false,
main_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(),
tray_origin: CHATGPT_URL.into(),
default_origin: CHATGPT_URL.into(),

View File

@ -52,7 +52,6 @@ async fn main() {
MacosLauncher::LaunchAgent,
None,
))
.plugin(tauri_plugin_window_state::Builder::default().build())
.invoke_handler(tauri::generate_handler![
cmd::drag_window,
cmd::fullscreen,
@ -88,6 +87,10 @@ async fn main() {
builder = builder.system_tray(menu::tray_menu());
}
if app_conf.save_window_state {
builder = builder.plugin(tauri_plugin_window_state::Builder::default().build());
}
builder
.on_menu_event(menu::menu_handler)
.on_system_tray_event(menu::tray_handler)

View File

@ -8,8 +8,8 @@ type rowSelectionOptions = {
key: 'id' | string;
rowType: 'id' | 'row' | 'all';
};
export function useTableRowSelection(options: Partial<rowSelectionOptions> = {}) {
const { key = 'id', rowType = 'id' } = options;
export function useTableRowSelection(options?: Partial<rowSelectionOptions>) {
const { key = 'id', rowType = 'id' } = options || {};
const [selectedRowKeys, setSelectedRowKeys] = useState<React.Key[]>([]);
const [selectedRowIDs, setSelectedRowIDs] = useState<string[]>([]);
const [selectedRows, setSelectedRows] = useState<Record<string | symbol, any>[]>([]);

View File

@ -18,6 +18,9 @@ export default function General() {
<Form.Item label="Stay On Top" name="stay_on_top" valuePropName="checked">
<Switch />
</Form.Item>
<Form.Item label="Save Window State" name="save_window_state" valuePropName="checked">
<Switch />
</Form.Item>
{platformInfo === 'darwin' && (
<Form.Item label="Titlebar" name="titlebar" valuePropName="checked">
<Switch />

View File

@ -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 SwitchOrigin from '@/components/SwitchOrigin';
@ -50,6 +50,12 @@ export default function MainWindow() {
<Form.Item label={<MainCloseLabel />} name="main_close" valuePropName="checked">
<Switch />
</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" />
<Form.Item label="User Agent (Main)" name="ua_window">
<Input.TextArea

View File

@ -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 { DISABLE_AUTO_COMPLETE } from '@/utils';
@ -23,6 +23,12 @@ export default function TrayWindow() {
<Form.Item label="Enable SystemTray" name="tray" valuePropName="checked">
<Switch />
</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" />
<Form.Item label={<UALabel />} name="ua_tray">
<Input.TextArea