build: fix

This commit is contained in:
时瑾 2025-11-03 12:52:23 +08:00
parent 57eef9cb86
commit 9b1ea32808
No known key found for this signature in database
GPG Key ID: 023F70A1B8F8C196
29 changed files with 123 additions and 109 deletions

View File

@ -24,6 +24,15 @@ const commaDangle = val => {
val.rules.camelcase = 'off';
}
/** 未使用的变量强制报错 */
if (val?.rules?.['@typescript-eslint/no-unused-vars']) {
val.rules['@typescript-eslint/no-unused-vars'] = ['error', {
argsIgnorePattern: '^_',
varsIgnorePattern: '^_',
caughtErrorsIgnorePattern: '^_',
}];
}
return val;
};

View File

@ -0,0 +1,2 @@
import eslintConfig from '../eslint.config.mjs';
export default eslintConfig;

View File

@ -44,7 +44,7 @@ function DirectoryTree ({
// 直接使用 basePath 调用接口,移除 process.platform 判断
const list = await FileManager.listDirectories(basePath);
setDirs(list.map((item) => item.name));
} catch (error) {
} catch (_error) {
// ...error handling...
}
};

View File

@ -24,7 +24,7 @@ export default function Hitokoto () {
const text = `${data?.hitokoto} —— ${data?.from} ${data?.from_who}`;
navigator.clipboard.writeText(text);
toast.success('复制成功');
} catch (error) {
} catch (_error) {
toast.error('复制失败, 请手动复制');
}
};

View File

@ -34,7 +34,7 @@ const FileInput: React.FC<FileInputProps> = ({
if (file) {
await onChange(file);
}
} catch (error) {
} catch (_error) {
console.error(error);
} finally {
setIsLoading(false);
@ -49,7 +49,7 @@ const FileInput: React.FC<FileInputProps> = ({
try {
setIsLoading(true);
if (onDelete) await onDelete();
} catch (error) {
} catch (_error) {
console.error(error);
} finally {
setIsLoading(false);

View File

@ -51,7 +51,7 @@ const RealTimeLogs = () => {
.join('\r\n');
Xterm.current?.clear();
Xterm.current?.write(_data);
} catch (error) {
} catch (_error) {
console.error(error);
toast.error('获取实时日志失败');
}
@ -76,7 +76,7 @@ const RealTimeLogs = () => {
return () => {
source.close();
};
} catch (error) {
} catch (_error) {
toast.error('获取实时日志失败');
}
};

View File

@ -41,7 +41,7 @@ const NetworkFormModal = <T extends keyof OneBotConfig['network']>(
await updateNetworkConfig(field, data);
}
toast.success('保存配置成功');
} catch (error) {
} catch (_error) {
const msg = (error as Error).message;
toast.error(`保存配置失败: ${msg}`);

View File

@ -77,7 +77,7 @@ const OneBotApiDebug: React.FC<OneBotApiDebugProps> = (props) => {
});
toast.dismiss(r);
});
} catch (error) {
} catch (_error) {
toast.error('请求体 JSON 格式错误');
setIsFetching(false);
toast.dismiss(r);

View File

@ -15,7 +15,7 @@ import CodeEditor from '@/components/code_editor';
import type { CodeEditorRef } from '@/components/code_editor';
export interface OneBotSendModalProps {
sendMessage: (msg: string) => void
sendMessage: (msg: string) => void;
}
const OneBotSendModal: React.FC<OneBotSendModalProps> = (props) => {
@ -34,7 +34,7 @@ const OneBotSendModal: React.FC<OneBotSendModalProps> = (props) => {
sendMessage(msg);
toast.success('消息发送成功');
onClose();
} catch (error) {
} catch (_error) {
toast.error('消息发送失败');
}
},

View File

@ -7,36 +7,36 @@ const TailwindMarkdown: React.FC<{ content: string }> = ({ content }) => {
className='prose prose-sm sm:prose lg:prose-lg xl:prose-xl'
remarkPlugins={[remarkGfm]}
components={{
h1: ({ node, ...props }) => (
h1: ({ node: _node, ...props }) => (
<h1 className='text-2xl font-bold' {...props} />
),
h2: ({ node, ...props }) => (
h2: ({ node: _node, ...props }) => (
<h2 className='text-xl font-bold' {...props} />
),
h3: ({ node, ...props }) => (
h3: ({ node: _node, ...props }) => (
<h3 className='text-lg font-bold' {...props} />
),
p: ({ node, ...props }) => <p className='m-0' {...props} />,
a: ({ node, ...props }) => (
p: ({ node: _node, ...props }) => <p className='m-0' {...props} />,
a: ({ node: _node, ...props }) => (
<a
className='text-primary-500 inline-block hover:underline'
target='_blank'
{...props}
/>
),
ul: ({ node, ...props }) => (
ul: ({ node: _node, ...props }) => (
<ul className='list-disc list-inside' {...props} />
),
ol: ({ node, ...props }) => (
ol: ({ node: _node, ...props }) => (
<ol className='list-decimal list-inside' {...props} />
),
blockquote: ({ node, ...props }) => (
blockquote: ({ node: _node, ...props }) => (
<blockquote
className='border-l-4 border-default-300 pl-4 italic'
{...props}
/>
),
code: ({ node, ...props }) => (
code: ({ node: _node, ...props }) => (
<code className='bg-default-100 p-1 rounded text-xs' {...props} />
),
}}

View File

@ -18,7 +18,7 @@ export function TerminalInstance ({ id }: TerminalInstanceProps) {
if (parsed.data) {
termRef.current?.write(parsed.data);
}
} catch (e) {
} catch (_e) {
termRef.current?.write(data);
}
};

View File

@ -100,7 +100,7 @@ export default class WebUIManager {
const data = JSON.parse(event.data);
data.message = data.message.replace(/\n/g, '\r\n');
writer([data]);
} catch (error) {
} catch (_error) {
console.error(error);
}
};
@ -134,7 +134,7 @@ export default class WebUIManager {
try {
const data = JSON.parse(event.data) as SystemStatus;
writer(data);
} catch (error) {
} catch (_error) {
console.error(error);
}
};

View File

@ -27,7 +27,7 @@ export function useWebSocketDebug (url: string, token: string) {
try {
const data = JSON.parse(event.data);
messageHistory.unshift(data);
} catch (error) {
} catch (_error) {
toast.error('WebSocket 消息解析失败');
}
}, []),

View File

@ -59,7 +59,7 @@ const Layout: React.FC<{ children: React.ReactNode }> = ({ children }) => {
navigate('/web_login', { replace: true });
}
}
} catch (error) {
} catch (_error) {
navigate('/web_login', { replace: true });
}
};

View File

@ -42,7 +42,7 @@ const ChangePasswordCard = () => {
setToken('');
localStorage.removeItem(key.token);
navigate('/web_login');
} catch (error) {
} catch (_error) {
const msg = (error as Error).message;
toast.error(`修改失败: ${msg}`);
}

View File

@ -37,7 +37,7 @@ const LoginConfigCard = () => {
try {
await QQManager.setQuickLoginQQ(data.quickLoginQQ);
toast.success('保存成功');
} catch (error) {
} catch (_error) {
const msg = (error as Error).message;
toast.error(`保存失败: ${msg}`);
}
@ -47,7 +47,7 @@ const LoginConfigCard = () => {
try {
await refreshQuickLogin();
toast.success('刷新成功');
} catch (error) {
} catch (_error) {
const msg = (error as Error).message;
toast.error(`刷新失败: ${msg}`);
}

View File

@ -34,7 +34,7 @@ const OneBotConfigCard = () => {
try {
await saveConfigWithoutNetwork(data);
toast.success('保存成功');
} catch (error) {
} catch (_error) {
const msg = (error as Error).message;
toast.error(`保存失败: ${msg}`);
}
@ -45,7 +45,7 @@ const OneBotConfigCard = () => {
setLoading(true);
await refreshConfig();
if (shotTip) toast.success('刷新成功');
} catch (error) {
} catch (_error) {
const msg = (error as Error).message;
toast.error(`刷新失败: ${msg}`);
} finally {

View File

@ -53,7 +53,7 @@ const ServerConfigCard = () => {
try {
await WebUIManager.updateWebUIConfig(data);
toast.success('保存成功');
} catch (error) {
} catch (_error) {
const msg = (error as Error).message;
toast.error(`保存失败: ${msg}`);
}
@ -63,7 +63,7 @@ const ServerConfigCard = () => {
try {
await refreshConfig();
toast.success('刷新成功');
} catch (error) {
} catch (_error) {
const msg = (error as Error).message;
toast.error(`刷新失败: ${msg}`);
}

View File

@ -146,7 +146,7 @@ const ThemeConfigCard = () => {
await WebUIManager.setThemeConfig(data.theme);
toast.success('保存成功');
loadTheme();
} catch (error) {
} catch (_error) {
const msg = (error as Error).message;
toast.error(`保存失败: ${msg}`);
}
@ -156,7 +156,7 @@ const ThemeConfigCard = () => {
try {
await refreshAsync();
toast.success('刷新成功');
} catch (error) {
} catch (_error) {
const msg = (error as Error).message;
toast.error(`刷新失败: ${msg}`);
}

View File

@ -48,7 +48,7 @@ const WebUIConfigCard = () => {
setCustomIcons(data.customIcons);
setB64img(data.background);
toast.success('保存成功');
} catch (error) {
} catch (_error) {
const msg = (error as Error).message;
toast.error(`保存失败: ${msg}`);
}
@ -74,7 +74,7 @@ const WebUIConfigCard = () => {
setTimeout(() => {
window.location.reload();
}, 1000);
} catch (error) {
} catch (_error) {
toast.error('上传失败: ' + (error as Error).message);
}
}}
@ -85,7 +85,7 @@ const WebUIConfigCard = () => {
setTimeout(() => {
window.location.reload();
}, 1000);
} catch (error) {
} catch (_error) {
toast.error('删除失败: ' + (error as Error).message);
}
}}

View File

@ -86,7 +86,7 @@ export default function FileManagerPage () {
try {
const fileList = await FileManager.listFiles(currentPath);
setFiles(sortFiles(fileList, sortDescriptor));
} catch (error) {
} catch (_error) {
toast.error('加载文件列表失败');
setFiles([]);
}
@ -123,7 +123,7 @@ export default function FileManagerPage () {
try {
const content = await FileManager.readFile(filePath);
setEditingFile({ path: filePath, content });
} catch (error) {
} catch (_error) {
toast.error('打开文件失败');
}
};
@ -135,7 +135,7 @@ export default function FileManagerPage () {
toast.success('保存成功');
setEditingFile(null);
loadFiles();
} catch (error) {
} catch (_error) {
toast.error('保存失败');
}
};
@ -149,7 +149,7 @@ export default function FileManagerPage () {
await FileManager.delete(filePath);
toast.success('删除成功');
loadFiles();
} catch (error) {
} catch (_error) {
toast.error('删除失败');
}
},
@ -175,7 +175,7 @@ export default function FileManagerPage () {
setIsCreateModalOpen(false);
setNewFileName('');
loadFiles();
} catch (error) {
} catch (_error) {
toast.error((error as Error)?.message || '创建失败');
}
};
@ -198,7 +198,7 @@ export default function FileManagerPage () {
toast.success('批量删除成功');
setSelectedFiles(new Set());
loadFiles();
} catch (error) {
} catch (_error) {
toast.error('批量删除失败');
}
},
@ -217,7 +217,7 @@ export default function FileManagerPage () {
setRenamingFile('');
setNewFileName('');
loadFiles();
} catch (error) {
} catch (_error) {
toast.error('重命名失败');
}
};
@ -233,7 +233,7 @@ export default function FileManagerPage () {
setIsMoveModalOpen(false);
setMoveTargetPath('');
loadFiles();
} catch (error) {
} catch (_error) {
toast.error('移动失败');
}
};
@ -256,7 +256,7 @@ export default function FileManagerPage () {
setMoveTargetPath('');
setSelectedFiles(new Set());
loadFiles();
} catch (error) {
} catch (_error) {
toast.error('批量移动失败');
}
};
@ -313,7 +313,7 @@ export default function FileManagerPage () {
.then(() => {
loadFiles();
});
} catch (error) {
} catch (_error) {
toast.error('上传失败');
}
};

View File

@ -59,7 +59,7 @@ const QQInfo: React.FC = () => {
};
export interface SystemStatusCardProps {
setArchInfo: (arch: string | undefined) => void
setArchInfo: (arch: string | undefined) => void;
}
const SystemStatusCard: React.FC<SystemStatusCardProps> = ({ setArchInfo }) => {
const [systemStatus, setSystemStatus] = useState<SystemStatus>();
@ -68,7 +68,7 @@ const SystemStatusCard: React.FC<SystemStatusCardProps> = ({ setArchInfo }) => {
try {
const event = WebUIManager.getSystemStatus(setSystemStatus);
return event;
} catch (error) {
} catch (_error) {
toast.error('获取系统状态失败');
}
}, []);

View File

@ -29,7 +29,7 @@ export default function LogsPage () {
try {
const result = await WebUIManager.getLogContent(selectedLog);
setLogContent(result);
} catch (error) {
} catch (_error) {
const msg = (error as Error).message;
toast.error(`加载日志失败: ${msg}`);
} finally {

View File

@ -84,7 +84,7 @@ export default function NetworkPage () {
try {
await refreshConfig();
setLoading(false);
} catch (error) {
} catch (_error) {
const msg = (error as Error).message;
toast.error(`获取配置失败: ${msg}`);
@ -112,7 +112,7 @@ export default function NetworkPage () {
await deleteNetworkConfig(field, name);
toast.success('删除配置成功');
resolve();
} catch (error) {
} catch (_error) {
const msg = (error as Error).message;
toast.error(`删除配置失败: ${msg}`);
@ -134,7 +134,7 @@ export default function NetworkPage () {
try {
await enableNetworkConfig(field, name);
toast.success('更新配置成功');
} catch (error) {
} catch (_error) {
const msg = (error as Error).message;
toast.error(`更新配置失败: ${msg}`);
@ -150,7 +150,7 @@ export default function NetworkPage () {
try {
await enableDebugNetworkConfig(field, name);
toast.success('更新配置成功');
} catch (error) {
} catch (_error) {
const msg = (error as Error).message;
toast.error(`更新配置失败: ${msg}`);

View File

@ -75,7 +75,7 @@ export default function TerminalPage () {
}
}
setTabs((prev) => prev.filter((tab) => tab.id !== id));
} catch (error) {
} catch (_error) {
toast.error('关闭终端失败');
}
};

View File

@ -34,7 +34,7 @@ export default function QQLoginPage () {
setIsLoading(true);
try {
await QQManager.setQuickLogin(uinValue);
} catch (error) {
} catch (_error) {
const msg = (error as Error).message;
toast.error(`快速登录QQ失败: ${msg}`);
@ -60,7 +60,7 @@ export default function QQLoginPage () {
} else {
setQrcode(data.qrcodeurl);
}
} catch (error) {
} catch (_error) {
const msg = (error as Error).message;
toast.error(`获取二维码失败: ${msg}`);
@ -72,7 +72,7 @@ export default function QQLoginPage () {
try {
const data = await QQManager.getQQQuickLoginListNew();
setQQList(data);
} catch (error) {
} catch (_error) {
try {
const data = await QQManager.getQQQuickLoginList();
@ -81,7 +81,7 @@ export default function QQLoginPage () {
}));
setQQList(qqList);
} catch (error) {
} catch (_error) {
const msg = (error as Error).message;
toast.error(`获取QQ列表失败: ${msg}`);

View File

@ -39,7 +39,7 @@ export default function WebLoginPage () {
setLocalToken(data);
navigate('/qq_login', { replace: true });
}
} catch (error) {
} catch (_error) {
toast.error((error as Error).message);
} finally {
setIsLoading(false);

View File

@ -13,6 +13,9 @@
"dev:shell": "vite build --mode shell",
"dev:shell-analysis": "vite build --mode shell-analysis",
"dev:webui": "cd napcat.webui && npm run dev",
"tsc": "npm run tsc:core && npm run tsc:webui",
"tsc:core": "tsc --noEmit",
"tsc:webui": "cd napcat.webui && tsc --noEmit",
"lint": "npm run lint:core && npm run lint:webui",
"lint:fix": "npm run lint:fix:core && npm run lint:fix:webui",
"lint:core": "eslint src/**/*.{js,ts}",
@ -70,4 +73,4 @@
"silk-wasm": "^3.6.1",
"ws": "^8.18.3"
}
}
}

View File

@ -1,51 +1,51 @@
{
"compilerOptions": {
"target": "ES2021",
"useDefineForClassFields": true,
"module": "ESNext",
"lib": [
"ES2021",
"DOM",
"DOM.Iterable"
],
"skipLibCheck": true,
"moduleResolution": "Node",
"experimentalDecorators": true,
"allowImportingTsExtensions": false,
"allowSyntheticDefaultImports": true,
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "preserve",
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noFallthroughCasesInSwitch": true,
"sourceMap": true,
"paths": {
"@/*": [
"./src/*"
],
"@webapi/*": [
"./src/webui/src/*"
]
},
"noImplicitAny": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"strictBindCallApply": true,
"alwaysStrict": true,
"noImplicitThis": true,
"noImplicitReturns": true,
"noPropertyAccessFromIndexSignature": true,
"noUncheckedIndexedAccess": true,
"exactOptionalPropertyTypes": false,//
"forceConsistentCasingInFileNames": true,
"useUnknownInCatchVariables": true,
"noImplicitOverride": true,
"strictPropertyInitialization": true
"compilerOptions": {
"target": "ES2021",
"useDefineForClassFields": true,
"module": "ESNext",
"lib": [
"ES2021",
"DOM",
"DOM.Iterable"
],
"skipLibCheck": true,
"moduleResolution": "Node",
"experimentalDecorators": true,
"allowImportingTsExtensions": false,
"allowSyntheticDefaultImports": true,
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "preserve",
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noFallthroughCasesInSwitch": true,
"sourceMap": true,
"paths": {
"@/*": [
"./src/*"
],
"@webapi/*": [
"./src/webui/src/*"
]
},
"include": [
"src/**/*.ts"
]
}
"noImplicitAny": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"strictBindCallApply": true,
"alwaysStrict": true,
"noImplicitThis": true,
"noImplicitReturns": true,
"noPropertyAccessFromIndexSignature": true,
"noUncheckedIndexedAccess": true,
"exactOptionalPropertyTypes": false, //
"forceConsistentCasingInFileNames": true,
"useUnknownInCatchVariables": true,
"noImplicitOverride": true,
"strictPropertyInitialization": true
},
"include": [
"src/**/*.ts"
]
}