@@ -66,9 +66,9 @@ import { Sqlite } from "@/lib/sqlite";
6666import { Errored } from "@/components/errored" ;
6767import { Endpoint } from "@/lib/endpoint" ;
6868
69- let window_api : typeof import ( "@tauri-apps/api/window" ) | undefined ;
69+ let tauri_window : typeof import ( "@tauri-apps/api/window" ) | undefined ;
7070if ( import . meta. env . TAURI_ENV_PLATFORM ) {
71- window_api = await import ( "@tauri-apps/api/window" ) ;
71+ tauri_window = await import ( "@tauri-apps/api/window" ) ;
7272}
7373
7474export const AppStore = createStore (
@@ -120,26 +120,28 @@ function Component() {
120120 } , [ ] ) ;
121121 //窗口配置
122122 useEffect ( ( ) => {
123- if ( window_api ) {
123+ if ( tauri_window ) {
124124 const cleanup = ( async ( ) => {
125125 //设置窗口标题
126- await window_api . getCurrentWindow ( ) . setTitle ( document . title ) ;
126+ await tauri_window . getCurrentWindow ( ) . setTitle ( document . title ) ;
127127 //同步标题变化
128128 const title_observer = new MutationObserver (
129129 async ( ) =>
130- await window_api . getCurrentWindow ( ) . setTitle ( document . title ) ,
130+ await tauri_window . getCurrentWindow ( ) . setTitle ( document . title ) ,
131131 ) ;
132132 title_observer . observe ( document . querySelector ( "title" ) ! , {
133133 childList : true ,
134134 characterData : true ,
135135 } ) ;
136136 //设置窗口缩放状态
137- set_is_maximized ( await window_api . getCurrentWindow ( ) . isMaximized ( ) ) ;
137+ set_is_maximized ( await tauri_window . getCurrentWindow ( ) . isMaximized ( ) ) ;
138138 //监控窗口缩放
139- const un_on_resized = await window_api
139+ const un_on_resized = await tauri_window
140140 . getCurrentWindow ( )
141141 . onResized ( async ( ) =>
142- set_is_maximized ( await window_api . getCurrentWindow ( ) . isMaximized ( ) ) ,
142+ set_is_maximized (
143+ await tauri_window . getCurrentWindow ( ) . isMaximized ( ) ,
144+ ) ,
143145 ) ;
144146 return ( ) => {
145147 title_observer . disconnect ( ) ;
@@ -279,13 +281,13 @@ function Component() {
279281 </ AlertDialog >
280282 </ div >
281283 { /* 窗口控制按钮 */ }
282- { window_api && (
284+ { tauri_window && (
283285 < div data-tauri-drag-region className = "flex-1 flex justify-end" >
284286 < Button
285287 variant = { "ghost" }
286288 className = "rounded-none cursor-pointer"
287289 onClick = { async ( ) =>
288- await window_api . getCurrentWindow ( ) . minimize ( )
290+ await tauri_window . getCurrentWindow ( ) . minimize ( )
289291 }
290292 >
291293 < Minimize2 />
@@ -294,7 +296,7 @@ function Component() {
294296 variant = { "ghost" }
295297 className = "rounded-none cursor-pointer"
296298 onClick = { async ( ) =>
297- await window_api . getCurrentWindow ( ) . toggleMaximize ( )
299+ await tauri_window . getCurrentWindow ( ) . toggleMaximize ( )
298300 }
299301 >
300302 { ! is_maximized ? < Maximize /> : < Minimize /> }
@@ -303,7 +305,7 @@ function Component() {
303305 variant = { "ghost" }
304306 className = "rounded-none cursor-pointer hover:bg-red-600 hover:text-white active:bg-red-500"
305307 onClick = { async ( ) =>
306- await window_api . getCurrentWindow ( ) . close ( )
308+ await tauri_window . getCurrentWindow ( ) . close ( )
307309 }
308310 >
309311 < X />
0 commit comments