reactor:osName 的获取,从 getSystemInfoSync 迁移到 getDeviceInfo

reactor:pixelRatio/windowHeight/windowWidth 的获取,从 getSystemInfoSync 迁移到 getWindowInfo
pull/147/head
YunaiV 2025-04-29 20:13:18 +08:00
parent 04bb5e65d3
commit 82aada5ecd
8 changed files with 21 additions and 22 deletions

View File

@ -72,7 +72,7 @@
</template>
<script>
import { deepMerge, addStyle, addUnit, sleep, getPx, sys } from '@/sheep/helper';
import { deepMerge, addStyle, addUnit, sleep, getPx } from '@/sheep/helper';
// #ifdef APP-NVUE
const animation = uni.requireNativePlugin('animation');
const dom = uni.requireNativePlugin('dom');
@ -221,7 +221,8 @@
methods: {
$uGetRect(selector, all) {
return new Promise((resolve) => {
uni.createSelectorQuery()
uni
.createSelectorQuery()
.in(this)
[all ? 'selectAll' : 'select'](selector)
.boundingClientRect((rect) => {
@ -301,7 +302,7 @@
return total + curr.rect.width;
}, 0);
//
const windowWidth = sys().windowWidth;
const windowWidth = uni.getWindowInfo().windowWidth;
// tabs-itemscroll-view
let scrollLeft =
offsetLeft -

View File

@ -60,7 +60,7 @@
}
},
dpr() {
return this.pixelRatio || uni.getSystemInfoSync().pixelRatio;
return this.pixelRatio || uni.getWindowInfo().pixelRatio;
},
boardWidth() {
const {width = 0} = (this.elements && this.elements.css) || this.elements || this
@ -168,7 +168,7 @@
},
runTask(){
while(this.tasks.length){
const task = this.tasks.shift()
const task = this.tasks.shift()
this.canvasToTempFilePath(task)
}
},
@ -199,7 +199,7 @@
// #endif
await this.getSize(args)
const ctx = await this.getContext();
let {
use2dCanvas,
boardWidth,
@ -243,7 +243,7 @@
}
}
this.painter = new Painter(param)
}
}
try{
// vue3 data
const { width, height } = await this.painter.source(JSON.parse(JSON.stringify(args)))
@ -278,7 +278,7 @@
}catch(e){
//TODO handle the exception
}
},
canvasDraw(flag = false) {
return new Promise((resolve, reject) => this.ctx.draw(flag, () => setTimeout(() => resolve(), this
@ -308,7 +308,7 @@
this.use2dCanvas = false;
this.canvas = res;
}
// measureText mock
if (!ctx.measureText) {
function strLen(str) {
@ -334,7 +334,7 @@
};
}
}
// #ifdef MP-ALIPAY
ctx.scale(dpr, dpr);
// #endif
@ -384,7 +384,7 @@
this.$emit('fail', e)
}
}
let { top: y = 0, left: x = 0, width, height } = this.boundary || this;
// let destWidth = width * dpr;
// let destHeight = height * dpr;
@ -392,7 +392,7 @@
// width = destWidth;
// height = destHeight;
// #endif
const copyArgs = Object.assign({
// x,
// y,

View File

@ -6,16 +6,13 @@ import {
networkReg
} from './utils';
const dom = weex.requireModule('dom')
import {
version
} from '../../package.json'
export default {
data() {
return {
tempFilePath: [],
isInitFile: false,
osName: uni.getSystemInfoSync().osName
osName: uni.getDeviceInfo().osName
}
},
methods: {

View File

@ -3,7 +3,8 @@ export const isBase64 = (path) => /^data:image\/(\w+);base64/.test(path);
export function sleep(delay) {
return new Promise(resolve => setTimeout(resolve, delay))
}
let {platform, SDKVersion} = uni.getSystemInfoSync()
let platform = uni.getDeviceInfo().platform
let SDKVersion = uni.getSystemInfoSync().SDKVersion
export const isPC = /windows|mac/.test(platform)
// 缓存图片
let cache = {}
@ -316,7 +317,7 @@ export function getImageInfo(path, useCORS) {
// #ifdef APP-PLUS
// console.log('getImageInfo', +new Date() - time)
// ios 比较严格 可能需要设置跨域
if(uni.getSystemInfoSync().osName == 'ios' && useCORS) {
if(uni.getDeviceInfo().osName === 'ios' && useCORS) {
pathToBase64(image.path).then(base64 => {
image.path = base64
cache[path] = image

View File

@ -432,7 +432,7 @@
mounted() {
// #ifdef APP-NVUE
const res = uni.getSystemInfoSync();
const res = uni.getWindowInfo();
this.fixNvueBug = {
top: res.windowHeight / 2,
left: res.windowWidth / 2

View File

@ -473,7 +473,7 @@
right.setDate(this.$refs.right.nowDate.fullDate)
},
platform() {
const systemInfo = uni.getSystemInfoSync()
const systemInfo = uni.getWindowInfo()
this.isPhone = systemInfo.windowWidth <= 500
this.windowWidth = systemInfo.windowWidth
},

View File

@ -13,7 +13,7 @@
}
},
mounted() {
this.statusBarHeight = uni.getSystemInfoSync().statusBarHeight + 'px'
this.statusBarHeight = uni.getWindowInfo().statusBarHeight + 'px'
}
}
</script>

View File

@ -187,7 +187,7 @@
// #endif
// #ifdef APP-NVUE
dom.getComponentRect(this.$refs['animationEle'], (res) => {
let winWidth = uni.getSystemInfoSync().windowWidth
let winWidth = uni.getWindowInfo().windowWidth
this.textWidth = res.size.width
animation.transition(this.$refs['animationEle'], {
styles: {