mirror of
https://wget.la/https://github.com/Wxw-Gu/WechatExplorer
synced 2026-08-18 03:57:02 +08:00
增加自动登录环境开关
This commit is contained in:
@@ -1,6 +1,10 @@
|
|||||||
# WeChat Database Key (Optional, can be entered in UI)
|
# WeChat Database Key (Optional, can be entered in UI)
|
||||||
VITE_DB_KEY=
|
VITE_DB_KEY=
|
||||||
|
|
||||||
|
# Auto login on startup with VITE_DB_KEY or saved key.
|
||||||
|
# Set to true/1/yes/on for local development. Default is disabled.
|
||||||
|
VITE_AUTO_LOGIN=false
|
||||||
|
|
||||||
# AI API Configuration (Optional, can be entered in UI)
|
# AI API Configuration (Optional, can be entered in UI)
|
||||||
VITE_DEEPSEEK_API_KEY=
|
VITE_DEEPSEEK_API_KEY=
|
||||||
VITE_AI_BASE_URL=https://api.deepseek.com
|
VITE_AI_BASE_URL=https://api.deepseek.com
|
||||||
|
|||||||
+12
-18
@@ -48,6 +48,9 @@ interface SelfInfo {
|
|||||||
const MAC_KEY_FAQ_URL = 'https://github.com/hicccc77/WeFlow/blob/main/docs/MAC-KEY-FAQ.md'
|
const MAC_KEY_FAQ_URL = 'https://github.com/hicccc77/WeFlow/blob/main/docs/MAC-KEY-FAQ.md'
|
||||||
const MESSAGE_MONITOR_DEBOUNCE_MS = 8000
|
const MESSAGE_MONITOR_DEBOUNCE_MS = 8000
|
||||||
const VIEW_MESSAGE_LIMIT = 600
|
const VIEW_MESSAGE_LIMIT = 600
|
||||||
|
const AUTO_LOGIN_ENABLED = ['1', 'true', 'yes', 'on'].includes(
|
||||||
|
String(import.meta.env.VITE_AUTO_LOGIN || '').trim().toLowerCase()
|
||||||
|
)
|
||||||
|
|
||||||
const getMessageIdentity = (message: Message): string => {
|
const getMessageIdentity = (message: Message): string => {
|
||||||
if (message.localId) return `local:${message.localId}`
|
if (message.localId) return `local:${message.localId}`
|
||||||
@@ -288,21 +291,18 @@ function App(): React.ReactElement {
|
|||||||
setDbKey(key)
|
setDbKey(key)
|
||||||
setAutoConnectSource(envKey ? 'env' : 'saved')
|
setAutoConnectSource(envKey ? 'env' : 'saved')
|
||||||
setDbKeyStatus(
|
setDbKeyStatus(
|
||||||
envKey ? '已加载环境变量中的密钥,请手动点击 Connect' : '已加载安全保存的密钥,请手动点击 Connect'
|
AUTO_LOGIN_ENABLED
|
||||||
)
|
? envKey
|
||||||
setDbKeyStatusKind('normal')
|
? '检测到环境变量中的密钥,正在自动连接...'
|
||||||
setBootState('login')
|
: '已加载安全保存的密钥,正在自动连接...'
|
||||||
}
|
: envKey
|
||||||
if (true) return
|
? '已加载环境变量中的密钥,请手动点击 Connect'
|
||||||
if (active) {
|
: '已加载安全保存的密钥,请手动点击 Connect'
|
||||||
setBootState('connecting')
|
|
||||||
setDbKey(key)
|
|
||||||
setAutoConnectSource(envKey ? 'env' : 'saved')
|
|
||||||
setDbKeyStatus(
|
|
||||||
envKey ? '检测到环境变量中的密钥,正在自动连接...' : '已加载安全保存的密钥,正在自动连接...'
|
|
||||||
)
|
)
|
||||||
setDbKeyStatusKind('normal')
|
setDbKeyStatusKind('normal')
|
||||||
|
setBootState(AUTO_LOGIN_ENABLED ? 'connecting' : 'login')
|
||||||
}
|
}
|
||||||
|
if (!AUTO_LOGIN_ENABLED) return
|
||||||
try {
|
try {
|
||||||
const result: any = await window.api.initDb(key)
|
const result: any = await window.api.initDb(key)
|
||||||
if (!active) return
|
if (!active) return
|
||||||
@@ -342,12 +342,6 @@ function App(): React.ReactElement {
|
|||||||
}
|
}
|
||||||
}, [])
|
}, [])
|
||||||
|
|
||||||
// useEffect(() => {
|
|
||||||
// if (import.meta.env.VITE_DB_KEY) {
|
|
||||||
// handleLogin(import.meta.env.VITE_DB_KEY);
|
|
||||||
// }
|
|
||||||
// }, []);
|
|
||||||
|
|
||||||
const handleLogin = async (keyInput?: string): Promise<void> => {
|
const handleLogin = async (keyInput?: string): Promise<void> => {
|
||||||
const keyToUse = keyInput || dbKey
|
const keyToUse = keyInput || dbKey
|
||||||
if (!keyToUse) return
|
if (!keyToUse) return
|
||||||
|
|||||||
Reference in New Issue
Block a user