mirror of
https://github.com/hicccc77/WeFlow.git
synced 2026-03-25 15:25:50 +00:00
feat: add progress
This commit is contained in:
@@ -2172,4 +2172,71 @@
|
||||
width: 100%;
|
||||
margin-top: 12px;
|
||||
}
|
||||
}
|
||||
|
||||
.brute-force-progress {
|
||||
margin-top: 12px;
|
||||
padding: 14px 16px;
|
||||
background: var(--bg-tertiary);
|
||||
border: 1px solid var(--border-color);
|
||||
border-radius: 12px;
|
||||
animation: slideUp 0.3s ease;
|
||||
|
||||
.status-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
margin-bottom: 10px;
|
||||
|
||||
.status-text {
|
||||
font-size: 13px;
|
||||
color: var(--text-primary);
|
||||
font-weight: 500;
|
||||
margin: 0;
|
||||
// 增加文字呼吸灯效果,表明正在运行
|
||||
animation: pulse 2s ease-in-out infinite;
|
||||
}
|
||||
|
||||
.percent {
|
||||
font-size: 14px;
|
||||
color: var(--primary);
|
||||
font-weight: 700;
|
||||
font-family: var(--font-mono);
|
||||
}
|
||||
}
|
||||
|
||||
.progress-bar-container {
|
||||
width: 100%;
|
||||
height: 8px;
|
||||
background: var(--bg-primary);
|
||||
border-radius: 4px;
|
||||
overflow: hidden;
|
||||
border: 1px solid var(--border-color);
|
||||
box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.05);
|
||||
|
||||
.fill {
|
||||
height: 100%;
|
||||
background: linear-gradient(90deg, var(--primary) 0%, color-mix(in srgb, var(--primary) 60%, white) 100%);
|
||||
border-radius: 4px;
|
||||
transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
|
||||
position: relative;
|
||||
|
||||
// 流光扫过的高亮特效
|
||||
&::after {
|
||||
content: '';
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
background: linear-gradient(
|
||||
90deg,
|
||||
transparent,
|
||||
rgba(255, 255, 255, 0.3),
|
||||
transparent
|
||||
);
|
||||
animation: progress-shimmer 1.5s infinite linear;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -82,6 +82,8 @@ function SettingsPage() {
|
||||
const exportExcelColumnsDropdownRef = useRef<HTMLDivElement>(null)
|
||||
const exportConcurrencyDropdownRef = useRef<HTMLDivElement>(null)
|
||||
const [cachePath, setCachePath] = useState('')
|
||||
const [imageKeyProgress, setImageKeyProgress] = useState(0)
|
||||
const [imageKeyPercent, setImageKeyPercent] = useState<number | null>(null)
|
||||
|
||||
const [logEnabled, setLogEnabled] = useState(false)
|
||||
const [whisperModelName, setWhisperModelName] = useState('base')
|
||||
@@ -222,8 +224,28 @@ function SettingsPage() {
|
||||
const removeDb = window.electronAPI.key.onDbKeyStatus((payload: { message: string; level: number }) => {
|
||||
setDbKeyStatus(payload.message)
|
||||
})
|
||||
const removeImage = window.electronAPI.key.onImageKeyStatus((payload: { message: string }) => {
|
||||
setImageKeyStatus(payload.message)
|
||||
|
||||
const removeImage = window.electronAPI.key.onImageKeyStatus((payload: { message: string, percent?: number }) => {
|
||||
let msg = payload.message;
|
||||
let pct = payload.percent;
|
||||
|
||||
// 如果后端没有显式传 percent,则用正则从字符串中提取如 "(12.5%)"
|
||||
if (pct === undefined) {
|
||||
const match = msg.match(/\(([\d.]+)%\)/);
|
||||
if (match) {
|
||||
pct = parseFloat(match[1]);
|
||||
// 将百分比从文本中剥离,让 UI 更清爽
|
||||
msg = msg.replace(/\s*\([\d.]+%\)/, '');
|
||||
}
|
||||
}
|
||||
|
||||
setImageKeyStatus(msg);
|
||||
if (pct !== undefined) {
|
||||
setImageKeyPercent(pct);
|
||||
} else if (msg.includes('启动多核') || msg.includes('定位') || msg.includes('准备')) {
|
||||
// 预热阶段
|
||||
setImageKeyPercent(0);
|
||||
}
|
||||
})
|
||||
return () => {
|
||||
removeDb?.()
|
||||
@@ -745,15 +767,18 @@ function SettingsPage() {
|
||||
}
|
||||
|
||||
const handleAutoGetImageKey = async () => {
|
||||
if (isFetchingImageKey) return
|
||||
if (isFetchingImageKey) return;
|
||||
if (!dbPath) {
|
||||
showMessage('请先选择数据库目录', false)
|
||||
return
|
||||
showMessage('请先选择数据库目录', false);
|
||||
return;
|
||||
}
|
||||
setIsFetchingImageKey(true)
|
||||
setImageKeyStatus('正在准备获取图片密钥...')
|
||||
setIsFetchingImageKey(true);
|
||||
setImageKeyPercent(0)
|
||||
setImageKeyStatus('正在初始化多核爆破引擎...');
|
||||
setImageKeyProgress(0); // 重置进度
|
||||
|
||||
try {
|
||||
const accountPath = wxid ? `${dbPath}/${wxid}` : dbPath
|
||||
const accountPath = wxid ? `${dbPath}/${wxid}` : dbPath;
|
||||
const result = await window.electronAPI.key.autoGetImageKey(accountPath)
|
||||
if (result.success && result.aesKey) {
|
||||
if (typeof result.xorKey === 'number') {
|
||||
@@ -1352,11 +1377,19 @@ function SettingsPage() {
|
||||
<Plug size={14} /> {isFetchingImageKey ? '获取中...' : '自动获取图片密钥'}
|
||||
</button>
|
||||
{isFetchingImageKey ? (
|
||||
<div className="form-hint status-text" style={{ color: '#007bff', fontWeight: 'bold', marginTop: '6px' }}>
|
||||
{imageKeyStatus || '正在启动多核爆破引擎...'}
|
||||
<div className="brute-force-progress">
|
||||
<div className="status-header">
|
||||
<span className="status-text">{imageKeyStatus || '正在启动多核爆破引擎...'}</span>
|
||||
{imageKeyPercent !== null && <span className="percent">{imageKeyPercent.toFixed(1)}%</span>}
|
||||
</div>
|
||||
{imageKeyPercent !== null && (
|
||||
<div className="progress-bar-container">
|
||||
<div className="fill" style={{ width: `${imageKeyPercent}%` }}></div>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
) : (
|
||||
imageKeyStatus && <div className="form-hint status-text">{imageKeyStatus}</div>
|
||||
imageKeyStatus && <div className="form-hint status-text" style={{ marginTop: '8px' }}>{imageKeyStatus}</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user