Updated tauri configuration
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"$schema": "https://raw.githubusercontent.com/tauri-apps/tauri/dev/crates/tauri-utils/schema.json",
|
"$schema": "https://schema.tauri.app/config/2",
|
||||||
"productName": "Discord Presence",
|
"productName": "Discord Presence",
|
||||||
"version": "0.1.0",
|
"version": "0.1.0",
|
||||||
"identifier": "org.racooncity.discord-presence",
|
"identifier": "org.racooncity.discord-presence",
|
||||||
@@ -19,7 +19,22 @@
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
"security": {
|
"security": {
|
||||||
"csp": "null"
|
"csp": null
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"bundle": {
|
||||||
|
"active": true,
|
||||||
|
"targets": [
|
||||||
|
"nsis",
|
||||||
|
"deb",
|
||||||
|
"appimage"
|
||||||
|
],
|
||||||
|
"icon": [
|
||||||
|
"icons/32x32.png",
|
||||||
|
"icons/128x128.png",
|
||||||
|
"icons/128x128@2x.png",
|
||||||
|
"icons/icon.icns",
|
||||||
|
"icons/icon.ico"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+12
@@ -1,9 +1,11 @@
|
|||||||
const { invoke } = window.__TAURI__.core;
|
const { invoke } = window.__TAURI__.core;
|
||||||
|
|
||||||
|
// ── State ──────────────────────────────────────────────
|
||||||
let connected = false;
|
let connected = false;
|
||||||
let timerStart = null;
|
let timerStart = null;
|
||||||
let timerInterval = null;
|
let timerInterval = null;
|
||||||
|
|
||||||
|
// ── Elements ───────────────────────────────────────────
|
||||||
const appIdInput = document.getElementById("appId");
|
const appIdInput = document.getElementById("appId");
|
||||||
const statusInput = document.getElementById("statusInput");
|
const statusInput = document.getElementById("statusInput");
|
||||||
const detailsInput = document.getElementById("detailsInput");
|
const detailsInput = document.getElementById("detailsInput");
|
||||||
@@ -18,6 +20,7 @@ const previewStatus = document.getElementById("previewStatus");
|
|||||||
const previewDetails = document.getElementById("previewDetails");
|
const previewDetails = document.getElementById("previewDetails");
|
||||||
const previewTime = document.getElementById("previewTime");
|
const previewTime = document.getElementById("previewTime");
|
||||||
|
|
||||||
|
// ── Connection ─────────────────────────────────────────
|
||||||
async function toggleConnection() {
|
async function toggleConnection() {
|
||||||
if (connected) {
|
if (connected) {
|
||||||
try {
|
try {
|
||||||
@@ -66,6 +69,7 @@ function setConnected(state) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ── Activity ───────────────────────────────────────────
|
||||||
async function setActivity() {
|
async function setActivity() {
|
||||||
const status = statusInput.value.trim();
|
const status = statusInput.value.trim();
|
||||||
const details = detailsInput.value.trim();
|
const details = detailsInput.value.trim();
|
||||||
@@ -76,6 +80,7 @@ async function setActivity() {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
await invoke("set_activity", { status, details, showTime, elapsedSeconds });
|
await invoke("set_activity", { status, details, showTime, elapsedSeconds });
|
||||||
|
// Update preview timer to reflect the spoofed offset
|
||||||
if (elapsedSeconds > 0) {
|
if (elapsedSeconds > 0) {
|
||||||
timerStart = Date.now() - (elapsedSeconds * 1000);
|
timerStart = Date.now() - (elapsedSeconds * 1000);
|
||||||
}
|
}
|
||||||
@@ -96,6 +101,7 @@ async function clearActivity() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ── Preview ────────────────────────────────────────────
|
||||||
function updatePreview(status, details, showTime) {
|
function updatePreview(status, details, showTime) {
|
||||||
previewTitle.textContent = appIdInput.value ? "Your App Name" : "—";
|
previewTitle.textContent = appIdInput.value ? "Your App Name" : "—";
|
||||||
|
|
||||||
@@ -127,6 +133,7 @@ function resetPreview() {
|
|||||||
previewTime.classList.add("hidden");
|
previewTime.classList.add("hidden");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Live-update the preview as you type
|
||||||
statusInput.addEventListener("input", () => {
|
statusInput.addEventListener("input", () => {
|
||||||
if (previewStatus.textContent || statusInput.value) {
|
if (previewStatus.textContent || statusInput.value) {
|
||||||
previewStatus.textContent = statusInput.value || "";
|
previewStatus.textContent = statusInput.value || "";
|
||||||
@@ -140,10 +147,12 @@ detailsInput.addEventListener("input", () => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Submit on Enter from either input
|
||||||
statusInput.addEventListener("keydown", (e) => { if (e.key === "Enter" && connected) setActivity(); });
|
statusInput.addEventListener("keydown", (e) => { if (e.key === "Enter" && connected) setActivity(); });
|
||||||
detailsInput.addEventListener("keydown", (e) => { if (e.key === "Enter" && connected) setActivity(); });
|
detailsInput.addEventListener("keydown", (e) => { if (e.key === "Enter" && connected) setActivity(); });
|
||||||
appIdInput.addEventListener("keydown", (e) => { if (e.key === "Enter" && !connected) toggleConnection(); });
|
appIdInput.addEventListener("keydown", (e) => { if (e.key === "Enter" && !connected) toggleConnection(); });
|
||||||
|
|
||||||
|
// ── Timer ──────────────────────────────────────────────
|
||||||
function startTimer() {
|
function startTimer() {
|
||||||
stopTimer();
|
stopTimer();
|
||||||
timerInterval = setInterval(() => {
|
timerInterval = setInterval(() => {
|
||||||
@@ -167,6 +176,7 @@ function stopTimer() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ── Help Modal ─────────────────────────────────────────
|
||||||
function openHelp() {
|
function openHelp() {
|
||||||
document.getElementById("helpModal").classList.remove("hidden");
|
document.getElementById("helpModal").classList.remove("hidden");
|
||||||
}
|
}
|
||||||
@@ -175,10 +185,12 @@ function closeHelp() {
|
|||||||
document.getElementById("helpModal").classList.add("hidden");
|
document.getElementById("helpModal").classList.add("hidden");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Close help on Escape
|
||||||
document.addEventListener("keydown", (e) => {
|
document.addEventListener("keydown", (e) => {
|
||||||
if (e.key === "Escape") closeHelp();
|
if (e.key === "Escape") closeHelp();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// ── Toast ──────────────────────────────────────────────
|
||||||
function toast(msg, type = "neutral") {
|
function toast(msg, type = "neutral") {
|
||||||
const container = document.getElementById("toastContainer");
|
const container = document.getElementById("toastContainer");
|
||||||
const colors = {
|
const colors = {
|
||||||
|
|||||||
Reference in New Issue
Block a user