Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
wzj-java
uni-app
提交
1fd11424
U
uni-app
项目概览
wzj-java
/
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,发现更多精彩内容 >>
提交
1fd11424
编写于
11月 12, 2021
作者:
fxy060608
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat: add getLaunchOptionsSync, getEnterOptionsSync
上级
5e07520d
变更
28
显示空白变更内容
内联
并排
Showing
28 changed file
with
387 addition
and
91 deletion
+387
-91
packages/shims-uni-app.d.ts
packages/shims-uni-app.d.ts
+4
-0
packages/uni-api/src/index.ts
packages/uni-api/src/index.ts
+1
-1
packages/uni-api/src/service/lifecycle/app.ts
packages/uni-api/src/service/lifecycle/app.ts
+41
-0
packages/uni-app-plus/dist/uni-app-service.es.js
packages/uni-app-plus/dist/uni-app-service.es.js
+92
-29
packages/uni-app-plus/src/platform/index.ts
packages/uni-app-plus/src/platform/index.ts
+5
-0
packages/uni-app-plus/src/service/api/index.ts
packages/uni-app-plus/src/service/api/index.ts
+2
-0
packages/uni-app-plus/src/service/framework/app/initAppLaunch.ts
...s/uni-app-plus/src/service/framework/app/initAppLaunch.ts
+14
-6
packages/uni-app-plus/src/service/framework/app/initEntry.ts
packages/uni-app-plus/src/service/framework/app/initEntry.ts
+5
-3
packages/uni-app-plus/src/service/framework/app/initGlobalEvent.ts
...uni-app-plus/src/service/framework/app/initGlobalEvent.ts
+12
-2
packages/uni-app-plus/src/service/framework/app/utils.ts
packages/uni-app-plus/src/service/framework/app/utils.ts
+66
-0
packages/uni-core/src/service/index.ts
packages/uni-core/src/service/index.ts
+1
-0
packages/uni-core/src/service/init/on.ts
packages/uni-core/src/service/init/on.ts
+4
-10
packages/uni-core/src/service/utils.ts
packages/uni-core/src/service/utils.ts
+18
-0
packages/uni-h5-vite/lib/api.json
packages/uni-h5-vite/lib/api.json
+2
-0
packages/uni-h5/dist/uni-h5.es.js
packages/uni-h5/dist/uni-h5.es.js
+56
-19
packages/uni-h5/src/framework/setup/index.ts
packages/uni-h5/src/framework/setup/index.ts
+17
-12
packages/uni-h5/src/framework/setup/utils.ts
packages/uni-h5/src/framework/setup/utils.ts
+29
-0
packages/uni-h5/src/platform/index.ts
packages/uni-h5/src/platform/index.ts
+1
-0
packages/uni-h5/src/service/api/index.ts
packages/uni-h5/src/service/api/index.ts
+2
-0
packages/uni-mp-alipay/dist/uni.mp.esm.js
packages/uni-mp-alipay/dist/uni.mp.esm.js
+1
-1
packages/uni-mp-baidu/dist/uni.mp.esm.js
packages/uni-mp-baidu/dist/uni.mp.esm.js
+1
-1
packages/uni-mp-core/src/runtime/app.ts
packages/uni-mp-core/src/runtime/app.ts
+7
-1
packages/uni-mp-kuaishou/dist/uni.mp.esm.js
packages/uni-mp-kuaishou/dist/uni.mp.esm.js
+1
-1
packages/uni-mp-lark/dist/uni.mp.esm.js
packages/uni-mp-lark/dist/uni.mp.esm.js
+1
-1
packages/uni-mp-qq/dist/uni.mp.esm.js
packages/uni-mp-qq/dist/uni.mp.esm.js
+1
-1
packages/uni-mp-toutiao/dist/uni.mp.esm.js
packages/uni-mp-toutiao/dist/uni.mp.esm.js
+1
-1
packages/uni-mp-weixin/dist/uni.mp.esm.js
packages/uni-mp-weixin/dist/uni.mp.esm.js
+1
-1
packages/uni-quickapp-webview/dist/uni.mp.esm.js
packages/uni-quickapp-webview/dist/uni.mp.esm.js
+1
-1
未找到文件。
packages/shims-uni-app.d.ts
浏览文件 @
1fd11424
...
...
@@ -61,6 +61,10 @@ declare namespace UniApp {
qqMapKey
?:
string
googleMapKey
?:
string
// app-plus
referrerInfo
?:
{
appId
:
string
extraData
:
Record
<
string
,
any
>
}
entryPagePath
?:
string
entryPageQuery
?:
string
realEntryPagePath
?:
string
...
...
packages/uni-api/src/index.ts
浏览文件 @
1fd11424
...
...
@@ -19,7 +19,7 @@ export * from './service/ui/setPageMeta'
export
*
from
'
./service/keyboard/getSelectedTextRange
'
export
*
from
'
./service/
hook
/app
'
export
*
from
'
./service/
lifecycle
/app
'
// protocols
export
*
from
'
./protocols/base/canIUse
'
...
...
packages/uni-api/src/service/
hook
/app.ts
→
packages/uni-api/src/service/
lifecycle
/app.ts
浏览文件 @
1fd11424
import
{
getEnterOptions
,
getLaunchOptions
}
from
'
@dcloudio/uni-platform
'
import
{
ON_LAUNCH
}
from
'
@dcloudio/uni-shared
'
import
{
defineSyncApi
}
from
'
../../helpers/api
'
import
{
ComponentInternalInstance
,
injectHook
}
from
'
vue
'
...
...
@@ -17,3 +19,23 @@ export function injectAppLaunchHooks(appInstance: ComponentInternalInstance) {
injectHook
(
ON_LAUNCH
,
hook
,
appInstance
)
})
}
type
API_TYPE_GET_ENTER_OPTIONS_SYNC
=
typeof
uni
.
getLaunchOptionsSync
const
API_GET_ENTER_OPTIONS_SYNC
=
'
getEnterOptionsSync
'
export
const
getEnterOptionsSync
=
defineSyncApi
<
API_TYPE_GET_ENTER_OPTIONS_SYNC
>
(
API_GET_ENTER_OPTIONS_SYNC
,
()
=>
{
return
getEnterOptions
()
}
)
type
API_TYPE_GET_LAUNCH_OPTIONS_SYNC
=
typeof
uni
.
getLaunchOptionsSync
const
API_GET_LAUNCH_OPTIONS_SYNC
=
'
getLaunchOptionsSync
'
export
const
getLaunchOptionsSync
=
defineSyncApi
<
API_TYPE_GET_LAUNCH_OPTIONS_SYNC
>
(
API_GET_LAUNCH_OPTIONS_SYNC
,
()
=>
{
return
getLaunchOptions
()
}
)
packages/uni-app-plus/dist/uni-app-service.es.js
浏览文件 @
1fd11424
...
...
@@ -2225,17 +2225,9 @@ var serviceContext = (function (vue) {
invokeHook(getCurrentPage(), ON_RESIZE, res);
UniServiceJSBridge.invokeOnCallback('onWindowResize', res); // API
}
function onAppEnterForeground() {
function onAppEnterForeground(
enterOptions
) {
const page = getCurrentPage();
const showOptions = {
path: '',
query: {},
};
if (page) {
showOptions.path = page.$page.route;
showOptions.query = page.$page.options;
}
invokeHook(getApp(), ON_SHOW, showOptions);
invokeHook(getApp(), ON_SHOW, enterOptions);
invokeHook(page, ON_SHOW);
}
function onAppEnterBackground() {
...
...
@@ -2343,6 +2335,18 @@ var serviceContext = (function (vue) {
initAppConfig(app._context.config);
}
function createLaunchOptions() {
return {
path: '',
query: {},
scene: 1001,
referrerInfo: {
appId: '',
extraData: {},
},
};
}
function getRealPath(filepath) {
// 无协议的情况补全 https
if (filepath.indexOf('//') === 0) {
...
...
@@ -2649,6 +2653,55 @@ var serviceContext = (function (vue) {
UniServiceJSBridge.unsubscribe(getEventName(reqId));
}
const EVENT_BACKBUTTON = 'backbutton';
function backbuttonListener() {
uni.navigateBack({
from: 'backbutton',
success() { }, // 传入空方法,避免返回Promise,因为onBackPress可能导致fail
});
}
const enterOptions = createLaunchOptions();
const launchOptions = createLaunchOptions();
function getLaunchOptions() {
return launchOptions;
}
function getEnterOptions() {
return enterOptions;
}
function initEnterOptions({ path, query, referrerInfo, }) {
extend(enterOptions, {
path,
query: query ? parseQuery(query) : {},
referrerInfo: referrerInfo || {},
});
}
function initLaunchOptions({ path, query, referrerInfo, }) {
extend(launchOptions, {
path,
query: query ? parseQuery(query) : {},
referrerInfo: referrerInfo || {},
});
extend(enterOptions, launchOptions);
return launchOptions;
}
function parseRedirectInfo() {
const weexPlus = weex.requireModule('plus');
const { path, query, extraData, userAction } = weexPlus.getRedirectInfo() || {};
const referrerInfo = {
appId: '',
extraData: {},
};
if (extraData) {
referrerInfo.extraData = extraData;
}
return {
path,
query: query ? '?' + query : '',
referrerInfo,
userAction,
};
}
const TEMP_PATH$1 = '';
const API_UPX2PX = 'upx2px';
...
...
@@ -4507,6 +4560,14 @@ var serviceContext = (function (vue) {
vue.injectHook(ON_LAUNCH, hook, appInstance);
});
}
const API_GET_ENTER_OPTIONS_SYNC = 'getEnterOptionsSync';
const getEnterOptionsSync = defineSyncApi(API_GET_ENTER_OPTIONS_SYNC, () => {
return getEnterOptions();
});
const API_GET_LAUNCH_OPTIONS_SYNC = 'getLaunchOptionsSync';
const getLaunchOptionsSync = defineSyncApi(API_GET_LAUNCH_OPTIONS_SYNC, () => {
return getLaunchOptions();
});
const API_GET_BACKGROUND_AUDIO_MANAGER = 'getBackgroundAudioManager';
...
...
@@ -10179,9 +10240,10 @@ var serviceContext = (function (vue) {
let entryPageQuery;
const weexPlus = weex.requireModule('plus');
if (weexPlus.getRedirectInfo) {
const info = weexPlus.getRedirectInfo() || {};
entryPagePath = info.path;
entryPageQuery = info.query ? '?' + info.query : '';
const { path, query, referrerInfo } = parseRedirectInfo();
entryPagePath = path;
entryPageQuery = query;
__uniConfig.referrerInfo = referrerInfo;
}
else {
const argsJsonStr = plus.runtime.arguments;
...
...
@@ -10244,14 +10306,6 @@ var serviceContext = (function (vue) {
}
}
const EVENT_BACKBUTTON = 'backbutton';
function backbuttonListener() {
uni.navigateBack({
from: 'backbutton',
success() { }, // 传入空方法,避免返回Promise,因为onBackPress可能导致fail
});
}
function initGlobalEvent() {
const plusGlobalEvent = plus.globalEvent;
const weexGlobalEvent = weex.requireModule('globalEvent');
...
...
@@ -10268,7 +10322,11 @@ var serviceContext = (function (vue) {
emit(ON_APP_ENTER_BACKGROUND);
});
plusGlobalEvent.addEventListener('resume', () => {
emit(ON_APP_ENTER_FOREGROUND);
const info = parseRedirectInfo();
if (info.userAction) {
initEnterOptions(info);
}
emit(ON_APP_ENTER_FOREGROUND, getEnterOptions());
});
weexGlobalEvent.addEventListener('uistylechange', function (event) {
const args = {
...
...
@@ -10303,12 +10361,15 @@ var serviceContext = (function (vue) {
}
function initAppLaunch(appVm) {
const args = {
path: __uniConfig.entryPagePath,
query: {},
scene: 1001,
app: appVm,
};
const { entryPagePath, entryPageQuery, referrerInfo } = __uniConfig;
const args = extend({
// 为了让 uni-stat 在 uni.onLaunch 中可以 mixin
app: { mixin: appVm.$.appContext.app.mixin },
}, initLaunchOptions({
path: entryPagePath,
query: entryPageQuery,
referrerInfo: referrerInfo,
}));
injectAppLaunchHooks(appVm.$);
invokeHook(appVm, ON_LAUNCH, args);
invokeHook(appVm, ON_SHOW, args);
...
...
@@ -12775,6 +12836,8 @@ var serviceContext = (function (vue) {
onAppLaunch: onAppLaunch,
onLocaleChange: onLocaleChange,
setPageMeta: setPageMeta,
getEnterOptionsSync: getEnterOptionsSync,
getLaunchOptionsSync: getLaunchOptionsSync,
setStorageSync: setStorageSync,
setStorage: setStorage,
getStorageSync: getStorageSync,
...
...
packages/uni-app-plus/src/platform/index.ts
浏览文件 @
1fd11424
...
...
@@ -24,3 +24,8 @@ export function getSameOriginUrl(url: string): Promise<string> {
return
Promise
.
resolve
(
url
)
}
export
const
TEMP_PATH
=
''
export
{
getEnterOptions
,
getLaunchOptions
,
}
from
'
../service/framework/app/utils
'
packages/uni-app-plus/src/service/api/index.ts
浏览文件 @
1fd11424
...
...
@@ -107,4 +107,6 @@ export {
onAppLaunch
,
onLocaleChange
,
setPageMeta
,
getEnterOptionsSync
,
getLaunchOptionsSync
,
}
from
'
@dcloudio/uni-api
'
packages/uni-app-plus/src/service/framework/app/initAppLaunch.ts
浏览文件 @
1fd11424
import
{
extend
}
from
'
@vue/shared
'
import
{
injectAppLaunchHooks
}
from
'
@dcloudio/uni-api
'
import
{
invokeHook
}
from
'
@dcloudio/uni-core
'
import
{
ON_LAUNCH
,
ON_SHOW
,
ON_HIDE
}
from
'
@dcloudio/uni-shared
'
import
{
ComponentPublicInstance
}
from
'
vue
'
import
{
initLaunchOptions
}
from
'
./utils
'
export
function
initAppLaunch
(
appVm
:
ComponentPublicInstance
)
{
const
args
=
{
path
:
__uniConfig
.
entryPagePath
,
query
:
{},
scene
:
1001
,
app
:
appVm
,
}
const
{
entryPagePath
,
entryPageQuery
,
referrerInfo
}
=
__uniConfig
const
args
=
extend
(
{
// 为了让 uni-stat 在 uni.onLaunch 中可以 mixin
app
:
{
mixin
:
appVm
.
$
.
appContext
.
app
.
mixin
},
},
initLaunchOptions
({
path
:
entryPagePath
,
query
:
entryPageQuery
,
referrerInfo
:
referrerInfo
,
})
)
injectAppLaunchHooks
(
appVm
.
$
)
invokeHook
(
appVm
,
ON_LAUNCH
,
args
)
invokeHook
(
appVm
,
ON_SHOW
,
args
)
...
...
packages/uni-app-plus/src/service/framework/app/initEntry.ts
浏览文件 @
1fd11424
import
{
getRouteOptions
}
from
'
@dcloudio/uni-core
'
import
{
parseRedirectInfo
}
from
'
./utils
'
let
isInitEntryPage
=
false
...
...
@@ -14,9 +15,10 @@ export function initEntry() {
const
weexPlus
=
weex
.
requireModule
(
'
plus
'
)
if
(
weexPlus
.
getRedirectInfo
)
{
const
info
=
weexPlus
.
getRedirectInfo
()
||
{}
entryPagePath
=
info
.
path
entryPageQuery
=
info
.
query
?
'
?
'
+
info
.
query
:
''
const
{
path
,
query
,
referrerInfo
}
=
parseRedirectInfo
()
entryPagePath
=
path
entryPageQuery
=
query
__uniConfig
.
referrerInfo
=
referrerInfo
}
else
{
const
argsJsonStr
=
plus
.
runtime
.
arguments
if
(
!
argsJsonStr
)
{
...
...
packages/uni-app-plus/src/service/framework/app/initGlobalEvent.ts
浏览文件 @
1fd11424
...
...
@@ -5,7 +5,13 @@ import {
ON_THEME_CHANGE
,
ON_KEYBOARD_HEIGHT_CHANGE
,
}
from
'
@dcloudio/uni-shared
'
import
{
EVENT_BACKBUTTON
,
backbuttonListener
}
from
'
./utils
'
import
{
EVENT_BACKBUTTON
,
backbuttonListener
,
parseRedirectInfo
,
initEnterOptions
,
getEnterOptions
,
}
from
'
./utils
'
export
function
initGlobalEvent
()
{
const
plusGlobalEvent
=
(
plus
as
any
).
globalEvent
...
...
@@ -25,7 +31,11 @@ export function initGlobalEvent() {
})
plusGlobalEvent
.
addEventListener
(
'
resume
'
,
()
=>
{
emit
(
ON_APP_ENTER_FOREGROUND
)
const
info
=
parseRedirectInfo
()
if
(
info
.
userAction
)
{
initEnterOptions
(
info
)
}
emit
(
ON_APP_ENTER_FOREGROUND
,
getEnterOptions
())
})
weexGlobalEvent
.
addEventListener
(
...
...
packages/uni-app-plus/src/service/framework/app/utils.ts
浏览文件 @
1fd11424
import
{
extend
}
from
'
@vue/shared
'
import
{
parseQuery
}
from
'
@dcloudio/uni-shared
'
import
{
createLaunchOptions
,
LaunchOptions
}
from
'
@dcloudio/uni-core
'
export
const
EVENT_BACKBUTTON
=
'
backbutton
'
export
function
backbuttonListener
()
{
uni
.
navigateBack
({
from
:
'
backbutton
'
,
success
()
{},
// 传入空方法,避免返回Promise,因为onBackPress可能导致fail
}
as
UniApp
.
NavigateBackOptions
)
}
const
enterOptions
:
LaunchOptions
=
createLaunchOptions
()
const
launchOptions
:
LaunchOptions
=
createLaunchOptions
()
export
function
getLaunchOptions
()
{
return
launchOptions
}
export
function
getEnterOptions
()
{
return
enterOptions
}
export
function
initEnterOptions
({
path
,
query
,
referrerInfo
,
}:
Partial
<
RedirectInfo
>
)
{
extend
(
enterOptions
,
{
path
,
query
:
query
?
parseQuery
(
query
)
:
{},
referrerInfo
:
referrerInfo
||
{},
})
}
export
function
initLaunchOptions
({
path
,
query
,
referrerInfo
,
}:
Partial
<
RedirectInfo
>
)
{
extend
(
launchOptions
,
{
path
,
query
:
query
?
parseQuery
(
query
)
:
{},
referrerInfo
:
referrerInfo
||
{},
})
extend
(
enterOptions
,
launchOptions
)
return
launchOptions
}
interface
RedirectInfo
extends
Omit
<
LaunchOptions
,
'
query
'
|
'
scene
'
>
{
query
:
string
userAction
:
boolean
}
export
function
parseRedirectInfo
():
RedirectInfo
{
const
weexPlus
=
weex
.
requireModule
(
'
plus
'
)
const
{
path
,
query
,
extraData
,
userAction
}
=
weexPlus
.
getRedirectInfo
()
||
{}
const
referrerInfo
:
UniApp
.
UniConfig
[
'
referrerInfo
'
]
=
{
appId
:
''
,
extraData
:
{},
}
if
(
extraData
)
{
referrerInfo
.
extraData
=
extraData
}
return
{
path
,
query
:
query
?
'
?
'
+
query
:
''
,
referrerInfo
,
userAction
,
}
}
packages/uni-core/src/service/index.ts
浏览文件 @
1fd11424
...
...
@@ -5,3 +5,4 @@ export {
}
from
'
./bridge
'
export
{
initService
,
initAppVm
,
initPageVm
}
from
'
./init
'
export
{
initServicePlugin
}
from
'
./plugin
'
export
*
from
'
./utils
'
packages/uni-core/src/service/init/on.ts
浏览文件 @
1fd11424
...
...
@@ -8,6 +8,7 @@ import {
import
{
ComponentPublicInstance
}
from
'
@vue/runtime-core
'
import
{
invokeHook
}
from
'
../../helpers/hook
'
import
{
getCurrentPage
}
from
'
../../helpers/page
'
import
{
LaunchOptions
}
from
'
../utils
'
export
function
initOn
()
{
const
{
on
}
=
UniServiceJSBridge
...
...
@@ -21,17 +22,10 @@ function onResize(res: UniApp.WindowResizeResult) {
UniServiceJSBridge
.
invokeOnCallback
(
'
onWindowResize
'
,
res
)
// API
}
function
onAppEnterForeground
()
{
function
onAppEnterForeground
(
enterOptions
:
LaunchOptions
)
{
const
page
=
getCurrentPage
()
const
showOptions
=
{
path
:
''
,
query
:
{},
}
if
(
page
)
{
showOptions
.
path
=
page
.
$page
.
route
showOptions
.
query
=
page
.
$page
.
options
}
invokeHook
(
getApp
()
as
ComponentPublicInstance
,
ON_SHOW
,
showOptions
)
invokeHook
(
getApp
()
as
ComponentPublicInstance
,
ON_SHOW
,
enterOptions
)
invokeHook
(
page
as
ComponentPublicInstance
,
ON_SHOW
)
}
...
...
packages/uni-core/src/service/utils.ts
0 → 100644
浏览文件 @
1fd11424
export
interface
LaunchOptions
{
path
:
string
query
:
Record
<
string
,
any
>
scene
:
number
referrerInfo
:
{
appId
:
string
;
extraData
:
Record
<
string
,
any
>
}
}
export
function
createLaunchOptions
()
{
return
{
path
:
''
,
query
:
{},
scene
:
1001
,
referrerInfo
:
{
appId
:
''
,
extraData
:
{},
},
}
}
packages/uni-h5-vite/lib/api.json
浏览文件 @
1fd11424
...
...
@@ -31,8 +31,10 @@
"createVideoContext"
,
"downloadFile"
,
"getClipboardData"
,
"getEnterOptionsSync"
,
"getFileInfo"
,
"getImageInfo"
,
"getLaunchOptionsSync"
,
"getLeftWindowStyle"
,
"getLocale"
,
"getLocation"
,
...
...
packages/uni-h5/dist/uni-h5.es.js
浏览文件 @
1fd11424
...
...
@@ -1397,17 +1397,9 @@ function onResize$1(res) {
invokeHook(getCurrentPage(), ON_RESIZE, res);
UniServiceJSBridge.invokeOnCallback("onWindowResize", res);
}
function onAppEnterForeground() {
function onAppEnterForeground(
enterOptions2
) {
const page = getCurrentPage();
const showOptions = {
path: "",
query: {}
};
if (page) {
showOptions.path = page.$page.route;
showOptions.query = page.$page.options;
}
invokeHook(getApp(), ON_SHOW, showOptions);
invokeHook(getApp(), ON_SHOW, enterOptions2);
invokeHook(page, ON_SHOW);
}
function onAppEnterBackground() {
...
...
@@ -1509,6 +1501,17 @@ function initAppConfig(appConfig) {
function initServicePlugin(app) {
initAppConfig(app._context.config);
}
function createLaunchOptions() {
return {
path: "",
query: {},
scene: 1001,
referrerInfo: {
appId: "",
extraData: {}
}
};
}
function converPx(value) {
if (/^-?\d+[ur]px$/i.test(value)) {
return value.replace(/(^-?\d+)[ur]px$/i, (text2, num) => {
...
...
@@ -4473,6 +4476,14 @@ function injectAppLaunchHooks(appInstance) {
injectHook(ON_LAUNCH, hook, appInstance);
});
}
const API_GET_ENTER_OPTIONS_SYNC = "getEnterOptionsSync";
const getEnterOptionsSync = /* @__PURE__ */ defineSyncApi(API_GET_ENTER_OPTIONS_SYNC, () => {
return getEnterOptions();
});
const API_GET_LAUNCH_OPTIONS_SYNC = "getLaunchOptionsSync";
const getLaunchOptionsSync = /* @__PURE__ */ defineSyncApi(API_GET_LAUNCH_OPTIONS_SYNC, () => {
return getLaunchOptions();
});
const API_CAN_I_USE = "canIUse";
const CanIUseProtocol = [
{
...
...
@@ -6084,6 +6095,25 @@ function revokeObjectURL(url) {
URL.revokeObjectURL(url);
delete files[url];
}
const launchOptions = createLaunchOptions();
const enterOptions = createLaunchOptions();
function getEnterOptions() {
return enterOptions;
}
function getLaunchOptions() {
return launchOptions;
}
function initLaunchOptions({
path,
query
}) {
extend(launchOptions, {
path,
query
});
extend(enterOptions, launchOptions);
return launchOptions;
}
var ResizeSensor = /* @__PURE__ */ defineBuiltInComponent({
name: "ResizeSensor",
props: {
...
...
@@ -13976,14 +14006,14 @@ function setupApp(comp) {
const onLaunch = () => {
const { onLaunch: onLaunch2, onShow, onPageNotFound } = instance2;
const path = route.path.substr(1);
const launchOptions = {
const launchOptions2 = extend({
app: { mixin: instance2.appContext.app.mixin }
}, initLaunchOptions({
path: path || __uniRoutes[0].meta.route,
query: decodedQuery(route.query),
scene: 1001,
app: instance2.proxy
};
onLaunch2 && invokeArrayFns$1(onLaunch2, launchOptions);
onShow && invokeArrayFns$1(onShow, launchOptions);
query: decodedQuery(route.query)
}));
onLaunch2 && invokeArrayFns$1(onLaunch2, launchOptions2);
onShow && invokeArrayFns$1(onShow, launchOptions2);
if (__UNI_FEATURE_PAGES__) {
if (!route.matched.length) {
const pageNotFoundOptions = {
...
...
@@ -14038,7 +14068,12 @@ function onMessage(evt) {
}
}
function onVisibilityChange() {
UniServiceJSBridge.emit(document.visibilityState === "visible" ? ON_APP_ENTER_FOREGROUND : ON_APP_ENTER_BACKGROUND);
const { emit: emit2 } = UniServiceJSBridge;
if (document.visibilityState === "visible") {
emit2(ON_APP_ENTER_FOREGROUND, getEnterOptions());
} else {
emit2(ON_APP_ENTER_BACKGROUND);
}
}
function formatTime(val) {
val = val > 0 && val < Infinity ? val : 0;
...
...
@@ -19667,6 +19702,8 @@ var api = {
onAppLaunch,
onLocaleChange,
setPageMeta,
getEnterOptionsSync,
getLaunchOptionsSync,
cssVar,
cssEnv,
cssConstant,
...
...
@@ -21826,4 +21863,4 @@ var index = /* @__PURE__ */ defineSystemComponent({
return openBlock(), createBlock("div", clazz, [loadingVNode]);
}
});
export { $emit, $off, $on, $once, index$8 as Ad, index$7 as AdContentPage, index$6 as AdDraw, index$1 as AsyncErrorComponent, index as AsyncLoadingComponent, index$y as Button, index$5 as Camera, index$w as Canvas, index$u as Checkbox, index$v as CheckboxGroup, index$a as CoverImage, index$b as CoverView, index$t as Editor, index$A as Form, index$s as Icon, index$r as Image, Input, index$z as Label, LayoutComponent, index$4 as LivePlayer, index$3 as LivePusher, Map$1 as Map, MovableArea, MovableView, index$q as Navigator, index$2 as PageComponent, index$9 as Picker, PickerView, PickerViewColumn, index$p as Progress, index$n as Radio, index$o as RadioGroup, ResizeSensor, index$m as RichText, ScrollView, index$l as Slider, Swiper, SwiperItem, index$k as Switch, index$j as Text, index$i as Textarea, UniServiceJSBridge$1 as UniServiceJSBridge, UniViewJSBridge$1 as UniViewJSBridge, index$e as Video, index$h as View, index$d as WebView, addInterceptor, addPhoneContact, arrayBufferToBase64, base64ToArrayBuffer, canIUse, canvasGetImageData, canvasPutImageData, canvasToTempFilePath, chooseFile, chooseImage, chooseLocation, chooseVideo, clearStorage, clearStorageSync, closeSocket, connectSocket, createAnimation$1 as createAnimation, createCameraContext, createCanvasContext, createInnerAudioContext, createIntersectionObserver, createLivePlayerContext, createMapContext, createMediaQueryObserver, createSelectorQuery, createVideoContext, cssBackdropFilter, cssConstant, cssEnv, cssVar, downloadFile, getApp$1 as getApp, getClipboardData, getCurrentPages$1 as getCurrentPages, get
FileInfo, getImageInfo
, getLeftWindowStyle, getLocale, getLocation, getNetworkType, getProvider, getRealPath, getRecorderManager, getRightWindowStyle, getSavedFileInfo, getSavedFileList, getScreenBrightness, getSelectedTextRange$1 as getSelectedTextRange, getStorage, getStorageInfo, getStorageInfoSync, getStorageSync, getSystemInfo, getSystemInfoSync, getTopWindowStyle, getVideoInfo, hideKeyboard, hideLeftWindow, hideLoading, hideNavigationBarLoading, hideRightWindow, hideTabBar, hideTabBarRedDot, hideToast, hideTopWindow, interceptors, loadFontFace, login, makePhoneCall, navigateBack, navigateTo, offAccelerometerChange, offCompassChange, offNetworkStatusChange, offWindowResize, onAccelerometerChange, onAppLaunch, onCompassChange, onGyroscopeChange, onLocaleChange, onMemoryWarning, onNetworkStatusChange, onSocketClose, onSocketError, onSocketMessage, onSocketOpen, onTabBarMidButtonTap, onUserCaptureScreen, onWindowResize, openDocument, openLocation, pageScrollTo, index$f as plugin, preloadPage, previewImage, reLaunch, redirectTo, removeInterceptor, removeSavedFileInfo, removeStorage, removeStorageSync, removeTabBarBadge, request, saveFile, saveImageToPhotosAlbum, saveVideoToPhotosAlbum, scanCode, sendSocketMessage, setClipboardData, setKeepScreenOn, setLeftWindowStyle, setLocale, setNavigationBarColor, setNavigationBarTitle, setPageMeta, setRightWindowStyle, setScreenBrightness, setStorage, setStorageSync, setTabBarBadge, setTabBarItem, setTabBarStyle, setTopWindowStyle, setupApp, setupPage, setupWindow, showActionSheet, showLeftWindow, showLoading, showModal, showNavigationBarLoading, showRightWindow, showTabBar, showTabBarRedDot, showToast, showTopWindow, startAccelerometer, startCompass, startGyroscope, startPullDownRefresh, stopAccelerometer, stopCompass, stopGyroscope, stopPullDownRefresh, switchTab, uni$1 as uni, uploadFile, upx2px, useI18n, useTabBar, vibrateLong, vibrateShort };
export { $emit, $off, $on, $once, index$8 as Ad, index$7 as AdContentPage, index$6 as AdDraw, index$1 as AsyncErrorComponent, index as AsyncLoadingComponent, index$y as Button, index$5 as Camera, index$w as Canvas, index$u as Checkbox, index$v as CheckboxGroup, index$a as CoverImage, index$b as CoverView, index$t as Editor, index$A as Form, index$s as Icon, index$r as Image, Input, index$z as Label, LayoutComponent, index$4 as LivePlayer, index$3 as LivePusher, Map$1 as Map, MovableArea, MovableView, index$q as Navigator, index$2 as PageComponent, index$9 as Picker, PickerView, PickerViewColumn, index$p as Progress, index$n as Radio, index$o as RadioGroup, ResizeSensor, index$m as RichText, ScrollView, index$l as Slider, Swiper, SwiperItem, index$k as Switch, index$j as Text, index$i as Textarea, UniServiceJSBridge$1 as UniServiceJSBridge, UniViewJSBridge$1 as UniViewJSBridge, index$e as Video, index$h as View, index$d as WebView, addInterceptor, addPhoneContact, arrayBufferToBase64, base64ToArrayBuffer, canIUse, canvasGetImageData, canvasPutImageData, canvasToTempFilePath, chooseFile, chooseImage, chooseLocation, chooseVideo, clearStorage, clearStorageSync, closeSocket, connectSocket, createAnimation$1 as createAnimation, createCameraContext, createCanvasContext, createInnerAudioContext, createIntersectionObserver, createLivePlayerContext, createMapContext, createMediaQueryObserver, createSelectorQuery, createVideoContext, cssBackdropFilter, cssConstant, cssEnv, cssVar, downloadFile, getApp$1 as getApp, getClipboardData, getCurrentPages$1 as getCurrentPages, get
EnterOptionsSync, getFileInfo, getImageInfo, getLaunchOptionsSync
, getLeftWindowStyle, getLocale, getLocation, getNetworkType, getProvider, getRealPath, getRecorderManager, getRightWindowStyle, getSavedFileInfo, getSavedFileList, getScreenBrightness, getSelectedTextRange$1 as getSelectedTextRange, getStorage, getStorageInfo, getStorageInfoSync, getStorageSync, getSystemInfo, getSystemInfoSync, getTopWindowStyle, getVideoInfo, hideKeyboard, hideLeftWindow, hideLoading, hideNavigationBarLoading, hideRightWindow, hideTabBar, hideTabBarRedDot, hideToast, hideTopWindow, interceptors, loadFontFace, login, makePhoneCall, navigateBack, navigateTo, offAccelerometerChange, offCompassChange, offNetworkStatusChange, offWindowResize, onAccelerometerChange, onAppLaunch, onCompassChange, onGyroscopeChange, onLocaleChange, onMemoryWarning, onNetworkStatusChange, onSocketClose, onSocketError, onSocketMessage, onSocketOpen, onTabBarMidButtonTap, onUserCaptureScreen, onWindowResize, openDocument, openLocation, pageScrollTo, index$f as plugin, preloadPage, previewImage, reLaunch, redirectTo, removeInterceptor, removeSavedFileInfo, removeStorage, removeStorageSync, removeTabBarBadge, request, saveFile, saveImageToPhotosAlbum, saveVideoToPhotosAlbum, scanCode, sendSocketMessage, setClipboardData, setKeepScreenOn, setLeftWindowStyle, setLocale, setNavigationBarColor, setNavigationBarTitle, setPageMeta, setRightWindowStyle, setScreenBrightness, setStorage, setStorageSync, setTabBarBadge, setTabBarItem, setTabBarStyle, setTopWindowStyle, setupApp, setupPage, setupWindow, showActionSheet, showLeftWindow, showLoading, showModal, showNavigationBarLoading, showRightWindow, showTabBar, showTabBarRedDot, showToast, showTopWindow, startAccelerometer, startCompass, startGyroscope, startPullDownRefresh, stopAccelerometer, stopCompass, stopGyroscope, stopPullDownRefresh, switchTab, uni$1 as uni, uploadFile, upx2px, useI18n, useTabBar, vibrateLong, vibrateShort };
packages/uni-h5/src/framework/setup/index.ts
浏览文件 @
1fd11424
import
{
invokeArrayFns
,
isPlainObject
}
from
'
@vue/shared
'
import
{
extend
,
invokeArrayFns
,
isPlainObject
}
from
'
@vue/shared
'
import
{
nextTick
,
ComponentInternalInstance
,
...
...
@@ -29,6 +29,7 @@ import { LayoutComponent } from '../..'
import
{
initApp
}
from
'
./app
'
import
{
initPage
,
onPageShow
,
onPageReady
}
from
'
./page
'
import
{
usePageMeta
,
usePageRoute
}
from
'
./provide
'
import
{
initLaunchOptions
,
getEnterOptions
}
from
'
./utils
'
interface
SetupComponentOptions
{
init
:
(
vm
:
ComponentPublicInstance
)
=>
void
...
...
@@ -141,12 +142,15 @@ export function setupApp(comp: any) {
const
onLaunch
=
()
=>
{
const
{
onLaunch
,
onShow
,
onPageNotFound
}
=
instance
const
path
=
route
.
path
.
substr
(
1
)
const
launchOptions
=
{
const
launchOptions
=
extend
(
{
app
:
{
mixin
:
instance
.
appContext
.
app
.
mixin
},
},
initLaunchOptions
({
path
:
path
||
__uniRoutes
[
0
].
meta
.
route
,
query
:
decodedQuery
(
route
.
query
),
scene
:
1001
,
app
:
instance
.
proxy
,
}
})
)
onLaunch
&&
invokeArrayFns
(
onLaunch
,
launchOptions
)
onShow
&&
invokeArrayFns
(
onShow
,
launchOptions
)
if
(
__UNI_FEATURE_PAGES__
)
{
...
...
@@ -213,9 +217,10 @@ function onMessage(evt: {
}
}
function
onVisibilityChange
()
{
UniServiceJSBridge
.
emit
(
document
.
visibilityState
===
'
visible
'
?
ON_APP_ENTER_FOREGROUND
:
ON_APP_ENTER_BACKGROUND
)
const
{
emit
}
=
UniServiceJSBridge
if
(
document
.
visibilityState
===
'
visible
'
)
{
emit
(
ON_APP_ENTER_FOREGROUND
,
getEnterOptions
())
}
else
{
emit
(
ON_APP_ENTER_BACKGROUND
)
}
}
packages/uni-h5/src/framework/setup/utils.ts
0 → 100644
浏览文件 @
1fd11424
import
{
extend
}
from
'
@vue/shared
'
import
{
createLaunchOptions
,
LaunchOptions
}
from
'
@dcloudio/uni-core
'
const
launchOptions
:
LaunchOptions
=
createLaunchOptions
()
const
enterOptions
:
LaunchOptions
=
createLaunchOptions
()
export
function
getEnterOptions
()
{
return
enterOptions
}
export
function
getLaunchOptions
()
{
return
launchOptions
}
export
function
initLaunchOptions
({
path
,
query
,
}:
{
path
:
string
query
:
Record
<
string
,
any
>
})
{
extend
(
launchOptions
,
{
path
,
query
,
})
extend
(
enterOptions
,
launchOptions
)
return
launchOptions
}
packages/uni-h5/src/platform/index.ts
浏览文件 @
1fd11424
...
...
@@ -15,3 +15,4 @@ export {
export
*
from
'
./saveImage
'
export
*
from
'
./constants
'
export
{
getSameOriginUrl
}
from
'
../helpers/file
'
export
{
getEnterOptions
,
getLaunchOptions
}
from
'
../framework/setup/utils
'
packages/uni-h5/src/service/api/index.ts
浏览文件 @
1fd11424
...
...
@@ -95,5 +95,7 @@ export {
onAppLaunch
,
onLocaleChange
,
setPageMeta
,
getEnterOptionsSync
,
getLaunchOptionsSync
,
}
from
'
@dcloudio/uni-api
'
//#endif
packages/uni-mp-alipay/dist/uni.mp.esm.js
浏览文件 @
1fd11424
...
...
@@ -313,7 +313,7 @@ function parseApp(instance, parseAppOptions) {
});
injectAppLaunchHooks
(
internalInstance
);
ctx
.
globalData
=
this
.
globalData
;
instance
.
$callHook
(
ON_LAUNCH
,
extend
({
app
:
this
},
options
));
instance
.
$callHook
(
ON_LAUNCH
,
extend
({
app
:
{
mixin
:
internalInstance
.
appContext
.
app
.
mixin
}
},
options
));
},
};
initLocale
(
instance
);
...
...
packages/uni-mp-baidu/dist/uni.mp.esm.js
浏览文件 @
1fd11424
...
...
@@ -372,7 +372,7 @@ function parseApp(instance, parseAppOptions) {
});
injectAppLaunchHooks
(
internalInstance
);
ctx
.
globalData
=
this
.
globalData
;
instance
.
$callHook
(
ON_LAUNCH
,
extend
({
app
:
this
},
options
));
instance
.
$callHook
(
ON_LAUNCH
,
extend
({
app
:
{
mixin
:
internalInstance
.
appContext
.
app
.
mixin
}
},
options
));
},
};
initLocale
(
instance
);
...
...
packages/uni-mp-core/src/runtime/app.ts
浏览文件 @
1fd11424
...
...
@@ -66,7 +66,13 @@ function parseApp(
injectAppLaunchHooks
(
internalInstance
)
ctx
.
globalData
=
this
.
globalData
instance
.
$callHook
(
ON_LAUNCH
,
extend
({
app
:
this
},
options
))
instance
.
$callHook
(
ON_LAUNCH
,
extend
(
{
app
:
{
mixin
:
internalInstance
.
appContext
.
app
.
mixin
}
},
options
)
)
},
}
...
...
packages/uni-mp-kuaishou/dist/uni.mp.esm.js
浏览文件 @
1fd11424
...
...
@@ -367,7 +367,7 @@ function parseApp(instance, parseAppOptions) {
});
injectAppLaunchHooks
(
internalInstance
);
ctx
.
globalData
=
this
.
globalData
;
instance
.
$callHook
(
ON_LAUNCH
,
extend
({
app
:
this
},
options
));
instance
.
$callHook
(
ON_LAUNCH
,
extend
({
app
:
{
mixin
:
internalInstance
.
appContext
.
app
.
mixin
}
},
options
));
},
};
initLocale
(
instance
);
...
...
packages/uni-mp-lark/dist/uni.mp.esm.js
浏览文件 @
1fd11424
...
...
@@ -366,7 +366,7 @@ function parseApp(instance, parseAppOptions) {
});
injectAppLaunchHooks
(
internalInstance
);
ctx
.
globalData
=
this
.
globalData
;
instance
.
$callHook
(
ON_LAUNCH
,
extend
({
app
:
this
},
options
));
instance
.
$callHook
(
ON_LAUNCH
,
extend
({
app
:
{
mixin
:
internalInstance
.
appContext
.
app
.
mixin
}
},
options
));
},
};
initLocale
(
instance
);
...
...
packages/uni-mp-qq/dist/uni.mp.esm.js
浏览文件 @
1fd11424
...
...
@@ -363,7 +363,7 @@ function parseApp(instance, parseAppOptions) {
});
injectAppLaunchHooks
(
internalInstance
);
ctx
.
globalData
=
this
.
globalData
;
instance
.
$callHook
(
ON_LAUNCH
,
extend
({
app
:
this
},
options
));
instance
.
$callHook
(
ON_LAUNCH
,
extend
({
app
:
{
mixin
:
internalInstance
.
appContext
.
app
.
mixin
}
},
options
));
},
};
initLocale
(
instance
);
...
...
packages/uni-mp-toutiao/dist/uni.mp.esm.js
浏览文件 @
1fd11424
...
...
@@ -366,7 +366,7 @@ function parseApp(instance, parseAppOptions) {
});
injectAppLaunchHooks
(
internalInstance
);
ctx
.
globalData
=
this
.
globalData
;
instance
.
$callHook
(
ON_LAUNCH
,
extend
({
app
:
this
},
options
));
instance
.
$callHook
(
ON_LAUNCH
,
extend
({
app
:
{
mixin
:
internalInstance
.
appContext
.
app
.
mixin
}
},
options
));
},
};
initLocale
(
instance
);
...
...
packages/uni-mp-weixin/dist/uni.mp.esm.js
浏览文件 @
1fd11424
...
...
@@ -235,7 +235,7 @@ function parseApp(instance, parseAppOptions) {
});
injectAppLaunchHooks
(
internalInstance
);
ctx
.
globalData
=
this
.
globalData
;
instance
.
$callHook
(
ON_LAUNCH
,
extend
({
app
:
this
},
options
));
instance
.
$callHook
(
ON_LAUNCH
,
extend
({
app
:
{
mixin
:
internalInstance
.
appContext
.
app
.
mixin
}
},
options
));
},
};
initLocale
(
instance
);
...
...
packages/uni-quickapp-webview/dist/uni.mp.esm.js
浏览文件 @
1fd11424
...
...
@@ -363,7 +363,7 @@ function parseApp(instance, parseAppOptions) {
});
injectAppLaunchHooks
(
internalInstance
);
ctx
.
globalData
=
this
.
globalData
;
instance
.
$callHook
(
ON_LAUNCH
,
extend
({
app
:
this
},
options
));
instance
.
$callHook
(
ON_LAUNCH
,
extend
({
app
:
{
mixin
:
internalInstance
.
appContext
.
app
.
mixin
}
},
options
));
},
};
initLocale
(
instance
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录