1
1
<script lang =" ts" >
2
- import { goto } from " $app/navigation" ;
3
- import { Hero , IdentityCard } from " $lib/fragments" ;
4
- import type { GlobalState } from " $lib/global" ;
5
- import { Drawer } from " $lib/ui" ;
6
- import * as Button from " $lib/ui/Button" ;
7
- import { QrCodeIcon , Settings02Icon } from " @hugeicons/core-free-icons" ;
8
- import { HugeiconsIcon } from " @hugeicons/svelte" ;
9
- import { getCurrent } from " @tauri-apps/plugin-deep-link" ;
10
- import { type Snippet , getContext , onMount } from " svelte" ;
11
- import { onDestroy } from " svelte" ;
12
- import { Shadow } from " svelte-loading-spinners" ;
13
- import QrCode from " svelte-qrcode" ;
14
-
15
- let userData: Record <string , unknown > | undefined = $state (undefined );
16
- let greeting: string | undefined = $state (undefined );
17
- let ename: string | undefined = $state (undefined );
18
- let profileCreationStatus: " idle" | " loading" | " success" | " failed" =
19
- $state (" idle" );
20
-
21
- let shareQRdrawerOpen = $state (false );
22
- let statusInterval: ReturnType <typeof setInterval > | undefined =
23
- $state (undefined );
24
-
25
- function shareQR() {
26
- alert (" QR Code shared!" );
27
- shareQRdrawerOpen = false ;
28
- }
29
-
30
- async function retryProfileCreation() {
31
- try {
32
- await globalState .vaultController .retryProfileCreation ();
33
- } catch (error ) {
34
- console .error (" Retry failed:" , error );
2
+ import { goto } from " $app/navigation" ;
3
+ import { Hero , IdentityCard } from " $lib/fragments" ;
4
+ import type { GlobalState } from " $lib/global" ;
5
+ import { Drawer } from " $lib/ui" ;
6
+ import * as Button from " $lib/ui/Button" ;
7
+ import { QrCodeIcon , Settings02Icon } from " @hugeicons/core-free-icons" ;
8
+ import { HugeiconsIcon } from " @hugeicons/svelte" ;
9
+ import { getCurrent } from " @tauri-apps/plugin-deep-link" ;
10
+ import { type Snippet , getContext , onMount } from " svelte" ;
11
+ import { onDestroy } from " svelte" ;
12
+ import { Shadow } from " svelte-loading-spinners" ;
13
+ import QrCode from " svelte-qrcode" ;
14
+
15
+ let userData: Record <string , unknown > | undefined = $state (undefined );
16
+ let greeting: string | undefined = $state (undefined );
17
+ let ename: string | undefined = $state (undefined );
18
+ let profileCreationStatus: " idle" | " loading" | " success" | " failed" =
19
+ $state (" idle" );
20
+
21
+ let shareQRdrawerOpen = $state (false );
22
+ let statusInterval: ReturnType <typeof setInterval > | undefined =
23
+ $state (undefined );
24
+
25
+ function shareQR() {
26
+ alert (" QR Code shared!" );
27
+ shareQRdrawerOpen = false ;
35
28
}
36
- }
37
29
38
- const globalState = getContext <() => GlobalState >(" globalState" )();
30
+ async function retryProfileCreation() {
31
+ try {
32
+ await globalState .vaultController .retryProfileCreation ();
33
+ } catch (error ) {
34
+ console .error (" Retry failed:" , error );
35
+ }
36
+ }
39
37
40
- onMount (async () => {
41
- // Load initial data
42
- (async () => {
43
- const userInfo = await globalState .userController .user ;
44
- const isFake = await globalState .userController .isFake ;
45
- userData = { ... userInfo , isFake };
46
- const vaultData = await globalState .vaultController .vault ;
47
- ename = vaultData ?.ename ;
48
- })();
38
+ const globalState = getContext <() => GlobalState >(" globalState" )();
49
39
50
40
onMount (async () => {
51
41
// Load initial data
@@ -66,6 +56,18 @@ onMount(async () => {
66
56
// Check status periodically
67
57
statusInterval = setInterval (checkStatus , 1000 );
68
58
59
+ const urls = await getCurrent ();
60
+ if (urls && urls .length > 0 ) {
61
+ const url = urls [0 ];
62
+ const [scheme, ... rest] = url .split (" ://" );
63
+ const deeplink = rest .join (" ://" );
64
+ console .log (" URL" , scheme , deeplink );
65
+ if (scheme !== " w3ds" ) {
66
+ console .error (" unsupported url scheme" );
67
+ }
68
+ goto (` /scan-qr?${deeplink } ` );
69
+ }
70
+
69
71
const currentHour = new Date ().getHours ();
70
72
greeting =
71
73
currentHour > 17
@@ -75,32 +77,11 @@ onMount(async () => {
75
77
: " Good Morning" ;
76
78
});
77
79
78
- const urls = await getCurrent ();
79
- if (urls && urls .length > 0 ) {
80
- const url = urls [0 ];
81
- const [scheme, ... rest] = url .split (" ://" );
82
- const deeplink = rest .join (" ://" );
83
- console .log (" URL" , scheme , deeplink );
84
- if (scheme !== " w3ds" ) {
85
- console .error (" unsupported url scheme" );
80
+ onDestroy (() => {
81
+ if (statusInterval ) {
82
+ clearInterval (statusInterval );
86
83
}
87
- goto (` /scan-qr?${deeplink } ` );
88
- }
89
-
90
- const currentHour = new Date ().getHours ();
91
- greeting =
92
- currentHour > 17
93
- ? " Good Evening"
94
- : currentHour > 12
95
- ? " Good Afternoon"
96
- : " Good Morning" ;
97
- });
98
-
99
- onDestroy (() => {
100
- if (statusInterval ) {
101
- clearInterval (statusInterval );
102
- }
103
- });
84
+ });
104
85
</script >
105
86
106
87
{#if profileCreationStatus === " loading" }
0 commit comments