Commit ee25daf1bd57b16f947a96b0ad6bdaf6510f7710

Authored by ly525
1 parent a24d7435

use rem to adjust mobile

back-end/h5-api/views/engine.ejs
@@ -9,11 +9,34 @@ @@ -9,11 +9,34 @@
9 <meta content="telephone=no" name="format-detection"> 9 <meta content="telephone=no" name="format-detection">
10 <meta content="email=no" name="format-detection"> 10 <meta content="email=no" name="format-detection">
11 <script src="https://cdn.jsdelivr.net/npm/vue"></script> 11 <script src="https://cdn.jsdelivr.net/npm/vue"></script>
12 - <script type="text/javascript" src="http://g.tbcdn.cn/mtb/lib-flexible/0.3.4/flexible.js"></script> 12 + <!-- <script type="text/javascript" src="http://g.tbcdn.cn/mtb/lib-flexible/0.3.4/flexible.js"></script> -->
13 <!-- <link rel="stylesheet" href="/be-static/be-static-luban-h5/engine/engine.css"> --> 13 <!-- <link rel="stylesheet" href="/be-static/be-static-luban-h5/engine/engine.css"> -->
14 <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/Swiper/4.5.0/css/swiper.min.css"> 14 <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/Swiper/4.5.0/css/swiper.min.css">
15 <link rel="stylesheet" href="https://meyerweb.com/eric/tools/css/reset/reset.css"> 15 <link rel="stylesheet" href="https://meyerweb.com/eric/tools/css/reset/reset.css">
16 <script src="https://cdnjs.cloudflare.com/ajax/libs/Swiper/4.5.0/js/swiper.min.js"></script> 16 <script src="https://cdnjs.cloudflare.com/ajax/libs/Swiper/4.5.0/js/swiper.min.js"></script>
  17 + <script>
  18 + function setDocFontSize(base) {
  19 + var width = 375,
  20 + domEle = document.documentElement;
  21 + dw = domEle.clientWidth || width,
  22 + iw = window.innerWidth || width,
  23 + sw = window.screen.width || iw,
  24 + saw = window.screen.availWidth || iw,
  25 + w = Math.min(dw, iw, sw, saw);
  26 + base = base || 750;
  27 + if (w > base) {
  28 + w = base;
  29 + }
  30 + if (window.devicePixelRatio) {
  31 + dpr = window.devicePixelRatio;
  32 + } else {
  33 + dpr = navigator.userAgent.match(/iphone/i) ? (w > 818 ? 3 : w > 480 ? 2 : 1) : 1;
  34 + }
  35 + dpr = Math.floor(dpr);
  36 + domEle.style.fontSize = w / base * 100 + "px";
  37 + domEle.dataset.dpr = dpr;
  38 + }
  39 + </script>
17 <script>window.__work = <%- JSON.stringify(work) %></script> 40 <script>window.__work = <%- JSON.stringify(work) %></script>
18 <script src="/engine-assets/engine.js"></script> 41 <script src="/engine-assets/engine.js"></script>
19 <style> 42 <style>
@@ -27,7 +50,7 @@ @@ -27,7 +50,7 @@
27 </style> 50 </style>
28 </head> 51 </head>
29 52
30 -<body> 53 +<body onload="setDocFontSize(320)">
31 <div id="app"> 54 <div id="app">
32 <button class="swiper-button-next" style="position: fixed;left: 1000px">Next</button> 55 <button class="swiper-button-next" style="position: fixed;left: 1000px">Next</button>
33 <button class="swiper-button-prev" style="position: fixed;left: 1000px">Prev</button> 56 <button class="swiper-button-prev" style="position: fixed;left: 1000px">Prev</button>
front-end/h5/src/components/core/editor/modals/preview.vue
@@ -17,7 +17,7 @@ export default { @@ -17,7 +17,7 @@ export default {
17 work: state => state.work 17 work: state => state.work
18 }), 18 }),
19 releaseUrl () { 19 releaseUrl () {
20 - return `//localhost:1337/works/preview/${this.work.id}` 20 + return `http://${window.location.hostname}:1337/works/preview/${this.work.id}`
21 } 21 }
22 }, 22 },
23 data () { 23 data () {
@@ -60,7 +60,10 @@ export default { @@ -60,7 +60,10 @@ export default {
60 let iframeWin = document.getElementById('iframe-for-preview').contentWindow 60 let iframeWin = document.getElementById('iframe-for-preview').contentWindow
61 // iframeWin.postMessage('next', window.location.origin); 61 // iframeWin.postMessage('next', window.location.origin);
62 iframeWin.postMessage(message, 'http://localhost:1337') 62 iframeWin.postMessage(message, 'http://localhost:1337')
63 - } 63 + },
  64 + openNewTab () {
  65 + window.open(this.releaseUrl);
  66 + },
64 }, 67 },
65 render (h) { 68 render (h) {
66 return ( 69 return (
@@ -122,11 +125,16 @@ export default { @@ -122,11 +125,16 @@ export default {
122 <div class="label">手机扫码分享给好友</div> 125 <div class="label">手机扫码分享给好友</div>
123 <div class="code"> 126 <div class="code">
124 <canvas style="float: left" id="qrcode-container"></canvas> 127 <canvas style="float: left" id="qrcode-container"></canvas>
  128 + <div>
  129 + <a-button type="dashed" onClick={() => this.openNewTab()}>打开预览 URL </a-button>
  130 + </div>
  131 + {/**
125 <a-radio-group class="radios" value={this.qrcodeSize} onChange={e => { this.qrcodeSize = e.target.value }}> 132 <a-radio-group class="radios" value={this.qrcodeSize} onChange={e => { this.qrcodeSize = e.target.value }}>
126 <a-radio label={500} value={500}>500x500</a-radio> 133 <a-radio label={500} value={500}>500x500</a-radio>
127 <a-radio label={1000} value={1000}>1000x1000</a-radio> 134 <a-radio label={1000} value={1000}>1000x1000</a-radio>
128 <a-radio label={2000} value={2000}>2000x2000</a-radio> 135 <a-radio label={2000} value={2000}>2000x2000</a-radio>
129 </a-radio-group> 136 </a-radio-group>
  137 + */}
130 </div> 138 </div>
131 </div> 139 </div>
132 </div> 140 </div>
front-end/h5/src/utils/element.js
@@ -31,7 +31,7 @@ function px2Rem (px) { @@ -31,7 +31,7 @@ function px2Rem (px) {
31 * @param {Number} px 元素的某个属性的像素值,比如 height 31 * @param {Number} px 元素的某个属性的像素值,比如 height
32 * @param {Boolean} isToRem 是否将 px 转换为 rem 32 * @param {Boolean} isToRem 是否将 px 转换为 rem
33 */ 33 */
34 -export function parsePx (px, isRem = false) { 34 +export function parsePx (px, isRem = true) {
35 if (isRem) return px2Rem(px) 35 if (isRem) return px2Rem(px)
36 return `${px}px` 36 return `${px}px`
37 } 37 }