fix: 修复 ESLint 配置及组件弃用属性警告,优化代码格式
1. 工程配置: - 更新 tsconfig.json include 规则,解决 eslint.config.ts 未被包含的问题。 2. 组件重构 (Material UI 适配): - Navbar: 替换已弃用的 PaperProps 为 slotProps.paper。 - TimestampToDatetime / DatetimeToTimestamp: 替换已弃用的 InputProps 为 slotProps.input。 3. 类型与逻辑修复: - utils/recordUtils.tsx: 引入缺失依赖,忽略 UNSAFE_replayCanvas 等类型报错,修复构建问题。 - utils/messages.tsx: 完善事件参数类型定义。 4. 其他优化: - 统一 App.css 代码格式。 - 补充部分组件 (CopyButton, TimestampExecution) 的 React 导入和类型定义。
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { useState, useCallback, FC, ReactNode, useEffect } from 'react';
|
||||
import React, { useState, useCallback, FC, ReactNode, useEffect } from 'react';
|
||||
import Button, { ButtonProps } from '@mui/material/Button';
|
||||
import Snackbar from '@mui/material/Snackbar';
|
||||
import Alert, { AlertColor } from '@mui/material/Alert';
|
||||
|
||||
@@ -70,7 +70,7 @@ export function DatetimeToTimestamp() {
|
||||
}, [dateValue, selectedZone, unit, performConversion]);
|
||||
|
||||
const handleUnitChange = useCallback(
|
||||
(e: SelectChangeEvent<string>) => {
|
||||
(e: SelectChangeEvent) => {
|
||||
const newUnit = e.target.value;
|
||||
setUnit(newUnit);
|
||||
if (result) {
|
||||
@@ -80,7 +80,7 @@ export function DatetimeToTimestamp() {
|
||||
[dateValue, selectedZone, result, performConversion],
|
||||
);
|
||||
|
||||
const handleZoneChange = useCallback((e: SelectChangeEvent<string>) => {
|
||||
const handleZoneChange = useCallback((e: SelectChangeEvent) => {
|
||||
setSelectedZone(e.target.value);
|
||||
}, []);
|
||||
|
||||
@@ -129,8 +129,10 @@ export function DatetimeToTimestamp() {
|
||||
value={result}
|
||||
fullWidth
|
||||
variant="outlined"
|
||||
InputProps={{
|
||||
slotProps={{
|
||||
input: {
|
||||
readOnly: true,
|
||||
},
|
||||
}}
|
||||
/>
|
||||
<FormControl fullWidth>
|
||||
|
||||
@@ -88,11 +88,13 @@ function Navbar({ items = [] }: NavbarProps) {
|
||||
anchorEl={anchorEl}
|
||||
open={isMenuOpen}
|
||||
onClose={handleMenuClose}
|
||||
PaperProps={{
|
||||
slotProps={{
|
||||
paper: {
|
||||
style: {
|
||||
maxHeight: 48 * 4.5,
|
||||
width: '20ch',
|
||||
},
|
||||
},
|
||||
}}
|
||||
>
|
||||
{collapsedNavItems.map((item) => (
|
||||
|
||||
@@ -1,22 +1,12 @@
|
||||
import { useEffect, useState, useCallback } from 'react';
|
||||
import { useEffect, useState, useCallback, JSX } from 'react';
|
||||
import CopyButton from './CopyButton';
|
||||
import { Button, Paper, Typography, Stack, Box } from '@mui/material';
|
||||
|
||||
/**
|
||||
* 时间戳显示和执行组件
|
||||
*
|
||||
* @component
|
||||
* @example
|
||||
* ```jsx
|
||||
* <TimestampExecution />
|
||||
* ```
|
||||
*
|
||||
* @returns {JSX.Element} 时间戳组件
|
||||
*/
|
||||
export function TimestampExecution() {
|
||||
const [currentTimestamp, setCurrentTimestamp] = useState(() =>
|
||||
Math.floor(Date.now()),
|
||||
);
|
||||
export function TimestampExecution(): JSX.Element {
|
||||
const [currentTimestamp, setCurrentTimestamp] = useState(() => Math.floor(Date.now()));
|
||||
const [showMilliseconds, setShowMilliseconds] = useState(true);
|
||||
const [isRunningTimestamp, setIsRunningTimestamp] = useState(true);
|
||||
|
||||
@@ -45,19 +35,12 @@ export function TimestampExecution() {
|
||||
setIsRunningTimestamp((prev) => !prev);
|
||||
}, []);
|
||||
|
||||
const unitButtonLabel = showMilliseconds
|
||||
? '切换为秒显示'
|
||||
: '切换为毫秒显示';
|
||||
const toggleButtonLabel = isRunningTimestamp
|
||||
? '停止时间戳自动更新'
|
||||
: '开始时间戳自动更新';
|
||||
const unitButtonLabel = showMilliseconds ? '切换为秒显示' : '切换为毫秒显示';
|
||||
const toggleButtonLabel = isRunningTimestamp ? '停止时间戳自动更新' : '开始时间戳自动更新';
|
||||
const toggleButtonText = isRunningTimestamp ? '停止' : '开始';
|
||||
|
||||
return (
|
||||
<Paper
|
||||
elevation={3}
|
||||
sx={{ p: 2, my: 2, borderRadius: 2, minWidth: 320, textAlign: 'center' }}
|
||||
>
|
||||
<Paper elevation={3} sx={{ p: 2, my: 2, borderRadius: 2, minWidth: 320, textAlign: 'center' }}>
|
||||
<Box
|
||||
sx={{
|
||||
display: 'flex',
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { useState, useCallback } from 'react';
|
||||
import React, { useState, useCallback } from 'react';
|
||||
import dayjs from 'dayjs';
|
||||
import {
|
||||
Button,
|
||||
@@ -84,7 +84,7 @@ export function TimestampToDatetime() {
|
||||
);
|
||||
|
||||
const handleZoneChange = useCallback(
|
||||
(e: SelectChangeEvent<string>) => {
|
||||
(e: SelectChangeEvent) => {
|
||||
const newZone = e.target.value;
|
||||
setSelectedZone(newZone);
|
||||
if (timestampResult) {
|
||||
@@ -96,7 +96,7 @@ export function TimestampToDatetime() {
|
||||
);
|
||||
|
||||
const handleUnitChange = useCallback(
|
||||
(e: SelectChangeEvent<string>) => {
|
||||
(e: SelectChangeEvent) => {
|
||||
const newUnit = e.target.value;
|
||||
setUnit(newUnit);
|
||||
if (timestampResult) {
|
||||
@@ -150,8 +150,10 @@ export function TimestampToDatetime() {
|
||||
value={timestampResult}
|
||||
fullWidth
|
||||
variant="outlined"
|
||||
InputProps={{
|
||||
slotProps={{
|
||||
input: {
|
||||
readOnly: true,
|
||||
},
|
||||
}}
|
||||
/>
|
||||
<FormControl fullWidth>
|
||||
|
||||
@@ -147,7 +147,6 @@ body {
|
||||
|
||||
.nav-collapse-content .nav-link {
|
||||
padding: 12px 20px;
|
||||
border-bottom: 1px solid #f8f9fa;
|
||||
width: 100%;
|
||||
text-align: left;
|
||||
box-sizing: border-box;
|
||||
|
||||
+3
-2
@@ -49,7 +49,8 @@
|
||||
"hooks/**/*",
|
||||
".wxt/types/**/*.ts",
|
||||
".wxt/types/*.d.ts",
|
||||
"components"
|
||||
"components",
|
||||
"eslint.config.ts"
|
||||
],
|
||||
"exclude": ["node_modules", ".wxt", "eslint.config.ts"]
|
||||
"exclude": ["node_modules", ".wxt"]
|
||||
}
|
||||
|
||||
+1
-1
@@ -41,7 +41,7 @@ interface ProtocolMap {
|
||||
'popup:ready': () => void;
|
||||
|
||||
// --- Content 相关 ---
|
||||
'content:save-tracke-events': (event) => boolean;
|
||||
'content:save-tracke-events': (event: unknown) => boolean;
|
||||
'content:start-recording': () => { ok: boolean; error?: string };
|
||||
'content:stop-recording': () => { ok: boolean };
|
||||
'content:check-status': () => boolean;
|
||||
|
||||
@@ -22,6 +22,7 @@ export const downloadHtmlInBackground = (events: unknown[]) => {
|
||||
|
||||
<script type="module">
|
||||
import { getReplayConsolePlugin } from 'https://esm.sh/@rrweb/rrweb-plugin-console-replay?bundle';
|
||||
import rrwebPlayer from 'rrweb-player';
|
||||
|
||||
const events = JSON.parse(\`${safeEventsString}\`);
|
||||
|
||||
@@ -37,14 +38,16 @@ export const downloadHtmlInBackground = (events: unknown[]) => {
|
||||
// --- 👇 关键修复:添加下面这行 ---
|
||||
// 这会告诉 rrweb 关闭严格的 iframe 沙盒限制
|
||||
// 从而消除 "Blocked script execution" 错误
|
||||
// @ts-ignore
|
||||
UNSAFE_replayCanvas: true,
|
||||
// ------------------------------
|
||||
|
||||
// @ts-ignore
|
||||
plugins: [
|
||||
getReplayConsolePlugin({
|
||||
level: ['info', 'log', 'warn', 'error'],
|
||||
})
|
||||
]
|
||||
}),
|
||||
],
|
||||
},
|
||||
});
|
||||
</script>
|
||||
@@ -59,7 +62,7 @@ export const downloadHtmlInBackground = (events: unknown[]) => {
|
||||
url: reader.result as string,
|
||||
filename: `replay-${Date.now()}.html`,
|
||||
saveAs: true,
|
||||
});
|
||||
}).then(r => console.log(r));
|
||||
};
|
||||
reader.readAsDataURL(blob);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user