mirror of
https://github.com/hicccc77/WeFlow.git
synced 2026-03-25 07:16:51 +00:00
支持朋友圈防撤回;修复朋友圈回复嵌套关系错误;支持朋友圈评论表情解析;支持删除本地朋友圈记录
This commit is contained in:
@@ -190,6 +190,32 @@
|
||||
background: var(--bg-tertiary);
|
||||
border-color: var(--text-secondary);
|
||||
}
|
||||
|
||||
&.delete-btn:hover {
|
||||
color: #ff4d4f;
|
||||
border-color: rgba(255, 77, 79, 0.4);
|
||||
background: rgba(255, 77, 79, 0.08);
|
||||
}
|
||||
|
||||
&:disabled {
|
||||
opacity: 0.4;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
}
|
||||
|
||||
.post-protected-badge {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 3px;
|
||||
opacity: 0;
|
||||
transition: opacity 0.2s;
|
||||
color: var(--color-success, #4caf50);
|
||||
font-size: 11px;
|
||||
font-weight: 500;
|
||||
padding: 3px 7px;
|
||||
border-radius: 5px;
|
||||
background: rgba(76, 175, 80, 0.08);
|
||||
border: 1px solid rgba(76, 175, 80, 0.2);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -197,6 +223,258 @@
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
.sns-post-item:hover .post-protected-badge {
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
// 删除确认弹窗
|
||||
.sns-confirm-overlay {
|
||||
position: fixed;
|
||||
inset: 0;
|
||||
background: rgba(0, 0, 0, 0.15);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
z-index: 1000;
|
||||
backdrop-filter: blur(2px);
|
||||
}
|
||||
|
||||
.sns-confirm-dialog {
|
||||
background: var(--bg-secondary);
|
||||
border: 1px solid var(--border-color);
|
||||
border-radius: 14px;
|
||||
padding: 28px 28px 22px;
|
||||
width: 300px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
|
||||
|
||||
.sns-confirm-icon {
|
||||
width: 48px;
|
||||
height: 48px;
|
||||
border-radius: 12px;
|
||||
background: rgba(255, 77, 79, 0.1);
|
||||
color: #ff4d4f;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
margin-bottom: 4px;
|
||||
}
|
||||
|
||||
.sns-confirm-title {
|
||||
font-size: 16px;
|
||||
font-weight: 600;
|
||||
color: var(--text-primary);
|
||||
}
|
||||
|
||||
.sns-confirm-desc {
|
||||
font-size: 13px;
|
||||
color: var(--text-secondary);
|
||||
text-align: center;
|
||||
line-height: 1.5;
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
|
||||
.sns-confirm-actions {
|
||||
display: flex;
|
||||
gap: 10px;
|
||||
width: 100%;
|
||||
margin-top: 4px;
|
||||
|
||||
button {
|
||||
flex: 1;
|
||||
height: 36px;
|
||||
border-radius: 8px;
|
||||
font-size: 14px;
|
||||
font-weight: 500;
|
||||
cursor: pointer;
|
||||
border: 1px solid var(--border-color);
|
||||
transition: all 0.15s;
|
||||
}
|
||||
|
||||
.sns-confirm-cancel {
|
||||
background: var(--bg-tertiary);
|
||||
color: var(--text-secondary);
|
||||
|
||||
&:hover {
|
||||
background: var(--bg-hover);
|
||||
color: var(--text-primary);
|
||||
}
|
||||
}
|
||||
|
||||
.sns-confirm-ok {
|
||||
background: #ff4d4f;
|
||||
color: #fff;
|
||||
border-color: #ff4d4f;
|
||||
|
||||
&:hover {
|
||||
background: #ff7875;
|
||||
border-color: #ff7875;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 朋友圈防删除插件对话框
|
||||
.sns-protect-dialog {
|
||||
background: var(--bg-secondary);
|
||||
border: 1px solid var(--border-color);
|
||||
border-radius: 16px;
|
||||
width: 340px;
|
||||
padding: 32px 28px 24px;
|
||||
position: relative;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
gap: 0;
|
||||
box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
|
||||
|
||||
.sns-protect-close {
|
||||
position: absolute;
|
||||
top: 14px;
|
||||
right: 14px;
|
||||
background: none;
|
||||
border: none;
|
||||
color: var(--text-tertiary);
|
||||
cursor: pointer;
|
||||
padding: 4px;
|
||||
border-radius: 6px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
|
||||
&:hover {
|
||||
color: var(--text-primary);
|
||||
background: var(--bg-hover);
|
||||
}
|
||||
}
|
||||
|
||||
.sns-protect-hero {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.sns-protect-icon-wrap {
|
||||
width: 64px;
|
||||
height: 64px;
|
||||
border-radius: 18px;
|
||||
background: var(--bg-tertiary);
|
||||
color: var(--text-tertiary);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
transition: all 0.3s;
|
||||
|
||||
&.active {
|
||||
background: rgba(76, 175, 80, 0.12);
|
||||
color: var(--color-success, #4caf50);
|
||||
}
|
||||
}
|
||||
|
||||
.sns-protect-title {
|
||||
font-size: 17px;
|
||||
font-weight: 600;
|
||||
color: var(--text-primary);
|
||||
}
|
||||
|
||||
.sns-protect-status-badge {
|
||||
font-size: 12px;
|
||||
font-weight: 500;
|
||||
padding: 3px 10px;
|
||||
border-radius: 20px;
|
||||
|
||||
&.on {
|
||||
background: rgba(76, 175, 80, 0.12);
|
||||
color: var(--color-success, #4caf50);
|
||||
}
|
||||
|
||||
&.off {
|
||||
background: var(--bg-tertiary);
|
||||
color: var(--text-tertiary);
|
||||
}
|
||||
}
|
||||
|
||||
.sns-protect-desc {
|
||||
font-size: 13px;
|
||||
color: var(--text-secondary);
|
||||
text-align: center;
|
||||
line-height: 1.6;
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
|
||||
.sns-protect-feedback {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
font-size: 13px;
|
||||
padding: 8px 12px;
|
||||
border-radius: 8px;
|
||||
width: 100%;
|
||||
margin-bottom: 14px;
|
||||
box-sizing: border-box;
|
||||
|
||||
&.success {
|
||||
background: rgba(76, 175, 80, 0.1);
|
||||
color: var(--color-success, #4caf50);
|
||||
}
|
||||
|
||||
&.error {
|
||||
background: rgba(244, 67, 54, 0.1);
|
||||
color: var(--color-error, #f44336);
|
||||
}
|
||||
}
|
||||
|
||||
.sns-protect-actions {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.sns-protect-btn {
|
||||
width: 100%;
|
||||
height: 40px;
|
||||
border-radius: 10px;
|
||||
font-size: 14px;
|
||||
font-weight: 500;
|
||||
cursor: pointer;
|
||||
border: none;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 7px;
|
||||
transition: all 0.15s;
|
||||
|
||||
&.primary {
|
||||
background: var(--color-primary, #1677ff);
|
||||
color: #fff;
|
||||
|
||||
&:hover:not(:disabled) {
|
||||
filter: brightness(1.1);
|
||||
}
|
||||
}
|
||||
|
||||
&.danger {
|
||||
background: var(--bg-tertiary);
|
||||
color: var(--text-secondary);
|
||||
border: 1px solid var(--border-color);
|
||||
|
||||
&:hover:not(:disabled) {
|
||||
background: rgba(255, 77, 79, 0.08);
|
||||
color: #ff4d4f;
|
||||
border-color: rgba(255, 77, 79, 0.3);
|
||||
}
|
||||
}
|
||||
|
||||
&:disabled {
|
||||
opacity: 0.5;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.post-text {
|
||||
font-size: 15px;
|
||||
line-height: 1.6;
|
||||
@@ -322,6 +600,13 @@
|
||||
.comment-colon {
|
||||
margin-right: 4px;
|
||||
}
|
||||
|
||||
.comment-custom-emoji {
|
||||
display: inline-block;
|
||||
vertical-align: middle;
|
||||
border-radius: 4px;
|
||||
margin-left: 2px;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -950,7 +1235,7 @@
|
||||
display: flex;
|
||||
|
||||
&:hover {
|
||||
background: rgba(0, 0, 0, 0.05);
|
||||
background: var(--bg-primary);
|
||||
color: var(--text-primary);
|
||||
}
|
||||
}
|
||||
@@ -992,7 +1277,7 @@
|
||||
Export Dialog
|
||||
========================================= */
|
||||
.export-dialog {
|
||||
background: rgba(255, 255, 255, 0.88);
|
||||
background: var(--bg-secondary);
|
||||
border-radius: var(--sns-border-radius-lg);
|
||||
box-shadow: 0 12px 40px rgba(0, 0, 0, 0.18);
|
||||
width: 480px;
|
||||
@@ -1028,7 +1313,7 @@
|
||||
display: flex;
|
||||
|
||||
&:hover {
|
||||
background: rgba(0, 0, 0, 0.05);
|
||||
background: var(--bg-primary);
|
||||
color: var(--text-primary);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { useEffect, useLayoutEffect, useState, useRef, useCallback } from 'react'
|
||||
import { RefreshCw, Search, X, Download, FolderOpen, FileJson, FileText, Image, CheckCircle, AlertCircle, Calendar, Users, Info, ChevronLeft, ChevronRight } from 'lucide-react'
|
||||
import { RefreshCw, Search, X, Download, FolderOpen, FileJson, FileText, Image, CheckCircle, AlertCircle, Calendar, Users, Info, ChevronLeft, ChevronRight, Shield, ShieldOff } from 'lucide-react'
|
||||
import JumpToDateDialog from '../components/JumpToDateDialog'
|
||||
import './SnsPage.scss'
|
||||
import { SnsPost } from '../types/sns'
|
||||
@@ -46,6 +46,12 @@ export default function SnsPage() {
|
||||
const [calendarPicker, setCalendarPicker] = useState<{ field: 'start' | 'end'; month: Date } | null>(null)
|
||||
const [showYearMonthPicker, setShowYearMonthPicker] = useState(false)
|
||||
|
||||
// 触发器相关状态
|
||||
const [showTriggerDialog, setShowTriggerDialog] = useState(false)
|
||||
const [triggerInstalled, setTriggerInstalled] = useState<boolean | null>(null)
|
||||
const [triggerLoading, setTriggerLoading] = useState(false)
|
||||
const [triggerMessage, setTriggerMessage] = useState<{ type: 'success' | 'error'; text: string } | null>(null)
|
||||
|
||||
const postsContainerRef = useRef<HTMLDivElement>(null)
|
||||
const [hasNewer, setHasNewer] = useState(false)
|
||||
const [loadingNewer, setLoadingNewer] = useState(false)
|
||||
@@ -56,7 +62,6 @@ export default function SnsPage() {
|
||||
useEffect(() => {
|
||||
postsRef.current = posts
|
||||
}, [posts])
|
||||
|
||||
// 在 DOM 更新后、浏览器绘制前同步调整滚动位置,防止向上加载时页面跳动
|
||||
useLayoutEffect(() => {
|
||||
const snapshot = scrollAdjustmentRef.current;
|
||||
@@ -285,6 +290,25 @@ export default function SnsPage() {
|
||||
<div className="feed-header">
|
||||
<h2>朋友圈</h2>
|
||||
<div className="header-actions">
|
||||
<button
|
||||
onClick={async () => {
|
||||
setTriggerMessage(null)
|
||||
setShowTriggerDialog(true)
|
||||
setTriggerLoading(true)
|
||||
try {
|
||||
const r = await window.electronAPI.sns.checkBlockDeleteTrigger()
|
||||
setTriggerInstalled(r.success ? (r.installed ?? false) : false)
|
||||
} catch {
|
||||
setTriggerInstalled(false)
|
||||
} finally {
|
||||
setTriggerLoading(false)
|
||||
}
|
||||
}}
|
||||
className="icon-btn"
|
||||
title="朋友圈保护插件"
|
||||
>
|
||||
<Shield size={20} />
|
||||
</button>
|
||||
<button
|
||||
onClick={() => {
|
||||
setExportResult(null)
|
||||
@@ -329,7 +353,7 @@ export default function SnsPage() {
|
||||
{posts.map(post => (
|
||||
<SnsPostItem
|
||||
key={post.id}
|
||||
post={post}
|
||||
post={{ ...post, isProtected: triggerInstalled === true }}
|
||||
onPreview={(src, isVideo, liveVideoPath) => {
|
||||
if (isVideo) {
|
||||
void window.electronAPI.window.openVideoPlayerWindow(src)
|
||||
@@ -338,6 +362,7 @@ export default function SnsPage() {
|
||||
}
|
||||
}}
|
||||
onDebug={(p) => setDebugPost(p)}
|
||||
onDelete={(postId) => setPosts(prev => prev.filter(p => p.id !== postId))}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
@@ -426,6 +451,101 @@ export default function SnsPage() {
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* 朋友圈防删除插件对话框 */}
|
||||
{showTriggerDialog && (
|
||||
<div className="modal-overlay" onClick={() => { setShowTriggerDialog(false); setTriggerMessage(null) }}>
|
||||
<div className="sns-protect-dialog" onClick={(e) => e.stopPropagation()}>
|
||||
<button className="close-btn sns-protect-close" onClick={() => { setShowTriggerDialog(false); setTriggerMessage(null) }}>
|
||||
<X size={18} />
|
||||
</button>
|
||||
|
||||
{/* 顶部图标区 */}
|
||||
<div className="sns-protect-hero">
|
||||
<div className={`sns-protect-icon-wrap ${triggerInstalled ? 'active' : ''}`}>
|
||||
{triggerLoading
|
||||
? <RefreshCw size={28} className="spinning" />
|
||||
: triggerInstalled
|
||||
? <Shield size={28} />
|
||||
: <ShieldOff size={28} />
|
||||
}
|
||||
</div>
|
||||
<div className="sns-protect-title">朋友圈防删除</div>
|
||||
<div className={`sns-protect-status-badge ${triggerInstalled ? 'on' : 'off'}`}>
|
||||
{triggerLoading ? '检查中…' : triggerInstalled ? '已启用' : '未启用'}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* 说明 */}
|
||||
<div className="sns-protect-desc">
|
||||
启用后,WeFlow将拦截朋友圈删除操作<br/>已同步的动态不会从本地数据库中消失<br/>新的动态仍可正常同步。
|
||||
</div>
|
||||
|
||||
{/* 操作反馈 */}
|
||||
{triggerMessage && (
|
||||
<div className={`sns-protect-feedback ${triggerMessage.type}`}>
|
||||
{triggerMessage.type === 'success' ? <CheckCircle size={14} /> : <AlertCircle size={14} />}
|
||||
<span>{triggerMessage.text}</span>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* 操作按钮 */}
|
||||
<div className="sns-protect-actions">
|
||||
{!triggerInstalled ? (
|
||||
<button
|
||||
className="sns-protect-btn primary"
|
||||
disabled={triggerLoading}
|
||||
onClick={async () => {
|
||||
setTriggerLoading(true)
|
||||
setTriggerMessage(null)
|
||||
try {
|
||||
const r = await window.electronAPI.sns.installBlockDeleteTrigger()
|
||||
if (r.success) {
|
||||
setTriggerInstalled(true)
|
||||
setTriggerMessage({ type: 'success', text: r.alreadyInstalled ? '插件已存在,无需重复安装' : '已启用朋友圈防删除保护' })
|
||||
} else {
|
||||
setTriggerMessage({ type: 'error', text: r.error || '安装失败' })
|
||||
}
|
||||
} catch (e: any) {
|
||||
setTriggerMessage({ type: 'error', text: e.message || String(e) })
|
||||
} finally {
|
||||
setTriggerLoading(false)
|
||||
}
|
||||
}}
|
||||
>
|
||||
<Shield size={15} />
|
||||
启用保护
|
||||
</button>
|
||||
) : (
|
||||
<button
|
||||
className="sns-protect-btn danger"
|
||||
disabled={triggerLoading}
|
||||
onClick={async () => {
|
||||
setTriggerLoading(true)
|
||||
setTriggerMessage(null)
|
||||
try {
|
||||
const r = await window.electronAPI.sns.uninstallBlockDeleteTrigger()
|
||||
if (r.success) {
|
||||
setTriggerInstalled(false)
|
||||
setTriggerMessage({ type: 'success', text: '已关闭朋友圈防删除保护' })
|
||||
} else {
|
||||
setTriggerMessage({ type: 'error', text: r.error || '卸载失败' })
|
||||
}
|
||||
} catch (e: any) {
|
||||
setTriggerMessage({ type: 'error', text: e.message || String(e) })
|
||||
} finally {
|
||||
setTriggerLoading(false)
|
||||
}
|
||||
}}
|
||||
>
|
||||
<ShieldOff size={15} />
|
||||
关闭保护
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* 导出对话框 */}
|
||||
{showExportDialog && (
|
||||
<div className="modal-overlay" onClick={() => !isExporting && setShowExportDialog(false)}>
|
||||
|
||||
Reference in New Issue
Block a user