Skip to content

Commit

Permalink
feat: testing auto updates with gist (#20)
Browse files Browse the repository at this point in the history
* feat: added readme file

* feat: search support and bug fixes (#4)

* fix: Auto updater with github gist (#6)

* feat: search support and bug fixes

* fix: auto updater
Added github gist for testing auto updates

* fix: testing macos build (#8)

* feat: search support and bug fixes

* fix: auto updater
Added github gist for testing auto updates

* fix: testing build for macos

* fix: testing macos cert (#10)

* feat: search support and bug fixes

* fix: auto updater
Added github gist for testing auto updates

* fix: testing build for macos

* fix: testing macos cert

* fix: macos cert (#12)

* feat: search support and bug fixes

* fix: auto updater
Added github gist for testing auto updates

* fix: testing build for macos

* fix: testing macos cert

* fix: building macos cert

* release (#13) (#14)

* feat: added readme file

* feat: search support and bug fixes (#4)

* fix: Auto updater with github gist (#6)

* feat: search support and bug fixes

* fix: auto updater
Added github gist for testing auto updates

* fix: testing macos build (#8)

* feat: search support and bug fixes

* fix: auto updater
Added github gist for testing auto updates

* fix: testing build for macos

* fix: testing macos cert (#10)

* feat: search support and bug fixes

* fix: auto updater
Added github gist for testing auto updates

* fix: testing build for macos

* fix: testing macos cert

* fix: macos cert (#12)

* feat: search support and bug fixes

* fix: auto updater
Added github gist for testing auto updates

* fix: testing build for macos

* fix: testing macos cert

* fix: building macos cert

* disabled macos support (#15)

* feat: search support and bug fixes

* fix: auto updater
Added github gist for testing auto updates

* fix: testing build for macos

* fix: testing macos cert

* fix: building macos cert

* release (#13)

* feat: added readme file

* feat: search support and bug fixes (#4)

* fix: Auto updater with github gist (#6)

* feat: search support and bug fixes

* fix: auto updater
Added github gist for testing auto updates

* fix: testing macos build (#8)

* feat: search support and bug fixes

* fix: auto updater
Added github gist for testing auto updates

* fix: testing build for macos

* fix: testing macos cert (#10)

* feat: search support and bug fixes

* fix: auto updater
Added github gist for testing auto updates

* fix: testing build for macos

* fix: testing macos cert

* fix: macos cert (#12)

* feat: search support and bug fixes

* fix: auto updater
Added github gist for testing auto updates

* fix: testing build for macos

* fix: testing macos cert

* fix: building macos cert

* update: disabled mac and linux support

* Dev (#17)

* feat: search support and bug fixes

* fix: auto updater
Added github gist for testing auto updates

* fix: testing build for macos

* fix: testing macos cert

* fix: building macos cert

* release (#13)

* feat: added readme file

* feat: search support and bug fixes (#4)

* fix: Auto updater with github gist (#6)

* feat: search support and bug fixes

* fix: auto updater
Added github gist for testing auto updates

* fix: testing macos build (#8)

* feat: search support and bug fixes

* fix: auto updater
Added github gist for testing auto updates

* fix: testing build for macos

* fix: testing macos cert (#10)

* feat: search support and bug fixes

* fix: auto updater
Added github gist for testing auto updates

* fix: testing build for macos

* fix: testing macos cert

* fix: macos cert (#12)

* feat: search support and bug fixes

* fix: auto updater
Added github gist for testing auto updates

* fix: testing build for macos

* fix: testing macos cert

* fix: building macos cert

* update: disabled mac and linux support

* disabled mac

* feat: testing auto updates with gist (#19)

* feat: search support and bug fixes

* fix: auto updater
Added github gist for testing auto updates

* fix: testing build for macos

* fix: testing macos cert

* fix: building macos cert

* release (#13)

* feat: added readme file

* feat: search support and bug fixes (#4)

* fix: Auto updater with github gist (#6)

* feat: search support and bug fixes

* fix: auto updater
Added github gist for testing auto updates

* fix: testing macos build (#8)

* feat: search support and bug fixes

* fix: auto updater
Added github gist for testing auto updates

* fix: testing build for macos

* fix: testing macos cert (#10)

* feat: search support and bug fixes

* fix: auto updater
Added github gist for testing auto updates

* fix: testing build for macos

* fix: testing macos cert

* fix: macos cert (#12)

* feat: search support and bug fixes

* fix: auto updater
Added github gist for testing auto updates

* fix: testing build for macos

* fix: testing macos cert

* fix: building macos cert

* update: disabled mac and linux support

* disabled mac

* feat: testing auto updater with gist

* feat: testing auto updater with gist
  • Loading branch information
HoaX7 authored Sep 20, 2024
1 parent 61e71a1 commit bb6dbd2
Show file tree
Hide file tree
Showing 18 changed files with 242 additions and 58 deletions.
2 changes: 1 addition & 1 deletion app/docs/readme.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<h1 class="mt-8">Scribe v0.1.0</h1><p>A Simple opensource note taking app perfect for quick notes or detailed plans, stay on top of your day and never lose track of your ideas again.</p><p>This markdown was created using scribe.</p><h2 class="mt-8">Quick notes</h2><p>Press <code class="px-1 bg-gray-200 rounded">Ctrl+space</code>&nbsp;from anywhere to jot down notes without having to worry about where to save them. The app will automatically save the contents in a <code class="px-1 bg-gray-200 rounded">shortnotes.md</code>&nbsp;in the selected directory.</p><h1 class="mt-8">Settings</h1><p>All notes by default are saved in the installation path under a <code class="px-1 bg-gray-200 rounded">docs</code>&nbsp;folder.</p><p>You can modify the save path by clicking on <code class="px-1 bg-gray-200 rounded">File &gt; Settings</code>.</p><p><strong>Note: You must move the files manually to the new save directory.</strong></p><h1 class="mt-8">Key features</h1><ul class="px-2 mx-2 my-2"><li class="my-1"><p>Built for speed with rust.</p></li><li class="my-1"><p>Close the app and take notes from anywhere.</p></li><li class="my-1"><p>Markdown shortcuts make it easy to format the text while typing.</p><p>To test that, start a new line and type <code class="px-1 bg-gray-200 rounded">#</code> followed by a space to get a heading. Try <code class="px-1 bg-gray-200 rounded">#</code>, <code class="px-1 bg-gray-200 rounded">##</code>, <code class="px-1 bg-gray-200 rounded">###</code>, <code class="px-1 bg-gray-200 rounded">####</code>, <code class="px-1 bg-gray-200 rounded">#####</code>, <code class="px-1 bg-gray-200 rounded">######</code> for different levels.</p></li><li class="my-1"><p>You can also try <code class="px-1 bg-gray-200 rounded">&gt;</code> for blockquotes, <code class="px-1 bg-gray-200 rounded">*</code>, <code class="px-1 bg-gray-200 rounded">-</code> or <code class="px-1 bg-gray-200 rounded">+</code> for bullet lists, or <code class="px-1 bg-gray-200 rounded">`foobar`</code> to highlight code, <code class="px-1 bg-gray-200 rounded">~~tildes~~</code> to strike text, or <code class="px-1 bg-gray-200 rounded">==equal signs==</code> to highlight text,&nbsp;<code class="px-1 bg-gray-200 rounded">(c)</code> to see how it’s converted to a proper © character. You can also try <code class="px-1 bg-gray-200 rounded">-&gt;</code>, <code class="px-1 bg-gray-200 rounded">&gt;&gt;</code>, <code class="px-1 bg-gray-200 rounded">1/2</code>, <code class="px-1 bg-gray-200 rounded">!=</code>, or <code class="px-1 bg-gray-200 rounded">--</code>,&nbsp;<code class="px-1 bg-gray-200 rounded">**</code>&nbsp;for bold and&nbsp;<code class="px-1 bg-gray-200 rounded">_Italic_</code>&nbsp;<em>for italic.</em></p></li><li class="my-1"><p>An inline toolbar is also available when you select text.</p></li></ul><h1 class="mt-8">Roadmap</h1><ul class="px-2 mx-2 my-2"><li class="my-1"><p>Integration with notion.</p></li></ul>
<h1 class="mt-8">Scribe v0.1.0</h1><p>A Simple opensource note taking app perfect for quick notes or detailed plans, stay on top of your day and never lose track of your ideas again.</p><p>This markdown was created using scribe.</p><h2 class="mt-8">Quick notes</h2><p>Press <code class="px-1 bg-gray-200 rounded">Ctrl+Enter</code>, <code class="px-1 bg-gray-200 rounded">Cmd+Enter</code> on mac from anywhere to jot down notes without having to worry about where to save them. The app will automatically save the contents in a <code class="px-1 bg-gray-200 rounded">shortnotes.md</code>&nbsp;in the selected directory.</p><h1 class="mt-8">Settings</h1><p>All notes by default are saved in the installation path under a <code class="px-1 bg-gray-200 rounded">docs</code>&nbsp;folder.</p><p>You can modify the save path by clicking on <code class="px-1 bg-gray-200 rounded">File &gt; Settings</code>.</p><p><strong>Note: You must move the files manually to the new save directory.</strong></p><h1 class="mt-8">Key features</h1><ul class="px-2 mx-2 my-2"><li class="my-1"><p>Built for speed with rust.</p></li><li class="my-1"><p>Close the app and take notes from anywhere.</p></li><li class="my-1"><p>Markdown shortcuts make it easy to format the text while typing.</p><p>To test that, start a new line and type <code class="px-1 bg-gray-200 rounded">#</code> followed by a space to get a heading. Try <code class="px-1 bg-gray-200 rounded">#</code>, <code class="px-1 bg-gray-200 rounded">##</code>, <code class="px-1 bg-gray-200 rounded">###</code>, <code class="px-1 bg-gray-200 rounded">####</code>, <code class="px-1 bg-gray-200 rounded">#####</code>, <code class="px-1 bg-gray-200 rounded">######</code> for different levels.</p></li><li class="my-1"><p>You can also try <code class="px-1 bg-gray-200 rounded">&gt;</code> for blockquotes, <code class="px-1 bg-gray-200 rounded">*</code>, <code class="px-1 bg-gray-200 rounded">-</code> or <code class="px-1 bg-gray-200 rounded">+</code> for bullet lists, or <code class="px-1 bg-gray-200 rounded">`foobar`</code> to highlight code, <code class="px-1 bg-gray-200 rounded">~~tildes~~</code> to strike text, or <code class="px-1 bg-gray-200 rounded">==equal signs==</code> to highlight text,&nbsp;<code class="px-1 bg-gray-200 rounded">(c)</code> to see how it’s converted to a proper © character. You can also try <code class="px-1 bg-gray-200 rounded">-&gt;</code>, <code class="px-1 bg-gray-200 rounded">&gt;&gt;</code>, <code class="px-1 bg-gray-200 rounded">1/2</code>, <code class="px-1 bg-gray-200 rounded">!=</code>, or <code class="px-1 bg-gray-200 rounded">--</code>,&nbsp;<code class="px-1 bg-gray-200 rounded">**</code>&nbsp;for bold and&nbsp;<code class="px-1 bg-gray-200 rounded">_Italic_</code>&nbsp;<em>for italic.</em></p></li><li class="my-1"><p>An inline toolbar is also available when you select text.</p></li></ul><h1 class="mt-8">Roadmap</h1><ul class="px-2 mx-2 my-2"><li class="my-1"><p>Integration with notion.</p></li></ul>
3 changes: 2 additions & 1 deletion app/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 app/src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "scribe"
version = "0.2.0"
version = "0.3.0"
description = "A note taking app with seamless user experience"
authors = ["HoaX7"]
license = ""
Expand All @@ -20,6 +20,7 @@ serde = { version = "1.0", features = ["derive"] }
tauri = { version = "1.7.2", features = [ "dialog-confirm", "updater", "dialog-open", "path-all", "window-close", "global-shortcut", "global-shortcut-all", "os-all", "window-unmaximize", "system-tray", "window-maximize", "window-minimize", "window-start-dragging", "window-hide"] }
window-shadows = "0.2.2"
noteapp_lib = { path = "../../backend/noteapp_lib" }
winapi = { version = "0.3.9", features = ["winuser", "dwmapi"] }

[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
2 changes: 1 addition & 1 deletion app/src-tauri/docs/readme.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<h1 class="mt-8">Scribe v0.1.0</h1><p>A Simple opensource note taking app perfect for quick notes or detailed plans, stay on top of your day and never lose track of your ideas again.</p><p>This markdown was created using scribe.</p><h2 class="mt-8">Quick notes</h2><p>Press <code class="px-1 bg-gray-200 rounded">Ctrl+space</code>&nbsp;from anywhere to jot down notes without having to worry about where to save them. The app will automatically save the contents in a <code class="px-1 bg-gray-200 rounded">shortnotes.md</code>&nbsp;in the selected directory.</p><h1 class="mt-8">Settings</h1><p>All notes by default are saved in the installation path under a <code class="px-1 bg-gray-200 rounded">docs</code>&nbsp;folder.</p><p>You can modify the save path by clicking on <code class="px-1 bg-gray-200 rounded">File &gt; Settings</code>.</p><p><strong>Note: You must move the files manually to the new save directory.</strong></p><h1 class="mt-8">Key features</h1><ul class="px-2 mx-2 my-2"><li class="my-1"><p>Built for speed with rust.</p></li><li class="my-1"><p>Close the app and take notes from anywhere.</p></li><li class="my-1"><p>Markdown shortcuts make it easy to format the text while typing.</p><p>To test that, start a new line and type <code class="px-1 bg-gray-200 rounded">#</code> followed by a space to get a heading. Try <code class="px-1 bg-gray-200 rounded">#</code>, <code class="px-1 bg-gray-200 rounded">##</code>, <code class="px-1 bg-gray-200 rounded">###</code>, <code class="px-1 bg-gray-200 rounded">####</code>, <code class="px-1 bg-gray-200 rounded">#####</code>, <code class="px-1 bg-gray-200 rounded">######</code> for different levels.</p></li><li class="my-1"><p>You can also try <code class="px-1 bg-gray-200 rounded">&gt;</code> for blockquotes, <code class="px-1 bg-gray-200 rounded">*</code>, <code class="px-1 bg-gray-200 rounded">-</code> or <code class="px-1 bg-gray-200 rounded">+</code> for bullet lists, or <code class="px-1 bg-gray-200 rounded">`foobar`</code> to highlight code, <code class="px-1 bg-gray-200 rounded">~~tildes~~</code> to strike text, or <code class="px-1 bg-gray-200 rounded">==equal signs==</code> to highlight text,&nbsp;<code class="px-1 bg-gray-200 rounded">(c)</code> to see how it’s converted to a proper © character. You can also try <code class="px-1 bg-gray-200 rounded">-&gt;</code>, <code class="px-1 bg-gray-200 rounded">&gt;&gt;</code>, <code class="px-1 bg-gray-200 rounded">1/2</code>, <code class="px-1 bg-gray-200 rounded">!=</code>, or <code class="px-1 bg-gray-200 rounded">--</code>,&nbsp;<code class="px-1 bg-gray-200 rounded">**</code>&nbsp;for bold and&nbsp;<code class="px-1 bg-gray-200 rounded">_Italic_</code>&nbsp;<em>for italic.</em></p></li><li class="my-1"><p>An inline toolbar is also available when you select text.</p></li></ul><h1 class="mt-8">Roadmap</h1><ul class="px-2 mx-2 my-2"><li class="my-1"><p>Integration with notion.</p></li></ul>
<h1 class="mt-8">Scribe v0.1.0</h1><p>A Simple opensource note taking app perfect for quick notes or detailed plans, stay on top of your day and never lose track of your ideas again.</p><p>This markdown was created using scribe.</p><h2 class="mt-8">Quick notes</h2><p>Press <code class="px-1 bg-gray-200 rounded">Ctrl+Enter</code>, <code class="px-1 bg-gray-200 rounded">Cmd+Enter</code>&nbsp;on Macos from anywhere to jot down notes without having to worry about where to save them. The app will automatically save the contents in a <code class="px-1 bg-gray-200 rounded">shortnotes.md</code>&nbsp;in the selected directory.</p><h1 class="mt-8">Settings</h1><p>All notes by default are saved in the installation path under a <code class="px-1 bg-gray-200 rounded">docs</code>&nbsp;folder.</p><p>You can modify the save path by clicking on <code class="px-1 bg-gray-200 rounded">File &gt; Settings</code>.</p><p><strong>Note: You must move the files manually to the new save directory.</strong></p><h1 class="mt-8">Key features</h1><ul class="px-2 mx-2 my-2"><li class="my-1"><p>Built for speed with rust.</p></li><li class="my-1"><p>Close the app and take notes from anywhere.</p></li><li class="my-1"><p>Markdown shortcuts make it easy to format the text while typing.</p><p>To test that, start a new line and type <code class="px-1 bg-gray-200 rounded">#</code> followed by a space to get a heading. Try <code class="px-1 bg-gray-200 rounded">#</code>, <code class="px-1 bg-gray-200 rounded">##</code>, <code class="px-1 bg-gray-200 rounded">###</code>, <code class="px-1 bg-gray-200 rounded">####</code>, <code class="px-1 bg-gray-200 rounded">#####</code>, <code class="px-1 bg-gray-200 rounded">######</code> for different levels.</p></li><li class="my-1"><p>You can also try <code class="px-1 bg-gray-200 rounded">&gt;</code> for blockquotes, <code class="px-1 bg-gray-200 rounded">*</code>, <code class="px-1 bg-gray-200 rounded">-</code> or <code class="px-1 bg-gray-200 rounded">+</code> for bullet lists, or <code class="px-1 bg-gray-200 rounded">`foobar`</code> to highlight code, <code class="px-1 bg-gray-200 rounded">~~tildes~~</code> to strike text, or <code class="px-1 bg-gray-200 rounded">==equal signs==</code> to highlight text,&nbsp;<code class="px-1 bg-gray-200 rounded">(c)</code> to see how it’s converted to a proper © character. You can also try <code class="px-1 bg-gray-200 rounded">-&gt;</code>, <code class="px-1 bg-gray-200 rounded">&gt;&gt;</code>, <code class="px-1 bg-gray-200 rounded">1/2</code>, <code class="px-1 bg-gray-200 rounded">!=</code>, or <code class="px-1 bg-gray-200 rounded">--</code>,&nbsp;<code class="px-1 bg-gray-200 rounded">**</code>&nbsp;for bold and&nbsp;<code class="px-1 bg-gray-200 rounded">_Italic_</code>&nbsp;<em>for italic.</em></p></li><li class="my-1"><p>An inline toolbar is also available when you select text.</p></li><li class="my-1"><p>To refresh the app press <code class="px-1 bg-gray-200 rounded">F5</code>.</p></li></ul><h1 class="mt-8">Roadmap</h1><ul class="px-2 mx-2 my-2"><li class="my-1"><p>Integration with notion.</p></li></ul>
53 changes: 52 additions & 1 deletion app/src-tauri/src/shortcuts/mod.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
use tauri::{App, AppHandle, GlobalShortcutManager, Manager, WindowBuilder, WindowUrl};
use window_shadows::set_shadow;
use winapi::um::winuser::{GetForegroundWindow, GetWindowRect, GetSystemMetrics, SM_CXSCREEN, SM_CYSCREEN};
use winapi::shared::windef::{RECT, HWND__};
use winapi::um::dwmapi::DwmGetWindowAttribute;
use winapi::um::dwmapi::DWMWA_EXTENDED_FRAME_BOUNDS;

struct ShortNotesWindow;
impl ShortNotesWindow {
const LABEL: &str = "short_notes_window";
const SHORTCUT: &str = "CommandOrControl+Space";
const SHORTCUT: &str = "CommandOrControl+Enter";
const W: f64 = 400.0;
const H: f64 = 200.0;
const URL: &str = "shortNotes";
Expand All @@ -19,6 +23,9 @@ pub fn register_shortcuts(app: &mut App) {
}

pub fn make_shortnotes_window(handle: &AppHandle) {
if deny_quicknote() {
return;
}
if let Some(window) = handle.get_window(ShortNotesWindow::LABEL) {
window.show().unwrap();
window.set_focus().unwrap();
Expand All @@ -36,3 +43,47 @@ pub fn make_shortnotes_window(handle: &AppHandle) {
window.show().unwrap();
}
}

fn deny_quicknote() -> bool {
unsafe {
let hwnd = GetForegroundWindow();
if hwnd.is_null() {
return false;
}
is_fullscreen(hwnd)
// TODO - allow users to add a list of window names to disable quicknote
}
}

fn is_fullscreen(hwnd: *mut HWND__) -> bool {
unsafe {
// Get the screen resolution
let screen_width = GetSystemMetrics(SM_CXSCREEN);
let screen_height = GetSystemMetrics(SM_CYSCREEN);

// Get the window rectangle
let mut rect: RECT = std::mem::zeroed();
if GetWindowRect(hwnd, &mut rect) == 0 {
return false;
}

// Compare window dimensions to screen size
let window_width = rect.right - rect.left;
let window_height = rect.bottom - rect.top;

if window_width == screen_width && window_height == screen_height {
// Further check if the window has no decorations (i.e., it's borderless)
let mut frame_rect: RECT = std::mem::zeroed();
if DwmGetWindowAttribute(
hwnd,
DWMWA_EXTENDED_FRAME_BOUNDS,
&mut frame_rect as *mut RECT as *mut _,
std::mem::size_of::<RECT>() as u32
) == 0 {
return frame_rect.left == rect.left && frame_rect.right == rect.right &&
frame_rect.top == rect.top && frame_rect.bottom == rect.bottom;
}
}
false
}
}
4 changes: 2 additions & 2 deletions app/src-tauri/tauri.conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
},
"package": {
"productName": "scribe",
"version": "0.2.0"
"version": "0.3.0"
},
"tauri": {
"allowlist": {
Expand Down Expand Up @@ -75,7 +75,7 @@
"updater": {
"active": true,
"dialog": true,
"endpoints": ["https://scribe.izzi-xenex.xyz/tauri/{{target}}/{{arch}}/{{current_version}}", "https://gist.githubusercontent.com/HoaX7/b73dc436fe3c529ae4cfa1068b1c8fba/raw/"],
"endpoints": ["https://scribe.izzi-xenex.xyz/tauri/{{target}}/{{arch}}/{{current_version}}", "https://gist.githubusercontent.com/HoaX7/26a914ff0cdfe097c949db0ac825a94f/raw/"],
"pubkey": "dW50cnVzdGVkIGNvbW1lbnQ6IG1pbmlzaWduIHB1YmxpYyBrZXk6IEJDQzY3MjU3MDQ3MDQ1OEYKUldTUFJYQUVWM0xHdktsNDY4RHREYzZnV3BDV3pxS1NVRHNQZGZhSHZqOTlvbXZ1YWdtdkU3b2kK",
"windows": {
"installMode": "passive"
Expand Down
38 changes: 38 additions & 0 deletions app/src/api/update.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import {
checkUpdate,
installUpdate,
onUpdaterEvent,
} from "@tauri-apps/api/updater";
import { relaunch } from "@tauri-apps/api/process";

const unlisten = await onUpdaterEvent(({ error, status }) => {
// This will log all updater events, including status updates and errors.
console.log("Updater event", error, status);
});

try {
const { shouldUpdate, manifest } = await checkUpdate();
console.log({
shouldUpdate,
manifest
});
if (shouldUpdate) {
const ask = window.confirm("A new update is available");
// You could show a dialog asking the user if they want to install the update here.
console.log(
`Installing update ${manifest?.version}, ${manifest?.date}, ${manifest?.body}`
);

// Install the update. This will also restart the app on Windows!
// await installUpdate();

// // On macOS and Linux you will need to restart the app manually.
// // You could use this step to display another confirmation dialog.
// await relaunch();
}
} catch (error) {
console.error(error);
}

// you need to call unlisten if your handler goes out of scope, for example if the component is unmounted.
unlisten();
5 changes: 3 additions & 2 deletions app/src/lib/components/menu/Main.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,18 @@
import Settings from "../settings/Index.svelte";
import TauriEventListener from "$lib/hooks/TauriEventListener.svelte";
import { TAURI_EVENTS } from "../../../utils/constants";
import { emit } from "@tauri-apps/api/event";
import SettingStore from "../../../store/settings";
const ctx = ContextStore.getContext();
const settingCtx = SettingStore.getContext();
let menubar = [];
let activeMenu = "";
let showSettings = false;
const closeMenu = () => {
activeMenu = "";
};
$: menubar = getMenuBar($ctx.page, () => (showSettings = true));
$: menubar = getMenuBar($ctx.page, $settingCtx.os, () => (showSettings = true));
const closeSettings = () => {
showSettings = false;
Expand Down
69 changes: 36 additions & 33 deletions app/src/lib/components/menu/items.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { appWindow, WebviewWindow } from "@tauri-apps/api/window";
import { openShortNoteWindow } from "../../../api";
import { SHORT_NOTE_WINDOW_LABEL } from "../../../utils/constants";
import { SHORT_NOTE_WINDOW_LABEL, Shortcuts } from "../../../utils/constants";

export type MenuItemProps = {
name: string;
Expand All @@ -23,35 +23,38 @@ const quitApp = () => {
shortnotesWindow?.close?.();
appWindow.close();
};
export const getMenuBar = (page?: string, cb?: () => void) => [
{
name: "File",
items: [
{
name: "Save",
command: emitSave,
shortcut: "Ctrl+S",
disabled: !page,
},
{
name: "Shortnotes",
command: openShortNoteWindow,
shortcut: "Ctrl+Space",
},
{
name: "Refresh",
command: () => window.location.reload(),
shortcut: "F5"
},
{
name: "Settings",
command: () => cb?.(),
},
{
name: "Quit",
command: quitApp,
classname: "border-t",
},
],
},
];
export const getMenuBar = (page?: string, os?: string, cb?: () => void) => {
const shortcutObj = Shortcuts(os);
return [
{
name: "File",
items: [
{
name: "Save",
command: emitSave,
shortcut: shortcutObj.SAVE,
disabled: !page,
},
{
name: "Shortnotes",
command: openShortNoteWindow,
shortcut: shortcutObj.QUICKNOTE,
},
{
name: "Refresh",
command: () => window.location.reload(),
shortcut: "F5"
},
{
name: "Settings",
command: () => cb?.(),
},
{
name: "Quit",
command: quitApp,
classname: "border-t",
},
],
},
];
};
Loading

0 comments on commit bb6dbd2

Please sign in to comment.