Skip to content

Commit

Permalink
feat: debug local development page
Browse files Browse the repository at this point in the history
  • Loading branch information
l1xnan committed Mar 13, 2024
1 parent b45b591 commit 0c2f8c8
Show file tree
Hide file tree
Showing 6 changed files with 78 additions and 43 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"@tabler/icons-react": "^3.0.0",
"@tanstack/react-table": "^8.11.0",
"@tanstack/react-virtual": "^3.0.1",
"@tauri-apps/api": "2.0.0-beta.3",
"@tauri-apps/api": "2.0.0-beta.5",
"@tauri-apps/plugin-clipboard-manager": "2.0.0-beta.2",
"@tauri-apps/plugin-dialog": "2.0.0-beta.2",
"@tauri-apps/plugin-log": "2.0.0-beta.2",
Expand Down Expand Up @@ -81,7 +81,7 @@
"devDependencies": {
"@swc-jotai/debug-label": "^0.1.0",
"@swc-jotai/react-refresh": "^0.1.0",
"@tauri-apps/cli": "2.0.0-beta.5",
"@tauri-apps/cli": "2.0.0-beta.9",
"@types/node": "^20.11.5",
"@types/react": "^18.2.60",
"@types/react-dom": "^18.2.19",
Expand Down
80 changes: 40 additions & 40 deletions pnpm-lock.yaml

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

2 changes: 2 additions & 0 deletions src-tauri/capabilities/app.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
"updater:default",
"log:default",
"webview:default",
"webview:allow-create-webview",
"webview:allow-create-webview-window",
"shell:allow-open",
"clipboard-manager:allow-read",
"clipboard-manager:allow-write",
Expand Down
2 changes: 1 addition & 1 deletion src-tauri/tauri.conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"frontendDist": "../dist"
},
"app": {
"withGlobalTauri": false,
"withGlobalTauri": true,
"security": {
"csp": null
},
Expand Down
32 changes: 32 additions & 0 deletions src/pages/settings/AppSetting.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@ import SettingsIcon from '@mui/icons-material/Settings';
import { DialogClose } from '@radix-ui/react-dialog';
import { ReloadIcon } from '@radix-ui/react-icons';
import { getTauriVersion, getVersion } from '@tauri-apps/api/app';
import { WebviewWindow } from '@tauri-apps/api/webviewWindow';
import { relaunch } from '@tauri-apps/plugin-process';
import * as shell from '@tauri-apps/plugin-shell';
import { check } from '@tauri-apps/plugin-updater';
import { atom, useAtom } from 'jotai';
import { nanoid } from 'nanoid';
import { PropsWithChildren, useEffect, useState } from 'react';
import { useForm } from 'react-hook-form';
import { toast } from 'sonner';
Expand Down Expand Up @@ -38,6 +40,7 @@ import {
settingAtom,
useSettingStore,
} from '@/stores/setting';
import { isEmpty } from '@/utils';

const items = [
{
Expand Down Expand Up @@ -220,6 +223,9 @@ const UpdateForm = () => {
}
setLoading(false);
};

const debug = form.watch('debug');

return (
<>
<Form {...form}>
Expand Down Expand Up @@ -284,6 +290,32 @@ const UpdateForm = () => {
</Button>
</div>
</div>
<FormField
control={form.control}
name="debug"
render={({ field }) => (
<FormItem>
<FormLabel>Debug</FormLabel>
<FormDescription>Developer debugging</FormDescription>
<div className="flex flex-row">
<FormControl>
<Input placeholder="http://localhost:5173" {...field} />
</FormControl>
<Button
disabled={isEmpty(debug)}
onClick={async () => {
new WebviewWindow(nanoid(), {
url: debug,
title: `Debug-${debug}`,
});
}}
>
Open
</Button>
</div>
</FormItem>
)}
/>
</div>
<DialogFooter>
<DialogClose asChild>
Expand Down
1 change: 1 addition & 0 deletions src/stores/setting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export type SettingState = {
table_render: string;
auto_update?: boolean;
proxy?: string;
debug?: string;
csv?: CsvParam;
};

Expand Down

0 comments on commit 0c2f8c8

Please # to comment.