mirror of
https://github.com/Tencent/tdesign-vue-next-starter.git
synced 2024-12-23 23:06:48 +08:00
fix: 修复示例无法复制配置的问题 (#639)
This commit is contained in:
parent
81220e78c2
commit
badc73e82b
|
@ -65,12 +65,15 @@
|
|||
</t-form>
|
||||
<div class="setting-info">
|
||||
<p>请复制后手动修改配置文件: /src/config/style.ts</p>
|
||||
<t-button theme="primary" variant="text" @click="handleCopy"> 复制配置项 </t-button>
|
||||
</div>
|
||||
</div>
|
||||
</t-drawer>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import { MessagePlugin } from 'tdesign-vue-next';
|
||||
import { computed, onMounted, ref, watchEffect } from 'vue';
|
||||
import useClipboard from 'vue-clipboard3';
|
||||
|
||||
import LayoutMixIcon from '@/assets/assets-layout-mix.svg';
|
||||
import LayoutSideIcon from '@/assets/assets-layout-side.svg';
|
||||
|
@ -142,6 +145,20 @@ const handleCloseDrawer = () => {
|
|||
});
|
||||
};
|
||||
|
||||
const handleCopy = () => {
|
||||
const text = JSON.stringify(formData.value, null, 4);
|
||||
const { toClipboard } = useClipboard();
|
||||
toClipboard(text)
|
||||
.then(() => {
|
||||
MessagePlugin.closeAll();
|
||||
MessagePlugin.success('复制成功');
|
||||
})
|
||||
.catch(() => {
|
||||
MessagePlugin.closeAll();
|
||||
MessagePlugin.error('复制失败');
|
||||
});
|
||||
};
|
||||
|
||||
watchEffect(() => {
|
||||
if (formData.value.brandTheme) settingStore.updateConfig(formData.value);
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue
Block a user