-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.vue
147 lines (120 loc) · 3.35 KB
/
app.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
<script setup lang="ts">
useTokens()
useSafe()
const { library, provider, account } = useWeb3()
const { onDisconnect } = useConnectors()
const { lastModal } = useModal()
const { safeAddress } = storeToRefs(useSafe())
const { fromWei } = useBignumber()
const { avoProvider } = useSafe()
const { isMobile, actualWidth } = useSidebar()
const { isAnnouncementBannerVisible } = useBanner()
const actualWidthInPx = computed(() => `${actualWidth.value ? actualWidth.value : undefined}px`)
const { refresh } = useAsyncData(
'pending-deposit',
async () => {
if (!safeAddress.value)
return '0'
const amountInWei = await avoProvider.send('eth_getBalance', [
safeAddress.value,
'pending-deposit',
])
return fromWei(amountInWei || '0', 18).toFixed()
},
{
immediate: true,
server: false,
watch: [safeAddress],
},
)
useScriptTag('https://app.chatwoot.com/packs/js/sdk.js', () => {
// @ts-expect-error
if (!window.chatwootSDK)
return
// @ts-expect-error
window.chatwootSettings = {
hideMessageBubble: true,
}
// @ts-expect-error
window.chatwootSDK.run({
websiteToken: 'pmgPtAUDhoeVv7h9nS2xk7PF',
baseUrl: 'https://app.chatwoot.com',
})
const originalOnMessage: ((event: MessageEvent) => void) | null = window.onmessage
window.onmessage = function (e) {
const trustedOrigins = [window.origin, 'https://app.chatwoot.com']
if (!trustedOrigins.includes(e.origin))
return
if (originalOnMessage)
originalOnMessage(e)
}
}, {
async: true,
defer: true,
immediate: true,
})
onMounted(() => {
(window as any).library = library
const hideAllTooltipsOnScroll = useThrottleFn(() => {
[...document.querySelectorAll('[data-tippy-root]')].forEach(e =>
// @ts-expect-error
e._tippy?.hide(),
)
}, 1000)
document.addEventListener('scroll', hideAllTooltipsOnScroll, true)
return () => document.removeEventListener('scroll', hideAllTooltipsOnScroll)
})
watchThrottled(provider, () => {
if (!provider.value)
return
provider.value.on('accountsChanged', async () => {
const userNonce = useCookie<string | null>(`nonce-${account.value}`)
if (lastModal.value?.id !== 'request-terms-signature' && !userNonce.value) {
const { success } = await openRequestTermsSignature()
if (!success)
onDisconnect()
}
})
}, {
throttle: 1000,
immediate: true,
})
useIntervalFn(refresh, 15000)
</script>
<template>
<Html :class="isMobile && actualWidth ? 'overflow-hidden' : ''">
<Body :class="isMobile && actualWidth ? 'overflow-hidden' : ''">
<BannerAnnouncement v-if="isAnnouncementBannerVisible" />
<div class="layout-wrapper h-full">
<Sidebar :wrapper-class="isAnnouncementBannerVisible ? 'mt-7.5' : ''" />
<NuxtLayout>
<NuxtLoadingIndicator color="#07A65D" :height="2" />
<NuxtPage />
</NuxtLayout>
</div>
<BannerNewVersion />
<BannerMultisigOnboard />
<Notifications />
<TransactionsQueue />
<Modals />
<ChatBubble />
</Body>
</Html>
</template>
<style>
#__nuxt {
width: 100%;
height: 100%;
}
.layout-wrapper {
transform: translateX(v-bind(actualWidthInPx));
@apply transition-transform
}
@screen sm {
.layout-wrapper {
margin-left: v-bind(actualWidthInPx);
transform: none;
@apply transition-[margin-left]
}
}
</style>