移动端适配

dev
truthhun 1 year ago
parent 21f46f0562
commit c66929863e

@ -96,7 +96,7 @@
? 'total, prev, pager, next'
: 'total, prev, pager, next, jumper'
"
:pager-count="4"
:pager-count="isMobile ? 5 : 7"
:small="isMobile"
:total="total"
@current-change="pageChange"

@ -33,7 +33,7 @@
? 'total, prev, pager, next'
: 'total, prev, pager, next, jumper'
"
:pager-count="4"
:pager-count="isMobile ? 5 : 7"
:small="isMobile"
:total="total"
@current-change="pageChange"

@ -67,7 +67,7 @@
? 'total, prev, pager, next'
: 'total, prev, pager, next, jumper'
"
:pager-count="4"
:pager-count="isMobile ? 5 : 7"
:small="isMobile"
:total="total"
>

@ -1,5 +1,5 @@
{
"name": "web",
"name": "moredoc",
"version": "1.0.0",
"lockfileVersion": 1,
"requires": true,
@ -12076,6 +12076,11 @@
"resolved": "https://registry.npmmirror.com/q/-/q-1.5.1.tgz",
"integrity": "sha512-kV/CThkXo6xyFEZUugw/+pIOywXcDbFYgSct5cT3gqlbkBE1SJdwy6UQoZvodiWF/ckQLZyDE/Bu1M6gVu5lVw=="
},
"qrcodejs2": {
"version": "0.0.2",
"resolved": "https://registry.npmjs.org/qrcodejs2/-/qrcodejs2-0.0.2.tgz",
"integrity": "sha512-+Y4HA+cb6qUzdgvI3KML8GYpMFwB24dFwzMkS/yXq6hwtUGNUnZQdUnksrV1XGMc2mid5ROw5SAuY9XhI3ValA=="
},
"qs": {
"version": "6.11.0",
"resolved": "https://registry.npmmirror.com/qs/-/qs-6.11.0.tgz",

@ -22,6 +22,7 @@
"element-ui": "^2.15.10",
"hotkeys-js": "^3.10.0",
"nuxt": "^2.15.8",
"qrcodejs2": "0.0.2",
"qs": "^6.11.0",
"vue": "^2.6.14",
"vue-color": "^2.8.1",
@ -49,4 +50,4 @@
"stylelint-config-prettier": "^8.0.2",
"stylelint-config-standard": "^21.0.0"
}
}
}

@ -131,7 +131,7 @@
? 'total, prev, pager, next'
: 'total, prev, pager, next, jumper'
"
:pager-count="4"
:pager-count="isMobile ? 5 : 7"
:small="isMobile"
:total="total"
@current-change="pageChange"

@ -7,6 +7,20 @@
<h1>
<img :src="`/static/images/${document.icon}_24.png`" alt="" />
{{ document.title }}
<el-popover
class="hidden-xs-only"
placement="bottom"
width="200"
trigger="hover"
v-show="document.id > 0"
>
<div id="qrcode" ref="qrcode" class="qrcode text-center"></div>
<span slot="reference">
<span target="_blank" class="share-wechat">
<i class="fa fa-qrcode"></i>
</span>
</span>
</el-popover>
</h1>
<el-breadcrumb separator-class="el-icon-arrow-right">
<el-breadcrumb-item>
@ -338,6 +352,7 @@ import {
import { getFavorite, createFavorite, deleteFavorite } from '~/api/favorite'
import { formatDatetime, formatBytes, getIcon } from '~/utils/utils'
import { documentStatusOptions } from '~/utils/enum'
import QRCode from 'qrcodejs2' // qrcode
import FormComment from '~/components/FormComment.vue'
import CommentList from '~/components/CommentList.vue'
export default {
@ -451,56 +466,58 @@ export default {
id: this.documentId,
with_author: true,
})
if (res.status === 200) {
const doc = res.data || {}
doc.score = parseFloat(doc.score) / 100 || 4.0
if (!doc.preview || doc.preview >= doc.pages) {
doc.preview = doc.pages
}
if (res.status !== 200) {
this.$message.error(res.data.message)
this.$router.replace('/404')
return
}
const doc = res.data || {}
doc.score = parseFloat(doc.score) / 100 || 4.0
//
let preview = 2
if (doc.preview < preview) {
preview = doc.preview
}
if (!doc.preview || doc.preview >= doc.pages) {
doc.preview = doc.pages
}
//
const pages = []
for (let i = 1; i <= preview; i++) {
const src = doc.enable_gzip
? `/view/page/${doc.attachment.hash}/${i}.gzip.svg`
: `/view/page/${doc.attachment.hash}/${i}.svg`
pages.push({
lazySrc: src,
src: src,
alt: `${doc.title}${i + 1}`,
})
}
//
let preview = 2
if (doc.preview < preview) {
preview = doc.preview
}
this.breadcrumbs = (doc.category_id || []).map((id) => {
return this.categoryMap[id]
//
const pages = []
for (let i = 1; i <= preview; i++) {
const src = doc.enable_gzip
? `/view/page/${doc.attachment.hash}/${i}.gzip.svg`
: `/view/page/${doc.attachment.hash}/${i}.svg`
pages.push({
lazySrc: src,
src: src,
alt: `${doc.title}${i + 1}`,
})
}
doc.icon = getIcon(doc.ext)
this.pages = pages
this.document = doc
this.pageWidth = this.$refs.docPages.offsetWidth
this.pageHeight =
(this.$refs.docPages.offsetWidth / doc.width) * doc.height
this.breadcrumbs = (doc.category_id || []).map((id) => {
return this.categoryMap[id]
})
if (doc.status !== 2) {
// 2
this.documentStatusOptions.map((item) => {
if (item.value === doc.status) {
this.tips = `当前文档【${item.label}】,可能暂时无法正常提供预览,建议您下载到本地进行阅读。`
}
})
}
} else {
this.$message.error(res.data.message)
this.$router.replace('/404')
doc.icon = getIcon(doc.ext)
this.pages = pages
this.document = doc
this.pageWidth = this.$refs.docPages.offsetWidth
this.pageHeight =
(this.$refs.docPages.offsetWidth / doc.width) * doc.height
if (doc.status !== 2) {
// 2
this.documentStatusOptions.map((item) => {
if (item.value === doc.status) {
this.tips = `当前文档【${item.label}】,可能暂时无法正常提供预览,建议您下载到本地进行阅读。`
}
})
}
this.genQrcode()
},
handleResize() {
this.calcPageSize()
@ -788,6 +805,19 @@ export default {
this.$message.error(res.data.message)
}
},
genQrcode() {
//
this.$refs.qrcode.innerHTML =
'<div style="margin-bottom:10px">手机扫码,畅享阅读</div>'
// eslint-disable-next-line no-new
new QRCode('qrcode', {
width: 200,
height: 200,
text: location.href,
colorDark: '#000',
colorLight: '#fff',
})
},
},
}
</script>
@ -807,6 +837,13 @@ export default {
position: relative;
top: 3px;
}
.fa-qrcode {
cursor: pointer;
margin-left: 5px;
font-size: 26px;
top: 2px;
position: relative;
}
}
.el-breadcrumb {
font-weight: normal;

@ -172,7 +172,7 @@
? 'total, prev, pager, next'
: 'total, prev, pager, next, jumper'
"
:pager-count="4"
:pager-count="isMobile ? 5 : 7"
:small="isMobile"
:total="total"
@current-change="onPageChange"

Loading…
Cancel
Save