Skip to content

Commit

Permalink
fix: several bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
Ghomist committed Feb 23, 2025
1 parent ee04371 commit 451420f
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 14 deletions.
16 changes: 15 additions & 1 deletion src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@ tauri-build = { version = "2", features = [] }

[dependencies]
encoding = "0.2.33"
tauri = { version = "2", features = [ "protocol-asset", "tray-icon", "image-png"] }
tauri = { version = "2", features = [
"protocol-asset",
"image-png",
"devtools",
] }
serde = { version = "1", features = ["derive"] }
serde_json = "1"
tauri-plugin-shell = "2"
Expand All @@ -31,3 +35,13 @@ zip = "2.2.2"
tauri-plugin-positioner = "2"
tauri-plugin-single-instance = "2"
tauri-plugin-updater = "2"

[profile.dev]
incremental = true

[profile.release]
codegen-units = 1 # Enable LLVM
lto = true
opt-level = 2
panic = "abort"
strip = true
12 changes: 9 additions & 3 deletions src-tauri/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,19 @@ pub fn log(msg: String) {
}

#[tauri::command]
pub async fn hide_window<R: Runtime>(window: tauri::Window<R>) -> Result<(), String> {
pub fn hide_window<R: Runtime>(window: tauri::Window<R>) -> Result<(), String> {
window.hide().map_err(|e| e.to_string())?;
Ok(())
}

#[tauri::command]
pub async fn show_window<R: Runtime>(window: tauri::Window<R>) -> Result<(), String> {
pub fn show_window<R: Runtime>(window: tauri::Window<R>) -> Result<(), String> {
window.show().map_err(|e| e.to_string())?;
Ok(())
}

#[tauri::command]
pub async fn toggle_window<R: Runtime>(window: tauri::Window<R>) -> Result<(), String> {
pub fn toggle_window<R: Runtime>(window: tauri::Window<R>) -> Result<(), String> {
let visible = window.is_visible().map_err(|e| e.to_string())?;
if visible {
window.hide().map_err(|e| e.to_string())?;
Expand All @@ -27,3 +27,9 @@ pub async fn toggle_window<R: Runtime>(window: tauri::Window<R>) -> Result<(), S
}
Ok(())
}

#[tauri::command]
pub fn open_devtools<R: Runtime>(window: tauri::WebviewWindow<R>) -> Result<(), String> {
window.open_devtools();
Ok(())
}
1 change: 1 addition & 0 deletions src-tauri/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ pub fn run() {
app::hide_window,
app::show_window,
app::toggle_window,
app::open_devtools,
fs::exists,
fs::size,
fs::list,
Expand Down
4 changes: 2 additions & 2 deletions src-tauri/tauri.conf.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"$schema": "https://schema.tauri.app/config/2",
"productName": "rockoon",
"version": "1.5.2",
"version": "1.5.3",
"identifier": "com.ghomist.rockoon",
"build": {
"beforeDevCommand": "pnpm dev",
"devUrl": "http://localhost:1420",
"devUrl": "http://127.0.0.1:1420",
"beforeBuildCommand": "pnpm build",
"frontendDist": "../dist"
},
Expand Down
3 changes: 2 additions & 1 deletion src/api/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@ export default {
log: (msg: string) => invoke("log", { msg }),
hideWindow: () => invoke("hide_window"),
showWindow: () => invoke("show_window"),
toggleWindow: () => invoke("toggle_window")
toggleWindow: () => invoke("toggle_window"),
openDevtools: () => invoke("open_devtools")
};
2 changes: 1 addition & 1 deletion src/assets/theme/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
--color-text: #0f0f0f;
--color-text-light: var(--color-ignore);
--color-text-prime: var(--color-prime);
--color-text-invert: white;
--color-text-invert: var(--color-prime-invert);

--box-background: rgba(255, 255, 255, 0.85);
--box-background-no-trans: rgb(255, 255, 255);
Expand Down
11 changes: 6 additions & 5 deletions src/views/settings/SettingsPage.vue
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<script setup lang="ts">
import app from "@/api/app";
import BasicButton from "@/components/BasicButton.vue";
import BasicCollapse from "@/components/BasicCollapse.vue";
import BasicConfig from "@/components/BasicConfig.vue";
Expand All @@ -9,12 +10,12 @@ import SwitchButton from "@/components/SwitchButton.vue";
import { usePrefStore } from "@/stores/pref";
import { openDialog, sendMessage } from "@/utils/message";
import storage from "@/utils/storage";
import { checkUpdate } from "@/utils/updater";
import { getTauriVersion, getVersion } from "@tauri-apps/api/app";
import { open } from "@tauri-apps/plugin-shell";
import { convertFileSrc } from "@tauri-apps/api/core";
import { open as browseFile } from "@tauri-apps/plugin-dialog";
import { open } from "@tauri-apps/plugin-shell";
import { onMounted, ref } from "vue";
import { convertFileSrc } from "@tauri-apps/api/core";
import { checkUpdate } from "@/utils/updater";
const pref = usePrefStore();
Expand Down Expand Up @@ -105,8 +106,8 @@ const onSendMessage = () => {
sendMessage(debugContent.value);
};
const openDevtools = () => {
// TODO
const openDevtools = async () => {
await app.openDevtools();
};
const clearStorage = () => {
Expand Down
2 changes: 1 addition & 1 deletion vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";
import path from "path";

const host = process.env.TAURI_DEV_HOST;
const host = process.env.TAURI_DEV_HOST ?? "127.0.0.1";

// https://vitejs.dev/config/
export default defineConfig(async () => ({
Expand Down

0 comments on commit 451420f

Please sign in to comment.