Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
uni-app
提交
8a00c42a
U
uni-app
项目概览
DCloud
/
uni-app
3 个月 前同步成功
通知
720
Star
38705
Fork
3642
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
7
列表
看板
标记
里程碑
合并请求
1
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
U
uni-app
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
7
Issue
7
列表
看板
标记
里程碑
合并请求
1
合并请求
1
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
8a00c42a
编写于
12月 08, 2021
作者:
fxy060608
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat(app): add referrerInfo
上级
bf33a6c7
变更
6
显示空白变更内容
内联
并排
Showing
6 changed file
with
276 addition
and
45 deletion
+276
-45
lib/apis.js
lib/apis.js
+4
-3
packages/uni-app-plus/dist/index.v3.js
packages/uni-app-plus/dist/index.v3.js
+128
-25
src/platforms/app-plus/service/framework/app.js
src/platforms/app-plus/service/framework/app.js
+8
-4
src/platforms/app-plus/service/framework/config.js
src/platforms/app-plus/service/framework/config.js
+15
-4
src/platforms/app-plus/service/framework/utils.js
src/platforms/app-plus/service/framework/utils.js
+80
-0
src/platforms/app-plus/service/framework/webview/on-webview-pop-gesture.js
...-plus/service/framework/webview/on-webview-pop-gesture.js
+41
-9
未找到文件。
lib/apis.js
浏览文件 @
8a00c42a
...
@@ -245,7 +245,8 @@ const third = [
...
@@ -245,7 +245,8 @@ const third = [
'
preloadPage
'
,
'
preloadPage
'
,
'
unPreloadPage
'
,
'
unPreloadPage
'
,
'
loadSubPackage
'
,
'
loadSubPackage
'
,
'
sendHostEvent
'
'
sendHostEvent
'
,
'
navigateToMiniProgram
'
]
]
const
ad
=
[
const
ad
=
[
...
...
packages/uni-app-plus/dist/index.v3.js
浏览文件 @
8a00c42a
...
@@ -256,7 +256,8 @@ var serviceContext = (function () {
...
@@ -256,7 +256,8 @@ var serviceContext = (function () {
'preloadPage',
'preloadPage',
'unPreloadPage',
'unPreloadPage',
'loadSubPackage',
'loadSubPackage',
'sendHostEvent'
'sendHostEvent',
'navigateToMiniProgram'
];
];
const ad = [
const ad = [
...
@@ -1702,13 +1703,17 @@ var serviceContext = (function () {
...
@@ -1702,13 +1703,17 @@ var serviceContext = (function () {
"uni.chooseLocation.cancel": "取消"
"uni.chooseLocation.cancel": "取消"
};
};
const messages = {
const messages = {};
{
Object.assign(messages, {
en,
en,
es,
es,
fr,
fr,
'zh-Hans': zhHans,
'zh-Hans': zhHans,
'zh-Hant': zhHant
'zh-Hant': zhHant
};
});
}
let locale;
let locale;
...
@@ -5802,7 +5807,7 @@ var serviceContext = (function () {
...
@@ -5802,7 +5807,7 @@ var serviceContext = (function () {
animationDuration: 200,
animationDuration: 200,
uniNView: {
uniNView: {
path: `${(typeof process === 'object' && process.env && process.env.VUE_APP_TEMPLATE_PATH) || ''}/${url}.js`,
path: `${(typeof process === 'object' && process.env && process.env.VUE_APP_TEMPLATE_PATH) || ''}/${url}.js`,
defaultFontSize:
plus_.screen.resolutionWidth / 20
,
defaultFontSize:
16
,
viewport: plus_.screen.resolutionWidth
viewport: plus_.screen.resolutionWidth
}
}
};
};
...
@@ -9225,7 +9230,7 @@ var serviceContext = (function () {
...
@@ -9225,7 +9230,7 @@ var serviceContext = (function () {
});
});
}
}
function onWebviewPopGesture
(webview) {
function onWebviewPopGesture
(webview) {
let popStartStatusBarStyle;
let popStartStatusBarStyle;
webview.addEventListener('popGesture', e => {
webview.addEventListener('popGesture', e => {
if (e.type === 'start') {
if (e.type === 'start') {
...
@@ -9242,16 +9247,49 @@ var serviceContext = (function () {
...
@@ -9242,16 +9247,49 @@ var serviceContext = (function () {
const pages = getCurrentPages();
const pages = getCurrentPages();
const page = pages[pages.length - 1];
const page = pages[pages.length - 1];
page && page.$remove();
page && page.$remove();
setStatusBarStyle();
setStatusBarStyle();
if (page && isDirectPage(page)) {
reLaunchEntryPage();
} else {
UniServiceJSBridge.emit('onAppRoute', {
UniServiceJSBridge.emit('onAppRoute', {
type: 'navigateBack'
type: 'navigateBack'
});
});
}
}
}
});
}
/**
* 是否处于直达页面
* @param page
* @returns
*/
function isDirectPage(page) {
return (
__uniConfig.realEntryPagePath &&
page.$page.route === __uniConfig.entryPagePath
)
}
/**
* 重新启动到首页
*/
function reLaunchEntryPage() {
__uniConfig.entryPagePath = __uniConfig.realEntryPagePath;
delete __uniConfig.realEntryPagePath;
uni.reLaunch({
url: addLeadingSlash(__uniConfig.entryPagePath),
});
});
}
}
function hasLeadingSlash(str) {
return str.indexOf('/') === 0
}
function addLeadingSlash(str) {
return hasLeadingSlash(str) ? str : '/' + str
}
let preloadWebview;
let preloadWebview;
let id$1 = 2;
let id$1 = 2;
...
@@ -9753,6 +9791,64 @@ var serviceContext = (function () {
...
@@ -9753,6 +9791,64 @@ var serviceContext = (function () {
return pageVm
return pageVm
}
}
const extend = Object.assign;
function createLaunchOptions () {
return {
path: '',
query: {},
scene: 1001,
referrerInfo: {
appId: '',
extraData: {}
}
}
}
const enterOptions = createLaunchOptions();
const launchOptions = createLaunchOptions();
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');
if (weexPlus.getRedirectInfo) {
const {
path,
query,
extraData,
userAction,
fromAppid
} =
weexPlus.getRedirectInfo() || {};
const referrerInfo = {
appId: fromAppid,
extraData: {}
};
if (extraData) {
referrerInfo.extraData = extraData;
}
return {
path: path || '',
query: query ? '?' + query : '',
referrerInfo,
userAction
}
}
}
let isInitEntryPage = false;
let isInitEntryPage = false;
function initEntryPage () {
function initEntryPage () {
...
@@ -9767,9 +9863,16 @@ var serviceContext = (function () {
...
@@ -9767,9 +9863,16 @@ var serviceContext = (function () {
const weexPlus = weex.requireModule('plus');
const weexPlus = weex.requireModule('plus');
if (weexPlus.getRedirectInfo) {
if (weexPlus.getRedirectInfo) {
const info = weexPlus.getRedirectInfo() || {};
const {
entryPagePath = info.path;
path,
entryPageQuery = info.query ? ('?' + info.query) : '';
query,
referrerInfo
} = parseRedirectInfo();
if (path) {
entryPagePath = path;
entryPageQuery = query;
}
__uniConfig.referrerInfo = referrerInfo;
} else {
} else {
const argsJsonStr = plus.runtime.arguments;
const argsJsonStr = plus.runtime.arguments;
if (!argsJsonStr) {
if (!argsJsonStr) {
...
@@ -21993,11 +22096,11 @@ var serviceContext = (function () {
...
@@ -21993,11 +22096,11 @@ var serviceContext = (function () {
}
}
function initAppLaunch (appVm) {
function initAppLaunch (appVm) {
const args = {
const args =
initLaunchOptions(
{
path: __uniConfig.entryPagePath,
path: __uniConfig.entryPagePath,
query:
{}
,
query:
__uniConfig.entryPageQuery
,
scene: 1001
referrerInfo: __uniConfig.referrerInfo
};
}
)
;
callAppHook(appVm, 'onLaunch', args);
callAppHook(appVm, 'onLaunch', args);
callAppHook(appVm, 'onShow', args);
callAppHook(appVm, 'onShow', args);
...
...
src/platforms/app-plus/service/framework/app.js
浏览文件 @
8a00c42a
...
@@ -45,6 +45,10 @@ import {
...
@@ -45,6 +45,10 @@ import {
backbuttonListener
backbuttonListener
}
from
'
./backbutton
'
}
from
'
./backbutton
'
import
{
initLaunchOptions
}
from
'
./utils
'
let
appCtx
let
appCtx
const
defaultApp
=
{
const
defaultApp
=
{
...
@@ -143,11 +147,11 @@ function onPlusMessage (e) {
...
@@ -143,11 +147,11 @@ function onPlusMessage (e) {
}
}
function
initAppLaunch
(
appVm
)
{
function
initAppLaunch
(
appVm
)
{
const
args
=
{
const
args
=
initLaunchOptions
(
{
path
:
__uniConfig
.
entryPagePath
,
path
:
__uniConfig
.
entryPagePath
,
query
:
{}
,
query
:
__uniConfig
.
entryPageQuery
,
scene
:
1001
referrerInfo
:
__uniConfig
.
referrerInfo
}
}
)
callAppHook
(
appVm
,
'
onLaunch
'
,
args
)
callAppHook
(
appVm
,
'
onLaunch
'
,
args
)
callAppHook
(
appVm
,
'
onShow
'
,
args
)
callAppHook
(
appVm
,
'
onShow
'
,
args
)
...
...
src/platforms/app-plus/service/framework/config.js
浏览文件 @
8a00c42a
import
{
parseRedirectInfo
}
from
'
./utils
'
function
parseRoutes
(
config
)
{
function
parseRoutes
(
config
)
{
__uniRoutes
.
length
=
0
__uniRoutes
.
length
=
0
/* eslint-disable no-mixed-operators */
/* eslint-disable no-mixed-operators */
...
@@ -51,9 +55,16 @@ export function initEntryPage () {
...
@@ -51,9 +55,16 @@ export function initEntryPage () {
const
weexPlus
=
weex
.
requireModule
(
'
plus
'
)
const
weexPlus
=
weex
.
requireModule
(
'
plus
'
)
if
(
weexPlus
.
getRedirectInfo
)
{
if
(
weexPlus
.
getRedirectInfo
)
{
const
info
=
weexPlus
.
getRedirectInfo
()
||
{}
const
{
entryPagePath
=
info
.
path
path
,
entryPageQuery
=
info
.
query
?
(
'
?
'
+
info
.
query
)
:
''
query
,
referrerInfo
}
=
parseRedirectInfo
()
if
(
path
)
{
entryPagePath
=
path
entryPageQuery
=
query
}
__uniConfig
.
referrerInfo
=
referrerInfo
}
else
{
}
else
{
const
argsJsonStr
=
plus
.
runtime
.
arguments
const
argsJsonStr
=
plus
.
runtime
.
arguments
if
(
!
argsJsonStr
)
{
if
(
!
argsJsonStr
)
{
...
...
src/platforms/app-plus/service/framework/utils.js
0 → 100644
浏览文件 @
8a00c42a
import
{
parseQuery
}
from
'
uni-shared
'
const
extend
=
Object
.
assign
function
createLaunchOptions
()
{
return
{
path
:
''
,
query
:
{},
scene
:
1001
,
referrerInfo
:
{
appId
:
''
,
extraData
:
{}
}
}
}
const
enterOptions
=
createLaunchOptions
()
const
launchOptions
=
createLaunchOptions
()
export
function
getLaunchOptions
()
{
return
launchOptions
}
export
function
getEnterOptions
()
{
return
enterOptions
}
export
function
initEnterOptions
({
path
,
query
,
referrerInfo
})
{
extend
(
enterOptions
,
{
path
,
query
:
query
?
parseQuery
(
query
)
:
{},
referrerInfo
:
referrerInfo
||
{}
})
}
export
function
initLaunchOptions
({
path
,
query
,
referrerInfo
})
{
extend
(
launchOptions
,
{
path
,
query
:
query
?
parseQuery
(
query
)
:
{},
referrerInfo
:
referrerInfo
||
{}
})
extend
(
enterOptions
,
launchOptions
)
return
launchOptions
}
export
function
parseRedirectInfo
()
{
const
weexPlus
=
weex
.
requireModule
(
'
plus
'
)
if
(
weexPlus
.
getRedirectInfo
)
{
const
{
path
,
query
,
extraData
,
userAction
,
fromAppid
}
=
weexPlus
.
getRedirectInfo
()
||
{}
const
referrerInfo
=
{
appId
:
fromAppid
,
extraData
:
{}
}
if
(
extraData
)
{
referrerInfo
.
extraData
=
extraData
}
return
{
path
:
path
||
''
,
query
:
query
?
'
?
'
+
query
:
''
,
referrerInfo
,
userAction
}
}
}
src/platforms/app-plus/service/framework/webview/on-webview-pop-gesture.js
浏览文件 @
8a00c42a
...
@@ -19,12 +19,44 @@ export function onWebviewPopGesture (webview) {
...
@@ -19,12 +19,44 @@ export function onWebviewPopGesture (webview) {
const
pages
=
getCurrentPages
()
const
pages
=
getCurrentPages
()
const
page
=
pages
[
pages
.
length
-
1
]
const
page
=
pages
[
pages
.
length
-
1
]
page
&&
page
.
$remove
()
page
&&
page
.
$remove
()
setStatusBarStyle
()
setStatusBarStyle
()
if
(
page
&&
isDirectPage
(
page
))
{
reLaunchEntryPage
()
}
else
{
UniServiceJSBridge
.
emit
(
'
onAppRoute
'
,
{
UniServiceJSBridge
.
emit
(
'
onAppRoute
'
,
{
type
:
'
navigateBack
'
type
:
'
navigateBack
'
})
})
}
}
}
})
})
}
}
/**
* 是否处于直达页面
* @param page
* @returns
*/
function
isDirectPage
(
page
)
{
return
(
__uniConfig
.
realEntryPagePath
&&
page
.
$page
.
route
===
__uniConfig
.
entryPagePath
)
}
/**
* 重新启动到首页
*/
function
reLaunchEntryPage
()
{
__uniConfig
.
entryPagePath
=
__uniConfig
.
realEntryPagePath
delete
__uniConfig
.
realEntryPagePath
uni
.
reLaunch
({
url
:
addLeadingSlash
(
__uniConfig
.
entryPagePath
)
})
}
function
hasLeadingSlash
(
str
)
{
return
str
.
indexOf
(
'
/
'
)
===
0
}
function
addLeadingSlash
(
str
)
{
return
hasLeadingSlash
(
str
)
?
str
:
'
/
'
+
str
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录