mirror of
https://github.com/woodchen-ink/nezha-dash-v1.git
synced 2025-07-18 09:31:55 +08:00
feat: forceUseSvgFlag
This commit is contained in:
parent
edd2404538
commit
704818d084
@ -5,7 +5,16 @@ import { useEffect, useState } from "react"
|
||||
export default function ServerFlag({ country_code, className }: { country_code: string; className?: string }) {
|
||||
const [supportsEmojiFlags, setSupportsEmojiFlags] = useState(false)
|
||||
|
||||
// @ts-expect-error ForceUseSvgFlag is a global variable
|
||||
const forceUseSvgFlag = window.ForceUseSvgFlag as boolean
|
||||
|
||||
useEffect(() => {
|
||||
if (forceUseSvgFlag) {
|
||||
// 如果环境变量要求直接使用 SVG,则无需检查 Emoji 支持
|
||||
setSupportsEmojiFlags(false)
|
||||
return
|
||||
}
|
||||
|
||||
const checkEmojiSupport = () => {
|
||||
const canvas = document.createElement("canvas")
|
||||
const ctx = canvas.getContext("2d")
|
||||
@ -27,7 +36,7 @@ export default function ServerFlag({ country_code, className }: { country_code:
|
||||
|
||||
return (
|
||||
<span className={cn("text-[12px] text-muted-foreground", className)}>
|
||||
{!supportsEmojiFlags ? <span className={`fi fi-${country_code}`} /> : getUnicodeFlagIcon(country_code)}
|
||||
{forceUseSvgFlag || !supportsEmojiFlags ? <span className={`fi fi-${country_code}`} /> : getUnicodeFlagIcon(country_code)}
|
||||
</span>
|
||||
)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user