mirror of
https://github.com/woodchen-ink/nezha-dash-v1.git
synced 2025-07-18 17:41:56 +08:00
feat: custom links
This commit is contained in:
parent
cbeed6b332
commit
6078c9f3e4
@ -62,16 +62,54 @@ function Header() {
|
|||||||
<p className="hidden text-sm font-medium opacity-40 md:block">{customDesc}</p>
|
<p className="hidden text-sm font-medium opacity-40 md:block">{customDesc}</p>
|
||||||
</section>
|
</section>
|
||||||
<section className="flex items-center gap-2">
|
<section className="flex items-center gap-2">
|
||||||
|
<div className="hidden sm:block">
|
||||||
|
<Links />
|
||||||
|
</div>
|
||||||
<DashboardLink />
|
<DashboardLink />
|
||||||
<LanguageSwitcher />
|
<LanguageSwitcher />
|
||||||
<ModeToggle />
|
<ModeToggle />
|
||||||
</section>
|
</section>
|
||||||
</section>
|
</section>
|
||||||
|
<div className="w-full justify-items-end sm:hidden mt-1">
|
||||||
|
<Links />
|
||||||
|
</div>
|
||||||
<Overview />
|
<Overview />
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type links = {
|
||||||
|
link: string
|
||||||
|
name: string
|
||||||
|
}
|
||||||
|
|
||||||
|
function Links() {
|
||||||
|
// @ts-expect-error CustomLinks is a global variable
|
||||||
|
const customLinks = window.CustomLinks as string
|
||||||
|
|
||||||
|
const links: links[] | null = customLinks ? JSON.parse(customLinks) : null
|
||||||
|
|
||||||
|
if (!links) return null
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="flex items-center gap-2 w-fit">
|
||||||
|
{links.map((link, index) => {
|
||||||
|
return (
|
||||||
|
<a
|
||||||
|
key={index}
|
||||||
|
href={link.link}
|
||||||
|
target="_blank"
|
||||||
|
rel="noopener noreferrer"
|
||||||
|
className="flex items-center gap-1 text-sm font-medium opacity-50 transition-opacity hover:opacity-100"
|
||||||
|
>
|
||||||
|
{link.name}
|
||||||
|
</a>
|
||||||
|
)
|
||||||
|
})}
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
function DashboardLink() {
|
function DashboardLink() {
|
||||||
const { t } = useTranslation()
|
const { t } = useTranslation()
|
||||||
const { data: userData } = useQuery({
|
const { data: userData } = useQuery({
|
||||||
@ -87,7 +125,7 @@ function DashboardLink() {
|
|||||||
href={"/dashboard"}
|
href={"/dashboard"}
|
||||||
target="_blank"
|
target="_blank"
|
||||||
rel="noopener noreferrer"
|
rel="noopener noreferrer"
|
||||||
className="flex items-center gap-1 text-sm font-medium opacity-50 transition-opacity hover:opacity-100"
|
className="flex items-center text-nowrap gap-1 text-sm font-medium opacity-50 transition-opacity hover:opacity-100"
|
||||||
>
|
>
|
||||||
{!userData?.data?.id && t("login")}
|
{!userData?.data?.id && t("login")}
|
||||||
{userData?.data?.id && t("dashboard")}
|
{userData?.data?.id && t("dashboard")}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user