Skip to content

Commit 0ca38b4

Browse files
committed
fix: some ui syles
1 parent 4b7b8b1 commit 0ca38b4

File tree

9 files changed

+83
-11
lines changed

9 files changed

+83
-11
lines changed

src/components/layout/footer/FooterInfo.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ const FooterBottom = async () => {
169169
</>
170170
)}
171171

172-
<Divider />
172+
<Divider className="hidden md:inline" />
173173
<GatewayCount />
174174
{/* {!!lastVisitor && (
175175
<>

src/components/layout/footer/GatewayCount.tsx

+45
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
'use client'
22

33
import { useOnlineCount } from '~/atoms'
4+
import { ImpressionView } from '~/components/common/ImpressionTracker'
5+
import { Divider } from '~/components/ui/divider'
46
import { FloatPopover } from '~/components/ui/float-popover'
57
import { NumberSmoothTransition } from '~/components/ui/number-transition/NumberSmoothTransition'
8+
import { TrackerAction } from '~/constants/tracker'
69
import { usePageIsActive } from '~/hooks/common/use-is-active'
10+
import { useSocketIsConnect } from '~/socket/hooks'
711

812
export const GatewayCount = () => {
913
return (
@@ -26,10 +30,51 @@ export const GatewayCount = () => {
2630
WebSocket
2731
用于通知站点,站长在站点的实时活动,包括不限于文章的发布和更新。
2832
</p>
33+
34+
<Divider />
35+
36+
<p>
37+
当前 Socket 状态: <ConnectedIndicator />
38+
</p>
2939
</div>
3040
</FloatPopover>
3141
)
3242
}
43+
44+
const ConnectedIndicator = () => {
45+
const connected = useSocketIsConnect()
46+
47+
return (
48+
<div className="inline-flex items-center">
49+
<ImpressionView
50+
trackerMessage="socket_status"
51+
action={TrackerAction.Impression}
52+
/>
53+
{connected ? (
54+
<>
55+
<span className="absolute h-5 w-5">
56+
<span className="absolute inset-0 z-[3] m-auto flex h-3 w-3 rounded-full bg-green-400" />
57+
<span className="absolute inset-0 z-[2] m-auto flex h-4 w-4 rounded-full bg-green-300" />
58+
<span className="relative z-[1] flex h-5 w-5 rounded-full bg-green-200 center" />
59+
</span>
60+
61+
<span className="ml-6">已连接</span>
62+
</>
63+
) : (
64+
<>
65+
<span className="absolute h-5 w-5">
66+
<span className="absolute inset-0 z-[3] m-auto flex h-3 w-3 rounded-full bg-red-400" />
67+
<span className="absolute inset-0 z-[2] m-auto flex h-4 w-4 rounded-full bg-red-300" />
68+
<span className="relative z-[1] flex h-5 w-5 rounded-full bg-red-200 center" />
69+
</span>
70+
71+
<span className="ml-6">未连接</span>
72+
</>
73+
)}
74+
</div>
75+
)
76+
}
77+
3378
const GatewayCountTrigger = () => {
3479
const isActive = usePageIsActive()
3580
const count = useOnlineCount()

src/components/layout/header/internal/Activity.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ export const Activity = memo(() => {
130130
return (
131131
<>
132132
{!!media && (
133-
<m.div className="absolute bottom-0 left-0 top-0 z-[10] flex items-center md:left-[-30px]">
133+
<m.div className="absolute bottom-0 left-0 top-0 z-[10] flex items-center lg:left-[-30px]">
134134
<div className="absolute inset-0 z-[-1] flex center">
135135
<div className="h-6 w-6 animate-ping rounded-md ring-2 ring-uk-red-dark" />
136136
</div>
@@ -149,7 +149,7 @@ export const Activity = memo(() => {
149149
{!!appLabels[processName] && (
150150
<m.div
151151
key={processName}
152-
className="pointer-events-auto absolute bottom-0 right-0 top-0 z-[10] flex items-center overflow-hidden md:right-[-25px]"
152+
className="pointer-events-auto absolute bottom-0 right-0 top-0 z-[10] flex items-center overflow-hidden lg:right-[-25px]"
153153
initial={{
154154
opacity: 0.2,
155155
y: 15,

src/components/layout/header/internal/HeaderDrawerContent.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export const HeaderDrawerContent = () => {
1414
const { config } = useHeaderConfig()
1515

1616
return (
17-
<div className="mt-12 max-h-screen w-[90vw] space-y-4 overflow-auto pb-8 scrollbar-none">
17+
<div className="mt-12 max-h-screen w-[90vw] space-y-4 overflow-auto pb-24 scrollbar-none">
1818
{config.map((section, index) => {
1919
return (
2020
<m.section

src/components/widgets/comment/CommentBox/ActionBar.tsx

+6-4
Original file line numberDiff line numberDiff line change
@@ -115,10 +115,12 @@ export const CommentBoxActionBar: Component = ({ className }) => {
115115
'flex-1 select-none text-[10px] text-zinc-500 transition-opacity',
116116
)}
117117
>
118-
支持 <b>Markdown</b>{' '}
119-
<MLink href="https://docs.github.com/zh/get-started/writing-on-github/getting-started-with-writing-and-formatting-on-github/basic-writing-and-formatting-syntax">
120-
GFM
121-
</MLink>
118+
<span className="hidden md:inline">
119+
支持 <b>Markdown</b>{' '}
120+
<MLink href="https://docs.github.com/zh/get-started/writing-on-github/getting-started-with-writing-and-formatting-on-github/basic-writing-and-formatting-syntax">
121+
GFM
122+
</MLink>
123+
</span>
122124
<CommentBoxSlotProvider />
123125
</span>
124126
<AnimatePresence>

src/components/widgets/comment/CommentBox/UniversalTextArea.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ export const UniversalTextArea = () => {
7878
const EmojiButton = () => {
7979
return (
8080
<button
81-
className="ml-4 inline-flex h-5 w-5 translate-y-1 text-base center"
81+
className="ml-0 inline-flex h-5 w-5 translate-y-1 text-base center md:ml-4"
8282
onClick={preventDefault}
8383
>
8484
<i className="icon-[mingcute--emoji-2-line]" />

src/lib/link-parser.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { isDev } from './env'
1+
import { isClientSide, isDev } from './env'
22

33
export const isTweetUrl = (url: URL) => {
44
return url.hostname === 'twitter.com' && url.pathname.startsWith('/')
@@ -63,6 +63,7 @@ export const isCodesandboxUrl = (url: URL) => {
6363
}
6464

6565
export const isSelfArticleUrl = (url: URL) => {
66+
if (!isClientSide) return false
6667
if (isDev && url.hostname === 'innei.in') return true
6768
return (
6869
url.hostname === location.hostname &&

src/socket/hooks.ts

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { atom, useAtomValue } from 'jotai'
2+
3+
import { jotaiStore } from '~/lib/store'
4+
5+
const socketIsConnectAtom = atom(false)
6+
export const useSocketIsConnect = () => {
7+
return useAtomValue(socketIsConnectAtom)
8+
}
9+
10+
export const setSocketIsConnect = (value: boolean) => {
11+
jotaiStore.set(socketIsConnectAtom, value)
12+
}

src/socket/socket-client.ts

+13-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { GATEWAY_URL } from '~/constants/env'
99
import { isDev } from '~/lib/env'
1010

1111
import { eventHandler } from './handler'
12+
import { setSocketIsConnect } from './hooks'
1213

1314
class SocketClient {
1415
public socket!: Socket
@@ -33,6 +34,15 @@ class SocketClient {
3334
if (!this.socket) {
3435
return
3536
}
37+
38+
this.socket.on('connect', () => {
39+
setSocketIsConnect(true)
40+
})
41+
42+
this.socket.on('disconnect', () => {
43+
setSocketIsConnect(false)
44+
})
45+
3646
this.socket.close()
3747
this.socket.open()
3848
this.socket.on(
@@ -70,7 +80,9 @@ class SocketClient {
7080
}
7181
})
7282
}
83+
84+
static shared = new SocketClient()
7385
}
7486

75-
export const socketClient = new SocketClient()
87+
export const socketClient = SocketClient.shared
7688
export type TSocketClient = SocketClient

0 commit comments

Comments
 (0)