Skip to content

Commit

Permalink
✨ feat(frontend): add collapsed and update version
Browse files Browse the repository at this point in the history
  • Loading branch information
CakeAL committed Nov 18, 2024
1 parent eb2b1d6 commit 2b58175
Show file tree
Hide file tree
Showing 11 changed files with 200 additions and 139 deletions.
1 change: 1 addition & 0 deletions components.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ declare module 'vue' {
NMessageProvider: typeof import('naive-ui')['NMessageProvider']
NModal: typeof import('naive-ui')['NModal']
NModalProvider: typeof import('naive-ui')['NModalProvider']
NP: typeof import('naive-ui')['NP']
NPopover: typeof import('naive-ui')['NPopover']
NProgress: typeof import('naive-ui')['NProgress']
NResult: typeof import('naive-ui')['NResult']
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "ustb-wifi-tools",
"private": true,
"version": "0.8.9",
"version": "0.9.0",
"type": "module",
"scripts": {
"dev": "vite",
Expand Down
2 changes: 1 addition & 1 deletion src-tauri/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "ustb-wifi-tools"
version = "0.8.9"
version = "0.9.0"
description = "A Tauri App that can be used to get information of the USTB Wifi"
authors = ["CakeAL"]
edition = "2021"
Expand Down
6 changes: 6 additions & 0 deletions src-tauri/src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -624,3 +624,9 @@ async fn update(

Ok(())
}

#[tauri::command(async)]
pub fn collapse(app_state: tauri::State<'_, AppState>, app: tauri::AppHandle, value: bool) {
app_state.setting.write().unwrap().set_collapsed(value);
let _ = app_state.setting.write().unwrap().write_setting(&app);
}
3 changes: 2 additions & 1 deletion src-tauri/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ pub fn run() {
reset_background_image,
set_background_transparence,
set_background_blur,
set_mac_custom_name
set_mac_custom_name,
collapse
])
.setup(|app| {
#[cfg(not(any(target_os = "android", target_os = "linux")))]
Expand Down
5 changes: 5 additions & 0 deletions src-tauri/src/setting.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ pub struct Setting {
pub background_image_path: Option<String>,
pub background_transparence: Option<u32>,
pub background_blur: Option<u32>,
pub collapsed: Option<bool>,
}

impl Setting {
Expand Down Expand Up @@ -103,6 +104,10 @@ impl Setting {
})
.or_insert(name.to_string());
}

pub fn set_collapsed(&mut self, collapsed: bool) {
self.collapsed = Some(collapsed);
}
}

fn get_config_path(app: &tauri::AppHandle) -> Result<PathBuf> {
Expand Down
2 changes: 1 addition & 1 deletion src-tauri/tauri.conf.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"productName": "ustb-wifi-tools",
"mainBinaryName": "ustb-wifi-tools",
"version": "0.8.9",
"version": "0.9.0",
"identifier": "ustb.wifi.tools",
"build": {
"beforeDevCommand": "pnpm dev",
Expand Down
18 changes: 15 additions & 3 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,22 @@ const apply_background = async () => {
// download
onMounted(() => {
check_update(false);
load_collapse();
});
// sider
const collapsed = ref(false);
const collapsed = ref(true);
const load_collapse = async () => {
let res = await invoke("load_setting") as string;
if (res.length > 0) {
let settings = JSON.parse(res);
collapsed.value = settings.collapsed;
}
};
const collapse = async (value: boolean) => {
collapsed.value = value;
await invoke("collapse", {value});
}
</script>

<template>
Expand All @@ -134,8 +146,8 @@ const collapsed = ref(false);
:width="200"
:collapsed="collapsed"
show-trigger
@collapse="collapsed = true"
@expand="collapsed = false"
@collapse="collapse(true)"
@expand="collapse(false)"
>
<Menu :collapsed="collapsed"></Menu>
</n-layout-sider>
Expand Down
11 changes: 6 additions & 5 deletions src/pages/About.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ const show = ref(false);
const show1 = ref(false);
</script>

<template> <n-scrollbar style="max-height: 100vh">
<div class="container">

<template>
<n-scrollbar style="max-height: 100vh">
<div class="container">
<n-h2 prefix="bar" type="success" style="margin-top: 15px">
<n-text type="success"> 关于作者以及 Tips </n-text>
</n-h2>
Expand Down Expand Up @@ -123,10 +123,11 @@ const show1 = ref(false);
<p>4. 通过 pt 站下载大型软件(比如 Photoshop 等)</p>
<p>5. 自建/使用 ipv6 代理服务器</p>
<br />
<p>当前 version = "0.8.9"</p>
<p>当前 version = "0.9.0"</p>
</n-space>
</n-card>
</div></n-scrollbar>
</div></n-scrollbar
>
</template>

<style scoped>
Expand Down
Loading

0 comments on commit 2b58175

Please sign in to comment.