feat(webui): add safety confirms and local-time rendering; support install.sh -ui

This commit is contained in:
lpf
2026-03-04 14:39:46 +08:00
parent 09c06786a4
commit ccf2ed4703
9 changed files with 252 additions and 49 deletions

View File

@@ -1,9 +1,11 @@
import React, { useEffect, useState } from 'react';
import { useTranslation } from 'react-i18next';
import { useAppContext } from '../context/AppContext';
import { useUI } from '../context/UIContext';
const Memory: React.FC = () => {
const { t } = useTranslation();
const ui = useUI();
const { q } = useAppContext();
const [files, setFiles] = useState<string[]>([]);
const [active, setActive] = useState('');
@@ -35,6 +37,13 @@ const Memory: React.FC = () => {
}
async function removeFile(path: string) {
const ok = await ui.confirmDialog({
title: t('memoryDeleteConfirmTitle'),
message: t('memoryDeleteConfirmMessage', { path }),
danger: true,
confirmText: t('delete'),
});
if (!ok) return;
await fetch(`/webui/api/memory${qp('path', path)}`, { method: 'DELETE' });
if (active === path) {
setActive('');