i
This commit is contained in:
gr
2026-10-22 11:12:29 +08:00
480 changed files with 9840 additions and 953 deletions
+34 -2
View File
@@ -26,15 +26,19 @@ const render = moduleFrom(template.code).render
const passthrough = { setup: (_, { slots }) => () => vue.h('div', [slots.default?.(), slots.headerToolbar?.()]) }
const picker = text => ({ setup: () => () => vue.h('button', text) })
function chat(policy = {}) {
function chat(policy = {}, migrationBlocked = vue.ref(false)) {
const requests = [], warnings = [], sdkCalls = []
const guard = moduleFrom(read('utils/appointment-call-guard.ts'))
const server = Object.fromEntries(['calls', 'call', 'groupCall'].map(name => [name, async params => { sdkCalls.push({ name, params }) }]))
const server = Object.fromEntries(['calls', 'call', 'groupCall', 'accept'].map(name => [name, async params => { sdkCalls.push({ name, params }) }]))
const api = { getCallSignature: async params => { requests.push(params); return policy } }
const result = moduleFrom(script.content, name => {
if (name === 'vue') return { ...vue, onMounted() {}, onUnmounted() {} }
if (name === '@/utils/appointment-type') return types
if (name === '@/utils/appointment-call-guard') return guard
if (name === '@/hooks/useDoctorWebConsultation') return {
useDoctorWebConsultation: () => ({ webConsultationBlocked: migrationBlocked, webConsultationMessage: vue.ref('网页端面诊已停用,请医生使用桌面应用进行面诊。'), ensureWebConsultationAllowed: () => !migrationBlocked.value })
}
if (name === '@/utils/doctor-web-consultation') return moduleFrom(read('utils/doctor-web-consultation.ts'))
if (name === '@/utils/im-chat-archive-trigger') return moduleFrom(read('utils/im-chat-archive-trigger.ts'))
if (name === '@/api/tcm') return api
if (name === '@/utils/feedback') return { default: { msgWarning: text => warnings.push(text) } }
@@ -144,3 +148,31 @@ test('singleton call guard switches to current chat and cancels a pending old co
releaseNew()
await assert.rejects(guard.checkAppointmentOutgoingCall({ type: 2 }), /先打开/)
})
test('a cached video session stops every outgoing SDK path and incoming accept after migration', async () => {
const blocked = vue.ref(false)
const { state, server, sdkCalls, requests } = chat(policy('video'), blocked)
state.installTUICallKitRoomHooks()
assert.equal(state.canVideoCall.value, true)
blocked.value = true
assert.equal(state.canVideoCall.value, false)
assert.equal(state.canAudioCall.value, false)
for (const method of ['call', 'calls', 'groupCall', 'accept']) {
await assert.rejects(server[method]({ type: 2 }), /桌面应用/)
}
await state.startGroupVideoCall()
assert.deepEqual(sdkCalls, [])
assert.deepEqual(requests, [])
})
test('a signature request spanning the deadline never reaches the calling SDK', async () => {
const blocked = vue.ref(false)
const { state, server, sdkCalls, api } = chat(policy('video'), blocked)
state.installTUICallKitRoomHooks()
api.getCallSignature = async () => {
blocked.value = true
return policy('video')
}
await assert.rejects(server.calls({ type: 2 }), /桌面应用/)
assert.deepEqual(sdkCalls, [])
})