20240517
This commit is contained in:
24
utils/formate.js
Normal file
24
utils/formate.js
Normal file
@@ -0,0 +1,24 @@
|
||||
|
||||
export function secondFormate (seconds) {
|
||||
let minute,second;
|
||||
seconds = Math.abs(seconds)
|
||||
minute = Math.floor(seconds / 60);
|
||||
minute = minute > 9 ? minute : '0' + minute;
|
||||
second = Math.floor(seconds % 60);
|
||||
second = second > 9 ? second : '0' + second;
|
||||
return `${minute}:${second}`;
|
||||
}
|
||||
|
||||
export function range(num, min, max) {
|
||||
return Math.min(Math.max(num, min), max);
|
||||
}
|
||||
|
||||
export function addNumber(num1, num2) {
|
||||
const cardinal = 10 ** 10;
|
||||
return Math.round((num1 + num2) * cardinal) / cardinal;
|
||||
}
|
||||
|
||||
export function sizeFormate (size) {
|
||||
const per = 1024 * 1024;
|
||||
return size >= per ? Number(size / per).toFixed(2) + 'M' : Number(size / 1024).toFixed(2) + 'KB';
|
||||
}
|
||||
20
utils/tool.js
Normal file
20
utils/tool.js
Normal file
@@ -0,0 +1,20 @@
|
||||
const { platform } = uni.getSystemInfoSync()
|
||||
|
||||
export function setFullScreen(isFullScreen) {
|
||||
const ori = isFullScreen ? 'landscape-primary' : 'portrait-primary';
|
||||
plus.screen.unlockOrientation();
|
||||
if (platform === 'android') {
|
||||
setTimeout(() => {
|
||||
plus.screen.lockOrientation(ori);
|
||||
}, 500)
|
||||
} else {
|
||||
plus.screen.lockOrientation(ori);
|
||||
}
|
||||
// 控制顶部状态栏展示
|
||||
plus.navigator.setFullscreen(isFullScreen);
|
||||
if (isFullScreen) {
|
||||
plus.navigator.hideSystemNavigation();
|
||||
} else {
|
||||
plus.navigator.showSystemNavigation();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user