|
|
@@ -26,7 +26,7 @@
|
|
|
<n-button text v-if="isMobile">长按保存图片</n-button>
|
|
|
<n-button text v-else @click="save">保存图片</n-button>
|
|
|
<n-button text :loading="loading" @click="changeType">换个样式</n-button>
|
|
|
- <n-button text>复制邀请链接</n-button>
|
|
|
+ <n-button text @click="copyShare">复制邀请链接</n-button>
|
|
|
</div>
|
|
|
|
|
|
<!-- <div class="tips" v-if="isMobile">长按保存图片</div>
|
|
|
@@ -40,8 +40,9 @@
|
|
|
</template>
|
|
|
|
|
|
<script setup lang="ts">
|
|
|
-import { NModal, NButton, NAvatar } from 'naive-ui'
|
|
|
+import { NModal, NButton, NAvatar, useMessage } from 'naive-ui'
|
|
|
import { ref, watch, computed } from 'vue'
|
|
|
+import { useClipboard } from '@vueuse/core'
|
|
|
import QrcodeVue from 'qrcode.vue'
|
|
|
import html2canvas from 'html2canvas'
|
|
|
import { useUserStore } from '@/store'
|
|
|
@@ -90,6 +91,7 @@ watch(
|
|
|
() => props.show,
|
|
|
val => {
|
|
|
if (val) {
|
|
|
+ shareType.value = Math.floor(Math.random() * 7)
|
|
|
changeType()
|
|
|
}
|
|
|
}
|
|
|
@@ -98,8 +100,7 @@ watch(
|
|
|
function changeType() {
|
|
|
loading.value = true
|
|
|
imgUrl.value = ''
|
|
|
- let type = Math.floor(Math.random() * 7)
|
|
|
- shareType.value = type !== shareType.value ? type : (type + 1) % 7
|
|
|
+ shareType.value = (shareType.value + 1) % 7
|
|
|
setTimeout(() => {
|
|
|
html2canvas(postRef.value!, {
|
|
|
useCORS: true,
|
|
|
@@ -129,6 +130,17 @@ function save() {
|
|
|
}
|
|
|
|
|
|
const { isMobile } = useBasicLayout()
|
|
|
+
|
|
|
+const message = useMessage()
|
|
|
+const { text, copy, copied, isSupported } = useClipboard()
|
|
|
+async function copyShare() {
|
|
|
+ try {
|
|
|
+ await copy('【CHILLGPT——开启人工智能时代】' + shareUrl.value)
|
|
|
+ message.success('复制成功')
|
|
|
+ } catch (e) {
|
|
|
+ console.error(e)
|
|
|
+ }
|
|
|
+}
|
|
|
</script>
|
|
|
|
|
|
<style lang="less" scoped>
|