mirror of
https://github.com/readest/readest
synced 2026-04-21 13:37:44 +00:00
feat(windows): use overlay scrollbar (#3868)
* feat(windows): use overlay scrollbar * fix format
This commit is contained in:
parent
73d30c103f
commit
7d852518a3
3 changed files with 19 additions and 5 deletions
|
|
@ -28,6 +28,8 @@ mod discord_rpc;
|
|||
#[cfg(target_os = "macos")]
|
||||
mod macos;
|
||||
mod transfer_file;
|
||||
#[cfg(target_os = "windows")]
|
||||
use tauri::webview::ScrollBarStyle;
|
||||
use tauri::{command, Emitter, WebviewUrl, WebviewWindowBuilder, Window};
|
||||
#[cfg(target_os = "android")]
|
||||
use tauri_plugin_native_bridge::register_select_directory_callback;
|
||||
|
|
@ -394,7 +396,9 @@ pub fn run() {
|
|||
|
||||
#[cfg(target_os = "windows")]
|
||||
{
|
||||
builder = builder.transparent(false);
|
||||
builder = builder
|
||||
.transparent(false)
|
||||
.scroll_bar_style(ScrollBarStyle::FluentOverlay);
|
||||
}
|
||||
#[cfg(target_os = "linux")]
|
||||
{
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ import { check } from '@tauri-apps/plugin-updater';
|
|||
import { type as osType } from '@tauri-apps/plugin-os';
|
||||
import { fetch } from '@tauri-apps/plugin-http';
|
||||
import { WebviewWindow } from '@tauri-apps/api/webviewWindow';
|
||||
import { ScrollBarStyle } from '@tauri-apps/api/window';
|
||||
import { TranslationFunc } from '@/hooks/useTranslation';
|
||||
import { setUpdaterWindowVisible } from '@/components/UpdaterWindow';
|
||||
import { isTauriAppPlatform } from '@/services/environment';
|
||||
|
|
@ -15,7 +16,7 @@ import {
|
|||
|
||||
const LAST_CHECK_KEY = 'lastAppUpdateCheck';
|
||||
|
||||
const showUpdateWindow = (latestVersion: string) => {
|
||||
const showUpdateWindow = (latestVersion: string, scrollBarStyle: ScrollBarStyle) => {
|
||||
const win = new WebviewWindow('updater', {
|
||||
url: `/updater?latestVersion=${latestVersion}`,
|
||||
title: 'Software Update',
|
||||
|
|
@ -23,6 +24,7 @@ const showUpdateWindow = (latestVersion: string) => {
|
|||
height: 406,
|
||||
center: true,
|
||||
resizable: true,
|
||||
scrollBarStyle,
|
||||
});
|
||||
win.once('tauri://created', () => {
|
||||
console.log('new window created');
|
||||
|
|
@ -47,7 +49,11 @@ export const checkForAppUpdates = async (
|
|||
if (['macos', 'windows', 'linux'].includes(OS_TYPE)) {
|
||||
const update = await check();
|
||||
if (update) {
|
||||
showUpdateWindow(update.version);
|
||||
// Enum ScrollBarStyle is exported as type by tauri, so it cannot be used directly.
|
||||
const scrollBarStyle = (OS_TYPE === 'windows'
|
||||
? 'fluentOverlay'
|
||||
: 'default') as unknown as ScrollBarStyle;
|
||||
showUpdateWindow(update.version, scrollBarStyle);
|
||||
}
|
||||
return !!update;
|
||||
} else if (OS_TYPE === 'android') {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import { useRouter, redirect } from 'next/navigation';
|
||||
import { getCurrentWindow } from '@tauri-apps/api/window';
|
||||
import { redirect, useRouter } from 'next/navigation';
|
||||
import { getCurrentWindow, ScrollBarStyle } from '@tauri-apps/api/window';
|
||||
import { WebviewWindow } from '@tauri-apps/api/webviewWindow';
|
||||
import { isPWA, isWebAppPlatform } from '@/services/environment';
|
||||
import { BOOK_IDS_SEPARATOR } from '@/services/constants';
|
||||
|
|
@ -21,6 +21,10 @@ const createReaderWindow = (appService: AppService, url: string) => {
|
|||
transparent: !appService.isMacOSApp,
|
||||
shadow: appService.isMacOSApp ? undefined : true,
|
||||
titleBarStyle: appService.isMacOSApp ? 'overlay' : undefined,
|
||||
// Enum ScrollBarStyle is exported as type by tauri, so it cannot be used directly.
|
||||
scrollBarStyle: (appService.osPlatform === 'windows'
|
||||
? 'fluentOverlay'
|
||||
: 'default') as unknown as ScrollBarStyle,
|
||||
});
|
||||
win.once('tauri://created', () => {
|
||||
console.log('new window created');
|
||||
|
|
|
|||
Loading…
Reference in a new issue