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