mirror of
https://github.com/Buriburizaem0n/admin-frontend-domain.git
synced 2026-02-04 20:50:07 +00:00
feat: 修改用户名,简化代码
This commit is contained in:
@@ -6,8 +6,8 @@ import {
|
||||
} from "@/components/ui/dropdown-menu"
|
||||
import { Button, ButtonProps } from "@/components/ui/button"
|
||||
import { forwardRef, useState } from "react"
|
||||
import { useConfig } from "@/hooks/useConfig"
|
||||
import { ConfigEssential } from "@/types"
|
||||
import useSettings from "@/hooks/useSetting"
|
||||
import { ModelConfig } from "@/types"
|
||||
import { Check, Clipboard } from "lucide-react"
|
||||
import { toast } from "sonner"
|
||||
|
||||
@@ -21,15 +21,15 @@ enum OSTypes {
|
||||
|
||||
export const InstallCommandsMenu = forwardRef<HTMLButtonElement, ButtonProps>((props, ref) => {
|
||||
const [copy, setCopy] = useState(false);
|
||||
const { config } = useConfig();
|
||||
const settings = useSettings();
|
||||
const { t } = useTranslation();
|
||||
|
||||
const switchState = async (type: number) => {
|
||||
if (!copy) {
|
||||
try {
|
||||
setCopy(true);
|
||||
if (config)
|
||||
await navigator.clipboard.writeText(generateCommand(type, config));
|
||||
if (settings)
|
||||
await navigator.clipboard.writeText(generateCommand(type, settings));
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
toast(t("Error"), {
|
||||
@@ -60,7 +60,7 @@ export const InstallCommandsMenu = forwardRef<HTMLButtonElement, ButtonProps>((p
|
||||
);
|
||||
})
|
||||
|
||||
const generateCommand = (type: number, { agent_secret_key, install_host, listen_port, tls }: ConfigEssential) => {
|
||||
const generateCommand = (type: number, { agent_secret_key, install_host, listen_port, tls }: ModelConfig) => {
|
||||
if (!install_host)
|
||||
throw new Error("You have not specify the installed host.");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user