修复国家检测bug
This commit is contained in:
@@ -53,16 +53,22 @@ export function usePythonBridge() {
|
||||
await window.electronAPI.tk.visitAnchor(id);
|
||||
};
|
||||
|
||||
// backStageloginStatus
|
||||
const backStageloginStatus = async () => {
|
||||
// 查询后台登录状态(合并接口,通过 account 参数区分)
|
||||
// account: 公会账号,不传则返回所有账号状态
|
||||
const backStageloginStatus = async (account) => {
|
||||
if (!inElectron) return null;
|
||||
return await window.electronAPI.tk.checkBackStageLoginStatus();
|
||||
try {
|
||||
const res = await window.electronAPI.tk.checkBackStageLoginStatus(account);
|
||||
return typeof res === 'string' ? JSON.parse(res) : res;
|
||||
} catch (e) {
|
||||
console.error('backStageloginStatus error:', e);
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
// backStageloginStatusCopy
|
||||
const backStageloginStatusCopy = async () => {
|
||||
if (!inElectron) return null;
|
||||
return await window.electronAPI.tk.checkBackStageLoginStatusCopy();
|
||||
// 兼容旧接口:查询副账号登录状态(内部调用合并后的接口)
|
||||
const backStageloginStatusCopy = async (account) => {
|
||||
return await backStageloginStatus(account);
|
||||
};
|
||||
|
||||
// exportToExcel
|
||||
@@ -125,9 +131,17 @@ export function usePythonBridge() {
|
||||
await window.electronAPI.tk.openRoom(id);
|
||||
};
|
||||
|
||||
// Clipboard helper - maybe use navigator.clipboard directly in Vue component?
|
||||
// Original used python bridge for clipboard.
|
||||
// Clipboard helper - 优先使用 Python RPC,fallback 到浏览器 API
|
||||
const setClipboards = async (text) => {
|
||||
if (inElectron) {
|
||||
try {
|
||||
const result = await window.electronAPI.tk.setClipboard(text);
|
||||
if (result.success) return true;
|
||||
} catch (e) {
|
||||
console.warn('Electron clipboard failed, fallback to browser:', e);
|
||||
}
|
||||
}
|
||||
// Fallback to browser API
|
||||
try {
|
||||
await navigator.clipboard.writeText(text);
|
||||
return true;
|
||||
@@ -137,6 +151,78 @@ export function usePythonBridge() {
|
||||
}
|
||||
}
|
||||
|
||||
// ========== 新增接口 ==========
|
||||
|
||||
// 启动大哥监控(TikTok 登录)
|
||||
const startBrotherMonitor = async () => {
|
||||
if (!inElectron) return { success: false, error: 'Not in Electron' };
|
||||
try {
|
||||
return await window.electronAPI.tk.startBrotherMonitor();
|
||||
} catch (e) {
|
||||
console.error('startBrotherMonitor error:', e);
|
||||
return { success: false, error: String(e) };
|
||||
}
|
||||
};
|
||||
|
||||
// 获取大哥模块 TikTok 登录状态
|
||||
const getBrotherLoginStatus = async () => {
|
||||
if (!inElectron) return { isLoggedIn: false };
|
||||
try {
|
||||
const res = await window.electronAPI.tk.getBrotherLoginStatus();
|
||||
return JSON.parse(res);
|
||||
} catch (e) {
|
||||
console.error('getBrotherLoginStatus error:', e);
|
||||
return { isLoggedIn: false };
|
||||
}
|
||||
};
|
||||
|
||||
// 打开大哥个人主页
|
||||
const visitGifter = async (data) => {
|
||||
if (!inElectron) return { success: false };
|
||||
try {
|
||||
// data 可以是 { id: 'xxx' } 或 { uniqueId: 'xxx' }
|
||||
return await window.electronAPI.tk.visitGifter(JSON.stringify(data));
|
||||
} catch (e) {
|
||||
console.error('visitGifter error:', e);
|
||||
return { success: false, error: String(e) };
|
||||
}
|
||||
};
|
||||
|
||||
// 关闭所有浏览器
|
||||
const closeAllBrowsers = async () => {
|
||||
if (!inElectron) return { success: false, error: 'Not in Electron' };
|
||||
try {
|
||||
return await window.electronAPI.tk.closeAllBrowsers();
|
||||
} catch (e) {
|
||||
console.error('closeAllBrowsers error:', e);
|
||||
return { success: false, error: String(e) };
|
||||
}
|
||||
};
|
||||
|
||||
// 加密存储账号信息
|
||||
const storageAccountInfo = async (data) => {
|
||||
if (!inElectron) return { success: false, error: 'Not in Electron' };
|
||||
try {
|
||||
// data: { key: string, data: object }
|
||||
return await window.electronAPI.tk.storageAccount(JSON.stringify(data));
|
||||
} catch (e) {
|
||||
console.error('storageAccountInfo error:', e);
|
||||
return { success: false, error: String(e) };
|
||||
}
|
||||
};
|
||||
|
||||
// 解密读取账号信息
|
||||
const readAccountInfo = async (key) => {
|
||||
if (!inElectron) return { status: 'error', message: 'Not in Electron', data: null };
|
||||
try {
|
||||
const res = await window.electronAPI.tk.readAccount(JSON.stringify({ key }));
|
||||
return JSON.parse(res);
|
||||
} catch (e) {
|
||||
console.error('readAccountInfo error:', e);
|
||||
return { status: 'error', message: String(e), data: null };
|
||||
}
|
||||
};
|
||||
|
||||
return {
|
||||
fetchDataConfig,
|
||||
fetchDataCount,
|
||||
@@ -156,6 +242,13 @@ export function usePythonBridge() {
|
||||
storageSetInfos,
|
||||
readSetInfos,
|
||||
openAnchorIdRooms,
|
||||
setClipboards
|
||||
setClipboards,
|
||||
// 新增接口
|
||||
startBrotherMonitor,
|
||||
getBrotherLoginStatus,
|
||||
visitGifter,
|
||||
closeAllBrowsers,
|
||||
storageAccountInfo,
|
||||
readAccountInfo
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user