fix(frontend): install available updates with one click
This commit is contained in:
parent
9bdda0b392
commit
b345b708ca
|
|
@ -1,14 +1,14 @@
|
|||
/**
|
||||
* 更新源配置、远端版本检查和更新进度。
|
||||
*/
|
||||
import { useCallback, useEffect, useState } from 'react';
|
||||
import { useEffect, useState } from 'react';
|
||||
import { Banner, Button, Input, Space, Tag, Timeline, Typography } from '@douyinfe/semi-ui';
|
||||
import { IconRefresh, IconSearch } from '@douyinfe/semi-icons';
|
||||
import { IconDownload, IconRefresh } from '@douyinfe/semi-icons';
|
||||
import { api, errorMessage } from '../../../lib/http';
|
||||
import { useAuth } from '../../../lib/auth';
|
||||
import { useT } from '../../../lib/i18n';
|
||||
import { useInterval, useResource } from '../../../components/hooks';
|
||||
import { ErrorBanner, KeyValueList, SectionCard, toastError, toastSuccess } from '../../../components/ui';
|
||||
import { useResource } from '../../../components/hooks';
|
||||
import { ErrorBanner, KeyValueList, SectionCard, toastSuccess, toastWarning } from '../../../components/ui';
|
||||
import { formatDateTime, formatNumber, truncate } from '../../../lib/format';
|
||||
import { Hint, LoadingBlock, Mono, PermissionBanner } from './common';
|
||||
|
||||
|
|
@ -39,6 +39,15 @@ function jobStateColor(state) {
|
|||
return 'grey';
|
||||
}
|
||||
|
||||
function updateBlocker(t, status) {
|
||||
if (!status.installed) return t('update.blockedNotGitTree');
|
||||
if (status.diverged) return t('update.blockedDiverged', { ahead: status.ahead, behind: status.behind });
|
||||
if (!status.updateAvailable && !status.buildPending) return '';
|
||||
if (status.rollbackPending) return t('updateUi.rollbackPending');
|
||||
if (status.blockingChanges?.length) return t('update.blockedLocalEdits', { n: status.blockingChanges.length });
|
||||
return '';
|
||||
}
|
||||
|
||||
export default function UpdateSection() {
|
||||
const t = useT();
|
||||
const { hasPermission } = useAuth();
|
||||
|
|
@ -47,9 +56,10 @@ export default function UpdateSection() {
|
|||
|
||||
const consoleRes = useResource(() => api.get('/system/update'), [canRead], { skip: !canRead });
|
||||
const [job, setJob] = useState(null);
|
||||
const [checking, setChecking] = useState(false);
|
||||
const [action, setAction] = useState('');
|
||||
const [checkResult, setCheckResult] = useState(null);
|
||||
const [checkError, setCheckError] = useState(null);
|
||||
const [actionError, setActionError] = useState(null);
|
||||
const [activationBootID, setActivationBootID] = useState(null);
|
||||
const [sourceDraft, setSourceDraft] = useState(null);
|
||||
const [savingSource, setSavingSource] = useState(false);
|
||||
const [sourceError, setSourceError] = useState(null);
|
||||
|
|
@ -58,39 +68,105 @@ export default function UpdateSection() {
|
|||
if (consoleRes.data) setJob(consoleRes.data.job || null);
|
||||
}, [consoleRes.data]);
|
||||
|
||||
const pollJob = useCallback(async () => {
|
||||
try {
|
||||
const payload = await api.get('/system/update/job');
|
||||
if (payload?.job) setJob(payload.job);
|
||||
} catch (error) {
|
||||
/* 轮询失败不打断页面,下一次继续 */
|
||||
}
|
||||
}, []);
|
||||
|
||||
const running = job?.state === 'running';
|
||||
const restarting = job?.state === 'succeeded' && job.restartRequested;
|
||||
const watchedJob = running || restarting ? job.id : null;
|
||||
const previousBootID = activationBootID || consoleRes.data?.bootID;
|
||||
const targetCommit = job?.result?.toCommit;
|
||||
const reloadStatus = consoleRes.reload;
|
||||
const needsRestart = consoleRes.data?.needsRestart;
|
||||
const source = consoleRes.data?.source;
|
||||
const sourceRepo = source?.repo || '';
|
||||
const sourceValue = sourceDraft ?? sourceRepo;
|
||||
const sourceChanged = sourceValue.trim() !== sourceRepo;
|
||||
const sourceBusy = savingSource || checking || running || consoleRes.loading;
|
||||
useInterval(pollJob, running ? 2000 : 0);
|
||||
const busy = Boolean(action || running || restarting);
|
||||
const sourceBusy = savingSource || busy || consoleRes.loading;
|
||||
|
||||
const check = async () => {
|
||||
if (!canManage || checking || savingSource) return;
|
||||
setChecking(true);
|
||||
setCheckError(null);
|
||||
setCheckResult(null);
|
||||
try {
|
||||
const payload = await api.post('/system/update/check', {});
|
||||
setCheckResult(payload?.status || null);
|
||||
if (payload?.status && !payload.status.checkError) {
|
||||
toastSuccess(t('updateUi.checkOk', null, '已获取远端版本信息'));
|
||||
useEffect(() => {
|
||||
if (!watchedJob) return;
|
||||
let cancelled = false;
|
||||
let timer;
|
||||
const poll = async () => {
|
||||
try {
|
||||
const { job: latest } = await api.get('/system/update/job', undefined, { timeout: 5000 });
|
||||
if (cancelled) return;
|
||||
if (latest?.id === watchedJob) {
|
||||
setJob(latest);
|
||||
if (latest.state !== 'running' && !latest.restartRequested) {
|
||||
setCheckResult(null);
|
||||
if (latest.state === 'succeeded') {
|
||||
if (latest.result?.needsRestart) toastWarning(t('update.needsRestartToast'));
|
||||
else toastSuccess(t('update.jobDoneToast'));
|
||||
}
|
||||
reloadStatus({ silent: true });
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
// The new process starts with an empty job list. Confirm the
|
||||
// new boot before reloading the frontend bundle.
|
||||
const status = await api.get('/system/update', undefined, { timeout: 5000 });
|
||||
if (cancelled) return;
|
||||
const newBoot = previousBootID && status.bootID && status.bootID !== previousBootID;
|
||||
const matchesBuild = !targetCommit || !status.buildRevision || status.buildRevision.startsWith(targetCommit);
|
||||
if (newBoot && matchesBuild && !status.needsRestart) {
|
||||
window.location.reload();
|
||||
return;
|
||||
}
|
||||
}
|
||||
} catch {
|
||||
// Temporary connection failures during a restart are expected.
|
||||
}
|
||||
if (!cancelled) timer = setTimeout(poll, 2000);
|
||||
};
|
||||
poll();
|
||||
return () => {
|
||||
cancelled = true;
|
||||
clearTimeout(timer);
|
||||
};
|
||||
}, [watchedJob, previousBootID, targetCommit, reloadStatus, t]);
|
||||
|
||||
const update = async () => {
|
||||
if (!canManage || sourceBusy || sourceChanged) return;
|
||||
setAction('checking');
|
||||
setActionError(null);
|
||||
setCheckResult(null);
|
||||
let applyRequested = false;
|
||||
try {
|
||||
const { status } = await api.post('/system/update/check', {});
|
||||
if (!status) throw new Error(t('updateUi.statusMissing'));
|
||||
setCheckResult(status);
|
||||
if (status.checkError) return;
|
||||
|
||||
const blocker = updateBlocker(t, status);
|
||||
if (blocker) {
|
||||
setActionError(new Error(blocker));
|
||||
return;
|
||||
}
|
||||
if (!status.updateAvailable && !status.buildPending) {
|
||||
if (needsRestart) toastWarning(t('update.needsRestartToast'));
|
||||
else if (status.ahead > 0) toastSuccess(t('updateUi.noNewerVersion'));
|
||||
else toastSuccess(t('updateUi.currentVersion'));
|
||||
return;
|
||||
}
|
||||
|
||||
applyRequested = true;
|
||||
setAction('starting');
|
||||
const restart = Boolean(consoleRes.data?.autoRestart ?? consoleRes.data?.canRestart);
|
||||
const response = await api.post('/system/update/apply', { restart });
|
||||
if (!response?.job_id) throw new Error(t('updateUi.jobMissing'));
|
||||
setActivationBootID(response.bootID || null);
|
||||
setJob({ id: response.job_id, kind: 'apply', state: response.state || 'running', restartRequested: restart });
|
||||
} catch (error) {
|
||||
setCheckError(error);
|
||||
toastError(t('update.checkFailed', { reason: errorMessage(error) }, errorMessage(error)));
|
||||
const existingJob = error.status === 409 && error.payload?.job;
|
||||
if (applyRequested && existingJob?.id) {
|
||||
setActivationBootID(error.payload.bootID || null);
|
||||
setJob(existingJob);
|
||||
return;
|
||||
}
|
||||
setActionError(new Error(t(applyRequested ? 'update.applyFailed' : 'update.checkFailed', { reason: errorMessage(error) })));
|
||||
if (applyRequested) reloadStatus({ silent: true });
|
||||
} finally {
|
||||
setChecking(false);
|
||||
setAction('');
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -107,7 +183,7 @@ export default function UpdateSection() {
|
|||
consoleRes.setData(previous => ({ ...previous, source: payload.source }));
|
||||
setSourceDraft(null);
|
||||
setCheckResult(null);
|
||||
setCheckError(null);
|
||||
setActionError(null);
|
||||
toastSuccess(t('update.sourceSaveOk', null, '更新源已保存'));
|
||||
} catch (error) {
|
||||
setSourceError(error);
|
||||
|
|
@ -122,7 +198,6 @@ export default function UpdateSection() {
|
|||
if (consoleRes.loading && !consoleRes.data) return <LoadingBlock rows={6} />;
|
||||
|
||||
const snapshot = checkResult || consoleRes.data?.status || {};
|
||||
const needsRestart = consoleRes.data?.needsRestart;
|
||||
const binaryBuiltAt = consoleRes.data?.binaryBuiltAt;
|
||||
|
||||
const facts = [
|
||||
|
|
@ -148,35 +223,36 @@ export default function UpdateSection() {
|
|||
{ label: t('updateUi.blockingChanges', null, '阻止更新的文件数'), value: formatNumber((snapshot.blockingChanges || []).length) }
|
||||
];
|
||||
|
||||
const incoming = Array.isArray(snapshot.incoming) ? snapshot.incoming : [];
|
||||
const incoming = Array.isArray(checkResult?.incoming) ? checkResult.incoming : [];
|
||||
|
||||
return (
|
||||
<>
|
||||
<ErrorBanner error={consoleRes.error} onRetry={consoleRes.reload} />
|
||||
<SectionCard
|
||||
title={t('update.installTitle', null, '安装信息')}
|
||||
description={t('updateUi.pageHint', null, '查看本机安装和更新进度,管理更新源并检查远端版本。')}
|
||||
description={t('updateUi.pageHint')}
|
||||
extra={(
|
||||
<Space>
|
||||
<Button icon={<IconRefresh />} onClick={consoleRes.reload} loading={consoleRes.loading} disabled={savingSource || checking}>
|
||||
<Button icon={<IconRefresh />} onClick={() => reloadStatus()} loading={consoleRes.loading} disabled={savingSource || busy}>
|
||||
{t('common.refresh', null, '刷新')}
|
||||
</Button>
|
||||
<Button
|
||||
theme="solid"
|
||||
type="primary"
|
||||
icon={<IconSearch />}
|
||||
loading={checking}
|
||||
disabled={!canManage || savingSource}
|
||||
onClick={check}
|
||||
icon={<IconDownload aria-hidden="true" />}
|
||||
loading={Boolean(action)}
|
||||
disabled={!canManage || sourceBusy || sourceChanged}
|
||||
onClick={update}
|
||||
>
|
||||
{t('update.checkBtn', null, '检查更新')}
|
||||
{t(action === 'checking' ? 'update.checking' : action === 'starting' ? 'updateUi.starting' : 'updateUi.updateButton')}
|
||||
</Button>
|
||||
</Space>
|
||||
)}
|
||||
>
|
||||
{!canManage && (
|
||||
<Hint>{t('update.checkPermissionHint', null, '检查更新会访问远端仓库,需要 update:apply 权限。')}</Hint>
|
||||
<Hint>{t('updateUi.updatePermission')}</Hint>
|
||||
)}
|
||||
{sourceChanged && <Hint>{t('updateUi.saveSourceFirst')}</Hint>}
|
||||
<KeyValueList items={facts} columns={3} />
|
||||
{snapshot.goToolchain && (
|
||||
<Hint>{t('updateUi.toolchainPath', null, 'Go 工具链路径')} <Mono>{snapshot.goToolchain}</Mono></Hint>
|
||||
|
|
@ -220,8 +296,8 @@ export default function UpdateSection() {
|
|||
)}
|
||||
|
||||
<SectionCard title={t('update.remoteTitle', null, '远端版本')}>
|
||||
<ErrorBanner error={checkError} onRetry={check} />
|
||||
{!checkResult && !checkError && (
|
||||
<ErrorBanner error={actionError} onRetry={canManage && !sourceBusy && !sourceChanged ? update : undefined} />
|
||||
{!checkResult && !actionError && (
|
||||
<Text type="tertiary">{t('updateUi.versionUnchecked', null, '尚未检查远端版本。')}</Text>
|
||||
)}
|
||||
{checkResult && (
|
||||
|
|
@ -235,11 +311,14 @@ export default function UpdateSection() {
|
|||
/>
|
||||
) : (
|
||||
<Space wrap spacing={8}>
|
||||
<Tag size="small" color={checkResult.updateAvailable ? 'amber' : 'green'}>
|
||||
{checkResult.updateAvailable
|
||||
? t('update.behindCount', { n: checkResult.behind }, `落后 ${checkResult.behind} 个提交`)
|
||||
: t('update.upToDate', { commit: shortCommit(checkResult.commit) }, '已是最新')}
|
||||
</Tag>
|
||||
{checkResult.installed && (
|
||||
<Tag size="small" color={checkResult.updateAvailable || checkResult.buildPending || needsRestart ? 'amber' : 'green'}>
|
||||
{checkResult.updateAvailable ? t('update.behindCount', { n: checkResult.behind })
|
||||
: checkResult.buildPending ? t('updateUi.buildPending')
|
||||
: needsRestart ? t('update.restartNeeded')
|
||||
: t(checkResult.ahead > 0 ? 'updateUi.noNewerVersion' : 'updateUi.currentVersion')}
|
||||
</Tag>
|
||||
)}
|
||||
{checkResult.ahead > 0 && (
|
||||
<Tag size="small" color="blue">{t('update.aheadCount', { n: checkResult.ahead }, `领先 ${checkResult.ahead} 个提交`)}</Tag>
|
||||
)}
|
||||
|
|
@ -260,8 +339,8 @@ export default function UpdateSection() {
|
|||
</li>
|
||||
))}
|
||||
</ul>
|
||||
{checkResult.incomingTotal > incoming.length && (
|
||||
<Hint>{t('update.incomingTruncated', { total: checkResult.incomingTotal, shown: Math.min(10, incoming.length) }, `共 ${checkResult.incomingTotal} 个提交,仅显示前 ${incoming.length} 个`)}</Hint>
|
||||
{checkResult.incomingTotal > Math.min(10, incoming.length) && (
|
||||
<Hint>{t('update.incomingTruncated', { total: checkResult.incomingTotal, shown: Math.min(10, incoming.length) })}</Hint>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
|
|
@ -273,6 +352,9 @@ export default function UpdateSection() {
|
|||
title={t('update.jobTitle', null, '更新任务进度')}
|
||||
extra={job ? <Tag size="small" color={jobStateColor(job.state)}>{jobStateLabel(t, job.state)}</Tag> : null}
|
||||
>
|
||||
{restarting && <Hint>{t('update.restartRequestedToast')}</Hint>}
|
||||
{needsRestart && !busy && <Hint>{t('update.needsRestartToast')}</Hint>}
|
||||
{snapshot.buildPending && !busy && <Hint>{t('updateUi.resumeBuild')}</Hint>}
|
||||
{!job && <Text type="tertiary">{t('update.noJob', null, '暂无更新任务记录。')}</Text>}
|
||||
{job && (
|
||||
<>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,116 @@
|
|||
import { expect, test, UI_PERMISSIONS, visit } from './fixtures.mjs';
|
||||
|
||||
const statusPath = '/api/system/update';
|
||||
const checkPath = statusPath + '/check';
|
||||
const applyPath = statusPath + '/apply';
|
||||
const jobPath = statusPath + '/job';
|
||||
const currentCommit = 'ab123456';
|
||||
const nextCommit = 'cd123456';
|
||||
const local = { installed: true, canBuild: true, commit: currentCommit };
|
||||
const available = { ...local, remoteCommit: nextCommit, updateAvailable: true, behind: 1 };
|
||||
const running = { id: 'fixture-update', kind: 'apply', state: 'running' };
|
||||
|
||||
test.use({ appPermissions: [...UI_PERMISSIONS, 'update:apply'] });
|
||||
|
||||
async function openUpdate(page) {
|
||||
const main = await visit(page, 'settings?section=update');
|
||||
await expect(main.getByRole('button', { name: '检查更新', exact: true })).toHaveCount(0);
|
||||
return main;
|
||||
}
|
||||
|
||||
test('Update checks the configured source and reports when the versions match', async ({ page, mockApi }) => {
|
||||
mockApi.respond('GET', statusPath, { json: { status: local } });
|
||||
mockApi.respond('POST', checkPath, { json: { status: { ...local, remoteCommit: currentCommit } } });
|
||||
const main = await openUpdate(page);
|
||||
expect(mockApi.writes()).toEqual([]);
|
||||
await main.getByRole('button', { name: '更新', exact: true }).click();
|
||||
await expect(main.getByText('已是最新版', { exact: true })).toBeVisible();
|
||||
expect(mockApi.writes().map(entry => entry.path)).toEqual([checkPath]);
|
||||
});
|
||||
|
||||
test('Update starts a single job and refreshes local status after it builds', async ({ page, mockApi }) => {
|
||||
let completed = false;
|
||||
const succeeded = { ...running, state: 'succeeded', result: {
|
||||
fromCommit: currentCommit, toCommit: nextCommit, binaryBuilt: true, needsRestart: true
|
||||
} };
|
||||
mockApi.respond('GET', statusPath, () => ({ json: {
|
||||
status: completed ? { ...local, commit: nextCommit } : local,
|
||||
job: completed ? succeeded : null,
|
||||
canRestart: false,
|
||||
needsRestart: completed
|
||||
} }));
|
||||
mockApi.respond('POST', checkPath, { json: { status: available } });
|
||||
mockApi.respond('POST', applyPath, { status: 202, json: { job_id: running.id, state: running.state } });
|
||||
mockApi.respond('GET', jobPath, () => ({ json: { job: completed ? succeeded : running } }));
|
||||
const main = await openUpdate(page);
|
||||
const update = main.getByRole('button', { name: '更新', exact: true });
|
||||
await update.click();
|
||||
await expect(main.getByText('进行中', { exact: true })).toBeVisible();
|
||||
await expect(update).toBeDisabled();
|
||||
expect(mockApi.writes().map(({ path, body }) => [path, body])).toEqual([
|
||||
[checkPath, {}],
|
||||
[applyPath, { restart: false }]
|
||||
]);
|
||||
completed = true;
|
||||
await expect(main.getByText('已完成', { exact: true })).toBeVisible();
|
||||
await expect(main.getByText('二进制已换新,重启后才会生效', { exact: true })).toBeVisible();
|
||||
await expect(update).toBeEnabled();
|
||||
});
|
||||
|
||||
test('Update reloads the page after the new service boot answers', async ({ page, mockApi }) => {
|
||||
let restarted = false;
|
||||
mockApi.respond('GET', statusPath, () => ({ json: {
|
||||
status: { ...local, commit: restarted ? nextCommit : currentCommit },
|
||||
buildRevision: restarted ? nextCommit + 'deadbeef' : currentCommit,
|
||||
bootID: restarted ? 'boot-new' : 'boot-old',
|
||||
autoRestart: true
|
||||
} }));
|
||||
mockApi.respond('POST', checkPath, { json: { status: available } });
|
||||
mockApi.respond('POST', applyPath, { status: 202, json: {
|
||||
job_id: running.id, state: running.state, bootID: 'boot-old'
|
||||
} });
|
||||
mockApi.respond('GET', jobPath, () => ({ json: { job: restarted ? null : running } }));
|
||||
const main = await openUpdate(page);
|
||||
await main.getByRole('button', { name: '更新', exact: true }).click();
|
||||
await expect(main.getByText('进行中', { exact: true })).toBeVisible();
|
||||
expect(mockApi.calls('POST', applyPath)[0].body).toEqual({ restart: true });
|
||||
restarted = true;
|
||||
await expect(main.getByText('还没有更新记录', { exact: true })).toBeVisible();
|
||||
await expect(main.getByText(nextCommit + 'dead', { exact: true })).toBeVisible();
|
||||
expect(mockApi.calls('POST', applyPath)).toHaveLength(1);
|
||||
});
|
||||
|
||||
test('Update reports fetch failures and blocked installs without submitting a job', async ({ page, mockApi }) => {
|
||||
mockApi.respond('GET', statusPath, { json: { status: local } });
|
||||
const main = await openUpdate(page);
|
||||
const update = main.getByRole('button', { name: '更新', exact: true });
|
||||
|
||||
mockApi.respond('POST', checkPath, { json: { status: { ...local, checkError: '示例更新源暂不可达' } } });
|
||||
await update.click();
|
||||
await expect(main.getByText('检查失败:示例更新源暂不可达', { exact: true })).toBeVisible();
|
||||
|
||||
mockApi.respond('POST', checkPath, { json: { status: { ...available, ahead: 1, diverged: true } } });
|
||||
await update.click();
|
||||
await expect(main.getByText(/这是合并而不是下载/)).toBeVisible();
|
||||
|
||||
mockApi.respond('POST', checkPath, { json: { status: {
|
||||
...available, blockingChanges: [{ path: 'fixture.go', status: 'M' }]
|
||||
} } });
|
||||
await update.click();
|
||||
await expect(main.getByText(/有 1 个产品源码文件被本地改过/)).toBeVisible();
|
||||
expect(mockApi.writes().map(entry => entry.path)).toEqual([checkPath, checkPath, checkPath]);
|
||||
});
|
||||
|
||||
test('Update handles a pending build at the same version and follows a concurrent job', async ({ page, mockApi }) => {
|
||||
const pending = { ...local, buildPending: true, remoteCommit: currentCommit };
|
||||
mockApi.respond('GET', statusPath, { json: { status: pending } });
|
||||
mockApi.respond('POST', checkPath, { json: { status: pending } });
|
||||
mockApi.respond('POST', applyPath, { status: 409, json: { error: '更新正在进行', job: running } });
|
||||
mockApi.respond('GET', jobPath, { json: { job: running } });
|
||||
const main = await openUpdate(page);
|
||||
const update = main.getByRole('button', { name: '更新', exact: true });
|
||||
await update.click();
|
||||
await expect(main.getByText('进行中', { exact: true })).toBeVisible();
|
||||
await expect(update).toBeDisabled();
|
||||
expect(mockApi.writes().map(entry => entry.path)).toEqual([checkPath, applyPath]);
|
||||
});
|
||||
|
|
@ -1 +1 @@
|
|||
import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{S as t,t as n}from"./react-QV7DAAIx.js";import{C as r,I as i,P as a,U as o,V as s,bt as c,i as l,it as u,j as d,ot as f,rt as p,yt as m}from"./semi-CJoSwlZ2.js";import{F as h,I as g,P as _,a as v,b as y,c as b,d as x,f as S,l as C,m as w,p as T,s as E,u as D,x as O,y as k}from"./index-BDLJFuY8.js";var A=e(t(),1),j=e(n(),1),{Text:M}=o;function N(){let e=_(),{hasPermission:t}=h(),n=t(`agents:write`),o=t(`agents:delete`),[N,P]=(0,A.useState)(``),[F,I]=(0,A.useState)(null),[L,R]=(0,A.useState)(null),[z,B]=(0,A.useState)(!1),V=v(()=>g.get(`/multi-agent/markdown-agents`),[]),H=(Array.isArray(V.data?.agents)?V.data.agents:[]).filter(e=>{if(!N)return!0;let t=N.toLowerCase();return[e.name,e.id,e.filename,e.description].some(e=>String(e||``).toLowerCase().includes(t))}),U=async e=>{try{I(await g.get(`/multi-agent/markdown-agents/${encodeURIComponent(e.filename)}`))}catch(e){y(e,`读取智能体失败`)}},W=async()=>{let e=await L.form.validate();B(!0);try{await g.post(`/multi-agent/markdown-agents`,{filename:e.filename?.trim()||``,name:e.name.trim(),description:e.description?.trim()||``,instruction:e.instruction,kind:e.kind||`sub`,tools:String(e.tools||``).split(`,`).map(e=>e.trim()).filter(Boolean)}),O(`智能体已保存`),R(null),V.reload()}catch(e){y(e,`保存智能体失败`)}finally{B(!1)}},G=e=>k({title:`删除智能体「${e.name||e.filename}」?`,onOk:async()=>{await g.del(`/multi-agent/markdown-agents/${encodeURIComponent(e.filename)}`),O(`已删除`),V.reload()}});return(0,j.jsxs)(`div`,{children:[(0,j.jsx)(T,{title:e(`agents.title`,null,`智能体管理`),description:V.data?.dir?`目录:${V.data.dir}`:`以 Markdown 文件定义的子智能体与编排器。`,extra:(0,j.jsxs)(a,{children:[(0,j.jsx)(i,{icon:(0,j.jsx)(u,{}),onClick:()=>V.reload(),loading:V.loading,children:`刷新`}),n&&(0,j.jsx)(i,{theme:`solid`,type:`primary`,icon:(0,j.jsx)(f,{}),onClick:()=>R({record:null,form:{}}),children:`新建智能体`})]})}),V.data?.error&&(0,j.jsx)(C,{error:V.data.error}),(0,j.jsxs)(w,{title:`智能体(${H.length})`,children:[(0,j.jsx)(C,{error:V.error,onRetry:()=>V.reload()}),(0,j.jsx)(E,{columns:[{title:`智能体`,dataIndex:`name`,render:(e,t)=>(0,j.jsxs)(a,{vertical:!0,spacing:0,align:`start`,children:[(0,j.jsxs)(a,{children:[(0,j.jsx)(M,{strong:!0,children:e||t.id}),t.is_orchestrator&&(0,j.jsx)(d,{size:`small`,color:`purple`,children:`编排器`})]}),(0,j.jsx)(M,{type:`tertiary`,children:t.filename})]})},{title:`类型`,dataIndex:`kind`,width:110,render:e=>(0,j.jsx)(d,{size:`small`,children:e||`sub`})},{title:`描述`,dataIndex:`description`,render:e=>(0,j.jsx)(M,{type:`tertiary`,ellipsis:{showTooltip:!0},style:{maxWidth:460},children:e||`—`})},{title:`操作`,width:180,render:(e,t)=>(0,j.jsxs)(a,{children:[(0,j.jsx)(i,{size:`small`,theme:`borderless`,onClick:()=>U(t),children:`详情`}),n&&(0,j.jsx)(i,{size:`small`,theme:`borderless`,icon:(0,j.jsx)(m,{}),onClick:()=>R({record:t,form:{}})}),o&&(0,j.jsx)(i,{size:`small`,theme:`borderless`,type:`danger`,icon:(0,j.jsx)(c,{}),onClick:()=>G(t)})]})}],dataSource:H,rowKey:`filename`,loading:V.loading,pagination:{pageSize:20},toolbar:(0,j.jsx)(s,{prefix:(0,j.jsx)(p,{}),value:N,onChange:P,placeholder:`搜索名称或文件名`,style:{width:280}})})]}),(0,j.jsx)(r,{title:L?.record?`编辑智能体`:`新建智能体`,visible:!!L,onCancel:()=>R(null),onOk:W,confirmLoading:z,width:760,children:(0,j.jsxs)(l,{getFormApi:e=>R(t=>t&&{...t,form:e}),initValues:L?.record?{filename:L.record.filename,name:L.record.name,description:L.record.description,kind:L.record.kind||`sub`}:{kind:`sub`},children:[(0,j.jsx)(l.Input,{field:`filename`,label:`文件名(留空自动生成)`,placeholder:`例如 recon.md`}),(0,j.jsx)(l.Input,{field:`name`,label:`名称`,rules:[{required:!0,message:`请输入名称`}]}),(0,j.jsx)(l.Input,{field:`description`,label:`描述`}),(0,j.jsx)(l.Select,{field:`kind`,label:`类型`,optionList:[{value:`sub`,label:`子智能体`},{value:`orchestrator`,label:`编排器`},{value:`plan_execute`,label:`计划执行`}]}),(0,j.jsx)(l.Input,{field:`tools`,label:`工具(逗号分隔)`,placeholder:`toolName, mcp::tool`}),(0,j.jsx)(l.TextArea,{field:`instruction`,label:`指令(Markdown)`,autosize:{minRows:8,maxRows:20}})]})},L?.record?.filename||`new-agent`),(0,j.jsx)(b,{title:F?.name||`智能体详情`,visible:!!F,onCancel:()=>I(null),width:720,children:F&&(0,j.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:12},children:[(0,j.jsx)(x,{items:[{label:`文件名`,value:F.filename},{label:`ID`,value:F.id},{label:`类型`,value:F.kind},{label:`绑定角色`,value:F.bind_role||`—`},{label:`最大迭代`,value:F.max_iterations??`—`},{label:`工具`,value:Array.isArray(F.tools)&&F.tools.length?F.tools.join(`、`):`—`}]}),(0,j.jsx)(S,{content:F.instruction||F.raw||``}),(0,j.jsx)(D,{value:F.raw||F,title:`原始 Markdown`,collapsed:!0})]})})]})}export{N as default};
|
||||
import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{S as t,t as n}from"./react-QV7DAAIx.js";import{C as r,I as i,P as a,U as o,V as s,i as c,it as l,j as u,ot as d,rt as f,xt as p,yt as m}from"./semi-DNxeCrHm.js";import{F as h,I as g,P as _,a as v,b as y,c as b,d as x,f as S,l as C,m as w,p as T,s as E,u as D,x as O,y as k}from"./index-DJ5x9hL_.js";var A=e(t(),1),j=e(n(),1),{Text:M}=o;function N(){let e=_(),{hasPermission:t}=h(),n=t(`agents:write`),o=t(`agents:delete`),[N,P]=(0,A.useState)(``),[F,I]=(0,A.useState)(null),[L,R]=(0,A.useState)(null),[z,B]=(0,A.useState)(!1),V=v(()=>g.get(`/multi-agent/markdown-agents`),[]),H=(Array.isArray(V.data?.agents)?V.data.agents:[]).filter(e=>{if(!N)return!0;let t=N.toLowerCase();return[e.name,e.id,e.filename,e.description].some(e=>String(e||``).toLowerCase().includes(t))}),U=async e=>{try{I(await g.get(`/multi-agent/markdown-agents/${encodeURIComponent(e.filename)}`))}catch(e){y(e,`读取智能体失败`)}},W=async()=>{let e=await L.form.validate();B(!0);try{await g.post(`/multi-agent/markdown-agents`,{filename:e.filename?.trim()||``,name:e.name.trim(),description:e.description?.trim()||``,instruction:e.instruction,kind:e.kind||`sub`,tools:String(e.tools||``).split(`,`).map(e=>e.trim()).filter(Boolean)}),O(`智能体已保存`),R(null),V.reload()}catch(e){y(e,`保存智能体失败`)}finally{B(!1)}},G=e=>k({title:`删除智能体「${e.name||e.filename}」?`,onOk:async()=>{await g.del(`/multi-agent/markdown-agents/${encodeURIComponent(e.filename)}`),O(`已删除`),V.reload()}});return(0,j.jsxs)(`div`,{children:[(0,j.jsx)(T,{title:e(`agents.title`,null,`智能体管理`),description:V.data?.dir?`目录:${V.data.dir}`:`以 Markdown 文件定义的子智能体与编排器。`,extra:(0,j.jsxs)(a,{children:[(0,j.jsx)(i,{icon:(0,j.jsx)(l,{}),onClick:()=>V.reload(),loading:V.loading,children:`刷新`}),n&&(0,j.jsx)(i,{theme:`solid`,type:`primary`,icon:(0,j.jsx)(d,{}),onClick:()=>R({record:null,form:{}}),children:`新建智能体`})]})}),V.data?.error&&(0,j.jsx)(C,{error:V.data.error}),(0,j.jsxs)(w,{title:`智能体(${H.length})`,children:[(0,j.jsx)(C,{error:V.error,onRetry:()=>V.reload()}),(0,j.jsx)(E,{columns:[{title:`智能体`,dataIndex:`name`,render:(e,t)=>(0,j.jsxs)(a,{vertical:!0,spacing:0,align:`start`,children:[(0,j.jsxs)(a,{children:[(0,j.jsx)(M,{strong:!0,children:e||t.id}),t.is_orchestrator&&(0,j.jsx)(u,{size:`small`,color:`purple`,children:`编排器`})]}),(0,j.jsx)(M,{type:`tertiary`,children:t.filename})]})},{title:`类型`,dataIndex:`kind`,width:110,render:e=>(0,j.jsx)(u,{size:`small`,children:e||`sub`})},{title:`描述`,dataIndex:`description`,render:e=>(0,j.jsx)(M,{type:`tertiary`,ellipsis:{showTooltip:!0},style:{maxWidth:460},children:e||`—`})},{title:`操作`,width:180,render:(e,t)=>(0,j.jsxs)(a,{children:[(0,j.jsx)(i,{size:`small`,theme:`borderless`,onClick:()=>U(t),children:`详情`}),n&&(0,j.jsx)(i,{size:`small`,theme:`borderless`,icon:(0,j.jsx)(m,{}),onClick:()=>R({record:t,form:{}})}),o&&(0,j.jsx)(i,{size:`small`,theme:`borderless`,type:`danger`,icon:(0,j.jsx)(p,{}),onClick:()=>G(t)})]})}],dataSource:H,rowKey:`filename`,loading:V.loading,pagination:{pageSize:20},toolbar:(0,j.jsx)(s,{prefix:(0,j.jsx)(f,{}),value:N,onChange:P,placeholder:`搜索名称或文件名`,style:{width:280}})})]}),(0,j.jsx)(r,{title:L?.record?`编辑智能体`:`新建智能体`,visible:!!L,onCancel:()=>R(null),onOk:W,confirmLoading:z,width:760,children:(0,j.jsxs)(c,{getFormApi:e=>R(t=>t&&{...t,form:e}),initValues:L?.record?{filename:L.record.filename,name:L.record.name,description:L.record.description,kind:L.record.kind||`sub`}:{kind:`sub`},children:[(0,j.jsx)(c.Input,{field:`filename`,label:`文件名(留空自动生成)`,placeholder:`例如 recon.md`}),(0,j.jsx)(c.Input,{field:`name`,label:`名称`,rules:[{required:!0,message:`请输入名称`}]}),(0,j.jsx)(c.Input,{field:`description`,label:`描述`}),(0,j.jsx)(c.Select,{field:`kind`,label:`类型`,optionList:[{value:`sub`,label:`子智能体`},{value:`orchestrator`,label:`编排器`},{value:`plan_execute`,label:`计划执行`}]}),(0,j.jsx)(c.Input,{field:`tools`,label:`工具(逗号分隔)`,placeholder:`toolName, mcp::tool`}),(0,j.jsx)(c.TextArea,{field:`instruction`,label:`指令(Markdown)`,autosize:{minRows:8,maxRows:20}})]})},L?.record?.filename||`new-agent`),(0,j.jsx)(b,{title:F?.name||`智能体详情`,visible:!!F,onCancel:()=>I(null),width:720,children:F&&(0,j.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:12},children:[(0,j.jsx)(x,{items:[{label:`文件名`,value:F.filename},{label:`ID`,value:F.id},{label:`类型`,value:F.kind},{label:`绑定角色`,value:F.bind_role||`—`},{label:`最大迭代`,value:F.max_iterations??`—`},{label:`工具`,value:Array.isArray(F.tools)&&F.tools.length?F.tools.join(`、`):`—`}]}),(0,j.jsx)(S,{content:F.instruction||F.raw||``}),(0,j.jsx)(D,{value:F.raw||F,title:`原始 Markdown`,collapsed:!0})]})})]})}export{N as default};
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
|
@ -1 +1 @@
|
|||
import{I as e,L as t}from"./index-BDLJFuY8.js";var n=encodeURIComponent,r=t=>e.get(`/c2/listeners`,t),i=t=>e.post(`/c2/listeners`,t),a=(t,r)=>e.put(`/c2/listeners/${n(t)}`,r),o=t=>e.del(`/c2/listeners/${n(t)}`),s=t=>e.post(`/c2/listeners/${n(t)}/start`,{}),c=t=>e.post(`/c2/listeners/${n(t)}/stop`,{}),l=t=>e.get(`/c2/sessions`,t),u=t=>e.get(`/c2/sessions/${n(t)}`),d=t=>e.del(`/c2/sessions/${n(t)}`),f=t=>e.del(`/c2/sessions`,{body:{ids:t}}),p=(t,{sleepSeconds:r,jitterPercent:i})=>e.put(`/c2/sessions/${n(t)}/sleep`,{sleep_seconds:r,jitter_percent:i}),m=(t,r)=>e.put(`/c2/sessions/${n(t)}/note`,{note:r}),h=t=>e.get(`/c2/tasks`,t),g=t=>e.get(`/c2/tasks/${n(t)}`),_=t=>e.post(`/c2/tasks`,t),v=(t,r)=>e.post(`/c2/sessions/${n(t)}/tasks`,r),y=t=>e.post(`/c2/tasks/${n(t)}/cancel`,{}),b=(t,r=30)=>e.get(`/c2/tasks/${n(t)}/wait`,{timeout:r},{timeout:(r+10)*1e3}),x=t=>e.del(`/c2/tasks`,{body:{ids:t}}),S=(e,r)=>t(`/c2/tasks/${n(e)}/result-file`,{filename:r}),C=t=>e.post(`/c2/payloads/oneliner`,t),w=t=>e.post(`/c2/payloads/build`,t),T=(e,r)=>t(`/c2/payloads/${n(e)}/download`,{filename:r}),E=t=>e.get(`/c2/events`,t),D=t=>e.del(`/c2/events`,{body:{ids:t}}),O=()=>e.get(`/c2/profiles`),k=t=>e.post(`/c2/profiles`,t),A=(t,r)=>e.put(`/c2/profiles/${n(t)}`,r),j=t=>e.del(`/c2/profiles/${n(t)}`);async function M(){try{let t=await e.get(`/projects`,{limit:200});return Array.isArray(t?.projects)?t.projects:[]}catch{return[]}}export{b as A,h as C,c as D,s as E,a as O,l as S,p as T,g as _,k as a,O as b,D as c,d,f,u as g,S as h,i,A as k,o as l,T as m,w as n,v as o,x as p,y as r,_ as s,C as t,j as u,E as v,m as w,M as x,r as y};
|
||||
import{I as e,L as t}from"./index-DJ5x9hL_.js";var n=encodeURIComponent,r=t=>e.get(`/c2/listeners`,t),i=t=>e.post(`/c2/listeners`,t),a=(t,r)=>e.put(`/c2/listeners/${n(t)}`,r),o=t=>e.del(`/c2/listeners/${n(t)}`),s=t=>e.post(`/c2/listeners/${n(t)}/start`,{}),c=t=>e.post(`/c2/listeners/${n(t)}/stop`,{}),l=t=>e.get(`/c2/sessions`,t),u=t=>e.get(`/c2/sessions/${n(t)}`),d=t=>e.del(`/c2/sessions/${n(t)}`),f=t=>e.del(`/c2/sessions`,{body:{ids:t}}),p=(t,{sleepSeconds:r,jitterPercent:i})=>e.put(`/c2/sessions/${n(t)}/sleep`,{sleep_seconds:r,jitter_percent:i}),m=(t,r)=>e.put(`/c2/sessions/${n(t)}/note`,{note:r}),h=t=>e.get(`/c2/tasks`,t),g=t=>e.get(`/c2/tasks/${n(t)}`),_=t=>e.post(`/c2/tasks`,t),v=(t,r)=>e.post(`/c2/sessions/${n(t)}/tasks`,r),y=t=>e.post(`/c2/tasks/${n(t)}/cancel`,{}),b=(t,r=30)=>e.get(`/c2/tasks/${n(t)}/wait`,{timeout:r},{timeout:(r+10)*1e3}),x=t=>e.del(`/c2/tasks`,{body:{ids:t}}),S=(e,r)=>t(`/c2/tasks/${n(e)}/result-file`,{filename:r}),C=t=>e.post(`/c2/payloads/oneliner`,t),w=t=>e.post(`/c2/payloads/build`,t),T=(e,r)=>t(`/c2/payloads/${n(e)}/download`,{filename:r}),E=t=>e.get(`/c2/events`,t),D=t=>e.del(`/c2/events`,{body:{ids:t}}),O=()=>e.get(`/c2/profiles`),k=t=>e.post(`/c2/profiles`,t),A=(t,r)=>e.put(`/c2/profiles/${n(t)}`,r),j=t=>e.del(`/c2/profiles/${n(t)}`);async function M(){try{let t=await e.get(`/projects`,{limit:200});return Array.isArray(t?.projects)?t.projects:[]}catch{return[]}}export{b as A,h as C,c as D,s as E,a as O,l as S,p as T,g as _,k as a,O as b,D as c,d,f,u as g,S as h,i,A as k,o as l,T as m,w as n,v as o,x as p,y as r,_ as s,C as t,j as u,E as v,m as w,M as x,r as y};
|
||||
|
|
@ -1 +1 @@
|
|||
import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{I as t,P as n,U as r}from"./semi-CJoSwlZ2.js";import{E as i,P as a,k as o}from"./index-BDLJFuY8.js";import"./c2-shared-BVA2Xv1p.js";import{t as s}from"./react-QV7DAAIx.js";var c=e(s(),1),{Text:l}=r,u=[{value:`http_beacon`,label:`HTTP Beacon`},{value:`https_beacon`,label:`HTTPS Beacon`},{value:`tcp_reverse`,label:`TCP 反向`},{value:`websocket`,label:`WebSocket`}],d={running:`运行中`,stopped:`已停止`,error:`异常`},f={tcp_reverse:[{value:`bash`,label:`Bash (/dev/tcp)`},{value:`nc`,label:`Netcat (-e)`},{value:`nc_mkfifo`,label:`Netcat (mkfifo)`},{value:`python`,label:`Python`},{value:`perl`,label:`Perl`},{value:`powershell`,label:`PowerShell`}],http_beacon:[{value:`curl_beacon`,label:`Curl Beacon (HTTP)`}],https_beacon:[{value:`curl_beacon`,label:`Curl Beacon (HTTP)`}],websocket:[{value:`curl_beacon`,label:`Curl Beacon (HTTP)`}]},p=[{value:`shell`,label:`shell`},{value:`exec`,label:`exec`},{value:`ls`,label:`ls`},{value:`pwd`,label:`pwd`},{value:`cd`,label:`cd`},{value:`ps`,label:`ps`},{value:`kill_proc`,label:`kill_proc`},{value:`download`,label:`download`},{value:`upload`,label:`upload`},{value:`screenshot`,label:`screenshot`},{value:`sleep`,label:`sleep`},{value:`exit`,label:`exit`},{value:`self_delete`,label:`self_delete`},{value:`port_fwd`,label:`port_fwd`},{value:`socks_start`,label:`socks_start`},{value:`socks_stop`,label:`socks_stop`},{value:`load_assembly`,label:`load_assembly`},{value:`persist`,label:`persist`}],m=[{value:`queued`,label:`队列中`},{value:`sent`,label:`已发送`},{value:`running`,label:`执行中`},{value:`success`,label:`成功`},{value:`failed`,label:`失败`},{value:`cancelled`,label:`已取消`}],h=[{value:`info`,label:`信息`},{value:`warn`,label:`警告`},{value:`critical`,label:`严重`}],g=[{value:`listener`,label:`监听器`},{value:`session`,label:`会话`},{value:`task`,label:`任务`},{value:`payload`,label:`Payload`},{value:`opsec`,label:`OPSEC`}],_=[{value:`active`,label:`活跃`},{value:`sleeping`,label:`休眠`},{value:`dead`,label:`离线`},{value:`killed`,label:`已终止`}],v=[{value:`15m`,label:`最近15分钟`,ms:9e5},{value:`1h`,label:`最近1小时`,ms:36e5},{value:`24h`,label:`最近24小时`,ms:864e5},{value:`7d`,label:`最近7天`,ms:6048e5},{value:`all`,label:`全部`,ms:0}];function y(e){let t=v.find(t=>t.value===e);return!t||!t.ms?``:new Date(Date.now()-t.ms).toISOString()}function b({value:e,onChange:r,ns:i=`tasks`}){let o=a();return(0,c.jsxs)(n,{spacing:6,wrap:!0,className:`c2-time-presets`,children:[(0,c.jsx)(l,{type:`tertiary`,size:`small`,children:o(`c2.tasks.timePresets`,null,`快捷`)}),v.map(n=>(0,c.jsx)(t,{size:`small`,theme:n.value===e?`solid`:`borderless`,type:n.value===e?`primary`:`tertiary`,onClick:()=>r(n.value),children:o(`c2.${i}.preset${n.value===`all`?`All`:n.value}`,null,n.label)},n.value))]})}function x(e){let t=Number(e);return!Number.isFinite(t)||t<=0?`—`:t<1e3?`${Math.round(t)}ms`:t<6e4?`${(t/1e3).toFixed(1)}秒`:`${Math.round(t/6e4)}分钟`}function S({value:e}){let t=a();return e?(0,c.jsx)(`span`,{className:`c2-time-text`,title:i(e),children:o(e,t)}):(0,c.jsx)(l,{type:`tertiary`,children:`—`})}var C={running:`green`,stopped:`grey`,error:`red`},w={queued:`amber`,sent:`blue`,running:`blue`,success:`green`,failed:`red`,cancelled:`grey`},T={active:`green`,sleeping:`amber`,dead:`grey`,killed:`red`},E={info:`blue`,warn:`amber`,critical:`red`};export{d as a,T as c,m as d,p as f,y as g,x as h,C as i,_ as l,S as m,E as n,u as o,b as p,h as r,f as s,g as t,w as u};
|
||||
import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{I as t,P as n,U as r}from"./semi-DNxeCrHm.js";import{E as i,P as a,k as o}from"./index-DJ5x9hL_.js";import"./c2-shared-BMlZ1XNv.js";import{t as s}from"./react-QV7DAAIx.js";var c=e(s(),1),{Text:l}=r,u=[{value:`http_beacon`,label:`HTTP Beacon`},{value:`https_beacon`,label:`HTTPS Beacon`},{value:`tcp_reverse`,label:`TCP 反向`},{value:`websocket`,label:`WebSocket`}],d={running:`运行中`,stopped:`已停止`,error:`异常`},f={tcp_reverse:[{value:`bash`,label:`Bash (/dev/tcp)`},{value:`nc`,label:`Netcat (-e)`},{value:`nc_mkfifo`,label:`Netcat (mkfifo)`},{value:`python`,label:`Python`},{value:`perl`,label:`Perl`},{value:`powershell`,label:`PowerShell`}],http_beacon:[{value:`curl_beacon`,label:`Curl Beacon (HTTP)`}],https_beacon:[{value:`curl_beacon`,label:`Curl Beacon (HTTP)`}],websocket:[{value:`curl_beacon`,label:`Curl Beacon (HTTP)`}]},p=[{value:`shell`,label:`shell`},{value:`exec`,label:`exec`},{value:`ls`,label:`ls`},{value:`pwd`,label:`pwd`},{value:`cd`,label:`cd`},{value:`ps`,label:`ps`},{value:`kill_proc`,label:`kill_proc`},{value:`download`,label:`download`},{value:`upload`,label:`upload`},{value:`screenshot`,label:`screenshot`},{value:`sleep`,label:`sleep`},{value:`exit`,label:`exit`},{value:`self_delete`,label:`self_delete`},{value:`port_fwd`,label:`port_fwd`},{value:`socks_start`,label:`socks_start`},{value:`socks_stop`,label:`socks_stop`},{value:`load_assembly`,label:`load_assembly`},{value:`persist`,label:`persist`}],m=[{value:`queued`,label:`队列中`},{value:`sent`,label:`已发送`},{value:`running`,label:`执行中`},{value:`success`,label:`成功`},{value:`failed`,label:`失败`},{value:`cancelled`,label:`已取消`}],h=[{value:`info`,label:`信息`},{value:`warn`,label:`警告`},{value:`critical`,label:`严重`}],g=[{value:`listener`,label:`监听器`},{value:`session`,label:`会话`},{value:`task`,label:`任务`},{value:`payload`,label:`Payload`},{value:`opsec`,label:`OPSEC`}],_=[{value:`active`,label:`活跃`},{value:`sleeping`,label:`休眠`},{value:`dead`,label:`离线`},{value:`killed`,label:`已终止`}],v=[{value:`15m`,label:`最近15分钟`,ms:9e5},{value:`1h`,label:`最近1小时`,ms:36e5},{value:`24h`,label:`最近24小时`,ms:864e5},{value:`7d`,label:`最近7天`,ms:6048e5},{value:`all`,label:`全部`,ms:0}];function y(e){let t=v.find(t=>t.value===e);return!t||!t.ms?``:new Date(Date.now()-t.ms).toISOString()}function b({value:e,onChange:r,ns:i=`tasks`}){let o=a();return(0,c.jsxs)(n,{spacing:6,wrap:!0,className:`c2-time-presets`,children:[(0,c.jsx)(l,{type:`tertiary`,size:`small`,children:o(`c2.tasks.timePresets`,null,`快捷`)}),v.map(n=>(0,c.jsx)(t,{size:`small`,theme:n.value===e?`solid`:`borderless`,type:n.value===e?`primary`:`tertiary`,onClick:()=>r(n.value),children:o(`c2.${i}.preset${n.value===`all`?`All`:n.value}`,null,n.label)},n.value))]})}function x(e){let t=Number(e);return!Number.isFinite(t)||t<=0?`—`:t<1e3?`${Math.round(t)}ms`:t<6e4?`${(t/1e3).toFixed(1)}秒`:`${Math.round(t/6e4)}分钟`}function S({value:e}){let t=a();return e?(0,c.jsx)(`span`,{className:`c2-time-text`,title:i(e),children:o(e,t)}):(0,c.jsx)(l,{type:`tertiary`,children:`—`})}var C={running:`green`,stopped:`grey`,error:`red`},w={queued:`amber`,sent:`blue`,running:`blue`,success:`green`,failed:`red`,cancelled:`grey`},T={active:`green`,sleeping:`amber`,dead:`grey`,killed:`red`},E={info:`blue`,warn:`amber`,critical:`red`};export{d as a,T as c,m as d,p as f,y as g,x as h,C as i,_ as l,S as m,E as n,u as o,b as p,h as r,f as s,g as t,w as u};
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
|
@ -1 +1 @@
|
|||
import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{S as t,t as n}from"./react-QV7DAAIx.js";import{I as r,P as i,U as a,V as o,bt as s,it as c,j as l,rt as u}from"./semi-CJoSwlZ2.js";import{E as d,F as f,I as p,P as m,a as h,c as g,d as _,l as v,m as y,p as b,s as x,u as S,x as C,y as w}from"./index-BDLJFuY8.js";var T=e(t(),1),E=e(n(),1),{Text:D}=a;function O(){let e=m(),{hasPermission:t}=f(),n=t(`knowledge:delete`),[a,O]=(0,T.useState)(``),[k,A]=(0,T.useState)(50),[j,M]=(0,T.useState)(null),N=h(()=>p.get(`/knowledge/retrieval-logs`,{conversationId:a||void 0,limit:k}),[a,k]),P=Array.isArray(N.data?.logs)?N.data.logs:[],F=e=>w({title:`删除该检索日志?`,content:e.query||e.id,onOk:async()=>{await p.del(`/knowledge/retrieval-logs/${encodeURIComponent(e.id)}`),C(`已删除`),N.reload()}});return(0,E.jsxs)(`div`,{children:[(0,E.jsx)(b,{title:e(`knowledge.retrievalLogsTitle`,null,`检索历史`),description:`记录智能体每次知识库检索的语句、命中项与会话,用于回溯回答依据。`,extra:(0,E.jsx)(r,{icon:(0,E.jsx)(c,{}),onClick:()=>N.reload(),loading:N.loading,children:`刷新`})}),(0,E.jsxs)(y,{title:`检索记录(${P.length})`,children:[(0,E.jsx)(v,{error:N.error,onRetry:()=>N.reload()}),(0,E.jsx)(x,{columns:[{title:`检索语句`,dataIndex:`query`,render:(e,t)=>(0,E.jsx)(`button`,{type:`button`,className:`link-button`,onClick:()=>M(t),style:{background:`none`,border:`none`,padding:0,cursor:`pointer`,textAlign:`left`,color:`var(--semi-color-primary)`},children:e||`—`})},{title:`风险类型`,dataIndex:`riskType`,width:140,render:e=>e?(0,E.jsx)(l,{size:`small`,children:e}):`—`},{title:`命中知识项`,dataIndex:`retrievedItems`,width:120,render:e=>(0,E.jsxs)(D,{type:`tertiary`,children:[Array.isArray(e)?e.length:0,` 条`]})},{title:`会话`,dataIndex:`conversationId`,width:200,render:e=>(0,E.jsx)(D,{type:`tertiary`,ellipsis:{showTooltip:!0},children:e||`—`})},{title:`时间`,dataIndex:`createdAt`,width:180,render:e=>d(e)},{title:`操作`,width:110,render:(e,t)=>(0,E.jsxs)(i,{children:[(0,E.jsx)(r,{size:`small`,theme:`borderless`,onClick:()=>M(t),children:`详情`}),n&&(0,E.jsx)(r,{size:`small`,theme:`borderless`,type:`danger`,icon:(0,E.jsx)(s,{}),onClick:()=>F(t)})]})}],dataSource:P,rowKey:`id`,loading:N.loading,pagination:!1,toolbar:(0,E.jsxs)(i,{children:[(0,E.jsx)(o,{prefix:(0,E.jsx)(u,{}),placeholder:`按会话 ID 过滤`,value:a,onChange:O,style:{width:260}}),(0,E.jsx)(o,{placeholder:`条数`,value:String(k),onChange:e=>A(Math.min(Math.max(Number(e)||50,1),500)),style:{width:100},suffix:(0,E.jsx)(D,{type:`tertiary`,children:`条`})})]})})]}),(0,E.jsx)(g,{title:`检索日志详情`,visible:!!j,onCancel:()=>M(null),width:560,children:j&&(0,E.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:12},children:[(0,E.jsx)(_,{items:[{label:`日志 ID`,value:j.id},{label:`检索语句`,value:j.query},{label:`风险类型`,value:j.riskType||`—`},{label:`会话 ID`,value:j.conversationId||`—`},{label:`消息 ID`,value:j.messageId||`—`},{label:`时间`,value:d(j.createdAt)}]}),(0,E.jsx)(S,{value:j.retrievedItems||[],title:`命中知识项`})]})})]})}export{O as default};
|
||||
import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{S as t,t as n}from"./react-QV7DAAIx.js";import{I as r,P as i,U as a,V as o,it as s,j as c,rt as l,xt as u}from"./semi-DNxeCrHm.js";import{E as d,F as f,I as p,P as m,a as h,c as g,d as _,l as v,m as y,p as b,s as x,u as S,x as C,y as w}from"./index-DJ5x9hL_.js";var T=e(t(),1),E=e(n(),1),{Text:D}=a;function O(){let e=m(),{hasPermission:t}=f(),n=t(`knowledge:delete`),[a,O]=(0,T.useState)(``),[k,A]=(0,T.useState)(50),[j,M]=(0,T.useState)(null),N=h(()=>p.get(`/knowledge/retrieval-logs`,{conversationId:a||void 0,limit:k}),[a,k]),P=Array.isArray(N.data?.logs)?N.data.logs:[],F=e=>w({title:`删除该检索日志?`,content:e.query||e.id,onOk:async()=>{await p.del(`/knowledge/retrieval-logs/${encodeURIComponent(e.id)}`),C(`已删除`),N.reload()}});return(0,E.jsxs)(`div`,{children:[(0,E.jsx)(b,{title:e(`knowledge.retrievalLogsTitle`,null,`检索历史`),description:`记录智能体每次知识库检索的语句、命中项与会话,用于回溯回答依据。`,extra:(0,E.jsx)(r,{icon:(0,E.jsx)(s,{}),onClick:()=>N.reload(),loading:N.loading,children:`刷新`})}),(0,E.jsxs)(y,{title:`检索记录(${P.length})`,children:[(0,E.jsx)(v,{error:N.error,onRetry:()=>N.reload()}),(0,E.jsx)(x,{columns:[{title:`检索语句`,dataIndex:`query`,render:(e,t)=>(0,E.jsx)(`button`,{type:`button`,className:`link-button`,onClick:()=>M(t),style:{background:`none`,border:`none`,padding:0,cursor:`pointer`,textAlign:`left`,color:`var(--semi-color-primary)`},children:e||`—`})},{title:`风险类型`,dataIndex:`riskType`,width:140,render:e=>e?(0,E.jsx)(c,{size:`small`,children:e}):`—`},{title:`命中知识项`,dataIndex:`retrievedItems`,width:120,render:e=>(0,E.jsxs)(D,{type:`tertiary`,children:[Array.isArray(e)?e.length:0,` 条`]})},{title:`会话`,dataIndex:`conversationId`,width:200,render:e=>(0,E.jsx)(D,{type:`tertiary`,ellipsis:{showTooltip:!0},children:e||`—`})},{title:`时间`,dataIndex:`createdAt`,width:180,render:e=>d(e)},{title:`操作`,width:110,render:(e,t)=>(0,E.jsxs)(i,{children:[(0,E.jsx)(r,{size:`small`,theme:`borderless`,onClick:()=>M(t),children:`详情`}),n&&(0,E.jsx)(r,{size:`small`,theme:`borderless`,type:`danger`,icon:(0,E.jsx)(u,{}),onClick:()=>F(t)})]})}],dataSource:P,rowKey:`id`,loading:N.loading,pagination:!1,toolbar:(0,E.jsxs)(i,{children:[(0,E.jsx)(o,{prefix:(0,E.jsx)(l,{}),placeholder:`按会话 ID 过滤`,value:a,onChange:O,style:{width:260}}),(0,E.jsx)(o,{placeholder:`条数`,value:String(k),onChange:e=>A(Math.min(Math.max(Number(e)||50,1),500)),style:{width:100},suffix:(0,E.jsx)(D,{type:`tertiary`,children:`条`})})]})})]}),(0,E.jsx)(g,{title:`检索日志详情`,visible:!!j,onCancel:()=>M(null),width:560,children:j&&(0,E.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:12},children:[(0,E.jsx)(_,{items:[{label:`日志 ID`,value:j.id},{label:`检索语句`,value:j.query},{label:`风险类型`,value:j.riskType||`—`},{label:`会话 ID`,value:j.conversationId||`—`},{label:`消息 ID`,value:j.messageId||`—`},{label:`时间`,value:d(j.createdAt)}]}),(0,E.jsx)(S,{value:j.retrievedItems||[],title:`命中知识项`})]})})]})}export{O as default};
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
|
@ -1 +1 @@
|
|||
import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{S as t,t as n}from"./react-QV7DAAIx.js";import{C as r,I as i,P as a,U as o,V as s,bt as c,i as l,it as u,j as d,ot as f,rt as p,yt as m}from"./semi-CJoSwlZ2.js";import{F as h,I as g,P as _,a as v,b as y,l as b,m as x,p as S,s as C,x as w,y as T}from"./index-BDLJFuY8.js";var E=e(t(),1),D=e(n(),1),{Text:O}=o;function k(){let e=_(),{hasPermission:t}=h(),n=t(`roles:write`),o=t(`roles:delete`),[k,A]=(0,E.useState)(``),[j,M]=(0,E.useState)(null),[N,P]=(0,E.useState)(!1),F=v(()=>g.get(`/roles`),[]),I=(Array.isArray(F.data?.roles)?F.data.roles:[]).filter(e=>{if(!k)return!0;let t=k.toLowerCase();return[e.name,e.description].some(e=>String(e||``).toLowerCase().includes(t))}),L=async()=>{let e=await j.form.validate();P(!0);try{let t={name:e.name.trim(),description:e.description?.trim()||``,user_prompt:e.user_prompt||``,tools:String(e.tools||``).split(`,`).map(e=>e.trim()).filter(Boolean),enabled:e.enabled!==!1},n=j.role?.name;n&&n!==t.name?(await g.post(`/roles`,t),await g.del(`/roles/${encodeURIComponent(n)}`)):n?await g.put(`/roles/${encodeURIComponent(n)}`,t):await g.post(`/roles`,t),w(`角色已保存`),M(null),F.reload()}catch(e){y(e,`保存角色失败`)}finally{P(!1)}},R=e=>T({title:`删除角色「${e.name}」?`,content:`已绑定该角色的对话将失去对应提示词与工具配置。`,onOk:async()=>{await g.del(`/roles/${encodeURIComponent(e.name)}`),w(`已删除`),F.reload()}});return(0,D.jsxs)(`div`,{children:[(0,D.jsx)(S,{title:e(`roles.title`,null,`角色管理`),description:`角色定义对话的系统提示词、可用工具与绑定工作流。`,extra:(0,D.jsxs)(a,{children:[(0,D.jsx)(i,{icon:(0,D.jsx)(u,{}),onClick:()=>F.reload(),loading:F.loading,children:`刷新`}),n&&(0,D.jsx)(i,{theme:`solid`,type:`primary`,icon:(0,D.jsx)(f,{}),onClick:()=>M({role:null,form:{}}),children:`新建角色`})]})}),(0,D.jsxs)(x,{title:`角色(${I.length})`,children:[(0,D.jsx)(b,{error:F.error,onRetry:()=>F.reload()}),(0,D.jsx)(C,{columns:[{title:`角色`,dataIndex:`name`,render:(e,t)=>(0,D.jsxs)(a,{vertical:!0,spacing:0,align:`start`,children:[(0,D.jsxs)(a,{children:[(0,D.jsx)(O,{strong:!0,children:e}),t.enabled===!1&&(0,D.jsx)(d,{size:`small`,color:`grey`,children:`已停用`})]}),(0,D.jsx)(O,{type:`tertiary`,ellipsis:{showTooltip:!0},style:{maxWidth:460},children:t.description||`—`})]})},{title:`工具`,dataIndex:`tools`,width:260,render:e=>Array.isArray(e)&&e.length?(0,D.jsxs)(a,{wrap:!0,spacing:4,children:[e.slice(0,4).map(e=>(0,D.jsx)(d,{size:`small`,children:e},e)),e.length>4&&(0,D.jsxs)(O,{type:`tertiary`,children:[`+`,e.length-4]})]}):(0,D.jsx)(O,{type:`tertiary`,children:`未绑定`})},{title:`工作流`,dataIndex:`workflow_id`,width:160,render:e=>e||`—`},{title:`操作`,width:150,render:(e,t)=>(0,D.jsxs)(a,{children:[n&&(0,D.jsx)(i,{size:`small`,theme:`borderless`,icon:(0,D.jsx)(m,{}),onClick:()=>M({role:t,form:{}}),children:`编辑`}),o&&(0,D.jsx)(i,{size:`small`,theme:`borderless`,type:`danger`,icon:(0,D.jsx)(c,{}),onClick:()=>R(t)})]})}],dataSource:I,rowKey:`name`,loading:F.loading,pagination:{pageSize:20},toolbar:(0,D.jsx)(s,{prefix:(0,D.jsx)(p,{}),value:k,onChange:A,placeholder:`搜索角色名称`,style:{width:260}})})]}),(0,D.jsx)(r,{title:j?.role?`编辑角色`:`新建角色`,visible:!!j,onCancel:()=>M(null),onOk:L,confirmLoading:N,width:760,children:(0,D.jsxs)(l,{getFormApi:e=>M(t=>t&&{...t,form:e}),initValues:j?.role?{name:j.role.name,description:j.role.description,user_prompt:j.role.user_prompt,tools:Array.isArray(j.role.tools)?j.role.tools.join(`, `):``,enabled:j.role.enabled!==!1}:{enabled:!0},children:[(0,D.jsx)(l.Input,{field:`name`,label:`角色名称`,rules:[{required:!0,message:`请输入角色名称`}]}),(0,D.jsx)(l.Input,{field:`description`,label:`描述`}),(0,D.jsx)(l.Input,{field:`tools`,label:`工具(逗号分隔)`,placeholder:`toolName, mcp::toolName`}),(0,D.jsx)(l.TextArea,{field:`user_prompt`,label:`用户提示词(追加到用户消息前)`,autosize:{minRows:6,maxRows:18}}),(0,D.jsx)(l.Slot,{label:`启用`,children:(0,D.jsx)(l.Switch,{field:`enabled`})})]})},j?.role?.name||`new-role`)]})}export{k as default};
|
||||
import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{S as t,t as n}from"./react-QV7DAAIx.js";import{C as r,I as i,P as a,U as o,V as s,i as c,it as l,j as u,ot as d,rt as f,xt as p,yt as m}from"./semi-DNxeCrHm.js";import{F as h,I as g,P as _,a as v,b as y,l as b,m as x,p as S,s as C,x as w,y as T}from"./index-DJ5x9hL_.js";var E=e(t(),1),D=e(n(),1),{Text:O}=o;function k(){let e=_(),{hasPermission:t}=h(),n=t(`roles:write`),o=t(`roles:delete`),[k,A]=(0,E.useState)(``),[j,M]=(0,E.useState)(null),[N,P]=(0,E.useState)(!1),F=v(()=>g.get(`/roles`),[]),I=(Array.isArray(F.data?.roles)?F.data.roles:[]).filter(e=>{if(!k)return!0;let t=k.toLowerCase();return[e.name,e.description].some(e=>String(e||``).toLowerCase().includes(t))}),L=async()=>{let e=await j.form.validate();P(!0);try{let t={name:e.name.trim(),description:e.description?.trim()||``,user_prompt:e.user_prompt||``,tools:String(e.tools||``).split(`,`).map(e=>e.trim()).filter(Boolean),enabled:e.enabled!==!1},n=j.role?.name;n&&n!==t.name?(await g.post(`/roles`,t),await g.del(`/roles/${encodeURIComponent(n)}`)):n?await g.put(`/roles/${encodeURIComponent(n)}`,t):await g.post(`/roles`,t),w(`角色已保存`),M(null),F.reload()}catch(e){y(e,`保存角色失败`)}finally{P(!1)}},R=e=>T({title:`删除角色「${e.name}」?`,content:`已绑定该角色的对话将失去对应提示词与工具配置。`,onOk:async()=>{await g.del(`/roles/${encodeURIComponent(e.name)}`),w(`已删除`),F.reload()}});return(0,D.jsxs)(`div`,{children:[(0,D.jsx)(S,{title:e(`roles.title`,null,`角色管理`),description:`角色定义对话的系统提示词、可用工具与绑定工作流。`,extra:(0,D.jsxs)(a,{children:[(0,D.jsx)(i,{icon:(0,D.jsx)(l,{}),onClick:()=>F.reload(),loading:F.loading,children:`刷新`}),n&&(0,D.jsx)(i,{theme:`solid`,type:`primary`,icon:(0,D.jsx)(d,{}),onClick:()=>M({role:null,form:{}}),children:`新建角色`})]})}),(0,D.jsxs)(x,{title:`角色(${I.length})`,children:[(0,D.jsx)(b,{error:F.error,onRetry:()=>F.reload()}),(0,D.jsx)(C,{columns:[{title:`角色`,dataIndex:`name`,render:(e,t)=>(0,D.jsxs)(a,{vertical:!0,spacing:0,align:`start`,children:[(0,D.jsxs)(a,{children:[(0,D.jsx)(O,{strong:!0,children:e}),t.enabled===!1&&(0,D.jsx)(u,{size:`small`,color:`grey`,children:`已停用`})]}),(0,D.jsx)(O,{type:`tertiary`,ellipsis:{showTooltip:!0},style:{maxWidth:460},children:t.description||`—`})]})},{title:`工具`,dataIndex:`tools`,width:260,render:e=>Array.isArray(e)&&e.length?(0,D.jsxs)(a,{wrap:!0,spacing:4,children:[e.slice(0,4).map(e=>(0,D.jsx)(u,{size:`small`,children:e},e)),e.length>4&&(0,D.jsxs)(O,{type:`tertiary`,children:[`+`,e.length-4]})]}):(0,D.jsx)(O,{type:`tertiary`,children:`未绑定`})},{title:`工作流`,dataIndex:`workflow_id`,width:160,render:e=>e||`—`},{title:`操作`,width:150,render:(e,t)=>(0,D.jsxs)(a,{children:[n&&(0,D.jsx)(i,{size:`small`,theme:`borderless`,icon:(0,D.jsx)(m,{}),onClick:()=>M({role:t,form:{}}),children:`编辑`}),o&&(0,D.jsx)(i,{size:`small`,theme:`borderless`,type:`danger`,icon:(0,D.jsx)(p,{}),onClick:()=>R(t)})]})}],dataSource:I,rowKey:`name`,loading:F.loading,pagination:{pageSize:20},toolbar:(0,D.jsx)(s,{prefix:(0,D.jsx)(f,{}),value:k,onChange:A,placeholder:`搜索角色名称`,style:{width:260}})})]}),(0,D.jsx)(r,{title:j?.role?`编辑角色`:`新建角色`,visible:!!j,onCancel:()=>M(null),onOk:L,confirmLoading:N,width:760,children:(0,D.jsxs)(c,{getFormApi:e=>M(t=>t&&{...t,form:e}),initValues:j?.role?{name:j.role.name,description:j.role.description,user_prompt:j.role.user_prompt,tools:Array.isArray(j.role.tools)?j.role.tools.join(`, `):``,enabled:j.role.enabled!==!1}:{enabled:!0},children:[(0,D.jsx)(c.Input,{field:`name`,label:`角色名称`,rules:[{required:!0,message:`请输入角色名称`}]}),(0,D.jsx)(c.Input,{field:`description`,label:`描述`}),(0,D.jsx)(c.Input,{field:`tools`,label:`工具(逗号分隔)`,placeholder:`toolName, mcp::toolName`}),(0,D.jsx)(c.TextArea,{field:`user_prompt`,label:`用户提示词(追加到用户消息前)`,autosize:{minRows:6,maxRows:18}}),(0,D.jsx)(c.Slot,{label:`启用`,children:(0,D.jsx)(c.Switch,{field:`enabled`})})]})},j?.role?.name||`new-role`)]})}export{k as default};
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
|
@ -1 +1 @@
|
|||
import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{I as t,P as n,U as r,bt as i,it as a}from"./semi-CJoSwlZ2.js";import{D as o,F as s,I as c,O as l,P as u,_ as d,a as f,l as p,m,p as h,s as g,x as _,y as v}from"./index-BDLJFuY8.js";import{t as y}from"./react-QV7DAAIx.js";var b=e(y(),1),{Text:x}=r;function S(){let e=u(),{hasPermission:r}=s(),y=r(`skills:delete`),S=f(()=>c.get(`/skills/stats`),[]),C=Array.isArray(S.data?.stats)?S.data.stats:[],w=Number(S.data?.total_calls||0),T=Number(S.data?.total_success||0),E=w>0?T/w:null,D=()=>v({title:`清空所有技能调用统计?`,content:`只影响统计计数,不删除技能文件。`,onOk:async()=>{await c.del(`/skills/stats`),_(`统计已清空`),S.reload()}}),O=e=>v({title:`清空「${e}」的统计?`,onOk:async()=>{await c.del(`/skills/${encodeURIComponent(e)}/stats`),_(`已清空`),S.reload()}});return(0,b.jsxs)(`div`,{children:[(0,b.jsx)(h,{title:e(`skills.monitorTitle`,null,`技能状态`),description:S.data?.skills_dir?`技能目录:${S.data.skills_dir}`:`统计技能被调用的次数、成功率与最近使用时间。`,extra:(0,b.jsxs)(n,{children:[(0,b.jsx)(t,{icon:(0,b.jsx)(a,{}),onClick:()=>S.reload(),loading:S.loading,children:`刷新`}),y&&(0,b.jsx)(t,{type:`danger`,theme:`light`,onClick:D,children:`清空全部统计`})]})}),(0,b.jsx)(d,{columns:4,metrics:[{id:`skills`,label:`技能总数`,value:o(S.data?.total_skills||0),loading:S.loading},{id:`calls`,label:`调用总数`,value:o(w),loading:S.loading},{id:`success`,label:`成功次数`,value:o(T),loading:S.loading},{id:`rate`,label:`成功率`,value:E===null?`—`:l(E),tone:E!==null&&E<.8?`warning`:`success`,loading:S.loading}]}),(0,b.jsxs)(m,{title:`按技能统计`,children:[(0,b.jsx)(p,{error:S.error,onRetry:()=>S.reload()}),(0,b.jsx)(g,{columns:[{title:`技能`,dataIndex:`skill_name`,render:e=>(0,b.jsx)(x,{strong:!0,children:e})},{title:`调用次数`,dataIndex:`total_calls`,width:120,render:e=>o(e||0)},{title:`成功`,dataIndex:`success_calls`,width:100,render:e=>o(e||0)},{title:`失败`,dataIndex:`failed_calls`,width:100,render:e=>Number(e)>0?(0,b.jsx)(x,{type:`danger`,children:o(e)}):`0`},{title:`最后调用`,dataIndex:`last_call_time`,width:180,render:e=>e||`—`},{title:`操作`,width:110,render:(e,n)=>y&&Number(n.total_calls)>0?(0,b.jsx)(t,{size:`small`,theme:`borderless`,type:`danger`,icon:(0,b.jsx)(i,{}),onClick:()=>O(n.skill_name),children:`清空`}):null}],dataSource:C,rowKey:`skill_name`,loading:S.loading,pagination:{pageSize:20}})]})]})}export{S as default};
|
||||
import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{I as t,P as n,U as r,it as i,xt as a}from"./semi-DNxeCrHm.js";import{D as o,F as s,I as c,O as l,P as u,_ as d,a as f,l as p,m,p as h,s as g,x as _,y as v}from"./index-DJ5x9hL_.js";import{t as y}from"./react-QV7DAAIx.js";var b=e(y(),1),{Text:x}=r;function S(){let e=u(),{hasPermission:r}=s(),y=r(`skills:delete`),S=f(()=>c.get(`/skills/stats`),[]),C=Array.isArray(S.data?.stats)?S.data.stats:[],w=Number(S.data?.total_calls||0),T=Number(S.data?.total_success||0),E=w>0?T/w:null,D=()=>v({title:`清空所有技能调用统计?`,content:`只影响统计计数,不删除技能文件。`,onOk:async()=>{await c.del(`/skills/stats`),_(`统计已清空`),S.reload()}}),O=e=>v({title:`清空「${e}」的统计?`,onOk:async()=>{await c.del(`/skills/${encodeURIComponent(e)}/stats`),_(`已清空`),S.reload()}});return(0,b.jsxs)(`div`,{children:[(0,b.jsx)(h,{title:e(`skills.monitorTitle`,null,`技能状态`),description:S.data?.skills_dir?`技能目录:${S.data.skills_dir}`:`统计技能被调用的次数、成功率与最近使用时间。`,extra:(0,b.jsxs)(n,{children:[(0,b.jsx)(t,{icon:(0,b.jsx)(i,{}),onClick:()=>S.reload(),loading:S.loading,children:`刷新`}),y&&(0,b.jsx)(t,{type:`danger`,theme:`light`,onClick:D,children:`清空全部统计`})]})}),(0,b.jsx)(d,{columns:4,metrics:[{id:`skills`,label:`技能总数`,value:o(S.data?.total_skills||0),loading:S.loading},{id:`calls`,label:`调用总数`,value:o(w),loading:S.loading},{id:`success`,label:`成功次数`,value:o(T),loading:S.loading},{id:`rate`,label:`成功率`,value:E===null?`—`:l(E),tone:E!==null&&E<.8?`warning`:`success`,loading:S.loading}]}),(0,b.jsxs)(m,{title:`按技能统计`,children:[(0,b.jsx)(p,{error:S.error,onRetry:()=>S.reload()}),(0,b.jsx)(g,{columns:[{title:`技能`,dataIndex:`skill_name`,render:e=>(0,b.jsx)(x,{strong:!0,children:e})},{title:`调用次数`,dataIndex:`total_calls`,width:120,render:e=>o(e||0)},{title:`成功`,dataIndex:`success_calls`,width:100,render:e=>o(e||0)},{title:`失败`,dataIndex:`failed_calls`,width:100,render:e=>Number(e)>0?(0,b.jsx)(x,{type:`danger`,children:o(e)}):`0`},{title:`最后调用`,dataIndex:`last_call_time`,width:180,render:e=>e||`—`},{title:`操作`,width:110,render:(e,n)=>y&&Number(n.total_calls)>0?(0,b.jsx)(t,{size:`small`,theme:`borderless`,type:`danger`,icon:(0,b.jsx)(a,{}),onClick:()=>O(n.skill_name),children:`清空`}):null}],dataSource:C,rowKey:`skill_name`,loading:S.loading,pagination:{pageSize:20}})]})]})}export{S as default};
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
|
@ -18,10 +18,10 @@
|
|||
} catch (error) { /* first paint fallback */ }
|
||||
})();
|
||||
</script>
|
||||
<script type="module" crossorigin src="/static/app/assets/index-BDLJFuY8.js"></script>
|
||||
<script type="module" crossorigin src="/static/app/assets/index-DJ5x9hL_.js"></script>
|
||||
<link rel="modulepreload" crossorigin href="/static/app/assets/rolldown-runtime-WkwZ5CU-.js">
|
||||
<link rel="modulepreload" crossorigin href="/static/app/assets/react-QV7DAAIx.js">
|
||||
<link rel="modulepreload" crossorigin href="/static/app/assets/semi-CJoSwlZ2.js">
|
||||
<link rel="modulepreload" crossorigin href="/static/app/assets/semi-DNxeCrHm.js">
|
||||
<link rel="stylesheet" crossorigin href="/static/app/assets/semi-BUXPdXzR.css">
|
||||
<link rel="stylesheet" crossorigin href="/static/app/assets/index-B_jDLAQv.css">
|
||||
</head>
|
||||
|
|
|
|||
|
|
@ -3155,8 +3155,8 @@
|
|||
}
|
||||
},
|
||||
"updateUi": {
|
||||
"pageHint": "View this installation and update progress, manage the update source, and check remote versions.",
|
||||
"sourceSaveOnly": "Saving changes update.repo in the configuration file. Use Check for updates to read the remote version.",
|
||||
"pageHint": "Select Update to check the source and install any available version automatically.",
|
||||
"sourceSaveOnly": "Saving changes update.repo in the configuration file. The next update uses the saved address.",
|
||||
"sourcePermission": "Saving a URL here requires update management permission. You can also change update.repo in the configuration file the service uses.",
|
||||
"sourceResponseMissing": "The server did not return the update source. Refresh to verify the configuration.",
|
||||
"repo": "Update repository",
|
||||
|
|
@ -3165,7 +3165,16 @@
|
|||
"blockingChanges": "Files blocking updates",
|
||||
"toolchainPath": "Go toolchain path",
|
||||
"versionUnchecked": "The remote version has not been checked.",
|
||||
"checkOk": "Remote version details retrieved",
|
||||
"updateButton": "Update",
|
||||
"updatePermission": "Checking for and installing updates requires update management permission.",
|
||||
"saveSourceFirst": "Save the new update source address before updating.",
|
||||
"currentVersion": "Already up to date",
|
||||
"noNewerVersion": "The update source has no newer version",
|
||||
"starting": "Starting update…",
|
||||
"statusMissing": "The server did not return version information.",
|
||||
"jobMissing": "The server did not return an update job ID. Check the update progress.",
|
||||
"rollbackPending": "Finish the previous rollback before updating.",
|
||||
"resumeBuild": "The previous update still needs a build. Select Update to retry the build.",
|
||||
"diverged": "Local and remote histories have diverged",
|
||||
"taskId": "Job ID",
|
||||
"kind": "Job type",
|
||||
|
|
|
|||
|
|
@ -3143,8 +3143,8 @@
|
|||
}
|
||||
},
|
||||
"updateUi": {
|
||||
"pageHint": "查看本机安装和更新进度,管理更新源并检查远端版本。",
|
||||
"sourceSaveOnly": "保存会修改配置文件中的 update.repo。检查远端版本请点击「检查更新」。",
|
||||
"pageHint": "点击「更新」会检查更新源,并自动安装可用版本。",
|
||||
"sourceSaveOnly": "保存会修改配置文件中的 update.repo。下次点击「更新」时使用新地址。",
|
||||
"sourcePermission": "需要更新管理权限才能在这里保存地址。也可以在服务实际使用的配置文件中修改 update.repo。",
|
||||
"sourceResponseMissing": "服务端未返回更新源,刷新后可核对配置。",
|
||||
"repo": "更新源仓库",
|
||||
|
|
@ -3153,7 +3153,16 @@
|
|||
"blockingChanges": "阻止更新的文件数",
|
||||
"toolchainPath": "Go 工具链路径",
|
||||
"versionUnchecked": "尚未检查远端版本。",
|
||||
"checkOk": "已获取远端版本信息",
|
||||
"updateButton": "更新",
|
||||
"updatePermission": "需要更新管理权限才能检查并安装更新。",
|
||||
"saveSourceFirst": "请先保存修改后的更新源地址,再执行更新。",
|
||||
"currentVersion": "已是最新版",
|
||||
"noNewerVersion": "更新源没有更新的版本",
|
||||
"starting": "正在启动更新…",
|
||||
"statusMissing": "服务端未返回版本信息。",
|
||||
"jobMissing": "服务端未返回更新任务编号,请查看更新进度。",
|
||||
"rollbackPending": "上一次回滚尚未完成,请完成回滚后再更新。",
|
||||
"resumeBuild": "上一次更新仍待编译,点击「更新」可重试编译。",
|
||||
"diverged": "本机与远端提交历史已分叉",
|
||||
"taskId": "任务编号",
|
||||
"kind": "任务类型",
|
||||
|
|
|
|||
Loading…
Reference in New Issue