Skip to content

Commit 4b7b8b1

Browse files
committed
fix: iife
1 parent 06332ad commit 4b7b8b1

File tree

3 files changed

+29
-29
lines changed

3 files changed

+29
-29
lines changed

src/app/analyze.tsx

+26-26
Original file line numberDiff line numberDiff line change
@@ -25,34 +25,34 @@ export const Analyze = () => {
2525
return (
2626
<script
2727
dangerouslySetInnerHTML={{
28-
__html:
29-
`${function run() {
30-
document.addEventListener(
31-
'click',
32-
async (e) => {
33-
const $ = e.target as HTMLElement
34-
const event = $.dataset.event
35-
36-
if (event) {
37-
window.umami?.track(event, {
38-
type: 'click',
39-
})
40-
}
41-
},
42-
true,
43-
)
44-
45-
document.addEventListener('impression', async (e: any) => {
46-
const detail = e.detail as {
47-
action: TrackerAction
48-
label: string
28+
__html: `(${function () {
29+
document.addEventListener(
30+
'click',
31+
async (e) => {
32+
const $ = e.target as HTMLElement
33+
const event = $.dataset.event
34+
35+
if (event) {
36+
window.umami?.track(event, {
37+
type: 'click',
38+
})
4939
}
50-
51-
window.umami?.track(detail.label, {
52-
type: 'impression',
53-
})
40+
},
41+
true,
42+
)
43+
44+
document.addEventListener('impression', async (e: any) => {
45+
const detail = e.detail as {
46+
action: TrackerAction
47+
label: string
48+
}
49+
50+
console.log(detail, 'detail')
51+
window.umami?.track(detail.label, {
52+
type: 'impression',
5453
})
55-
}.toString()}\n` + `run();`,
54+
})
55+
}.toString()})();`,
5656
}}
5757
/>
5858
)

src/app/layout.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ const SayHi = () => {
149149
<script
150150
dangerouslySetInnerHTML={{
151151
__html: `var version = "${version}";
152-
${function info() {
152+
(${function () {
153153
console.log(
154154
`%c Mix Space %c https://github.com/mx-space `,
155155
'color: #fff; margin: 1em 0; padding: 5px 0; background: #2980b9;',
@@ -171,7 +171,7 @@ Stay hungry. Stay foolish. --Steve Jobs
171171
if (document.firstChild?.nodeType !== Node.COMMENT_NODE) {
172172
document.prepend(document.createComment(motto))
173173
}
174-
}.toString()}; info()`,
174+
}.toString()})();`,
175175
}}
176176
/>
177177
)

src/components/widgets/xlog/XLogSummary.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ const XLogSummary: FC<{
6767
Inner = null
6868
}
6969

70-
if (!cid || !data.data) {
70+
if (!cid || !data?.data) {
7171
Inner = null
7272
}
7373

0 commit comments

Comments
 (0)