完成链接复制
This commit is contained in:
@@ -1,10 +1,10 @@
|
||||
'use client'
|
||||
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Checkbox } from "@/components/ui/checkbox";
|
||||
import {
|
||||
Dialog,
|
||||
DialogContent,
|
||||
DialogDescription,
|
||||
DialogFooter,
|
||||
DialogHeader,
|
||||
DialogTitle,
|
||||
@@ -65,6 +65,9 @@ export default function AddBlog({ children, onRefresh }: AddBlogProps) {
|
||||
<DialogContent className="sm:max-w-[425px]">
|
||||
<DialogHeader>
|
||||
<DialogTitle>添加博客</DialogTitle>
|
||||
<DialogDescription>
|
||||
保存前请确认博客信息填写正确、权限配置合理
|
||||
</DialogDescription>
|
||||
</DialogHeader>
|
||||
<div className="grid gap-4 py-4">
|
||||
<div className="grid grid-cols-4 items-center gap-4">
|
||||
|
||||
@@ -4,6 +4,7 @@ import React, { useState } from "react"
|
||||
import {
|
||||
Dialog,
|
||||
DialogContent,
|
||||
DialogDescription,
|
||||
DialogFooter,
|
||||
DialogHeader,
|
||||
DialogTitle,
|
||||
@@ -74,7 +75,10 @@ export default function BlogEdit({ id, children, onRefresh }: BlogEditProps) {
|
||||
</DialogTrigger>
|
||||
<DialogContent className="sm:max-w-[425px]">
|
||||
<DialogHeader>
|
||||
<DialogTitle>添加博客</DialogTitle>
|
||||
<DialogTitle>编辑博客</DialogTitle>
|
||||
<DialogDescription>
|
||||
保存前请确认博客信息填写正确、权限配置合理
|
||||
</DialogDescription>
|
||||
</DialogHeader>
|
||||
{
|
||||
blog && (
|
||||
|
||||
@@ -14,6 +14,7 @@ import {
|
||||
import { Input } from "@/components/ui/input"
|
||||
import { Label } from "@/components/ui/label"
|
||||
import { AdminApi } from "@/lib/api";
|
||||
import { base62 } from "@/lib/utils";
|
||||
import React, { useEffect, useState } from "react";
|
||||
import { toast } from "sonner";
|
||||
|
||||
@@ -45,6 +46,15 @@ export function SetPasswordDialog({ id, children }: SetPasswordDialogProps) {
|
||||
}
|
||||
}, [open])
|
||||
|
||||
const handleCopyShareURL = () => {
|
||||
if (!password) {
|
||||
return toast.warning('请先填写新密码');
|
||||
}
|
||||
const url = `${window.location.origin}/blog/${base62.encode(Buffer.from(id.replace(/-/g, ''), 'hex'))}?p=${password}`;
|
||||
navigator.clipboard.writeText(url);
|
||||
toast.success('分享链接复制成功,请点击保存按钮以提交新密码');
|
||||
}
|
||||
|
||||
return (
|
||||
<Dialog open={open} onOpenChange={v => setOpen(v)}>
|
||||
<form>
|
||||
@@ -55,7 +65,7 @@ export function SetPasswordDialog({ id, children }: SetPasswordDialogProps) {
|
||||
<DialogHeader>
|
||||
<DialogTitle>修改密码</DialogTitle>
|
||||
<DialogDescription>
|
||||
通过密码访问受保护的文章,需开启“受密码保护”权限
|
||||
通过密码访问受保护的文章,需开启“受密码保护”权限。注意复制URL需要填写完新密码后再点击
|
||||
</DialogDescription>
|
||||
</DialogHeader>
|
||||
<div className="grid gap-4">
|
||||
@@ -70,10 +80,17 @@ export function SetPasswordDialog({ id, children }: SetPasswordDialogProps) {
|
||||
</div>
|
||||
</div>
|
||||
<DialogFooter>
|
||||
<div className="w-full flex justify-between">
|
||||
<div>
|
||||
<Button variant='secondary' onClick={handleCopyShareURL}>复制URl</Button>
|
||||
</div>
|
||||
<div className="flex gap-5">
|
||||
<DialogClose asChild>
|
||||
<Button variant="outline">取消</Button>
|
||||
</DialogClose>
|
||||
<Button type="submit" onClick={handleSubmit}>保存</Button>
|
||||
</div>
|
||||
</div>
|
||||
</DialogFooter>
|
||||
</DialogContent>
|
||||
</form>
|
||||
|
||||
Reference in New Issue
Block a user