Merge pull request #1241 from torhve/tauri

Update tauri to latest version, and make some improvements when running under tauri
This commit is contained in:
Tor Hveem 2023-02-16 19:14:33 +01:00 committed by GitHub
commit b4585bdd69
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 982 additions and 1506 deletions

View File

@ -1,4 +1,3 @@
# Generated by Cargo
# will have compiled files and executables
/target/
WixTools

2384
src-tauri/Cargo.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -1,23 +1,24 @@
[package]
name = "glowing-bear"
version = "0.1.0"
version = "0.10.0" #sync to ../package.json
description = "A web client for WeeChat"
authors = ["glowing-bear-contributors"]
license = "GPL-3.0"
repository = "https://github.com/glowing-bear/glowing-bear"
default-run = "app"
default-run = "glowing-bear"
edition = "2021"
rust-version = "1.57"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[build-dependencies]
tauri-build = { version = "1.0.0-rc.3", features = [] }
tauri-build = { version = "1.2.1", features = [] }
[dependencies]
serde_json = "1.0"
serde = { version = "1.0", features = ["derive"] }
tauri = { version = "1.0.0-rc.3", features = ["api-all"] }
tauri = { version = "1.2.4", features = ["api-all"] }
tauri-plugin-window-state = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "dev" }
[features]
# by default Tauri runs in production mode

View File

@ -5,6 +5,7 @@
fn main() {
tauri::Builder::default()
.plugin(tauri_plugin_window_state::Builder::default().build()) // register plugin to remember window state
.run(tauri::generate_context!())
.expect("error while running tauri application");
}

View File

@ -1,68 +1,65 @@
{
"build": {
"beforeBuildCommand": "npm run build",
"beforeDevCommand": "npm run start",
"devPath": " http://localhost:8080/",
"distDir": "../build",
"withGlobalTauri": true
},
"package": {
"productName": "glowing-bear",
"version": "0.1.0"
},
"build": {
"distDir": "../build",
"devPath": "http://localhost:8000",
"beforeDevCommand": "",
"beforeBuildCommand": ""
"version": "0.10.0"
},
"tauri": {
"allowlist": {
"all": true
},
"bundle": {
"active": true,
"targets": "all",
"identifier": "org.glowing-bear",
"category": "SocialNetworking",
"copyright": "Glowing Bear developers",
"deb": {
"depends": []
},
"externalBin": [],
"icon": [
"../src/assets/img/favicon.png",
"../src/assets/img/glowing_bear_128x128.png",
"../src/assets/img/glowing-bear.png",
"../src/assets/img/glowing-bear.icns"
],
"resources": [],
"externalBin": [],
"copyright": "",
"category": "Chat",
"shortDescription": "",
"longDescription": "",
"deb": {
"depends": [],
"useBootstrapper": false
},
"identifier": "org.glowing-bear",
"longDescription": "Glowing Bear is a web frontend for the WeeChat IRC client",
"macOS": {
"frameworks": [],
"minimumSystemVersion": "",
"useBootstrapper": false,
"entitlements": null,
"exceptionDomain": "",
"signingIdentity": null,
"frameworks": [],
"providerShortName": null,
"entitlements": null
"signingIdentity": null
},
"resources": [],
"shortDescription": "",
"targets": "all",
"windows": {
"certificateThumbprint": null,
"digestAlgorithm": "sha256",
"timestampUrl": ""
}
},
"security": {
"csp": null
},
"updater": {
"active": false
},
"allowlist": {
"all": true
},
"windows": [
{
"title": "Glowing Bear",
"center": true,
"width": 800,
"fullscreen": false,
"height": 600,
"resizable": true,
"fullscreen": false
"title": "Glowing Bear",
"width": 800
}
],
"security": {
"csp": null
}
]
}
}

View File

@ -563,7 +563,9 @@ weechat.directive('inputBar', function() {
// Alt+< -> switch to previous buffer
// https://w3c.github.io/uievents-code/#code-IntlBackslash
if ($event.altKey && (code === 60 || code === 226 || key === "IntlBackslash")) {
// Support both backquote and intlbackslash for this action, since macos is weird
// https://github.com/microsoft/vscode/issues/65082
if ($event.altKey && (code === 60 || code === 226 || key === "IntlBackslash" || key === "Backquote")) {
var previousBuffer = models.getPreviousBuffer();
if (previousBuffer) {
models.setActiveBuffer(previousBuffer.id);

View File

@ -25,7 +25,7 @@ weechat.factory('notifications', ['$rootScope', '$log', 'models', 'settings', 'u
}
// Check for serviceWorker support, and also disable serviceWorker if we're running in electron process, since that's just problematic and not necessary, since gb then already is in a separate process
if ('serviceWorker' in navigator && window.is_electron !== 1) {
if ('serviceWorker' in navigator && window.is_electron !== 1 && !utils.isTauri()) {
$log.info('Service Worker is supported');
navigator.serviceWorker.register('serviceworker.js').then(function(reg) {
$log.info('Service Worker install:', reg);
@ -52,6 +52,7 @@ weechat.factory('notifications', ['$rootScope', '$log', 'models', 'settings', 'u
};
var showNotification = function(buffer, title, body) {
$log.info('Showing notification', title);
if (serviceworker) {
navigator.serviceWorker.ready.then(function(registration) {
registration.showNotification(title, {
@ -87,13 +88,14 @@ weechat.factory('notifications', ['$rootScope', '$log', 'models', 'settings', 'u
body: body,
icon: 'assets/img/favicon.png'
});
$log.info('Using Web API Notification', notification);
// Save notification, so we can close all outstanding ones when disconnecting
notification.id = notifications.length;
notifications.push(notification);
// Cancel notification automatically
var timeout = 15*1000;
var timeout = 15*1000; // 15 seconds
notification.onshow = function() {
setTimeout(function() {
notification.close();
@ -101,7 +103,8 @@ weechat.factory('notifications', ['$rootScope', '$log', 'models', 'settings', 'u
};
// Click takes the user to the buffer
notification.onclick = function() {
notification.onclick = function(event) {
event.preventDefault();
models.setActiveBuffer(buffer.id);
window.focus();
notification.close();
@ -161,7 +164,13 @@ weechat.factory('notifications', ['$rootScope', '$log', 'models', 'settings', 'u
var activeBuffer = models.getActiveBuffer();
if (activeBuffer) {
$rootScope.pageTitle = activeBuffer.shortName + ' | ' + activeBuffer.rtitle;
let title = activeBuffer.shortName + ' | ' + activeBuffer.rtitle;
$rootScope.pageTitle = title;
// If running in Tauri, use platform code to update its window title
if (utils.isTauri()) {
__TAURI__.window.appWindow.setTitle(title);
}
}
};

View File

@ -28,6 +28,10 @@ weechat.factory('utils', function() {
return window.cordova !== undefined;
};
const _isTauri = window.__TAURI__ !== undefined;
var isTauri = function() {
return _isTauri;
}
// Inject a javascript (used by KaTeX)
var inject_script = function(script_url) {
@ -87,6 +91,7 @@ weechat.factory('utils', function() {
getClassStyle: getClassStyle,
isMobileUi: isMobileUi,
isCordova: isCordova,
isTauri: isTauri,
inject_script: inject_script,
inject_css: inject_css,
hexStringToByte: hexStringToByte,