UnisKB/ui/src/views/application-overview/component/EmbedDialog.vue

163 lines
4.5 KiB
Vue
Raw Normal View History

2023-11-30 03:29:31 +00:00
<template>
2024-06-05 07:58:50 +00:00
<el-dialog
2025-01-21 11:24:56 +00:00
:title="$t('views.applicationOverview.appInfo.embedInWebsite')"
2024-06-05 07:58:50 +00:00
v-model="dialogVisible"
width="900"
class="embed-dialog"
2024-09-24 11:01:35 +00:00
:close-on-click-modal="false"
:close-on-press-escape="false"
2024-06-05 07:58:50 +00:00
>
2023-11-30 03:29:31 +00:00
<el-row :gutter="12">
<el-col :span="8">
2023-11-30 03:29:31 +00:00
<div class="border">
2024-06-05 07:58:50 +00:00
<p class="title p-16 bold">
{{ $t('views.applicationOverview.appInfo.EmbedDialog.fullscreenModeTitle') }}
</p>
2024-08-20 03:25:23 +00:00
<img src="@/assets/window1.png" alt="" class="ml-8" height="150" />
<div class="code layout-bg border-t p-8">
<div class="flex-between p-8">
2024-06-05 07:58:50 +00:00
<span class="bold">{{
$t('views.applicationOverview.appInfo.EmbedDialog.copyInstructions')
}}</span>
2023-11-30 10:50:42 +00:00
<el-button text @click="copyClick(source1)">
2023-12-01 07:59:50 +00:00
<AppIcon iconName="app-copy"></AppIcon>
2023-11-30 03:29:31 +00:00
</el-button>
</div>
<el-scrollbar height="150" always>
<div class="pre-wrap p-8 pt-0">
{{ source1 }}
</div>
</el-scrollbar>
2023-11-30 03:29:31 +00:00
</div>
</div>
</el-col>
<el-col :span="8">
<div class="border">
<p class="title p-16 bold">
{{ $t('views.applicationOverview.appInfo.EmbedDialog.mobileModeTitle') }}
</p>
<img src="@/assets/window3.png" alt="" class="ml-8" height="150" />
<div class="code layout-bg border-t p-8">
<div class="flex-between p-8">
<span class="bold">{{
$t('views.applicationOverview.appInfo.EmbedDialog.copyInstructions')
}}</span>
<el-button text @click="copyClick(source3)">
<AppIcon iconName="app-copy"></AppIcon>
</el-button>
</div>
<el-scrollbar height="150" always>
<div class="pre-wrap p-8 pt-0">
{{ source3 }}
</div>
</el-scrollbar>
</div>
</div>
</el-col>
<el-col :span="8">
2023-11-30 03:29:31 +00:00
<div class="border">
2024-06-05 07:58:50 +00:00
<p class="title p-16 bold">
{{ $t('views.applicationOverview.appInfo.EmbedDialog.floatingModeTitle') }}
</p>
2024-08-20 03:25:23 +00:00
<img src="@/assets/window2.png" alt="" class="ml-8" height="150" />
<div class="code layout-bg border-t p-8">
<div class="flex-between p-8">
2024-06-05 07:58:50 +00:00
<span class="bold">{{
$t('views.applicationOverview.appInfo.EmbedDialog.copyInstructions')
}}</span>
2023-11-30 10:50:42 +00:00
<el-button text @click="copyClick(source2)">
2023-12-01 03:36:04 +00:00
<AppIcon iconName="app-copy"></AppIcon>
2023-11-30 03:29:31 +00:00
</el-button>
</div>
<el-scrollbar height="150" always>
<div class="pre-wrap p-8 pt-0">
{{ source2 }}
</div>
</el-scrollbar>
2023-11-30 03:29:31 +00:00
</div>
</div>
</el-col>
</el-row>
</el-dialog>
</template>
<script setup lang="ts">
import { computed, ref, watch } from 'vue'
2023-11-30 10:50:42 +00:00
import { copyClick } from '@/utils/clipboard'
import useStore from '@/stores'
2023-12-01 07:59:50 +00:00
2023-11-30 10:50:42 +00:00
const { application } = useStore()
2023-11-30 03:29:31 +00:00
const props = defineProps({
data: Object,
apiInputParams: String
})
2023-11-30 03:29:31 +00:00
const emit = defineEmits(['addData'])
const dialogVisible = ref<boolean>(false)
2023-11-30 10:50:42 +00:00
2023-12-01 07:59:50 +00:00
const source1 = ref('')
const source2 = ref('')
const source3 = ref('')
2023-12-01 07:59:50 +00:00
2024-09-24 11:01:35 +00:00
const urlParams1 = computed(() => (props.apiInputParams ? '?' + props.apiInputParams : ''))
const urlParams2 = computed(() => (props.apiInputParams ? '&' + props.apiInputParams : ''))
2023-12-01 07:59:50 +00:00
watch(dialogVisible, (bool) => {
if (!bool) {
source1.value = ''
source2.value = ''
source3.value = ''
2023-12-01 07:59:50 +00:00
}
})
const open = (val: string) => {
source1.value = `<iframe
src="${application.location + val + urlParams1.value}"
style="width: 100%; height: 100%;"
frameborder="0"
2023-11-30 03:29:31 +00:00
allow="microphone">
</iframe>
2023-12-01 07:59:50 +00:00
`
source2.value = `<script
2024-03-14 05:45:39 +00:00
async
defer
src="${window.location.origin}/api/application/embed?protocol=${window.location.protocol.replace(
':',
''
)}&host=${window.location.host}&token=${val}${urlParams2.value}">
2023-11-30 03:29:31 +00:00
<\/script>
2023-12-01 07:59:50 +00:00
`
source3.value = `<iframe
src="${application.location + val + urlParams1.value}?mode=mobile"
style="width: 100%; height: 100%;"
frameborder="0"
allow="microphone">
</iframe>
`
2023-11-30 03:29:31 +00:00
dialogVisible.value = true
}
defineExpose({ open })
</script>
<style lang="scss" scoped>
2023-11-30 03:29:31 +00:00
.embed-dialog {
2023-12-26 08:56:14 +00:00
.title {
color: var(--app-text-color) !important;
}
2023-11-30 03:29:31 +00:00
.code {
color: var(--app-text-color) !important;
2024-07-01 01:45:59 +00:00
2023-11-30 03:29:31 +00:00
font-weight: 400;
font-size: 13px;
white-space: pre;
height: 188px;
2023-11-30 03:29:31 +00:00
}
}
</style>