fix(剪贴板): 改进剪贴板操作的错误处理
在复制文本和图片到剪贴板时,捕获并返回更详细的错误信息 同时更新GlobalSnackbar组件,优化类型导入和消息显示
This commit is contained in:
@@ -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}
|
||||
</Alert>
|
||||
) : undefined}
|
||||
) : (
|
||||
<div>{message}</div>
|
||||
)}
|
||||
</Snackbar>
|
||||
</Portal>
|
||||
);
|
||||
@@ -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();
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user