Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
MuGuiLin
uni-app
提交
55ac1075
U
uni-app
项目概览
MuGuiLin
/
uni-app
与 Fork 源项目一致
Fork自
DCloud / uni-app
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
U
uni-app
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
55ac1075
编写于
2月 07, 2022
作者:
fxy060608
浏览文件
操作
浏览文件
下载
差异文件
chore: merge
上级
ed95b31c
23053d7f
变更
9
展开全部
隐藏空白更改
内联
并排
Showing
9 changed file
with
451 addition
and
530 deletion
+451
-530
packages/uni-app-plus/dist/uni-app-view.umd.js
packages/uni-app-plus/dist/uni-app-view.umd.js
+3
-3
packages/uni-app-plus/dist/uni.runtime.esm.js
packages/uni-app-plus/dist/uni.runtime.esm.js
+62
-62
packages/uni-app-plus/src/service/api/index.ts
packages/uni-app-plus/src/service/api/index.ts
+2
-1
packages/uni-app-plus/src/service/api/internal/global.ts
packages/uni-app-plus/src/service/api/internal/global.ts
+0
-0
packages/uni-components/src/helpers/hidpi.js
packages/uni-components/src/helpers/hidpi.js
+6
-4
packages/uni-components/src/vue/canvas/index.tsx
packages/uni-components/src/vue/canvas/index.tsx
+18
-7
packages/uni-h5/dist/uni-h5.cjs.js
packages/uni-h5/dist/uni-h5.cjs.js
+16
-11
packages/uni-h5/dist/uni-h5.es.js
packages/uni-h5/dist/uni-h5.es.js
+18
-12
pnpm-lock.yaml
pnpm-lock.yaml
+326
-430
未找到文件。
packages/uni-app-plus/dist/uni-app-view.umd.js
浏览文件 @
55ac1075
此差异已折叠。
点击以展开。
packages/uni-app-plus/dist/uni.runtime.esm.js
浏览文件 @
55ac1075
...
...
@@ -16612,6 +16612,67 @@ var serviceContext = (function (vue) {
return new SubNvue(id, isSub);
};
let lastStatusBarStyle;
let oldSetStatusBarStyle = plus.navigator.setStatusBarStyle;
function restoreOldSetStatusBarStyle(setStatusBarStyle) {
oldSetStatusBarStyle = setStatusBarStyle;
}
function newSetStatusBarStyle(style) {
lastStatusBarStyle = style;
oldSetStatusBarStyle(style);
}
plus.navigator.setStatusBarStyle = newSetStatusBarStyle;
function setStatusBarStyle(statusBarStyle) {
if (!statusBarStyle) {
const page = getCurrentPage();
if (!page) {
return;
}
statusBarStyle = page.$page.statusBarStyle;
if (!statusBarStyle || statusBarStyle === lastStatusBarStyle) {
return;
}
}
if (statusBarStyle === lastStatusBarStyle) {
return;
}
if ((process.env.NODE_ENV !== 'production')) {
console.log(formatLog('setStatusBarStyle', statusBarStyle));
}
lastStatusBarStyle = statusBarStyle;
plus.navigator.setStatusBarStyle(statusBarStyle);
}
function restoreGlobal(newVue, newWeex, newPlus, newSetTimeout, newClearTimeout, newSetInterval, newClearInterval) {
// 确保部分全局变量 是 app-service 中的
// 若首页 nvue 初始化比 app-service 快,导致框架处于该 nvue 环境下
// plus 如果不用 app-service,资源路径会出问题
// 若首页 nvue 被销毁,如 redirectTo 或 reLaunch,则这些全局功能会损坏
// 设置 vue3
// @ts-ignore 最终vue会被替换为vue
vue = newVue;
if (plus !== newPlus) {
if ((process.env.NODE_ENV !== 'production')) {
console.log(`[restoreGlobal][${Date.now()}]`);
}
weex = newWeex;
// @ts-ignore
plus = newPlus;
restoreOldSetStatusBarStyle(plus.navigator.setStatusBarStyle);
plus.navigator.setStatusBarStyle = newSetStatusBarStyle;
/* eslint-disable no-global-assign */
// @ts-ignore
setTimeout = newSetTimeout;
// @ts-ignore
clearTimeout = newClearTimeout;
// @ts-ignore
setInterval = newSetInterval;
// @ts-ignore
clearInterval = newClearInterval;
}
__uniConfig.serviceReady = true;
}
const providers = {
oauth(callback) {
plus.oauth.getServices((services) => {
...
...
@@ -17935,37 +17996,6 @@ var serviceContext = (function (vue) {
});
}
let lastStatusBarStyle;
let oldSetStatusBarStyle = plus.navigator.setStatusBarStyle;
function restoreOldSetStatusBarStyle(setStatusBarStyle) {
oldSetStatusBarStyle = setStatusBarStyle;
}
function newSetStatusBarStyle(style) {
lastStatusBarStyle = style;
oldSetStatusBarStyle(style);
}
plus.navigator.setStatusBarStyle = newSetStatusBarStyle;
function setStatusBarStyle(statusBarStyle) {
if (!statusBarStyle) {
const page = getCurrentPage();
if (!page) {
return;
}
statusBarStyle = page.$page.statusBarStyle;
if (!statusBarStyle || statusBarStyle === lastStatusBarStyle) {
return;
}
}
if (statusBarStyle === lastStatusBarStyle) {
return;
}
if ((process.env.NODE_ENV !== 'production')) {
console.log(formatLog('setStatusBarStyle', statusBarStyle));
}
lastStatusBarStyle = statusBarStyle;
plus.navigator.setStatusBarStyle(statusBarStyle);
}
function onWebviewPopGesture(webview) {
let popStartStatusBarStyle;
webview.addEventListener('popGesture', (e) => {
...
...
@@ -19226,36 +19256,6 @@ var serviceContext = (function (vue) {
};
}
function restoreGlobal(newVue, newWeex, newPlus, newSetTimeout, newClearTimeout, newSetInterval, newClearInterval) {
// 确保部分全局变量 是 app-service 中的
// 若首页 nvue 初始化比 app-service 快,导致框架处于该 nvue 环境下
// plus 如果不用 app-service,资源路径会出问题
// 若首页 nvue 被销毁,如 redirectTo 或 reLaunch,则这些全局功能会损坏
// 设置 vue3
// @ts-ignore 最终vue会被替换为vue
vue = newVue;
if (plus !== newPlus) {
if ((process.env.NODE_ENV !== 'production')) {
console.log(`[restoreGlobal][${Date.now()}]`);
}
weex = newWeex;
// @ts-ignore
plus = newPlus;
restoreOldSetStatusBarStyle(plus.navigator.setStatusBarStyle);
plus.navigator.setStatusBarStyle = newSetStatusBarStyle;
/* eslint-disable no-global-assign */
// @ts-ignore
setTimeout = newSetTimeout;
// @ts-ignore
clearTimeout = newClearTimeout;
// @ts-ignore
setInterval = newSetInterval;
// @ts-ignore
clearInterval = newClearInterval;
}
__uniConfig.serviceReady = true;
}
const EventType = {
load: 'load',
close: 'close',
...
...
@@ -20009,6 +20009,7 @@ var serviceContext = (function (vue) {
removeTabBarBadge: removeTabBarBadge,
hideTabBarRedDot: hideTabBarRedDot,
getSubNVueById: getSubNVueById,
restoreGlobal: restoreGlobal,
getProvider: getProvider,
login: login,
getUserInfo: getUserInfo,
...
...
@@ -20024,7 +20025,6 @@ var serviceContext = (function (vue) {
requireNativePlugin: requireNativePlugin,
sendNativeEvent: sendNativeEvent,
__vuePlugin: index$1,
restoreGlobal: restoreGlobal,
createRewardedVideoAd: createRewardedVideoAd,
createFullScreenVideoAd: createFullScreenVideoAd,
createInterstitialAd: createInterstitialAd,
...
...
packages/uni-app-plus/src/service/api/index.ts
浏览文件 @
55ac1075
...
...
@@ -55,6 +55,8 @@ export * from './ui/navigationBar'
export
*
from
'
./ui/tabBar
'
export
*
from
'
./ui/subNVue
'
export
*
from
'
./internal/global
'
export
*
from
'
./plugin/getProvider
'
export
*
from
'
./plugin/oauth
'
export
*
from
'
./plugin/registerRuntime
'
...
...
@@ -62,7 +64,6 @@ export * from './plugin/share'
export
*
from
'
./plugin/requestPayment
'
export
*
from
'
./plugin/requireNativePlugin
'
export
*
from
'
./plugin/vuePlugin
'
export
*
from
'
./plugin/restoreGlobal
'
export
{
sendHostEvent
,
navigateToMiniProgram
,
...
...
packages/uni-app-plus/src/service/api/
plugin/restoreG
lobal.ts
→
packages/uni-app-plus/src/service/api/
internal/g
lobal.ts
浏览文件 @
55ac1075
文件已移动
packages/uni-components/src/helpers/hidpi.js
浏览文件 @
55ac1075
...
...
@@ -17,10 +17,10 @@ export const pixelRatio = __NODE_JS__
return
(
window
.
devicePixelRatio
||
1
)
/
backingStore
})()
export
function
wrapper
(
canvas
)
{
canvas
.
width
=
canvas
.
offsetWidth
*
pixelRatio
canvas
.
height
=
canvas
.
offsetHeight
*
pixelRatio
canvas
.
getContext
(
'
2d
'
).
__hidpi__
=
true
export
function
wrapper
(
canvas
,
hidpi
=
true
)
{
canvas
.
width
=
canvas
.
offsetWidth
*
(
hidpi
?
pixelRatio
:
1
)
canvas
.
height
=
canvas
.
offsetHeight
*
(
hidpi
?
pixelRatio
:
1
)
canvas
.
getContext
(
'
2d
'
).
__hidpi__
=
hidpi
}
let
isHidpi
=
false
...
...
@@ -129,6 +129,7 @@ export function initHidpi() {
args
[
1
]
*=
pixelRatio
args
[
2
]
*=
pixelRatio
args
[
3
]
*=
pixelRatio
var
font
=
this
.
font
this
.
font
=
font
.
replace
(
...
...
@@ -153,6 +154,7 @@ export function initHidpi() {
args
[
1
]
*=
pixelRatio
// x
args
[
2
]
*=
pixelRatio
// y
args
[
3
]
*=
pixelRatio
var
font
=
this
.
font
this
.
font
=
font
.
replace
(
...
...
packages/uni-components/src/vue/canvas/index.tsx
浏览文件 @
55ac1075
...
...
@@ -66,6 +66,10 @@ const props = {
type
:
[
Boolean
,
String
],
default
:
false
,
},
hidpi
:
{
type
:
Boolean
,
default
:
true
,
},
}
type
Props
=
ExtractPropTypes
<
typeof
props
>
...
...
@@ -98,7 +102,11 @@ export default /*#__PURE__*/ defineBuiltInComponent({
})
const
{
_listeners
}
=
useListeners
(
props
,
$listeners
,
trigger
)
const
{
_handleSubscribe
,
_resize
}
=
useMethods
(
canvas
,
actionsWaiting
)
const
{
_handleSubscribe
,
_resize
}
=
useMethods
(
props
,
canvas
,
actionsWaiting
)
useSubscribe
(
_handleSubscribe
as
(
...
...
@@ -205,6 +213,7 @@ function useListeners(
}
function
useMethods
(
props
:
Props
,
canvasRef
:
Ref
<
HTMLCanvasElement
|
null
>
,
actionsWaiting
:
Ref
<
boolean
>
)
{
...
...
@@ -213,20 +222,22 @@ function useMethods(
[
key
:
string
]:
HTMLImageElement
&
{
ready
:
boolean
}
}
=
{}
const
_pixelRatio
=
computed
(()
=>
(
props
.
hidpi
?
pixelRatio
:
1
))
function
_resize
(
size
?:
{
width
:
number
;
height
:
number
})
{
let
canvas
=
canvasRef
.
value
!
var
hasChanged
=
!
size
||
canvas
.
width
!==
Math
.
floor
(
size
.
width
*
pixelRatio
)
||
canvas
.
height
!==
Math
.
floor
(
size
.
height
*
pixelRatio
)
canvas
.
width
!==
Math
.
floor
(
size
.
width
*
_pixelRatio
.
value
)
||
canvas
.
height
!==
Math
.
floor
(
size
.
height
*
_pixelRatio
.
value
)
if
(
!
hasChanged
)
return
if
(
canvas
.
width
>
0
&&
canvas
.
height
>
0
)
{
let
context
=
canvas
.
getContext
(
'
2d
'
)
!
let
imageData
=
context
.
getImageData
(
0
,
0
,
canvas
.
width
,
canvas
.
height
)
wrapper
(
canvas
)
wrapper
(
canvas
,
props
.
hidpi
)
context
.
putImageData
(
imageData
,
0
,
0
)
}
else
{
wrapper
(
canvas
)
wrapper
(
canvas
,
props
.
hidpi
)
}
}
function
actionsChanged
(
...
...
@@ -522,8 +533,8 @@ function useMethods(
height
=
height
?
Math
.
min
(
height
,
maxHeight
)
:
maxHeight
if
(
!
hidpi
)
{
if
(
!
destWidth
&&
!
destHeight
)
{
destWidth
=
Math
.
round
(
width
*
pixelRatio
)
destHeight
=
Math
.
round
(
height
*
pixelRatio
)
destWidth
=
Math
.
round
(
width
*
_pixelRatio
.
value
)
destHeight
=
Math
.
round
(
height
*
_pixelRatio
.
value
)
}
else
if
(
!
destWidth
)
{
destWidth
=
Math
.
round
((
width
/
height
)
*
destHeight
)
}
else
if
(
!
destHeight
)
{
...
...
packages/uni-h5/dist/uni-h5.cjs.js
浏览文件 @
55ac1075
...
...
@@ -1634,10 +1634,10 @@ function useResizeSensorReset(rootRef) {
};
}
const
pixelRatio
=
1
;
function
wrapper
(
canvas
)
{
canvas
.
width
=
canvas
.
offsetWidth
*
pixelRatio
;
canvas
.
height
=
canvas
.
offsetHeight
*
pixelRatio
;
canvas
.
getContext
(
"
2d
"
).
__hidpi__
=
true
;
function
wrapper
(
canvas
,
hidpi
=
true
)
{
canvas
.
width
=
canvas
.
offsetWidth
*
(
hidpi
?
pixelRatio
:
1
)
;
canvas
.
height
=
canvas
.
offsetHeight
*
(
hidpi
?
pixelRatio
:
1
)
;
canvas
.
getContext
(
"
2d
"
).
__hidpi__
=
hidpi
;
}
const
initHidpiOnce
=
/* @__PURE__ */
uniShared
.
once
(()
=>
{
return
void
0
;
...
...
@@ -1678,6 +1678,10 @@ const props$t = {
disableScroll
:
{
type
:
[
Boolean
,
String
],
default
:
false
},
hidpi
:
{
type
:
Boolean
,
default
:
true
}
};
var
index$B
=
/* @__PURE__ */
defineBuiltInComponent
({
...
...
@@ -1714,7 +1718,7 @@ var index$B = /* @__PURE__ */ defineBuiltInComponent({
const
{
_handleSubscribe
,
_resize
}
=
useMethods
(
canvas
,
actionsWaiting
);
}
=
useMethods
(
props2
,
canvas
,
actionsWaiting
);
useSubscribe
(
_handleSubscribe
,
useContextInfo
(
props2
.
canvasId
));
return
()
=>
{
const
{
...
...
@@ -1780,21 +1784,22 @@ function useListeners(props2, Listeners, trigger) {
_listeners
};
}
function
useMethods
(
canvasRef
,
actionsWaiting
)
{
function
useMethods
(
props2
,
canvasRef
,
actionsWaiting
)
{
let
_actionsDefer
=
[];
let
_images
=
{};
const
_pixelRatio
=
vue
.
computed
(()
=>
props2
.
hidpi
?
pixelRatio
:
1
);
function
_resize
(
size
)
{
let
canvas
=
canvasRef
.
value
;
var
hasChanged
=
!
size
||
canvas
.
width
!==
Math
.
floor
(
size
.
width
*
pixelRatio
)
||
canvas
.
height
!==
Math
.
floor
(
size
.
height
*
pixelRatio
);
var
hasChanged
=
!
size
||
canvas
.
width
!==
Math
.
floor
(
size
.
width
*
_pixelRatio
.
value
)
||
canvas
.
height
!==
Math
.
floor
(
size
.
height
*
_pixelRatio
.
value
);
if
(
!
hasChanged
)
return
;
if
(
canvas
.
width
>
0
&&
canvas
.
height
>
0
)
{
let
context
=
canvas
.
getContext
(
"
2d
"
);
let
imageData
=
context
.
getImageData
(
0
,
0
,
canvas
.
width
,
canvas
.
height
);
wrapper
(
canvas
);
wrapper
(
canvas
,
props2
.
hidpi
);
context
.
putImageData
(
imageData
,
0
,
0
);
}
else
{
wrapper
(
canvas
);
wrapper
(
canvas
,
props2
.
hidpi
);
}
}
function
actionsChanged
({
...
...
@@ -2004,8 +2009,8 @@ function useMethods(canvasRef, actionsWaiting) {
height
=
height
?
Math
.
min
(
height
,
maxHeight
)
:
maxHeight
;
if
(
!
hidpi
)
{
if
(
!
destWidth
&&
!
destHeight
)
{
destWidth
=
Math
.
round
(
width
*
pixelRatio
);
destHeight
=
Math
.
round
(
height
*
pixelRatio
);
destWidth
=
Math
.
round
(
width
*
_pixelRatio
.
value
);
destHeight
=
Math
.
round
(
height
*
_pixelRatio
.
value
);
}
else
if
(
!
destWidth
)
{
destWidth
=
Math
.
round
(
width
/
height
*
destHeight
);
}
else
if
(
!
destHeight
)
{
...
...
packages/uni-h5/dist/uni-h5.es.js
浏览文件 @
55ac1075
...
...
@@ -6245,10 +6245,10 @@ const pixelRatio = /* @__PURE__ */ function() {
const backingStore = context.backingStorePixelRatio || context.webkitBackingStorePixelRatio || context.mozBackingStorePixelRatio || context.msBackingStorePixelRatio || context.oBackingStorePixelRatio || context.backingStorePixelRatio || 1;
return (window.devicePixelRatio || 1) / backingStore;
}();
function wrapper(canvas) {
canvas.width = canvas.offsetWidth *
pixelRatio
;
canvas.height = canvas.offsetHeight *
pixelRatio
;
canvas.getContext("2d").__hidpi__ =
true
;
function wrapper(canvas
, hidpi = true
) {
canvas.width = canvas.offsetWidth *
(hidpi ? pixelRatio : 1)
;
canvas.height = canvas.offsetHeight *
(hidpi ? pixelRatio : 1)
;
canvas.getContext("2d").__hidpi__ =
hidpi
;
}
let isHidpi = false;
function initHidpi() {
...
...
@@ -6337,6 +6337,7 @@ function initHidpi() {
const args = Array.prototype.slice.call(arguments);
args[1] *= pixelRatio;
args[2] *= pixelRatio;
args[3] *= pixelRatio;
var font2 = this.font;
this.font = font2.replace(/(\d+\.?\d*)(px|em|rem|pt)/g, function(w, m, u) {
return m * pixelRatio + u;
...
...
@@ -6353,6 +6354,7 @@ function initHidpi() {
var args = Array.prototype.slice.call(arguments);
args[1] *= pixelRatio;
args[2] *= pixelRatio;
args[3] *= pixelRatio;
var font2 = this.font;
this.font = font2.replace(/(\d+\.?\d*)(px|em|rem|pt)/g, function(w, m, u) {
return m * pixelRatio + u;
...
...
@@ -6412,6 +6414,10 @@ const props$A = {
disableScroll: {
type: [Boolean, String],
default: false
},
hidpi: {
type: Boolean,
default: true
}
};
var index$w = /* @__PURE__ */ defineBuiltInComponent({
...
...
@@ -6448,7 +6454,7 @@ var index$w = /* @__PURE__ */ defineBuiltInComponent({
const {
_handleSubscribe,
_resize
} = useMethods(canvas, actionsWaiting);
} = useMethods(
props2,
canvas, actionsWaiting);
useSubscribe(_handleSubscribe, useContextInfo(props2.canvasId), true);
onMounted(() => {
_resize();
...
...
@@ -6517,21 +6523,22 @@ function useListeners(props2, Listeners, trigger) {
_listeners
};
}
function useMethods(canvasRef, actionsWaiting) {
function useMethods(
props2,
canvasRef, actionsWaiting) {
let _actionsDefer = [];
let _images = {};
const _pixelRatio = computed(() => props2.hidpi ? pixelRatio : 1);
function _resize(size) {
let canvas = canvasRef.value;
var hasChanged = !size || canvas.width !== Math.floor(size.width *
pixelRatio) || canvas.height !== Math.floor(size.height * pixelRatio
);
var hasChanged = !size || canvas.width !== Math.floor(size.width *
_pixelRatio.value) || canvas.height !== Math.floor(size.height * _pixelRatio.value
);
if (!hasChanged)
return;
if (canvas.width > 0 && canvas.height > 0) {
let context = canvas.getContext("2d");
let imageData = context.getImageData(0, 0, canvas.width, canvas.height);
wrapper(canvas);
wrapper(canvas
, props2.hidpi
);
context.putImageData(imageData, 0, 0);
} else {
wrapper(canvas);
wrapper(canvas
, props2.hidpi
);
}
}
function actionsChanged({
...
...
@@ -6741,8 +6748,8 @@ function useMethods(canvasRef, actionsWaiting) {
height = height ? Math.min(height, maxHeight) : maxHeight;
if (!hidpi) {
if (!destWidth && !destHeight) {
destWidth = Math.round(width *
pixelRatio
);
destHeight = Math.round(height *
pixelRatio
);
destWidth = Math.round(width *
_pixelRatio.value
);
destHeight = Math.round(height *
_pixelRatio.value
);
} else if (!destWidth) {
destWidth = Math.round(width / height * destHeight);
} else if (!destHeight) {
...
...
@@ -9666,7 +9673,6 @@ function useMovableViewState(props2, trigger, rootRef) {
}
}
function __handleTouchMove(event) {
event.stopPropagation();
if (!_isScaling && !props2.disabled && _isTouching) {
let x = _translateX;
let y = _translateY;
...
...
pnpm-lock.yaml
浏览文件 @
55ac1075
此差异已折叠。
点击以展开。
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录