perf: useOpenURL SaySimple
gitea/salix-front/pipeline/pr-master This commit looks good
Details
gitea/salix-front/pipeline/pr-master This commit looks good
Details
This commit is contained in:
parent
e2304396d8
commit
137798c959
|
@ -2,6 +2,7 @@
|
||||||
import { reactive, useAttrs, onBeforeMount, capitalize } from 'vue';
|
import { reactive, useAttrs, onBeforeMount, capitalize } from 'vue';
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
import { parsePhone } from 'src/filters';
|
import { parsePhone } from 'src/filters';
|
||||||
|
import useOpenURL from 'src/composables/useOpenURL';
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
phoneNumber: { type: [String, Number], default: null },
|
phoneNumber: { type: [String, Number], default: null },
|
||||||
channel: { type: Number, default: null },
|
channel: { type: Number, default: null },
|
||||||
|
@ -11,25 +12,31 @@ const config = reactive({
|
||||||
sip: { icon: 'phone', href: `sip:${props.phoneNumber}` },
|
sip: { icon: 'phone', href: `sip:${props.phoneNumber}` },
|
||||||
'say-simple': {
|
'say-simple': {
|
||||||
icon: 'vn:saysimple',
|
icon: 'vn:saysimple',
|
||||||
href: null,
|
|
||||||
channel: props.channel,
|
channel: props.channel,
|
||||||
|
url: null,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
const type = Object.keys(config).find((key) => key in useAttrs()) || 'sip';
|
const type = Object.keys(config).find((key) => key in useAttrs()) || 'sip';
|
||||||
|
|
||||||
onBeforeMount(async () => {
|
onBeforeMount(async () => {
|
||||||
let { channel } = config[type];
|
let { channel, url } = config[type];
|
||||||
|
|
||||||
if (type === 'say-simple') {
|
if (type === 'say-simple') {
|
||||||
const { url, defaultChannel } = (await axios.get('SaySimpleConfigs/findOne'))
|
const { url: defaultUrl, defaultChannel } = (
|
||||||
.data;
|
await axios.get('SaySimpleConfigs/findOne')
|
||||||
if (!channel) channel = defaultChannel;
|
).data;
|
||||||
|
if (!channel) config[type].channel = defaultChannel;
|
||||||
config[type].href = `${url}?customerIdentity=%2B${parsePhone(
|
if (!url) config[type].url = defaultUrl;
|
||||||
props.phoneNumber
|
|
||||||
)}&channelId=${channel}`;
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
function openSaySimple() {
|
||||||
|
useOpenURL(
|
||||||
|
`${config[type].url}?customerIdentity=%2B${parsePhone(
|
||||||
|
props.phoneNumber
|
||||||
|
)}&channelId=${config[type].channel}`
|
||||||
|
);
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
<QBtn
|
<QBtn
|
||||||
|
@ -40,8 +47,7 @@ onBeforeMount(async () => {
|
||||||
size="sm"
|
size="sm"
|
||||||
color="primary"
|
color="primary"
|
||||||
padding="none"
|
padding="none"
|
||||||
:href="config[type].href"
|
@click.stop="openSaySimple"
|
||||||
@click.stop
|
|
||||||
>
|
>
|
||||||
<QTooltip>
|
<QTooltip>
|
||||||
{{ capitalize(type).replace('-', '') }}
|
{{ capitalize(type).replace('-', '') }}
|
||||||
|
|
Loading…
Reference in New Issue