新增私密信件格式和发信人不需要输密码

This commit is contained in:
Li1304553726 2025-12-01 11:10:32 +08:00
parent da7d02fd11
commit 78514cb093
3 changed files with 15 additions and 49 deletions

View File

@ -63,7 +63,7 @@ export function LetterCard({ letter }: LetterCardProps) {
)}
{letter.title}
{/* 印章样式的"密"字 */}
{!letter?.isPublic && (
{(
<div className=" bg-red-600 text-white px-2 py-1 flex justify-center items-center rounded-md text-base font-bold border-2 border-white shadow-md">
</div>

View File

@ -80,14 +80,17 @@ export function PostDetailProvider({
const { data: post, isLoading }: { data: PostDto; isLoading: boolean } = (
api.post.findFirst as any
).useQuery(queryParams, { enabled: Boolean(editId) });
const { data: staff } : { data: StaffDto}= api.staff.findFirst.useQuery(
const { data: staff }: { data: StaffDto } = api.staff.findFirst.useQuery(
{ where: { id: post?.authorId } },
{ enabled: !!post?.authorId }
);
const canSee = useMemo(() => {
if (hasSomePermissions(RolePerms.READ_ANY_POST)) {
return true;
} else if (post?.authorId === user?.id) {
// 如果当前用户是作者,直接允许查看
return true;
} else if (
post?.receivers?.map((receiver) => receiver.id)?.includes(user?.id)
) {

View File

@ -1,5 +1,4 @@
import React from "react";
import { Select } from "antd";
import { useEffect, useState } from "react";
export default function PublicOrNotSelector({
@ -17,57 +16,21 @@ export default function PublicOrNotSelector({
setIsBrowserSupported(browserVersion >= 87);
}, []);
const options = [
{ value: true, label: "公开" },
{ value: false, label: "私密" },
];
useEffect(() => {
// 如果当前值不是 false将其设置为 false
if (value !== false && onChange) {
onChange(false);
}
}, [value, onChange]);
// 处理 Antd Select 的 onChange
const handleAntdChange = (newValue) => {
if (onChange) {
onChange(newValue);
}
};
// 处理原生 select 的 onChange
const handleNativeChange = (e) => {
if (onChange) {
// 将字符串 "true"/"false" 转换为布尔值
onChange(e.target.value === "true");
}
};
if (isBrowserSupported) {
return (
<Select
value={value}
onChange={handleAntdChange}
style={{
width: 150,
}}>
{options.map((option) => (
<Select.Option
key={String(option.value)}
value={option.value}>
{option.label}
</Select.Option>
))}
</Select>
<div></div>
);
} else {
return (
<select
value={String(value)}
onChange={handleNativeChange}
style={{ width: 150, height: "32px", borderRadius: "2px" }}>
{options.map((option) => (
<option
key={String(option.value)}
value={String(option.value)}>
{option.label}
</option>
))}
</select>
<div></div>
);
}
}
}