diff --git a/components/GlobalSnackbar.tsx b/components/GlobalSnackbar.tsx
index 023319e..c1b3314 100644
--- a/components/GlobalSnackbar.tsx
+++ b/components/GlobalSnackbar.tsx
@@ -35,7 +35,14 @@
* ```
*/
-import React, { JSX, useState, createContext, useContext, type ReactNode } from 'react';
+import {
+ JSX,
+ useState,
+ createContext,
+ useContext,
+ type ReactNode,
+ type SyntheticEvent,
+} from 'react';
import { Snackbar, Alert, type SxProps, type Theme, alpha, Portal } from '@mui/material';
/**
@@ -181,7 +188,9 @@ export function GlobalSnackbar({
>
{message}
- ) : undefined}
+ ) : (
+
{message}
+ )}
);
@@ -210,7 +219,7 @@ export function useSnackbarState(initialOptions?: SnackbarOptions): UseSnackbarS
setOpen(false);
};
- const handleClose = (_event?: React.SyntheticEvent | Event, reason?: string) => {
+ const handleClose = (_event?: SyntheticEvent | Event, reason?: string) => {
if (reason === 'clickaway') return;
closeMessage();
};
diff --git a/utils/clipboard.ts b/utils/clipboard.ts
index 1c7eb7c..99ca0f6 100644
--- a/utils/clipboard.ts
+++ b/utils/clipboard.ts
@@ -10,8 +10,8 @@ export const copyTextToClipboard = async (text: string): Promise => {
.then(() => {
resolve(true);
})
- .catch(() => {
- reject(false);
+ .catch((error) => {
+ reject(new Error(`复制文本到剪贴板失败,错误: ${error?.message || 'Unknown error'}`));
});
});
};
@@ -32,8 +32,8 @@ export const copyImageToClipboard = async (blob: Blob): Promise => {
.then(() => {
resolve(true);
})
- .catch(() => {
- reject(false);
+ .catch((error) => {
+ reject(new Error(`复制图片到剪贴板失败,错误: ${error?.message || 'Unknown error'}`));
});
});
};