Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
小浣熊撸代码
uni-app
提交
0ac66773
U
uni-app
项目概览
小浣熊撸代码
/
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,发现更多精彩内容 >>
提交
0ac66773
编写于
7月 29, 2021
作者:
fxy060608
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat(app): add onPageReady
上级
7cac403c
变更
10
显示空白变更内容
内联
并排
Showing
10 changed file
with
128 addition
and
22 deletion
+128
-22
packages/uni-app-plus/dist/uni-app-service.es.js
packages/uni-app-plus/dist/uni-app-service.es.js
+5
-1
packages/uni-app-plus/dist/uni-app-view.umd.js
packages/uni-app-plus/dist/uni-app-view.umd.js
+42
-7
packages/uni-app-plus/src/view/framework/dom/index.ts
packages/uni-app-plus/src/view/framework/dom/index.ts
+22
-2
packages/uni-app-plus/src/view/framework/dom/page.ts
packages/uni-app-plus/src/view/framework/dom/page.ts
+29
-7
packages/uni-app-vue/dist/service.runtime.esm.js
packages/uni-app-vue/dist/service.runtime.esm.js
+5
-1
packages/uni-shared/dist/uni-shared.cjs.js
packages/uni-shared/dist/uni-shared.cjs.js
+5
-1
packages/uni-shared/dist/uni-shared.es.js
packages/uni-shared/dist/uni-shared.es.js
+5
-1
packages/uni-shared/src/log.ts
packages/uni-shared/src/log.ts
+5
-1
packages/vite-plugin-uni/package.json
packages/vite-plugin-uni/package.json
+1
-1
packages/vite-plugin-uni/src/config/define.ts
packages/vite-plugin-uni/src/config/define.ts
+9
-0
未找到文件。
packages/uni-app-plus/dist/uni-app-service.es.js
浏览文件 @
0ac66773
...
...
@@ -727,8 +727,12 @@ var serviceContext = (function (vue) {
}, page.$page.id, callback);
}
let lastLogTime = 0;
function formatLog(module, ...args) {
return `[${Date.now()}][${module}]:${args
const now = Date.now();
const diff = lastLogTime ? now - lastLogTime : 0;
lastLogTime = now;
return `[${now}][${diff}ms][${module}]:${args
.map((arg) => JSON.stringify(arg))
.join(' ')}`;
}
...
...
packages/uni-app-plus/dist/uni-app-view.umd.js
浏览文件 @
0ac66773
...
...
@@ -153,8 +153,12 @@
const n = parseFloat(val);
return isNaN(n) ? val : n;
};
let lastLogTime = 0;
function formatLog(module, ...args) {
return `[${Date.now()}][${module}]\uFF1A${args.map((arg) => JSON.stringify(arg)).join(" ")}`;
const now = Date.now();
const diff = lastLogTime ? now - lastLogTime : 0;
lastLogTime = now;
return `[${now}][${diff}ms][${module}]\uFF1A${args.map((arg) => JSON.stringify(arg)).join(" ")}`;
}
function getCustomDataset(el) {
return extend({}, el.dataset, el.__uniDataset);
...
...
@@ -15926,6 +15930,22 @@
elements.set(id2, element);
return element;
}
const pageReadyCallbacks = [];
let isPageReady = false;
function onPageReady(callback) {
if (isPageReady) {
return callback();
}
pageReadyCallbacks.push(callback);
}
function setPageReady() {
{
console.log(formatLog("setPageReady", pageReadyCallbacks.length));
}
isPageReady = true;
pageReadyCallbacks.forEach((fn) => fn());
pageReadyCallbacks.length = 0;
}
function onPageCreated() {
}
function onPageCreate({
...
...
@@ -15945,9 +15965,6 @@
initPageInfo(route);
initSystemInfo(platform, pixelRatio2, windowWidth);
initPageElement();
if (css) {
initPageCss(route);
}
const pageId = plus.webview.currentWebview().id;
window.__id__ = pageId;
document.title = `${route}[${pageId}]`;
...
...
@@ -15957,6 +15974,11 @@
} else if (onPageScroll || onPageReachBottom) {
initPageScroll(onPageScroll, onPageReachBottom, onReachBottomDistance);
}
if (css) {
initPageCss(route);
} else {
setPageReady();
}
}
function initPageInfo(route) {
window.__PAGE_INFO__ = {
...
...
@@ -15974,13 +15996,15 @@
createElement(0, "div", -1, -1).$ = document.getElementById("app");
}
function initPageCss(route) {
{
console.log(formatLog("initPageCss", route + ".css"));
}
const element = document.createElement("link");
element.type = "text/css";
element.rel = "stylesheet";
element.href = route + ".css";
element.onload = function() {
window.dispatchEvent(new CustomEvent("updateview"));
};
element.onload = setPageReady;
element.onerror = setPageReady;
document.head.appendChild(element);
}
function initCssVar(statusbarHeight, windowTop, windowBottom) {
...
...
@@ -16018,6 +16042,17 @@
publish();
}
function onVdSync(actions) {
const firstAction = actions[0];
if (firstAction[0] === ACTION_TYPE_PAGE_CREATE) {
onPageCreateSync(firstAction);
} else {
onPageReady(() => onPageUpdateSync(actions));
}
}
function onPageCreateSync(action) {
return onPageCreate(action[1]);
}
function onPageUpdateSync(actions) {
const dictAction = actions[0];
const getDict = createGetDict(dictAction[0] === ACTION_TYPE_DICT ? dictAction[1] : []);
actions.forEach((action) => {
...
...
packages/uni-app-plus/src/view/framework/dom/index.ts
浏览文件 @
0ac66773
...
...
@@ -10,19 +10,39 @@ import {
ACTION_TYPE_ADD_EVENT
,
ACTION_TYPE_REMOVE_EVENT
,
ACTION_TYPE_SET_TEXT
,
PageCreateAction
,
}
from
'
@dcloudio/uni-shared
'
import
{
UniNodeJSONMinify
}
from
'
packages/uni-shared/src/vdom/Node
'
import
{
ACTION_TYPE_DICT
,
DictAction
,
Dictionary
}
from
'
../../../constants
'
import
{
createGetDict
,
decodeNodeJson
}
from
'
./decodeActions
'
import
{
$
,
createElement
,
onPageCreate
,
onPageCreated
}
from
'
./page
'
import
{
$
,
createElement
,
onPageCreate
,
onPageCreated
,
onPageReady
,
}
from
'
./page
'
import
{
flushPostActionJobs
}
from
'
./scheduler
'
export
function
onVdSync
(
actions
:
(
PageAction
|
DictAction
)[])
{
const
firstAction
=
actions
[
0
]
// page create
if
(
firstAction
[
0
]
===
ACTION_TYPE_PAGE_CREATE
)
{
onPageCreateSync
(
firstAction
)
}
else
{
onPageReady
(()
=>
onPageUpdateSync
(
actions
))
}
}
function
onPageCreateSync
(
action
:
PageCreateAction
)
{
return
onPageCreate
(
action
[
1
])
}
function
onPageUpdateSync
(
actions
:
(
PageAction
|
DictAction
)[])
{
const
dictAction
=
actions
[
0
]
const
getDict
=
createGetDict
(
dictAction
[
0
]
===
ACTION_TYPE_DICT
?
(
dictAction
[
1
]
as
Dictionary
)
:
[]
)
actions
.
forEach
((
action
)
=>
{
switch
(
action
[
0
])
{
case
ACTION_TYPE_PAGE_CREATE
:
...
...
packages/uni-app-plus/src/view/framework/dom/page.ts
浏览文件 @
0ac66773
...
...
@@ -64,6 +64,24 @@ export function createElement(
return
element
}
const
pageReadyCallbacks
:
(()
=>
void
)[]
=
[]
let
isPageReady
=
false
export
function
onPageReady
(
callback
:
()
=>
void
)
{
if
(
isPageReady
)
{
return
callback
()
}
pageReadyCallbacks
.
push
(
callback
)
}
function
setPageReady
()
{
if
(
__DEV__
)
{
console
.
log
(
formatLog
(
'
setPageReady
'
,
pageReadyCallbacks
.
length
))
}
isPageReady
=
true
pageReadyCallbacks
.
forEach
((
fn
)
=>
fn
())
pageReadyCallbacks
.
length
=
0
}
export
function
onPageCreated
()
{}
export
function
onPageCreate
({
...
...
@@ -85,10 +103,6 @@ export function onPageCreate({
// 初始化页面容器元素
initPageElement
()
if
(
css
)
{
initPageCss
(
route
)
}
const
pageId
=
plus
.
webview
.
currentWebview
().
id
!
;(
window
as
any
).
__id__
=
pageId
document
.
title
=
`
${
route
}
[
${
pageId
}
]`
...
...
@@ -100,6 +114,12 @@ export function onPageCreate({
}
else
if
(
onPageScroll
||
onPageReachBottom
)
{
initPageScroll
(
onPageScroll
,
onPageReachBottom
,
onReachBottomDistance
)
}
if
(
css
)
{
initPageCss
(
route
)
}
else
{
setPageReady
()
}
}
function
initPageInfo
(
route
:
string
)
{
...
...
@@ -125,13 +145,15 @@ function initPageElement() {
}
function
initPageCss
(
route
:
string
)
{
if
(
__DEV__
)
{
console
.
log
(
formatLog
(
'
initPageCss
'
,
route
+
'
.css
'
))
}
const
element
=
document
.
createElement
(
'
link
'
)
element
.
type
=
'
text/css
'
element
.
rel
=
'
stylesheet
'
element
.
href
=
route
+
'
.css
'
element
.
onload
=
function
()
{
window
.
dispatchEvent
(
new
CustomEvent
(
'
updateview
'
))
}
element
.
onload
=
setPageReady
element
.
onerror
=
setPageReady
document
.
head
.
appendChild
(
element
)
}
...
...
packages/uni-app-vue/dist/service.runtime.esm.js
浏览文件 @
0ac66773
...
...
@@ -37,9 +37,13 @@ export default function vueFactory(exports) {
*/
var
capitalize$1
=
cacheStringFunction$1
(
str
=>
str
.
charAt
(
0
).
toUpperCase
()
+
str
.
slice
(
1
));
var
lastLogTime
=
0
;
function
formatLog
(
module
,
...
args
)
{
return
"
[
"
.
concat
(
Date
.
now
(),
"
][
"
).
concat
(
module
,
"
]
\
uFF1A
"
).
concat
(
args
.
map
(
arg
=>
JSON
.
stringify
(
arg
)).
join
(
'
'
));
var
now
=
Date
.
now
();
var
diff
=
lastLogTime
?
now
-
lastLogTime
:
0
;
lastLogTime
=
now
;
return
"
[
"
.
concat
(
now
,
"
][
"
).
concat
(
diff
,
"
ms][
"
).
concat
(
module
,
"
]
\
uFF1A
"
).
concat
(
args
.
map
(
arg
=>
JSON
.
stringify
(
arg
)).
join
(
'
'
));
}
class
DOMException
extends
Error
{
...
...
packages/uni-shared/dist/uni-shared.cjs.js
浏览文件 @
0ac66773
...
...
@@ -4,8 +4,12 @@ Object.defineProperty(exports, '__esModule', { value: true });
var
shared
=
require
(
'
@vue/shared
'
);
let
lastLogTime
=
0
;
function
formatLog
(
module
,
...
args
)
{
return
`[
${
Date
.
now
()}
][
${
module
}
]:
${
args
const
now
=
Date
.
now
();
const
diff
=
lastLogTime
?
now
-
lastLogTime
:
0
;
lastLogTime
=
now
;
return
`[
${
now
}
][
${
diff
}
ms][
${
module
}
]:
${
args
.
map
((
arg
)
=>
JSON
.
stringify
(
arg
))
.
join
(
'
'
)}
`
;
}
...
...
packages/uni-shared/dist/uni-shared.es.js
浏览文件 @
0ac66773
import
{
camelize
,
extend
,
isString
,
isPlainObject
,
isArray
,
isHTMLTag
,
isSVGTag
,
capitalize
,
hyphenate
}
from
'
@vue/shared
'
;
let
lastLogTime
=
0
;
function
formatLog
(
module
,
...
args
)
{
return
`[
${
Date
.
now
()}
][
${
module
}
]:
${
args
const
now
=
Date
.
now
();
const
diff
=
lastLogTime
?
now
-
lastLogTime
:
0
;
lastLogTime
=
now
;
return
`[
${
now
}
][
${
diff
}
ms][
${
module
}
]:
${
args
.
map
((
arg
)
=>
JSON
.
stringify
(
arg
))
.
join
(
'
'
)}
`
;
}
...
...
packages/uni-shared/src/log.ts
浏览文件 @
0ac66773
let
lastLogTime
=
0
export
function
formatLog
(
module
:
string
,
...
args
:
any
[])
{
return
`[
${
Date
.
now
()}
][
${
module
}
]:
${
args
const
now
=
Date
.
now
()
const
diff
=
lastLogTime
?
now
-
lastLogTime
:
0
lastLogTime
=
now
return
`[
${
now
}
][
${
diff
}
ms][
${
module
}
]:
${
args
.
map
((
arg
)
=>
JSON
.
stringify
(
arg
))
.
join
(
'
'
)}
`
}
packages/vite-plugin-uni/package.json
浏览文件 @
0ac66773
...
...
@@ -40,7 +40,7 @@
"@types/sass"
:
"^1.16.0"
},
"uni-app"
:
{
"compilerVersion"
:
"3.
1.23
"
"compilerVersion"
:
"3.
2.0
"
},
"gitHead"
:
"4dd0e035b52584ff028ee3028c46adc555be0529"
}
packages/vite-plugin-uni/src/config/define.ts
浏览文件 @
0ac66773
import
{
UserConfig
}
from
'
vite
'
import
{
VitePluginUniResolvedOptions
}
from
'
..
'
import
{
parseManifestJsonOnce
,
runByHBuilderX
,
}
from
'
../../../uni-cli-shared/dist
'
export
function
createDefine
({
platform
,
}:
VitePluginUniResolvedOptions
):
UserConfig
[
'
define
'
]
{
const
manifestJson
=
parseManifestJsonOnce
(
process
.
env
.
UNI_INPUT_DIR
)
return
{
__VUE_PROD_DEVTOOLS__
:
false
,
'
process.env.NODE_ENV
'
:
JSON
.
stringify
(
process
.
env
.
NODE_ENV
),
'
process.env.UNI_APP_ID
'
:
JSON
.
stringify
(
manifestJson
.
appid
||
''
),
'
process.env.UNI_APP_NAME
'
:
JSON
.
stringify
(
manifestJson
.
name
||
''
),
'
process.env.UNI_PLATFORM
'
:
JSON
.
stringify
(
platform
),
'
process.env.RUN_BY_HBUILDERX
'
:
runByHBuilderX
(),
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录