debug mode

This commit is contained in:
2026-03-21 00:00:10 +08:00
parent 5165bc2c16
commit 680fd3c617
5 changed files with 29 additions and 5 deletions

View File

@@ -11,6 +11,7 @@ pub use window::open_config_window;
#[derive(Default, Serialize, Deserialize, Clone, Debug, Type)] #[derive(Default, Serialize, Deserialize, Clone, Debug, Type)]
pub struct AppConfig { pub struct AppConfig {
pub api_base_url: Option<String>, pub api_base_url: Option<String>,
pub debug_mode: bool,
} }
#[derive(Debug, Error)] #[derive(Debug, Error)]

View File

@@ -54,6 +54,7 @@ fn sanitize(mut config: AppConfig) -> AppConfig {
pub fn default_app_config() -> AppConfig { pub fn default_app_config() -> AppConfig {
AppConfig { AppConfig {
api_base_url: Some(DEFAULT_API_BASE_URL.to_string()), api_base_url: Some(DEFAULT_API_BASE_URL.to_string()),
debug_mode: false,
} }
} }

View File

@@ -175,7 +175,7 @@ userStatusChanged: "user-status-changed"
/** user-defined types **/ /** user-defined types **/
export type ActiveDollSpriteChanged = string | null export type ActiveDollSpriteChanged = string | null
export type AppConfig = { api_base_url: string | null } export type AppConfig = { api_base_url: string | null; debug_mode: boolean }
export type AppDataRefreshed = UserData export type AppDataRefreshed = UserData
export type AuthFlowStatus = "started" | "succeeded" | "failed" | "cancelled" export type AuthFlowStatus = "started" | "succeeded" | "failed" | "cancelled"
export type AuthFlowUpdated = AuthFlowUpdatedPayload export type AuthFlowUpdated = AuthFlowUpdatedPayload

View File

@@ -4,6 +4,7 @@
let form: AppConfig = { let form: AppConfig = {
api_base_url: "", api_base_url: "",
debug_mode: false,
}; };
let saving = false; let saving = false;
@@ -16,6 +17,7 @@
const config = await commands.getClientConfig(); const config = await commands.getClientConfig();
form = { form = {
api_base_url: config.api_base_url ?? "", api_base_url: config.api_base_url ?? "",
debug_mode: config.debug_mode ?? false,
}; };
} catch (err) { } catch (err) {
errorMessage = `Failed to load config: ${err}`; errorMessage = `Failed to load config: ${err}`;
@@ -53,6 +55,7 @@
try { try {
await commands.saveClientConfig({ await commands.saveClientConfig({
api_base_url: form.api_base_url?.trim() || null, api_base_url: form.api_base_url?.trim() || null,
debug_mode: form.debug_mode,
}); });
successMessage = "Success. Restart to apply changes."; successMessage = "Success. Restart to apply changes.";
@@ -91,6 +94,15 @@
placeholder="https://api.friendolls.adamcv.com" placeholder="https://api.friendolls.adamcv.com"
/> />
</label> </label>
<label class="flex flex-row items-center gap-3 cursor-pointer">
<span class="text-sm">Debug Mode</span>
<input
type="checkbox"
class="checkbox checkbox-primary"
bind:checked={form.debug_mode}
/>
</label>
</div> </div>
{#if errorMessage} {#if errorMessage}

View File

@@ -1,4 +1,5 @@
<script lang="ts"> <script lang="ts">
import { onMount } from "svelte";
import { cursorPositionOnScreen } from "../../events/cursor"; import { cursorPositionOnScreen } from "../../events/cursor";
import { friendsCursorPositions } from "../../events/friend-cursor"; import { friendsCursorPositions } from "../../events/friend-cursor";
import { appData } from "../../events/app-data"; import { appData } from "../../events/app-data";
@@ -17,6 +18,13 @@
import PetMessageSend from "./components/pet-message-send.svelte"; import PetMessageSend from "./components/pet-message-send.svelte";
import type { UserBasicDto } from "$lib/bindings"; import type { UserBasicDto } from "$lib/bindings";
let debugMode = false;
onMount(async () => {
const config = await commands.getClientConfig();
debugMode = config.debug_mode;
});
function getFriend(friendId: string): UserBasicDto | undefined { function getFriend(friendId: string): UserBasicDto | undefined {
return ( return (
($appData?.friends ?? []).find((friend) => friend.friend?.id === friendId) ($appData?.friends ?? []).find((friend) => friend.friend?.id === friendId)
@@ -56,6 +64,7 @@
</Neko> </Neko>
{/if} {/if}
{/each} {/each}
{#if debugMode}
<div id="debug-bar"> <div id="debug-bar">
<DebugBar <DebugBar
isInteractive={$sceneInteractive} isInteractive={$sceneInteractive}
@@ -66,4 +75,5 @@
friendsPresenceStates={$friendsPresenceStates} friendsPresenceStates={$friendsPresenceStates}
/> />
</div> </div>
{/if}
</div> </div>