refactor: 整体重构 (#1381)
* feat: pnpm new * Refactor build and release workflows, update dependencies Switch build scripts and workflows from npm to pnpm, update build and artifact paths, and simplify release workflow by removing version detection and changelog steps. Add new dependencies (silk-wasm, express, ws, node-pty-prebuilt-multiarch), update exports in package.json files, and add vite config for napcat-framework. Also, rename manifest.json for framework package and fix static asset copying in shell build config.
This commit is contained in:
1 parent
e2486606f9
commit
4360775eff
778 files changed
+2356
-26391
No files matched your search
@@ -0,0 +1,79 @@
|
||||
import { Tab, Tabs } from '@heroui/tabs';
|
||||
import { useRequest } from 'ahooks';
|
||||
import { useEffect, useState } from 'react';
|
||||
import toast from 'react-hot-toast';
|
||||
|
||||
import HistoryLogs from '@/components/log_com/history';
|
||||
import RealTimeLogs from '@/components/log_com/realtime';
|
||||
|
||||
import WebUIManager from '@/controllers/webui_manager';
|
||||
|
||||
export default function LogsPage () {
|
||||
const {
|
||||
data: logList,
|
||||
loading: logListLoading,
|
||||
error: logListError,
|
||||
refresh: refreshLogList,
|
||||
} = useRequest(WebUIManager.getLogList);
|
||||
const [selectedLog, setSelectedLog] = useState<string | null>(null);
|
||||
const [logContent, setLogContent] = useState<string | null>(null);
|
||||
const [logLoading, setLogLoading] = useState<boolean>(false);
|
||||
const onLogSelect = (name: string) => {
|
||||
setSelectedLog(name);
|
||||
};
|
||||
const onLoadLog = async () => {
|
||||
if (!selectedLog) {
|
||||
return;
|
||||
}
|
||||
setLogLoading(true);
|
||||
try {
|
||||
const result = await WebUIManager.getLogContent(selectedLog);
|
||||
setLogContent(result);
|
||||
} catch (error) {
|
||||
const msg = (error as Error).message;
|
||||
toast.error(`加载日志失败: ${msg}`);
|
||||
} finally {
|
||||
setLogLoading(false);
|
||||
}
|
||||
};
|
||||
useEffect(() => {
|
||||
if (logList && logList.length > 0) {
|
||||
setSelectedLog(logList[0]);
|
||||
}
|
||||
}, [logList]);
|
||||
useEffect(() => {
|
||||
if (selectedLog) {
|
||||
onLoadLog();
|
||||
}
|
||||
}, [selectedLog]);
|
||||
return (
|
||||
<div className='h-[calc(100vh_-_8rem)] flex flex-col gap-4 items-center pt-4 px-2'>
|
||||
<Tabs
|
||||
aria-label='Logs'
|
||||
classNames={{
|
||||
panel: 'w-full flex-1 h-full py-0 flex flex-col gap-4',
|
||||
base: 'flex-shrink-0 !h-fit',
|
||||
tabList: 'bg-opacity-50 backdrop-blur-sm',
|
||||
cursor: 'bg-opacity-60 backdrop-blur-sm',
|
||||
}}
|
||||
>
|
||||
<Tab title='实时日志'>
|
||||
<RealTimeLogs />
|
||||
</Tab>
|
||||
<Tab title='历史日志'>
|
||||
<HistoryLogs
|
||||
list={logList || []}
|
||||
onSelect={onLogSelect}
|
||||
selectedLog={selectedLog || undefined}
|
||||
refreshList={refreshLogList}
|
||||
refreshLog={onLoadLog}
|
||||
listLoading={logListLoading}
|
||||
logLoading={logLoading}
|
||||
listError={logListError}
|
||||
logContent={logContent || undefined}
|
||||
/>
|
||||
</Tab>
|
||||
</Tabs>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user