11<script setup lang="ts">
2- import {computed , ref } from " vue" ;
2+ import {computed , ref , watch } from " vue" ;
33import ServerCloudDemoDialog from " ./ServerCloudDemoDialog.vue" ;
4+ import {doCopy } from " ../common/util" ;
45
56const demoDialog = ref <InstanceType <typeof ServerCloudDemoDialog > | null >(null )
67
@@ -30,6 +31,21 @@ const content = computed(() => {
3031 }
3132 return lines .join (' \n ' )
3233})
34+ watch (() => visible .value , (v ) => {
35+ if (v ) {
36+ const codeElements = document .querySelectorAll (' .pb-content-info code' );
37+ codeElements .forEach ((codeElement ) => {
38+ if (codeElement .getAttribute (' data-click-bind' )) {
39+ return
40+ }
41+ codeElement .addEventListener (' click' , () => {
42+ const text = codeElement .textContent || ' '
43+ doCopy (text );
44+ })
45+ codeElement .setAttribute (' data-click-bind' , ' true' )
46+ });
47+ }
48+ })
3349 </script >
3450
3551<template >
@@ -45,7 +61,7 @@ const content = computed(() => {
4561 <template #title >
4662 {{ $t('使用说明') }}
4763 </template >
48- <div class =" overflow-y-auto overflow-x-hidden leading-6" style =" max-height :60vh ;" >
64+ <div class =" overflow-y-auto overflow-x-hidden leading-6 pb-content-info " style =" max-height :60vh ;" >
4965 <div v-html =" content" ></div >
5066 </div >
5167 </a-modal >
@@ -57,3 +73,16 @@ const content = computed(() => {
5773 </a-button >
5874 <ServerCloudDemoDialog ref =" demoDialog" />
5975</template >
76+
77+ <style lang="less" scoped>
78+ .pb-content-info {
79+ :deep(code ) {
80+ background : rgba (0 , 0 , 0 , 0.05 );
81+ border-radius : 0.2rem ;
82+ display : inline-block ;
83+ padding : 0.1rem 0.2rem ;
84+ cursor : pointer ;
85+ margin-bottom : 0.2rem ;
86+ }
87+ }
88+ </style >
0 commit comments