mirror of
				https://github.com/soybeanjs/soybean-admin.git
				synced 2025-11-04 15:53:43 +08:00 
			
		
		
		
	fix(projects): fix themeDrawer copy
This commit is contained in:
		@@ -1,5 +1,5 @@
 | 
				
			|||||||
<script setup lang="ts">
 | 
					<script setup lang="ts">
 | 
				
			||||||
import { onMounted, ref } from 'vue';
 | 
					import { computed, onMounted, ref } from 'vue';
 | 
				
			||||||
import Clipboard from 'clipboard';
 | 
					import Clipboard from 'clipboard';
 | 
				
			||||||
import { $t } from '@/locales';
 | 
					import { $t } from '@/locales';
 | 
				
			||||||
import { useThemeStore } from '@/store/modules/theme';
 | 
					import { useThemeStore } from '@/store/modules/theme';
 | 
				
			||||||
@@ -15,9 +15,7 @@ const domRef = ref<HTMLElement | null>(null);
 | 
				
			|||||||
function initClipboard() {
 | 
					function initClipboard() {
 | 
				
			||||||
  if (!domRef.value) return;
 | 
					  if (!domRef.value) return;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  const clipboard = new Clipboard(domRef.value, {
 | 
					  const clipboard = new Clipboard(domRef.value);
 | 
				
			||||||
    text: () => getClipboardText()
 | 
					 | 
				
			||||||
  });
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
  clipboard.on('success', () => {
 | 
					  clipboard.on('success', () => {
 | 
				
			||||||
    window.$message?.success($t('theme.configOperation.copySuccessMsg'));
 | 
					    window.$message?.success($t('theme.configOperation.copySuccessMsg'));
 | 
				
			||||||
@@ -40,6 +38,8 @@ function handleReset() {
 | 
				
			|||||||
  }, 50);
 | 
					  }, 50);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					const dataClipboardText = computed(() => getClipboardText());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
onMounted(() => {
 | 
					onMounted(() => {
 | 
				
			||||||
  initClipboard();
 | 
					  initClipboard();
 | 
				
			||||||
});
 | 
					});
 | 
				
			||||||
@@ -47,8 +47,9 @@ onMounted(() => {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
<template>
 | 
					<template>
 | 
				
			||||||
  <div class="flex justify-between w-full">
 | 
					  <div class="flex justify-between w-full">
 | 
				
			||||||
 | 
					    <textarea id="themeConfigCopyTarget" v-model="dataClipboardText" class="absolute opacity-0 -z-1" />
 | 
				
			||||||
    <NButton type="error" ghost @click="handleReset">{{ $t('theme.configOperation.resetConfig') }}</NButton>
 | 
					    <NButton type="error" ghost @click="handleReset">{{ $t('theme.configOperation.resetConfig') }}</NButton>
 | 
				
			||||||
    <div ref="domRef">
 | 
					    <div ref="domRef" data-clipboard-target="#themeConfigCopyTarget">
 | 
				
			||||||
      <NButton type="primary">{{ $t('theme.configOperation.copyConfig') }}</NButton>
 | 
					      <NButton type="primary">{{ $t('theme.configOperation.copyConfig') }}</NButton>
 | 
				
			||||||
    </div>
 | 
					    </div>
 | 
				
			||||||
  </div>
 | 
					  </div>
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user