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

二進制
public2.zip 查看文件


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

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

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

@@ -28,7 +28,9 @@
28 28
 
29 29
   const onLoad = (e) => {
30 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 34
     const xRate = width / naturalWidth;
33 35
     const yRate = height / naturalHeight;
34 36
 

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

@@ -0,0 +1,66 @@
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,7 +42,7 @@
42 42
   const [author, poemContent] = useModel('poem');
43 43
 
44 44
   const onLoad = (e) => {
45
-    const { width, height, naturalHeight, naturalWidth } = e.target;
45
+    const { clientWidth: width, clientHeight: height, naturalHeight, naturalWidth } = e.target;
46 46
     const xRate = width / naturalWidth;
47 47
     const yRate = height / naturalHeight;
48 48
 

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

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

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

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

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

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