20260131
This commit is contained in:
@@ -21,12 +21,12 @@ export const getSettings = async (): Promise<SiteSettings> => {
|
||||
let fileFormats: string[] | undefined;
|
||||
if (data.file_formats) {
|
||||
if (Array.isArray(data.file_formats)) {
|
||||
fileFormats = data.file_formats.map((x: any) => String(x).trim().replace(/^\./, '').toLowerCase()).filter((x: string) => x);
|
||||
fileFormats = data.file_formats.map((x: any) => String(x).trim().toLowerCase()).filter((x: string) => x);
|
||||
} else if (typeof data.file_formats === 'string') {
|
||||
try {
|
||||
const parsed = JSON.parse(data.file_formats);
|
||||
if (Array.isArray(parsed)) {
|
||||
fileFormats = parsed.map((x: any) => String(x).trim().replace(/^\./, '').toLowerCase()).filter((x: string) => x);
|
||||
fileFormats = parsed.map((x: any) => String(x).trim().toLowerCase()).filter((x: string) => x);
|
||||
}
|
||||
} catch {
|
||||
// ignore parse error
|
||||
|
||||
@@ -292,8 +292,8 @@ const CreatePost: React.FC = () => {
|
||||
}
|
||||
const formats = settings?.fileFormats;
|
||||
if (formats && formats.length > 0) {
|
||||
const ext = file.name.split('.').pop()?.toLowerCase() || '';
|
||||
if (!ext || !formats.includes(ext)) {
|
||||
const mime = (file.type || '').toLowerCase();
|
||||
if (!mime || !formats.includes(mime)) {
|
||||
dispatchToast(
|
||||
<Toast>
|
||||
<ToastTitle>上传的文件类型不支持</ToastTitle>
|
||||
|
||||
Reference in New Issue
Block a user