pope-test-callkit2
Version:
An Open-source Voice & Video Calling UI Component Based on Tencent Cloud Service.
57 lines (49 loc) • 1.14 kB
text/typescript
import { ref, onMounted, onUnmounted } from '../../adapter-vue';
import { TUIStore } from '../../TUICallService';
import { NAME, StoreName } from '../../TUICallService/const';
export function useTip() {
const tip = ref('');
const show = ref(true);
const duration = ref(0);
const handleCallTipsChange = (value) => {
duration.value = 0;
tip.value = value;
};
const handleToastInfoChange = (value) => {
let text = value;
if (typeof text === 'object') {
text = value?.text;
}
if (text) {
duration.value = 2000;
tip.value = text;
}
};
onMounted(() => {
TUIStore.watch(
StoreName.CALL,
{
[]: handleCallTipsChange,
},
{
notifyRangeWhenWatch: NAME.MYSELF,
},
);
TUIStore.watch(
StoreName.CALL,
{
[]: handleToastInfoChange,
},
);
});
onUnmounted(() => {
TUIStore.unwatch(
StoreName.CALL,
{
[]: handleCallTipsChange,
[]: handleToastInfoChange,
},
);
});
return { tip, show, duration };
}