feat: 根据设备信息自动识别终端类型

This commit is contained in:
wangjiahao 2021-12-21 10:57:37 +08:00
parent db242ba72b
commit 3222f645a1
2 changed files with 6 additions and 6 deletions

View File

@ -123,10 +123,6 @@ export default {
} }
}, },
created() { created() {
const terminalInfo = this.$route.query.terminal
if (terminalInfo) {
this.terminal = terminalInfo
}
}, },
computed: { computed: {
customStyle() { customStyle() {
@ -178,6 +174,7 @@ export default {
} }
}, },
mounted() { mounted() {
this._isMobile()
const _this = this const _this = this
const erd = elementResizeDetectorMaker() const erd = elementResizeDetectorMaker()
// div // div
@ -206,6 +203,11 @@ export default {
clearInterval(this.timer) clearInterval(this.timer)
}, },
methods: { methods: {
_isMobile() {
console.log('navigator.userAgent:' + navigator.userAgent)
const flag = navigator.userAgent.match(/(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i)
this.terminal = flag ? 'mobile' : 'pc'
},
canvasStyleDataInit() { canvasStyleDataInit() {
// //
this.searchCount = 0 this.searchCount = 0

View File

@ -299,7 +299,6 @@ export default {
// //
previewCanvasScale: { previewCanvasScale: {
handler(newVal, oldVal) { handler(newVal, oldVal) {
console.log('previewCanvasScale:' + JSON.stringify(this.previewCanvasScale))
this.destroyScaleTimeMachine() this.destroyScaleTimeMachine()
this.changeScaleIndex++ this.changeScaleIndex++
this.chartScale(this.changeScaleIndex) this.chartScale(this.changeScaleIndex)
@ -317,7 +316,6 @@ export default {
// //
mergeScale() { mergeScale() {
const scale = Math.min(this.previewCanvasScale.scalePointWidth, this.previewCanvasScale.scalePointHeight) * this.scaleCoefficient const scale = Math.min(this.previewCanvasScale.scalePointWidth, this.previewCanvasScale.scalePointHeight) * this.scaleCoefficient
console.log('scale' + scale + ';this.previewCanvasScale:' + JSON.stringify(this.previewCanvasScale))
const customAttrChart = JSON.parse(this.sourceCustomAttrStr) const customAttrChart = JSON.parse(this.sourceCustomAttrStr)
const customStyleChart = JSON.parse(this.sourceCustomStyleStr) const customStyleChart = JSON.parse(this.sourceCustomStyleStr)
recursionTransObj(customAttrTrans, customAttrChart, scale, this.scaleCoefficientType) recursionTransObj(customAttrTrans, customAttrChart, scale, this.scaleCoefficientType)