Skip to content

Commit

Permalink
fix(tauri): minimum width & height are added; exit not working on tauri
Browse files Browse the repository at this point in the history
  • Loading branch information
Muhammed-Rahif committed Dec 1, 2024
1 parent d91c1e8 commit 5cc5847
Show file tree
Hide file tree
Showing 15 changed files with 101 additions and 18 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
"@tauri-apps/api": "^2.0.2",
"@tauri-apps/plugin-dialog": "^2.0.0",
"@tauri-apps/plugin-fs": "^2.0.0",
"@tauri-apps/plugin-process": "^2.0.0",
"@tauri-apps/plugin-shell": "^2.0.1",
"caret-pos": "^2.0.0",
"localforage": "^1.10.0",
Expand Down
10 changes: 10 additions & 0 deletions pnpm-lock.yaml

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

11 changes: 11 additions & 0 deletions src-tauri/Cargo.lock

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

1 change: 1 addition & 0 deletions src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ tauri = { version = "2", features = [] }
tauri-plugin-fs = "2"
tauri-plugin-dialog = "2"
tauri-plugin-shell = "2"
tauri-plugin-process = "2"

[features]
# this feature is used for production builds or when `devPath` points to the filesystem and the built-in dev server is disabled.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
"dialog:allow-save",
"fs:default",
"dialog:default",
"shell:default"
"shell:default",
"process:default"
]
}
2 changes: 1 addition & 1 deletion src-tauri/gen/schemas/acl-manifests.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src-tauri/gen/schemas/capabilities.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"migrated":{"identifier":"migrated","description":"permissions that were migrated from v1","local":true,"windows":["main"],"permissions":["core:default","fs:allow-read-file","fs:allow-write-file","fs:allow-read-dir","fs:allow-copy-file","fs:allow-mkdir","fs:allow-remove","fs:allow-remove","fs:allow-rename","fs:allow-exists","core:window:allow-create","core:window:allow-center","core:window:allow-request-user-attention","core:window:allow-set-resizable","core:window:allow-set-maximizable","core:window:allow-set-minimizable","core:window:allow-set-closable","core:window:allow-set-title","core:window:allow-maximize","core:window:allow-unmaximize","core:window:allow-minimize","core:window:allow-unminimize","core:window:allow-show","core:window:allow-hide","core:window:allow-close","core:window:allow-set-decorations","core:window:allow-set-always-on-top","core:window:allow-set-content-protected","core:window:allow-set-size","core:window:allow-set-min-size","core:window:allow-set-max-size","core:window:allow-set-position","core:window:allow-set-fullscreen","core:window:allow-set-focus","core:window:allow-set-icon","core:window:allow-set-skip-taskbar","core:window:allow-set-cursor-grab","core:window:allow-set-cursor-visible","core:window:allow-set-cursor-icon","core:window:allow-set-cursor-position","core:window:allow-set-ignore-cursor-events","core:window:allow-start-dragging","core:webview:allow-print","dialog:allow-open","dialog:allow-save","fs:default","dialog:default","shell:default"]}}
{"migrated":{"identifier":"migrated","description":"permissions that were migrated from v1","local":true,"windows":["main"],"permissions":["core:default","fs:allow-read-file","fs:allow-write-file","fs:allow-read-dir","fs:allow-copy-file","fs:allow-mkdir","fs:allow-remove","fs:allow-remove","fs:allow-rename","fs:allow-exists","core:window:allow-create","core:window:allow-center","core:window:allow-request-user-attention","core:window:allow-set-resizable","core:window:allow-set-maximizable","core:window:allow-set-minimizable","core:window:allow-set-closable","core:window:allow-set-title","core:window:allow-maximize","core:window:allow-unmaximize","core:window:allow-minimize","core:window:allow-unminimize","core:window:allow-show","core:window:allow-hide","core:window:allow-close","core:window:allow-set-decorations","core:window:allow-set-always-on-top","core:window:allow-set-content-protected","core:window:allow-set-size","core:window:allow-set-min-size","core:window:allow-set-max-size","core:window:allow-set-position","core:window:allow-set-fullscreen","core:window:allow-set-focus","core:window:allow-set-icon","core:window:allow-set-skip-taskbar","core:window:allow-set-cursor-grab","core:window:allow-set-cursor-visible","core:window:allow-set-cursor-icon","core:window:allow-set-cursor-position","core:window:allow-set-ignore-cursor-events","core:window:allow-start-dragging","core:webview:allow-print","dialog:allow-open","dialog:allow-save","fs:default","dialog:default","shell:default","process:default"]}}
25 changes: 25 additions & 0 deletions src-tauri/gen/schemas/desktop-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -4842,6 +4842,31 @@
"type": "string",
"const": "fs:write-files"
},
{
"description": "This permission set configures which\nprocess feeatures are by default exposed.\n\n#### Granted Permissions\n\nThis enables to quit via `allow-exit` and restart via `allow-restart`\nthe application.\n",
"type": "string",
"const": "process:default"
},
{
"description": "Enables the exit command without any pre-configured scope.",
"type": "string",
"const": "process:allow-exit"
},
{
"description": "Enables the restart command without any pre-configured scope.",
"type": "string",
"const": "process:allow-restart"
},
{
"description": "Denies the exit command without any pre-configured scope.",
"type": "string",
"const": "process:deny-exit"
},
{
"description": "Denies the restart command without any pre-configured scope.",
"type": "string",
"const": "process:deny-restart"
},
{
"description": "This permission set configures which\nshell functionality is exposed by default.\n\n#### Granted Permissions\n\nIt allows to use the `open` functionality without any specific\nscope pre-configured. It will allow opening `http(s)://`,\n`tel:` and `mailto:` links.\n",
"type": "string",
Expand Down
25 changes: 25 additions & 0 deletions src-tauri/gen/schemas/linux-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -4842,6 +4842,31 @@
"type": "string",
"const": "fs:write-files"
},
{
"description": "This permission set configures which\nprocess feeatures are by default exposed.\n\n#### Granted Permissions\n\nThis enables to quit via `allow-exit` and restart via `allow-restart`\nthe application.\n",
"type": "string",
"const": "process:default"
},
{
"description": "Enables the exit command without any pre-configured scope.",
"type": "string",
"const": "process:allow-exit"
},
{
"description": "Enables the restart command without any pre-configured scope.",
"type": "string",
"const": "process:allow-restart"
},
{
"description": "Denies the exit command without any pre-configured scope.",
"type": "string",
"const": "process:deny-exit"
},
{
"description": "Denies the restart command without any pre-configured scope.",
"type": "string",
"const": "process:deny-restart"
},
{
"description": "This permission set configures which\nshell functionality is exposed by default.\n\n#### Granted Permissions\n\nIt allows to use the `open` functionality without any specific\nscope pre-configured. It will allow opening `http(s)://`,\n`tel:` and `mailto:` links.\n",
"type": "string",
Expand Down
13 changes: 7 additions & 6 deletions src-tauri/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
#[cfg_attr(mobile, tauri::mobile_entry_point)]
pub fn run() {
tauri::Builder::default()
.plugin(tauri_plugin_shell::init())
.plugin(tauri_plugin_dialog::init())
.plugin(tauri_plugin_fs::init())
.run(tauri::generate_context!())
.expect("error while running tauri application");
tauri::Builder::default()
.plugin(tauri_plugin_shell::init())
.plugin(tauri_plugin_dialog::init())
.plugin(tauri_plugin_fs::init())
.plugin(tauri_plugin_process::init())
.run(tauri::generate_context!())
.expect("error while running tauri application");
}
2 changes: 1 addition & 1 deletion src-tauri/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]

fn main() {
app_lib::run();
app_lib::run();
}
6 changes: 4 additions & 2 deletions src-tauri/tauri.conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,11 @@
{
"fullscreen": false,
"height": 600,
"width": 800,
"minHeight": 450,
"minWidth": 350,
"resizable": true,
"title": "Notpad",
"width": 800
"title": "Notpad"
}
],
"security": {
Expand Down
2 changes: 1 addition & 1 deletion src/lib/components/EditorTabs.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<div transition:slide>
<Tabs.List
class="w-full justify-start gap-1 overflow-x-auto
overflow-y-clip rounded-t-none shadow"
overflow-y-clip rounded-none shadow"
>
{#each $editors as editor}
<Tabs.Trigger value={editor.id} class="h-8 pl-2 pr-0">
Expand Down
2 changes: 1 addition & 1 deletion src/lib/components/MenuBar.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@

<svelte:window bind:innerWidth />

<Menubar.Root class="relative z-10 rounded-sm">
<Menubar.Root class="relative z-10 rounded-none">
<Menubar.Menu>
<Menubar.Trigger>File</Menubar.Trigger>
<Menubar.Content>
Expand Down
14 changes: 10 additions & 4 deletions src/lib/helpers/notpad.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import { EditOptions } from '@/src/lib/helpers/menubar/edit-options';
import { GithubApi } from '@/helpers/github-api';
import { SearchOptions } from '@/src/lib/helpers/menubar/search-options';
import { ViewOptions } from '@/src/lib/helpers/menubar/view-options';
import { exit } from '@tauri-apps/plugin-process';
import { isTauri } from '@/src/lib';

export class Notpad {
public static fileOptions: FileOptions = new FileOptions();
Expand All @@ -25,10 +27,14 @@ export class Notpad {

static close = () => {
try {
window.close();
toast.info(
'Closing the Notpad may not work in web browsers due to security restrictions. Please close the tab manually.'
);
if (isTauri) {
exit();
} else {
window.close();
toast.info(
'Closing the Notpad may not work in web browsers due to security restrictions. Please close the tab manually.'
);
}
} catch (err) {
this.showError(err);
}
Expand Down

0 comments on commit 5cc5847

Please sign in to comment.