mirror of
https://github.com/woodchen-ink/certimate.git
synced 2025-07-19 01:41:55 +08:00
fix file select
This commit is contained in:
parent
eeae9b4405
commit
844347acf9
1
ui/dist/assets/index-Cg0yCJnh.css
vendored
Normal file
1
ui/dist/assets/index-Cg0yCJnh.css
vendored
Normal file
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
1
ui/dist/assets/index-Kh_0Jotc.css
vendored
1
ui/dist/assets/index-Kh_0Jotc.css
vendored
File diff suppressed because one or more lines are too long
4
ui/dist/index.html
vendored
4
ui/dist/index.html
vendored
@ -5,8 +5,8 @@
|
|||||||
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
|
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
<title>Certimate - Your Trusted SSL Automation Partner</title>
|
<title>Certimate - Your Trusted SSL Automation Partner</title>
|
||||||
<script type="module" crossorigin src="/assets/index-BKUIxIk5.js"></script>
|
<script type="module" crossorigin src="/assets/index-D8T6Buyh.js"></script>
|
||||||
<link rel="stylesheet" crossorigin href="/assets/index-Kh_0Jotc.css">
|
<link rel="stylesheet" crossorigin href="/assets/index-Cg0yCJnh.css">
|
||||||
</head>
|
</head>
|
||||||
<body class="bg-background">
|
<body class="bg-background">
|
||||||
<div id="root"></div>
|
<div id="root"></div>
|
||||||
|
@ -138,7 +138,7 @@ export function AccessEdit({
|
|||||||
<DialogTitle>{op == "add" ? "添加" : "编辑"}授权</DialogTitle>
|
<DialogTitle>{op == "add" ? "添加" : "编辑"}授权</DialogTitle>
|
||||||
</DialogHeader>
|
</DialogHeader>
|
||||||
<ScrollArea className="max-h-[80vh]">
|
<ScrollArea className="max-h-[80vh]">
|
||||||
<div className="container">
|
<div className="container py-3">
|
||||||
<Label>服务商</Label>
|
<Label>服务商</Label>
|
||||||
|
|
||||||
<Select
|
<Select
|
||||||
|
@ -18,6 +18,7 @@ import { save } from "@/repository/access";
|
|||||||
import { ClientResponseError } from "pocketbase";
|
import { ClientResponseError } from "pocketbase";
|
||||||
import { PbErrorData } from "@/domain/base";
|
import { PbErrorData } from "@/domain/base";
|
||||||
import { readFileContent } from "@/lib/file";
|
import { readFileContent } from "@/lib/file";
|
||||||
|
import { useRef, useState } from "react";
|
||||||
|
|
||||||
const AccessSSHForm = ({
|
const AccessSSHForm = ({
|
||||||
data,
|
data,
|
||||||
@ -27,6 +28,11 @@ const AccessSSHForm = ({
|
|||||||
onAfterReq: () => void;
|
onAfterReq: () => void;
|
||||||
}) => {
|
}) => {
|
||||||
const { addAccess, updateAccess } = useConfig();
|
const { addAccess, updateAccess } = useConfig();
|
||||||
|
|
||||||
|
const fileInputRef = useRef<HTMLInputElement | null>(null);
|
||||||
|
|
||||||
|
const [fileName, setFileName] = useState("");
|
||||||
|
|
||||||
const formSchema = z.object({
|
const formSchema = z.object({
|
||||||
id: z.string().optional(),
|
id: z.string().optional(),
|
||||||
name: z.string().min(1).max(64),
|
name: z.string().min(1).max(64),
|
||||||
@ -38,7 +44,7 @@ const AccessSSHForm = ({
|
|||||||
username: z.string().min(1).max(64),
|
username: z.string().min(1).max(64),
|
||||||
password: z.string().min(0).max(64),
|
password: z.string().min(0).max(64),
|
||||||
key: z.string().min(0).max(20480),
|
key: z.string().min(0).max(20480),
|
||||||
keyFile: z.string().optional(),
|
keyFile: z.any().optional(),
|
||||||
command: z.string().min(1).max(2048),
|
command: z.string().min(1).max(2048),
|
||||||
certPath: z.string().min(0).max(2048),
|
certPath: z.string().min(0).max(2048),
|
||||||
keyPath: z.string().min(0).max(2048),
|
keyPath: z.string().min(0).max(2048),
|
||||||
@ -127,9 +133,16 @@ const AccessSSHForm = ({
|
|||||||
) => {
|
) => {
|
||||||
const file = event.target.files?.[0];
|
const file = event.target.files?.[0];
|
||||||
if (!file) return;
|
if (!file) return;
|
||||||
const content = await readFileContent(file);
|
const savedFile = file;
|
||||||
|
setFileName(savedFile.name);
|
||||||
|
const content = await readFileContent(savedFile);
|
||||||
form.setValue("key", content);
|
form.setValue("key", content);
|
||||||
form.setValue("keyFile", "");
|
};
|
||||||
|
|
||||||
|
const handleSelectFileClick = () => {
|
||||||
|
console.log(fileInputRef.current);
|
||||||
|
|
||||||
|
fileInputRef.current?.click();
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@ -279,12 +292,26 @@ const AccessSSHForm = ({
|
|||||||
<FormItem>
|
<FormItem>
|
||||||
<FormLabel>Key(使用证书登录)</FormLabel>
|
<FormLabel>Key(使用证书登录)</FormLabel>
|
||||||
<FormControl>
|
<FormControl>
|
||||||
<Input
|
<div>
|
||||||
placeholder="请输入Key"
|
<Button
|
||||||
{...field}
|
type={"button"}
|
||||||
type="file"
|
variant={"secondary"}
|
||||||
onChange={handleFileChange}
|
size={"sm"}
|
||||||
/>
|
className="w-48"
|
||||||
|
onClick={handleSelectFileClick}
|
||||||
|
>
|
||||||
|
{fileName ? fileName : "请选择文件"}
|
||||||
|
</Button>
|
||||||
|
<Input
|
||||||
|
placeholder="请输入Key"
|
||||||
|
{...field}
|
||||||
|
ref={fileInputRef}
|
||||||
|
className="hidden"
|
||||||
|
hidden
|
||||||
|
type="file"
|
||||||
|
onChange={handleFileChange}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
</FormControl>
|
</FormControl>
|
||||||
|
|
||||||
<FormMessage />
|
<FormMessage />
|
||||||
|
@ -227,7 +227,7 @@ export default function Dashboard() {
|
|||||||
href="https://github.com/usual2970/certimate/releases"
|
href="https://github.com/usual2970/certimate/releases"
|
||||||
target="_blank"
|
target="_blank"
|
||||||
>
|
>
|
||||||
Certimate v0.1.2
|
Certimate v0.1.3
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user