mirror of
https://wget.la/https://github.com/Wxw-Gu/WechatExplorer
synced 2026-10-04 03:01:42 +08:00
feat: 优化 macOS 微信发送消息能力
参考 wechat_chatter PR #36: https://github.com/yincongcyincong/wechat_chatter/pull/36 补充 WeChat 4.1.11.53 的 GetService / CdnManager 地址, 并适配绑定后的发送能力检测逻辑。
This commit is contained in:
@@ -169,9 +169,9 @@ describe('PersonalWechatSendDialog', () => {
|
||||
it('keeps the setup guide voice-only when voice capability is unavailable', async () => {
|
||||
getStatus.mockResolvedValue({ ...readyStatus, canSend: false, canSendVoice: false })
|
||||
renderDialog({ onOpenPersonalWechatSettings: vi.fn() })
|
||||
expect(await screen.findByText('验证消息能力')).toBeInTheDocument()
|
||||
expect(await screen.findByText('初始化发送能力')).toBeInTheDocument()
|
||||
expect(screen.getByText('语音消息')).toBeInTheDocument()
|
||||
expect(screen.queryByText('文字消息')).not.toBeInTheDocument()
|
||||
expect(screen.queryByText('图片和语音消息')).not.toBeInTheDocument()
|
||||
expect(screen.getByText('文字消息')).toBeInTheDocument()
|
||||
expect(screen.getByText('图片消息')).toBeInTheDocument()
|
||||
})
|
||||
})
|
||||
|
||||
@@ -11,6 +11,7 @@ const status = (
|
||||
arch: 'arm64',
|
||||
sipDisabled: true,
|
||||
wechatRunning: true,
|
||||
wechatPid: 123,
|
||||
endpoint: '127.0.0.1:58080',
|
||||
endpointReady: true,
|
||||
runtimeReady: true,
|
||||
@@ -34,10 +35,22 @@ describe('PersonalWechatCapabilityService', () => {
|
||||
['unsupported', status({ platform: 'linux' })],
|
||||
['unconfigured', status({ runtimeReady: false, boundWechatPid: undefined })],
|
||||
['needs_binding', status({ runtimeReady: true, boundWechatPid: undefined })],
|
||||
['needs_verification', status({ boundWechatPid: 123 })],
|
||||
['needs_binding', status({ runtimeReady: true, boundWechatPid: 999 })],
|
||||
['initializing', status({ boundWechatPid: 123 })],
|
||||
['ready', status({ state: 'online', boundWechatPid: 123, canSendImage: true, canSend: true })],
|
||||
[
|
||||
'ready',
|
||||
status({
|
||||
state: 'online',
|
||||
boundWechatPid: 123,
|
||||
canSend: true,
|
||||
canSendText: true,
|
||||
canSendImage: false,
|
||||
canSendVoice: true
|
||||
})
|
||||
],
|
||||
['error', status({ state: 'error', boundWechatPid: 123, error: 'hook failed' })],
|
||||
['needs_verification', status({ platform: 'win32', endpoint: '127.0.0.1:4567' })],
|
||||
['initializing', status({ platform: 'win32', endpoint: '127.0.0.1:4567' })],
|
||||
[
|
||||
'ready',
|
||||
status({
|
||||
|
||||
@@ -29,6 +29,7 @@ import {
|
||||
parseWindowsLoginStatus,
|
||||
parseWindowsHookResponse,
|
||||
parsePersonalWechatHookLog,
|
||||
deriveMacSendCapabilities,
|
||||
prepareWindowsImageFile,
|
||||
WindowsHookHttpError
|
||||
} from '../../src/main/services/personal-wechat-send-service'
|
||||
@@ -328,6 +329,32 @@ describe('personal WeChat runtime discovery', () => {
|
||||
})
|
||||
|
||||
describe('personal WeChat hook diagnostics', () => {
|
||||
it('marks media ready from initialized hooks without an upload capture event', () => {
|
||||
expect(
|
||||
deriveMacSendCapabilities({
|
||||
attached: true,
|
||||
baseAddressReady: true,
|
||||
textHookInstalled: true,
|
||||
textHookReady: true,
|
||||
imageHookInstalled: true,
|
||||
imagePathBound: true
|
||||
})
|
||||
).toEqual({ canSend: true, canSendText: true, canSendImage: true, canSendVoice: true })
|
||||
})
|
||||
|
||||
it('keeps sending unavailable until the native send context is captured', () => {
|
||||
expect(
|
||||
deriveMacSendCapabilities({
|
||||
attached: true,
|
||||
baseAddressReady: true,
|
||||
textHookInstalled: true,
|
||||
textHookReady: false,
|
||||
imageHookInstalled: true,
|
||||
imagePathBound: true
|
||||
}).canSend
|
||||
).toBe(false)
|
||||
})
|
||||
|
||||
it('does not treat a listening service as hook-ready after req2buf scan failure', () => {
|
||||
expect(
|
||||
parsePersonalWechatHookLog(
|
||||
@@ -350,7 +377,7 @@ describe('personal WeChat hook diagnostics', () => {
|
||||
).toMatchObject({ readiness: 'initializing', textHookInstalled: true })
|
||||
expect(
|
||||
parsePersonalWechatHookLog(
|
||||
JSON.stringify({ payload: '[+] 捕获到 StartTask 调用,X0:0x1, Payload: 0x2' })
|
||||
JSON.stringify({ payload: '[+] 捕获到有效 StartTask 上下文,X0:0x1, Payload: 0x2' })
|
||||
)
|
||||
).toMatchObject({ readiness: 'ready', textHookReady: true })
|
||||
})
|
||||
|
||||
@@ -122,7 +122,7 @@ describe('ScheduledReportApiService', () => {
|
||||
)
|
||||
})
|
||||
|
||||
it.each(['unsupported', 'unconfigured', 'needs_binding', 'needs_verification', 'error'] as const)(
|
||||
it.each(['unsupported', 'unconfigured', 'needs_binding', 'initializing', 'error'] as const)(
|
||||
'allows creation and leaves a send warning for capability state %s',
|
||||
async (status) => {
|
||||
const { api, service } = makeApi({ capability: capability(status) })
|
||||
|
||||
@@ -29,7 +29,7 @@ const capability: PersonalWechatSendCapability = {
|
||||
const unavailableCapability: PersonalWechatSendCapability = {
|
||||
...capability,
|
||||
ready: false,
|
||||
status: 'needs_verification',
|
||||
status: 'initializing',
|
||||
capabilities: { text: false, image: false, voice: false },
|
||||
message: '请先完成微信消息能力检测'
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user