Add clipboard & notification util
This commit is contained in:
7 files changed
+73
-10
No files matched your search
@@ -11,7 +11,9 @@
|
|||||||
"@fortawesome/free-solid-svg-icons": "^7.2.0",
|
"@fortawesome/free-solid-svg-icons": "^7.2.0",
|
||||||
"@fortawesome/react-fontawesome": "^3.3.0",
|
"@fortawesome/react-fontawesome": "^3.3.0",
|
||||||
"@tauri-apps/api": "2.10.1",
|
"@tauri-apps/api": "2.10.1",
|
||||||
|
"@tauri-apps/plugin-clipboard-manager": "~2",
|
||||||
"@tauri-apps/plugin-http": "~2",
|
"@tauri-apps/plugin-http": "~2",
|
||||||
|
"@tauri-apps/plugin-notification": "~2",
|
||||||
"@tauri-apps/plugin-opener": "~2",
|
"@tauri-apps/plugin-opener": "~2",
|
||||||
"next": "16.2.1",
|
"next": "16.2.1",
|
||||||
"react": "19.2.4",
|
"react": "19.2.4",
|
||||||
@@ -264,8 +266,12 @@
|
|||||||
|
|
||||||
"@tauri-apps/cli-win32-x64-msvc": ["@tauri-apps/cli-win32-x64-msvc@2.10.1", "", { "os": "win32", "cpu": "x64" }, "sha512-6Cn7YpPFwzChy0ERz6djKEmUehWrYlM+xTaNzGPgZocw3BD7OfwfWHKVWxXzdjEW2KfKkHddfdxK1XXTYqBRLg=="],
|
"@tauri-apps/cli-win32-x64-msvc": ["@tauri-apps/cli-win32-x64-msvc@2.10.1", "", { "os": "win32", "cpu": "x64" }, "sha512-6Cn7YpPFwzChy0ERz6djKEmUehWrYlM+xTaNzGPgZocw3BD7OfwfWHKVWxXzdjEW2KfKkHddfdxK1XXTYqBRLg=="],
|
||||||
|
|
||||||
|
"@tauri-apps/plugin-clipboard-manager": ["@tauri-apps/plugin-clipboard-manager@2.3.2", "", { "dependencies": { "@tauri-apps/api": "^2.8.0" } }, "sha512-CUlb5Hqi2oZbcZf4VUyUH53XWPPdtpw43EUpCza5HWZJwxEoDowFzNUDt1tRUXA8Uq+XPn17Ysfptip33sG4eQ=="],
|
||||||
|
|
||||||
"@tauri-apps/plugin-http": ["@tauri-apps/plugin-http@2.5.7", "", { "dependencies": { "@tauri-apps/api": "^2.10.1" } }, "sha512-+F2lEH/c9b0zSsOXKq+5hZNcd9F4IIKCK1T17RqMwpCmVnx2aoqY8yIBccCd25HTYUb3j6NPVbRax/m00hKG8A=="],
|
"@tauri-apps/plugin-http": ["@tauri-apps/plugin-http@2.5.7", "", { "dependencies": { "@tauri-apps/api": "^2.10.1" } }, "sha512-+F2lEH/c9b0zSsOXKq+5hZNcd9F4IIKCK1T17RqMwpCmVnx2aoqY8yIBccCd25HTYUb3j6NPVbRax/m00hKG8A=="],
|
||||||
|
|
||||||
|
"@tauri-apps/plugin-notification": ["@tauri-apps/plugin-notification@2.3.3", "", { "dependencies": { "@tauri-apps/api": "^2.8.0" } }, "sha512-Zw+ZH18RJb41G4NrfHgIuofJiymusqN+q8fGUIIV7vyCH+5sSn5coqRv/MWB9qETsUs97vmU045q7OyseCV3Qg=="],
|
||||||
|
|
||||||
"@tauri-apps/plugin-opener": ["@tauri-apps/plugin-opener@2.5.3", "", { "dependencies": { "@tauri-apps/api": "^2.8.0" } }, "sha512-CCcUltXMOfUEArbf3db3kCE7Ggy1ExBEBl51Ko2ODJ6GDYHRp1nSNlQm5uNCFY5k7/ufaK5Ib3Du/Zir19IYQQ=="],
|
"@tauri-apps/plugin-opener": ["@tauri-apps/plugin-opener@2.5.3", "", { "dependencies": { "@tauri-apps/api": "^2.8.0" } }, "sha512-CCcUltXMOfUEArbf3db3kCE7Ggy1ExBEBl51Ko2ODJ6GDYHRp1nSNlQm5uNCFY5k7/ufaK5Ib3Du/Zir19IYQQ=="],
|
||||||
|
|
||||||
"@tybys/wasm-util": ["@tybys/wasm-util@0.10.1", "", { "dependencies": { "tslib": "^2.4.0" } }, "sha512-9tTaPJLSiejZKx+Bmog4uSubteqTvFrVrURwkmHixBo0G4seD0zUxp98E1DzUBJxLQ3NPwXrGKDiVjwx/DpPsg=="],
|
"@tybys/wasm-util": ["@tybys/wasm-util@0.10.1", "", { "dependencies": { "tslib": "^2.4.0" } }, "sha512-9tTaPJLSiejZKx+Bmog4uSubteqTvFrVrURwkmHixBo0G4seD0zUxp98E1DzUBJxLQ3NPwXrGKDiVjwx/DpPsg=="],
|
||||||
|
|||||||
@@ -16,7 +16,9 @@
|
|||||||
"@fortawesome/free-solid-svg-icons": "^7.2.0",
|
"@fortawesome/free-solid-svg-icons": "^7.2.0",
|
||||||
"@fortawesome/react-fontawesome": "^3.3.0",
|
"@fortawesome/react-fontawesome": "^3.3.0",
|
||||||
"@tauri-apps/api": "2.10.1",
|
"@tauri-apps/api": "2.10.1",
|
||||||
|
"@tauri-apps/plugin-clipboard-manager": "~2",
|
||||||
"@tauri-apps/plugin-http": "~2",
|
"@tauri-apps/plugin-http": "~2",
|
||||||
|
"@tauri-apps/plugin-notification": "~2",
|
||||||
"@tauri-apps/plugin-opener": "~2",
|
"@tauri-apps/plugin-opener": "~2",
|
||||||
"next": "16.2.1",
|
"next": "16.2.1",
|
||||||
"react": "19.2.4",
|
"react": "19.2.4",
|
||||||
|
|||||||
@@ -18,4 +18,6 @@ serde = { version = "1.0.228", features = ["derive"] }
|
|||||||
serde_json = "1.0.149"
|
serde_json = "1.0.149"
|
||||||
tauri-plugin-http = "2"
|
tauri-plugin-http = "2"
|
||||||
tauri-plugin-opener = "2"
|
tauri-plugin-opener = "2"
|
||||||
|
tauri-plugin-notification = "2"
|
||||||
|
tauri-plugin-clipboard-manager = "2"
|
||||||
|
|
||||||
@@ -6,19 +6,42 @@
|
|||||||
"permissions": [
|
"permissions": [
|
||||||
"core:default",
|
"core:default",
|
||||||
"opener:default",
|
"opener:default",
|
||||||
|
"notification:default",
|
||||||
|
"clipboard-manager:default",
|
||||||
|
"clipboard-manager:allow-write-text",
|
||||||
{
|
{
|
||||||
"identifier": "http:default",
|
"identifier": "http:default",
|
||||||
"allow": [
|
"allow": [
|
||||||
{ "url": "https://games.lncvrt.xyz/api/launcher/latest" },
|
{
|
||||||
{ "url": "https://games.lncvrt.xyz/api/launcher/versions" },
|
"url": "https://games.lncvrt.xyz/api/launcher/latest"
|
||||||
{ "url": "https://games.lncvrt.xyz/api/launcher/download" },
|
},
|
||||||
{ "url": "https://games.lncvrt.xyz/api/launcher/mods" },
|
{
|
||||||
{ "url": "https://games.lncvrt.xyz/api/berrydash/account" },
|
"url": "https://games.lncvrt.xyz/api/launcher/versions"
|
||||||
{ "url": "https://games.lncvrt.xyz/api/berrydash/leaderboard/score" },
|
},
|
||||||
{ "url": "https://games.lncvrt.xyz/api/berrydash/leaderboard/berry" },
|
{
|
||||||
{ "url": "https://games.lncvrt.xyz/api/berrydash/leaderboard/coin" },
|
"url": "https://games.lncvrt.xyz/api/launcher/download"
|
||||||
{ "url": "https://games.lncvrt.xyz/api/berrydash/leaderboard/legacy" },
|
},
|
||||||
{ "url": "https://games.lncvrt.xyz/api/berrydash/leaderboard/total" }
|
{
|
||||||
|
"url": "https://games.lncvrt.xyz/api/launcher/mods"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"url": "https://games.lncvrt.xyz/api/berrydash/account"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"url": "https://games.lncvrt.xyz/api/berrydash/leaderboard/score"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"url": "https://games.lncvrt.xyz/api/berrydash/leaderboard/berry"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"url": "https://games.lncvrt.xyz/api/berrydash/leaderboard/coin"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"url": "https://games.lncvrt.xyz/api/berrydash/leaderboard/legacy"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"url": "https://games.lncvrt.xyz/api/berrydash/leaderboard/total"
|
||||||
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
#[cfg_attr(mobile, tauri::mobile_entry_point)]
|
#[cfg_attr(mobile, tauri::mobile_entry_point)]
|
||||||
pub fn run() {
|
pub fn run() {
|
||||||
tauri::Builder::default()
|
tauri::Builder::default()
|
||||||
|
.plugin(tauri_plugin_clipboard_manager::init())
|
||||||
|
.plugin(tauri_plugin_notification::init())
|
||||||
.plugin(tauri_plugin_opener::init())
|
.plugin(tauri_plugin_opener::init())
|
||||||
.plugin(tauri_plugin_http::init())
|
.plugin(tauri_plugin_http::init())
|
||||||
.invoke_handler(tauri::generate_handler![])
|
.invoke_handler(tauri::generate_handler![])
|
||||||
|
|||||||
@@ -0,0 +1,11 @@
|
|||||||
|
import { writeText } from '@tauri-apps/plugin-clipboard-manager'
|
||||||
|
import { notifyUser } from './notifications'
|
||||||
|
|
||||||
|
export async function copyToClipboard (
|
||||||
|
text: string,
|
||||||
|
notificationsAllowed: boolean
|
||||||
|
) {
|
||||||
|
await writeText(text)
|
||||||
|
if (notificationsAllowed)
|
||||||
|
await notifyUser('Copied', 'Text "' + text + '" copied to clipboard')
|
||||||
|
}
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
import {
|
||||||
|
isPermissionGranted,
|
||||||
|
requestPermission,
|
||||||
|
sendNotification
|
||||||
|
} from '@tauri-apps/plugin-notification'
|
||||||
|
|
||||||
|
export async function notifyUser (title: string, body: string) {
|
||||||
|
let permissionGranted = await isPermissionGranted()
|
||||||
|
if (!permissionGranted) {
|
||||||
|
const permission = await requestPermission()
|
||||||
|
permissionGranted = permission === 'granted'
|
||||||
|
}
|
||||||
|
|
||||||
|
if (permissionGranted) {
|
||||||
|
sendNotification({ title, body })
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in new issue
Block a user