Skip to content

Commit

Permalink
Feat: 增加背景颜色选择
Browse files Browse the repository at this point in the history
  • Loading branch information
Lruihao committed Apr 4, 2024
1 parent 108170f commit 1adfc97
Showing 1 changed file with 25 additions and 3 deletions.
28 changes: 25 additions & 3 deletions src/views/apple-devices-preview.vue
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
<!-- 网站预览图生成 -->
<template>
<div>
<div :style="{ backgroundColor: pageBackgroundColor }">
<div v-if="!isPreview" class="page-header">
<el-input v-model="desktopLink" placeholder="输入桌面端链接" />
<el-input v-model="mobileLink" placeholder="输入移动端链接" />
<el-switch v-model="showBangs" active-text="显示刘海" />
<el-color-picker v-model="pageBackgroundColor" :predefine="predefineColors" />
<el-button-group>
<el-button type="primary" size="medium" @click="preview">预览</el-button>
<el-button type="primary" size="medium" :loading="loading" @click="generatePreview">下载</el-button>
Expand Down Expand Up @@ -39,6 +40,19 @@ export default {
loading: false,
showBangs: false,
isPreview: false,
pageBackgroundColor: '#fff',
predefineColors: [
'#fff',
'#000',
'#ffe9e3',
'#dcd6f7',
'#B1B3E4',
'#81d795',
'#7ac5cd',
'#f6e58d',
'#ffbe76',
'#ff8e8e',
],
}
},
computed: {
Expand All @@ -52,6 +66,14 @@ export default {
headerContainer.style.display = val ? 'none' : 'flex'
},
},
mounted() {
// 监听键盘事件 Esc 退出预览
document.addEventListener('keydown', (e) => {
if (e.key === 'Escape') {
this.isPreview = false
}
})
},
methods: {
getIframeImage() {
const iframeHtml = document.querySelector('iframe')
Expand Down Expand Up @@ -92,7 +114,7 @@ export default {
preview() {
this.isPreview = true
this.$message({
message: '预览 15 秒后自动退出,你可以使用截图工具保存图片!',
message: '预览 15 秒后自动退出或按 ESC 键退出,你可以使用截图工具保存图片!',
type: 'info',
showClose: true,
duration: 2000,
Expand Down Expand Up @@ -142,7 +164,7 @@ export default {
gap: 0.5rem;
margin-block: 1rem;
.el-input {
width: 350px;
width: 300px;
}
}
.d-none {
Expand Down

0 comments on commit 1adfc97

Please sign in to comment.