Your Name 2 年之前
父節點
當前提交
84cb81787d

二進制
public2.zip 查看文件


+ 1
- 1
src/components/CoverBtn.vue 查看文件

37
 <style lang="less" scoped>
37
 <style lang="less" scoped>
38
 .cover-btn {
38
 .cover-btn {
39
   position: absolute;
39
   position: absolute;
40
-  background: rgba(255, 0, 0, 0.5);
40
+  // background: rgba(255, 0, 0, 0.5);
41
   z-index: 100;
41
   z-index: 100;
42
 }
42
 }
43
 </style>
43
 </style>

+ 3
- 1
src/components/Image.vue 查看文件

28
 
28
 
29
   const onLoad = (e) => {
29
   const onLoad = (e) => {
30
     emit('load', e);
30
     emit('load', e);
31
-    const { width, height, naturalHeight, naturalWidth } = e.target;
31
+    const { clientWidth: width, clientHeight: height, naturalHeight, naturalWidth } = e.target;
32
+    console.log(e.target);
33
+    console.log('----height-----height----->', window.devicePixelRatio, height, document.body.clientHeight); 
32
     const xRate = width / naturalWidth;
34
     const xRate = width / naturalWidth;
33
     const yRate = height / naturalHeight;
35
     const yRate = height / naturalHeight;
34
 
36
 

+ 66
- 0
src/components/VerticalText.vue 查看文件

1
+<template>
2
+  <div class="vertical-text">
3
+      <div class="vertical-row" v-for="(row, inx) in list" :key="`row-${inx}`" :style="getRowStyle(row)">
4
+        <div class="vertical-col" v-for="(text, i) in row" :key="`col-${i}`" :style="colStyle">
5
+          <span>{{ text }}</span>
6
+        </div>
7
+      </div>
8
+  </div>
9
+</template>
10
+
11
+<script setup>
12
+import { computed } from "@vue/runtime-core";
13
+
14
+const props = defineProps({
15
+  text: String,
16
+  size: {
17
+    type: Array,
18
+    default: [26, 18],
19
+  }
20
+});
21
+
22
+const colStyle = computed(() => {
23
+  return { width: `${props.size[0]}px`, height: `${props.size[0]}px`, fontSize: `${props.size[1]}px` }
24
+})
25
+
26
+const list = computed(() => {
27
+  const rows = (props.text || '').replace(/[\r\n]/g, '<br>').replace(/[\n]/g, '<br>').split('<br>');
28
+  return rows.map(it => it.split(''));
29
+});
30
+
31
+const getRowStyle = (row = []) => {
32
+  const width = Math.ceil(row.length / 8) * props.size[0];
33
+  return { width: `${width}px` }
34
+}
35
+
36
+</script>
37
+
38
+<style lang="less" scoped>
39
+.vertical-text {
40
+  width: 100%;
41
+  height: 100%;
42
+  text-align: right;
43
+  overflow-y: hidden;
44
+  overflow-x: auto;
45
+  display: flex;
46
+  flex-direction: row-reverse;
47
+
48
+  // & > div {
49
+  //   display: inline-block;
50
+  //   height: 100%;
51
+  // }
52
+
53
+  .vertical-row {
54
+    flex: none;
55
+    display: flex;
56
+    height: 100%;
57
+    flex-direction: column;
58
+    flex-wrap: wrap-reverse;
59
+  }
60
+
61
+  .vertical-col {
62
+    flex: none;
63
+  }
64
+}
65
+</style>
66
+

+ 1
- 1
src/pages/creation/index.vue 查看文件

42
   const [author, poemContent] = useModel('poem');
42
   const [author, poemContent] = useModel('poem');
43
 
43
 
44
   const onLoad = (e) => {
44
   const onLoad = (e) => {
45
-    const { width, height, naturalHeight, naturalWidth } = e.target;
45
+    const { clientWidth: width, clientHeight: height, naturalHeight, naturalWidth } = e.target;
46
     const xRate = width / naturalWidth;
46
     const xRate = width / naturalWidth;
47
     const yRate = height / naturalHeight;
47
     const yRate = height / naturalHeight;
48
 
48
 

+ 3
- 0
src/pages/index/index.vue 查看文件

22
   const gdStyle = ref({});
22
   const gdStyle = ref({});
23
   const pgStyle = ref({});
23
   const pgStyle = ref({});
24
 
24
 
25
+  console.log('---------render------------>')
26
+
25
   const onLoad = (e) => {
27
   const onLoad = (e) => {
28
+    console.log('---------onload------------>')
26
     const { width, height } = e.target;
29
     const { width, height } = e.target;
27
     gdStyle.value = {
30
     gdStyle.value = {
28
       width: `${width}px`,
31
       width: `${width}px`,

+ 9
- 6
src/pages/makeSaving/index.vue 查看文件

7
       <Image :src="backImg" :actions="actions" @load="onLoad"/>
7
       <Image :src="backImg" :actions="actions" @load="onLoad"/>
8
       <img :src="qrcode" alt="" class="qrcode" :style="qrStyle">
8
       <img :src="qrcode" alt="" class="qrcode" :style="qrStyle">
9
       <div class="poem-author" :style="iiStyle">{{ author }}</div>
9
       <div class="poem-author" :style="iiStyle">{{ author }}</div>
10
-      <div class="poem-content" :style="ttStyle" v-html="contentHtml"></div>
10
+      <div class="poem-content" :style="ttStyle">
11
+        <VerticalText :text="content" :size="sizeRef" />
12
+      </div>
11
     </div>
13
     </div>
12
     <TGradient :style="gdStyle" color="#0f2c37" />
14
     <TGradient :style="gdStyle" color="#0f2c37" />
13
     <template v-if="creation">
15
     <template v-if="creation">
24
   import html2canvas from 'html2canvas';
26
   import html2canvas from 'html2canvas';
25
   import Image from '@/components/Image.vue';
27
   import Image from '@/components/Image.vue';
26
   import TGradient from '@/components/TGradient.vue';
28
   import TGradient from '@/components/TGradient.vue';
29
+  import VerticalText from '../../components/VerticalText.vue';
27
   import { getPageStyle } from '@/utils/page';
30
   import { getPageStyle } from '@/utils/page';
28
   
31
   
29
   const backImg = './images/3.png';
32
   const backImg = './images/3.png';
54
   const psStyle = ref({});
57
   const psStyle = ref({});
55
   const qrStyle = ref({ width: '1px', height: '1px' });
58
   const qrStyle = ref({ width: '1px', height: '1px' });
56
   const pgStyle = ref({});
59
   const pgStyle = ref({});
60
+  const sizeRef = ref([26, 18]);
57
   const creation = ref();
61
   const creation = ref();
58
   const [author, content] = useModel('poem');
62
   const [author, content] = useModel('poem');
59
   const [qrcode] = useModel('qrcode');
63
   const [qrcode] = useModel('qrcode');
60
 
64
 
61
-  const contentHtml = computed(() => (content.value || '').replace(/[\r\n]/g, '<br>').replace(/[\n]/g, '<br>'));
62
-
63
   const onNextClick = () => {
65
   const onNextClick = () => {
64
     router.push('/creation');
66
     router.push('/creation');
65
   };
67
   };
66
 
68
 
67
   const onLoad = (e) => {
69
   const onLoad = (e) => {
68
-    console.log('---------')
69
-    const { width, height, naturalHeight, naturalWidth } = e.target;
70
+    const { clientWidth: width, clientHeight: height, naturalHeight, naturalWidth } = e.target;
70
     const xRate = width / naturalWidth;
71
     const xRate = width / naturalWidth;
71
     const yRate = height / naturalHeight;
72
     const yRate = height / naturalHeight;
72
 
73
 
101
       lineHeight: `${50 * xRate}px`,
102
       lineHeight: `${50 * xRate}px`,
102
     };
103
     };
103
 
104
 
105
+    sizeRef.value = [50 * xRate, 36 * xRate];
106
+
104
     iiStyle.value = {
107
     iiStyle.value = {
105
       top: `${authorHeight * yRate}px`,
108
       top: `${authorHeight * yRate}px`,
106
     };
109
     };
145
         // background: rgba(255, 0,0, .5);
148
         // background: rgba(255, 0,0, .5);
146
         position: absolute;
149
         position: absolute;
147
 
150
 
148
-        writing-mode: vertical-rl;
151
+        // writing-mode: vertical-rl;
149
         font-size: 18px;
152
         font-size: 18px;
150
         color: #0F3341;
153
         color: #0F3341;
151
         line-break: anywhere;
154
         line-break: anywhere;

+ 1
- 0
src/utils/page.js 查看文件

4
 const height = document.body.clientHeight;
4
 const height = document.body.clientHeight;
5
 
5
 
6
 export function getPageStyle(fitHeight) {
6
 export function getPageStyle(fitHeight) {
7
+  console.log('---------height------->', height);
7
   // return fitHeight > height ? { height: `${fitHeight}px`, overflow: 'hidden' } : { height: `${height}px`, overflow: 'hidden' }
8
   // return fitHeight > height ? { height: `${fitHeight}px`, overflow: 'hidden' } : { height: `${height}px`, overflow: 'hidden' }
8
   return {};
9
   return {};
9
 }
10
 }