|
@@ -5,11 +5,12 @@ import styles from './share.module.less'
|
|
|
import request from "/src/helpers/request";
|
|
|
import { vaildStudentUrl } from "/src/helpers/validate";
|
|
|
import { toPng } from "html-to-image";
|
|
|
-import copy from "copy-to-clipboard";
|
|
|
+import Clipboard from "clipboard";
|
|
|
import GroupChat from './groupChat'
|
|
|
import Preview from './preview'
|
|
|
import { state } from '/src/state'
|
|
|
const GroupChatRef: Ref<DefineComponent<{}, {}, any> | null> = ref(null)
|
|
|
+const shareText: Ref<HTMLDivElement | null> = ref(null)
|
|
|
export default defineComponent({
|
|
|
name: 'LiveBroadcastShare',
|
|
|
props: {
|
|
@@ -26,13 +27,13 @@ export default defineComponent({
|
|
|
liveStartTime: '',
|
|
|
liveRemark: '',
|
|
|
roomUid: '',
|
|
|
- speakerName:''
|
|
|
+ speakerName: ''
|
|
|
},
|
|
|
url: ''
|
|
|
}
|
|
|
},
|
|
|
async mounted() {
|
|
|
- this.detail = {...state.user}
|
|
|
+ this.detail = { ...state.user }
|
|
|
this.url = vaildStudentUrl() + `/#/liveClassTransfer?roomUid=${this.detail.roomUid}`;
|
|
|
},
|
|
|
methods: {
|
|
@@ -41,9 +42,25 @@ export default defineComponent({
|
|
|
}\n直播时间:${this.detail.liveStartTime || ""}\n直播内容:${this.detail.liveRemark || ""
|
|
|
}\n直播地址:${this.url}\n`;
|
|
|
if (text) {
|
|
|
- copy(text);
|
|
|
- ElMessage.success("复制成功");
|
|
|
- this.onClose()
|
|
|
+ const el = document.createElement('button')
|
|
|
+ var clipboard = new Clipboard(el, {
|
|
|
+ text: function (trigger) {
|
|
|
+ return text;
|
|
|
+ },
|
|
|
+ });
|
|
|
+ clipboard.on("success", (e) => {
|
|
|
+ ElMessage.success("复制成功");
|
|
|
+ this.onClose()
|
|
|
+ // 释放内存
|
|
|
+ clipboard.destroy();
|
|
|
+ });
|
|
|
+ clipboard.on("error", (e) => {
|
|
|
+ // 不支持复制
|
|
|
+ console.log("该浏览器不支持自动复制");
|
|
|
+ // 释放内存
|
|
|
+ clipboard.destroy();
|
|
|
+ });
|
|
|
+ el.click()
|
|
|
}
|
|
|
},
|
|
|
shareImage() {
|
|
@@ -82,7 +99,7 @@ export default defineComponent({
|
|
|
}
|
|
|
const res = await request.get('/api-web/imLiveBroadcastRoom/shareGroup', {
|
|
|
params: {
|
|
|
- ...obj
|
|
|
+ ...obj
|
|
|
}
|
|
|
});
|
|
|
ElMessage.success('分享成功')
|
|
@@ -116,7 +133,7 @@ export default defineComponent({
|
|
|
<p>直播内容:{this.detail.liveRemark}</p>
|
|
|
<p>直播地址:{this.url}</p>
|
|
|
</div>
|
|
|
- <div class={styles.shareBtn} onClick={this.copyText}>复制分享内容</div>
|
|
|
+ <div class={[styles.shareBtn, 'shareText']} onClick={this.copyText} ref='shareText' data-clipboard-action="copy">复制分享内容</div>
|
|
|
</div> : null}
|
|
|
</div >
|
|
|
{this.form.shareType === '2' ? <div class={styles.codeWrap} >
|