-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
✨ 将设置界面独立为一个窗口 #75
base: next
Are you sure you want to change the base?
✨ 将设置界面独立为一个窗口 #75
Conversation
#[command] | ||
pub async fn open_setting_page(handle: AppHandle) { | ||
let setting_page = handle.get_window("settings").unwrap(); | ||
// 居主页面之中 | ||
setting_page.center().unwrap(); | ||
setting_page.show().unwrap(); | ||
setting_page.set_focus().unwrap(); | ||
setting_page | ||
.clone() | ||
.on_window_event(move |event| { | ||
if let WindowEvent::CloseRequested { api, .. } = event { | ||
api.prevent_close(); | ||
setting_page.hide().unwrap(); | ||
} | ||
}); | ||
} | ||
|
||
#[command] | ||
pub async fn close_setting_page(handle: AppHandle) { | ||
let setting_window = handle.get_window("settings").unwrap(); | ||
setting_window.hide().unwrap(); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
关窗口这个不需要rust这边来,前端就有接口关
#[command] | ||
pub async fn open_setting_page(handle: AppHandle) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里面的都是tauri的api返回的Result,可以将接口返回写为 Result<(), tauri::Error> 然后去除内部的unwrap
const setting = reactive<{ | ||
// auto boot setting | ||
autoBoot: boolean, | ||
initAutoBoot: () => void, | ||
setAutoBoot: () => void, | ||
// quit | ||
close: () => void, | ||
checkUpdate: () => void | ||
autoBoot: boolean; | ||
initAutoBoot: () => void; | ||
setAutoBoot: () => void; | ||
// quit | ||
close: () => void; | ||
checkUpdate: () => void; | ||
// notification | ||
notify_mode: { idx: number, tip: string, value: string }, | ||
initNotifyMode: () => void | ||
setNotifyMode: () => void | ||
notify_mode: { idx: number; tip: string; value: string }; | ||
initNotifyMode: () => void; | ||
setNotifyMode: () => void; | ||
//version | ||
currentVersion: string, | ||
getAppVersion: () => void | ||
currentVersion: string; | ||
getAppVersion: () => void; | ||
}>({ | ||
currentVersion: "", | ||
getAppVersion: () => { | ||
app.getVersion().then((version) => { | ||
setting.currentVersion = version | ||
}) | ||
setting.currentVersion = version; | ||
}); | ||
}, | ||
notify_mode: NotifyMode.PopUpAndBeep, | ||
initNotifyMode: () => { | ||
notification.getNotificationMode() | ||
.then((v) => setting.notify_mode = v) | ||
notification.getNotificationMode().then((v) => (setting.notify_mode = v)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
我觉得这边设置可以通过后端来动态处理,而不是现在这样写死
<v-app class="setting"> | ||
|
||
<div > | ||
<v-app-bar title="设置" id="drag" color="#e6a23c" density="compact" data-tauri-drag-region> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
如果无法拖动,要不启用decorator?
已知问题