Skip to content

Commit

Permalink
feat: add window shadows to windows system, close #14 (#59)
Browse files Browse the repository at this point in the history
  • Loading branch information
ayangweb committed Mar 22, 2023
1 parent 52d1096 commit 254f301
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 5 deletions.
15 changes: 14 additions & 1 deletion src-tauri/Cargo.lock

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

3 changes: 2 additions & 1 deletion src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "chat_gpt"
version = "0.0.4"
version = "0.0.5"
description = "ChatGPT-Desktop"
authors = ["orangelckc", "bilibili-ayang"]
license = "MIT"
Expand All @@ -17,6 +17,7 @@ tauri = { version = "1.2", features = ["api-all", "macos-private-api", "system-t
tauri-plugin-autostart = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "dev" }
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
window-shadows = "0.2.1"


[dependencies.tauri-plugin-sql]
Expand Down
7 changes: 7 additions & 0 deletions src-tauri/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
// Prevents additional console window on Windows in release, DO NOT REMOVE!!
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]

use tauri::Manager;
use tauri_plugin_autostart::MacosLauncher;
use window_shadows::set_shadow;

mod tray;

Expand All @@ -10,6 +12,11 @@ fn main() {
.setup(|_app| {
#[cfg(target_os = "macos")]
_app.set_activation_policy(tauri::ActivationPolicy::Accessory);

#[cfg(any(windows, target_os = "macos"))]
let window = _app.get_window("main").unwrap();
set_shadow(&window, true).expect("Unsupported platform!");

Ok(())
})
.system_tray(tray::main_menu())
Expand Down
24 changes: 22 additions & 2 deletions src/App.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<script setup lang="ts">
import { appWindow } from '@tauri-apps/api/window'
import { platform } from '@tauri-apps/api/os'
import { initSQL } from '@/sqls'
import { useSettingsStore } from '@/stores'
import { useObserverLink } from '@/hooks'
Expand All @@ -8,6 +9,8 @@ const { isFix, windowFocused } = storeToRefs(useSettingsStore())
const isLoading = ref(true)
const windowClass = ref('')
onMounted(async () => {
await initSQL()
Expand All @@ -31,12 +34,29 @@ onMounted(async () => {
})
}
})
watch(
windowFocused,
async (newValue) => {
const platformName = await platform()
if (platformName !== 'darwin') {
windowClass.value = 'bordered'
} else {
let className = 'rounded-xl '
className += newValue ? 'bordered' : 'bordered-transparent'
windowClass.value = className
}
},
{ immediate: true }
)
</script>

<template>
<div
class="frosted flex h-screen flex-col overflow-hidden rounded-xl p-2"
:class="[windowFocused ? 'bordered' : 'bordered-transparent']"
class="frosted flex h-screen flex-col overflow-hidden p-2"
:class="[windowClass]"
>
<div
class="bg-gray/60 z-999 transition-300 fixed top-2 left-1/2 h-3 w-80 -translate-x-1/2 cursor-move rounded-md opacity-0 hover:opacity-100"
Expand Down
2 changes: 1 addition & 1 deletion src/components/Function/components/ShortcutKey.vue
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ const handleKeyup = (event: KeyboardEvent) => {
@keyup="handleKeyup"
>
<div
class="text-6 flex items-center gap-2 font-bold leading-none text-[var(--color-text-4)]"
class="text-6 flex items-center gap-2 font-sans font-bold leading-none text-[var(--color-text-4)]"
>
<!-- 热键 -->
<span
Expand Down

0 comments on commit 254f301

Please sign in to comment.