mirror of
https://github.com/hicccc77/WeFlow.git
synced 2026-04-22 15:09:04 +00:00
Merge pull request #24 from Jasonzhu1207/fix/ai-insight-weibo-ui-cookie-modal-timeout
fix: stabilize AI insight Weibo UI and cookie flow
This commit is contained in:
@@ -1849,6 +1849,20 @@
|
|||||||
animation: fadeIn 0.2s ease;
|
animation: fadeIn 0.2s ease;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.social-cookie-modal-overlay {
|
||||||
|
position: fixed;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
right: 0;
|
||||||
|
bottom: 0;
|
||||||
|
background: rgba(0, 0, 0, 0.52);
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
z-index: 2300;
|
||||||
|
animation: fadeIn 0.2s ease;
|
||||||
|
}
|
||||||
|
|
||||||
// API 警告弹窗
|
// API 警告弹窗
|
||||||
.api-warning-modal {
|
.api-warning-modal {
|
||||||
width: 420px;
|
width: 420px;
|
||||||
@@ -1920,6 +1934,9 @@
|
|||||||
|
|
||||||
.settings-inline-modal {
|
.settings-inline-modal {
|
||||||
width: min(560px, calc(100vw - 40px));
|
width: min(560px, calc(100vw - 40px));
|
||||||
|
max-height: min(720px, calc(100vh - 40px));
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
background: var(--bg-primary);
|
background: var(--bg-primary);
|
||||||
border-radius: 16px;
|
border-radius: 16px;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
@@ -1946,7 +1963,9 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.modal-body {
|
.modal-body {
|
||||||
|
flex: 1;
|
||||||
padding: 20px 24px;
|
padding: 20px 24px;
|
||||||
|
overflow-y: auto;
|
||||||
|
|
||||||
.warning-text {
|
.warning-text {
|
||||||
margin: 0 0 16px;
|
margin: 0 0 16px;
|
||||||
@@ -3580,6 +3599,103 @@
|
|||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
&.insight-social-tab {
|
||||||
|
.anti-revoke-list-header {
|
||||||
|
grid-template-columns: minmax(0, 1fr) minmax(300px, 420px) auto;
|
||||||
|
|
||||||
|
.insight-social-column-title {
|
||||||
|
color: var(--text-tertiary);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.anti-revoke-row {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: minmax(0, 1fr) minmax(300px, 420px) auto;
|
||||||
|
align-items: center;
|
||||||
|
gap: 14px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.anti-revoke-row-main {
|
||||||
|
min-width: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.insight-social-binding-cell {
|
||||||
|
min-width: 0;
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: minmax(0, 1fr) auto;
|
||||||
|
gap: 8px 10px;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.insight-social-binding-input-wrap {
|
||||||
|
min-width: 0;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.binding-platform-chip {
|
||||||
|
flex-shrink: 0;
|
||||||
|
border-radius: 999px;
|
||||||
|
padding: 2px 8px;
|
||||||
|
font-size: 11px;
|
||||||
|
color: var(--text-secondary);
|
||||||
|
border: 1px solid color-mix(in srgb, var(--border-color) 84%, transparent);
|
||||||
|
background: color-mix(in srgb, var(--bg-secondary) 88%, var(--bg-primary) 12%);
|
||||||
|
}
|
||||||
|
|
||||||
|
.insight-social-binding-input {
|
||||||
|
width: 100%;
|
||||||
|
min-width: 0;
|
||||||
|
height: 30px;
|
||||||
|
border-radius: 8px;
|
||||||
|
border: 1px solid var(--border-color);
|
||||||
|
background: color-mix(in srgb, var(--bg-primary) 92%, var(--bg-secondary) 8%);
|
||||||
|
color: var(--text-primary);
|
||||||
|
font-size: 12px;
|
||||||
|
padding: 0 10px;
|
||||||
|
outline: none;
|
||||||
|
transition: border-color 0.18s ease, box-shadow 0.18s ease;
|
||||||
|
|
||||||
|
&:focus {
|
||||||
|
border-color: color-mix(in srgb, var(--primary) 55%, var(--border-color));
|
||||||
|
box-shadow: 0 0 0 2px color-mix(in srgb, var(--primary) 16%, transparent);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.insight-social-binding-actions {
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-self: flex-end;
|
||||||
|
gap: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.insight-social-binding-feedback {
|
||||||
|
grid-column: 1 / span 2;
|
||||||
|
min-height: 18px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.binding-feedback {
|
||||||
|
font-size: 12px;
|
||||||
|
line-height: 1.4;
|
||||||
|
color: var(--text-secondary);
|
||||||
|
|
||||||
|
&.error {
|
||||||
|
color: color-mix(in srgb, var(--danger) 72%, var(--text-primary) 28%);
|
||||||
|
}
|
||||||
|
|
||||||
|
&.muted {
|
||||||
|
color: var(--text-tertiary);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.anti-revoke-row-status {
|
||||||
|
justify-self: flex-end;
|
||||||
|
align-items: flex-end;
|
||||||
|
max-width: none;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@media (max-width: 980px) {
|
@media (max-width: 980px) {
|
||||||
.anti-revoke-hero {
|
.anti-revoke-hero {
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
|
|||||||
@@ -2870,6 +2870,20 @@ function SettingsPage({ onClose }: SettingsPageProps = {}) {
|
|||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const withAsyncTimeout = async <T,>(task: Promise<T>, timeoutMs: number, timeoutMessage: string): Promise<T> => {
|
||||||
|
let timeoutHandle: ReturnType<typeof setTimeout> | null = null
|
||||||
|
try {
|
||||||
|
return await Promise.race([
|
||||||
|
task,
|
||||||
|
new Promise<T>((_, reject) => {
|
||||||
|
timeoutHandle = setTimeout(() => reject(new Error(timeoutMessage)), timeoutMs)
|
||||||
|
})
|
||||||
|
])
|
||||||
|
} finally {
|
||||||
|
if (timeoutHandle) clearTimeout(timeoutHandle)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const hasWeiboCookieConfigured = aiInsightWeiboCookie.trim().length > 0
|
const hasWeiboCookieConfigured = aiInsightWeiboCookie.trim().length > 0
|
||||||
|
|
||||||
const openWeiboCookieModal = () => {
|
const openWeiboCookieModal = () => {
|
||||||
@@ -2884,7 +2898,11 @@ function SettingsPage({ onClose }: SettingsPageProps = {}) {
|
|||||||
setIsSavingWeiboCookie(true)
|
setIsSavingWeiboCookie(true)
|
||||||
setWeiboCookieError('')
|
setWeiboCookieError('')
|
||||||
try {
|
try {
|
||||||
const result = await window.electronAPI.social.saveWeiboCookie(draftToSave)
|
const result = await withAsyncTimeout(
|
||||||
|
window.electronAPI.social.saveWeiboCookie(draftToSave),
|
||||||
|
10000,
|
||||||
|
'保存微博 Cookie 超时,请稍后重试'
|
||||||
|
)
|
||||||
if (!result.success) {
|
if (!result.success) {
|
||||||
setWeiboCookieError(result.error || '微博 Cookie 保存失败')
|
setWeiboCookieError(result.error || '微博 Cookie 保存失败')
|
||||||
return false
|
return false
|
||||||
@@ -2935,10 +2953,6 @@ function SettingsPage({ onClose }: SettingsPageProps = {}) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const handleSaveWeiboBinding = async (sessionId: string, displayName: string) => {
|
const handleSaveWeiboBinding = async (sessionId: string, displayName: string) => {
|
||||||
if (!hasWeiboCookieConfigured) {
|
|
||||||
setWeiboBindingErrors((prev) => ({ ...prev, [sessionId]: '请先填写微博 Cookie,再进行 UID 绑定' }))
|
|
||||||
return
|
|
||||||
}
|
|
||||||
const draftUid = getWeiboBindingDraftValue(sessionId)
|
const draftUid = getWeiboBindingDraftValue(sessionId)
|
||||||
setWeiboBindingLoadingSessionId(sessionId)
|
setWeiboBindingLoadingSessionId(sessionId)
|
||||||
setWeiboBindingErrors((prev) => {
|
setWeiboBindingErrors((prev) => {
|
||||||
@@ -2948,7 +2962,11 @@ function SettingsPage({ onClose }: SettingsPageProps = {}) {
|
|||||||
return next
|
return next
|
||||||
})
|
})
|
||||||
try {
|
try {
|
||||||
const result = await window.electronAPI.social.validateWeiboUid(draftUid)
|
const result = await withAsyncTimeout(
|
||||||
|
window.electronAPI.social.validateWeiboUid(draftUid),
|
||||||
|
12000,
|
||||||
|
'微博 UID 校验超时,请稍后重试'
|
||||||
|
)
|
||||||
if (!result.success || !result.uid) {
|
if (!result.success || !result.uid) {
|
||||||
setWeiboBindingErrors((prev) => ({ ...prev, [sessionId]: result.error || '微博 UID 校验失败' }))
|
setWeiboBindingErrors((prev) => ({ ...prev, [sessionId]: result.error || '微博 UID 校验失败' }))
|
||||||
return
|
return
|
||||||
@@ -3552,6 +3570,8 @@ function SettingsPage({ onClose }: SettingsPageProps = {}) {
|
|||||||
<span className="binding-feedback error">{weiboBindingError}</span>
|
<span className="binding-feedback error">{weiboBindingError}</span>
|
||||||
) : weiboBinding?.screenName ? (
|
) : weiboBinding?.screenName ? (
|
||||||
<span className="binding-feedback">@{weiboBinding.screenName}</span>
|
<span className="binding-feedback">@{weiboBinding.screenName}</span>
|
||||||
|
) : weiboBinding?.uid ? (
|
||||||
|
<span className="binding-feedback">已绑定 UID:{weiboBinding.uid}</span>
|
||||||
) : (
|
) : (
|
||||||
<span className="binding-feedback muted">仅支持手动填写数字 UID</span>
|
<span className="binding-feedback muted">仅支持手动填写数字 UID</span>
|
||||||
)}
|
)}
|
||||||
@@ -4563,7 +4583,7 @@ function SettingsPage({ onClose }: SettingsPageProps = {}) {
|
|||||||
|
|
||||||
{showWeiboCookieModal && (
|
{showWeiboCookieModal && (
|
||||||
<div
|
<div
|
||||||
className="modal-overlay"
|
className="social-cookie-modal-overlay"
|
||||||
onClick={(e) => {
|
onClick={(e) => {
|
||||||
e.stopPropagation()
|
e.stopPropagation()
|
||||||
void handleCloseWeiboCookieModal()
|
void handleCloseWeiboCookieModal()
|
||||||
|
|||||||
Reference in New Issue
Block a user