Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
uni-app
提交
d8deaaf8
U
uni-app
项目概览
DCloud
/
uni-app
2 个月 前同步成功
通知
717
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,发现更多精彩内容 >>
提交
d8deaaf8
编写于
1月 16, 2020
作者:
fxy060608
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat(mp-360): init
上级
4251ebf7
变更
20
展开全部
显示空白变更内容
内联
并排
Showing
20 changed file
with
545 addition
and
60 deletion
+545
-60
.eslintignore
.eslintignore
+2
-0
package.json
package.json
+4
-3
packages/uni-cli-shared/lib/manifest.js
packages/uni-cli-shared/lib/manifest.js
+10
-2
packages/uni-cli-shared/lib/platform.js
packages/uni-cli-shared/lib/platform.js
+13
-1
packages/uni-h5/dist/index.css
packages/uni-h5/dist/index.css
+1
-1
packages/uni-h5/dist/index.umd.min.js
packages/uni-h5/dist/index.umd.min.js
+1
-1
packages/uni-h5/manifest.json
packages/uni-h5/manifest.json
+8
-0
packages/uni-template-compiler/lib/module.js
packages/uni-template-compiler/lib/module.js
+1
-1
packages/vue-cli-plugin-uni/commands/build.js
packages/vue-cli-plugin-uni/commands/build.js
+1
-1
packages/vue-cli-plugin-uni/generator.js
packages/vue-cli-plugin-uni/generator.js
+4
-2
packages/vue-cli-plugin-uni/lib/env.js
packages/vue-cli-plugin-uni/lib/env.js
+10
-0
packages/vue-cli-plugin-uni/lib/h5/index.js
packages/vue-cli-plugin-uni/lib/h5/index.js
+12
-2
packages/vue-cli-plugin-uni/lib/h5/qh-api.js
packages/vue-cli-plugin-uni/lib/h5/qh-api.js
+1
-0
packages/vue-cli-plugin-uni/lib/h5/touch-emulator.js
packages/vue-cli-plugin-uni/lib/h5/touch-emulator.js
+370
-0
packages/webpack-uni-pages-loader/lib/platforms/h5.js
packages/webpack-uni-pages-loader/lib/platforms/h5.js
+20
-7
src/core/service/api/context/create-map-context.js
src/core/service/api/context/create-map-context.js
+2
-2
src/core/service/plugins/app/router-guard.js
src/core/service/plugins/app/router-guard.js
+25
-11
src/platforms/h5/components/page/index.vue
src/platforms/h5/components/page/index.vue
+29
-19
src/platforms/h5/components/system-routes/system-header.vue
src/platforms/h5/components/system-routes/system-header.vue
+5
-0
src/platforms/h5/service/api/ui/navigation-bar.js
src/platforms/h5/service/api/ui/navigation-bar.js
+26
-7
未找到文件。
.eslintignore
浏览文件 @
d8deaaf8
...
...
@@ -3,3 +3,5 @@ src/platforms/app-plus-nvue/runtime
build/rollup-plugin-require-context
packages/*/packages
packages/*/template/**/*
qh-api.js
touch-emulator.js
package.json
浏览文件 @
d8deaaf8
...
...
@@ -105,6 +105,7 @@
"my"
:
true
,
"swan"
:
true
,
"tt"
:
true
,
"qh"
:
true
,
"weex"
:
true
,
"__id__"
:
true
,
"__uniConfig"
:
true
,
...
...
packages/uni-cli-shared/lib/manifest.js
浏览文件 @
d8deaaf8
...
...
@@ -50,7 +50,11 @@ function getH5Options (manifestJson) {
h5
.
title
=
h5
.
title
||
manifestJson
.
name
||
''
if
(
process
.
env
.
UNI_SUB_PLATFORM
===
'
mp-360
'
)
{
// 360 小程序仅支持 hash 模式
h5
.
router
=
Object
.
assign
({},
defaultRouter
)
}
else
{
h5
.
router
=
Object
.
assign
({},
defaultRouter
,
h5
.
router
||
{})
}
h5
[
'
async
'
]
=
Object
.
assign
({},
defaultAsync
,
h5
[
'
async
'
]
||
{})
...
...
@@ -59,7 +63,6 @@ function getH5Options (manifestJson) {
if
(
base
.
indexOf
(
'
/
'
)
!==
0
)
{
base
=
'
/
'
+
base
}
if
(
base
.
substr
(
-
1
)
!==
'
/
'
)
{
base
=
base
+
'
/
'
}
...
...
@@ -76,6 +79,11 @@ function getH5Options (manifestJson) {
h5
.
publicPath
=
base
}
if
(
process
.
env
.
UNI_SUB_PLATFORM
===
'
mp-360
'
)
{
h5
.
router
.
base
=
'
/
'
h5
.
publicPath
=
'
/
'
}
/* eslint-disable no-mixed-operators */
h5
.
template
=
h5
.
template
&&
path
.
resolve
(
process
.
env
.
UNI_INPUT_DIR
,
h5
.
template
)
||
path
.
resolve
(
__dirname
,
'
../../../../public/index.html
'
)
...
...
packages/uni-cli-shared/lib/platform.js
浏览文件 @
d8deaaf8
...
...
@@ -340,6 +340,10 @@ const PLATFORMS = {
}
}
// 解决 vue-cli-service lint 时 UNI_PLATFORM 不存在
if
(
process
.
env
.
UNI_PLATFORM
===
'
mp-360
'
)
{
process
.
env
.
UNI_PLATFORM
=
'
h5
'
process
.
env
.
UNI_SUB_PLATFORM
=
'
mp-360
'
}
process
.
env
.
UNI_PLATFORM
=
process
.
env
.
UNI_PLATFORM
||
'
h5
'
const
platform
=
PLATFORMS
[
process
.
env
.
UNI_PLATFORM
]
...
...
@@ -375,6 +379,14 @@ if (process.env.UNI_PLATFORM.indexOf('app-') === 0) {
preprocessContext
[
'
APP
'
]
=
true
}
preprocessContext
[
'
MP-360
'
]
=
false
preprocessContext
[
'
MP_360
'
]
=
false
if
(
process
.
env
.
UNI_SUB_PLATFORM
===
'
mp-360
'
)
{
preprocessContext
[
'
H5
'
]
=
false
preprocessContext
[
'
MP-360
'
]
=
true
preprocessContext
[
'
MP_360
'
]
=
true
}
if
(
process
.
UNI_SCRIPT_DEFINE
&&
Object
.
keys
(
process
.
UNI_SCRIPT_DEFINE
).
length
)
{
Object
.
keys
(
process
.
UNI_SCRIPT_DEFINE
).
forEach
(
name
=>
{
preprocessContext
[
name
]
=
process
.
UNI_SCRIPT_DEFINE
[
name
]
...
...
packages/uni-h5/dist/index.css
浏览文件 @
d8deaaf8
此差异已折叠。
点击以展开。
packages/uni-h5/dist/index.umd.min.js
浏览文件 @
d8deaaf8
此差异已折叠。
点击以展开。
packages/uni-h5/manifest.json
浏览文件 @
d8deaaf8
...
...
@@ -289,6 +289,14 @@
"/core/helpers/protocol/media/preview-image.js"
,
"previewImage"
],
[
"/core/view/components/swiper/index.vue"
,
"Swiper"
],
[
"/core/view/components/swiper-item/index.vue"
,
"SwiperItem"
],
[
"/platforms/h5/components/system-routes/preview-image/index.vue"
,
"PreviewImage"
...
...
packages/uni-template-compiler/lib/module.js
浏览文件 @
d8deaaf8
...
...
@@ -12,7 +12,7 @@ module.exports = {
warn
})
{
if
(
process
.
env
.
UNI_PLATFORM
===
'
app-plus
'
&&
el
.
tag
===
'
ad
'
)
{
warn
(
"
app-vue平台, <ad> 组件暂不支持非 V3 编译, 详见: https://ask.dcloud.net.cn/article/36599
"
)
warn
(
'
app-vue平台, <ad> 组件暂不支持非 V3 编译, 详见: https://ask.dcloud.net.cn/article/36599
'
)
}
if
(
el
.
tag
===
'
slot
'
&&
!
el
.
attrsMap
[
'
name
'
])
{
el
.
attrsList
.
push
({
...
...
packages/vue-cli-plugin-uni/commands/build.js
浏览文件 @
d8deaaf8
...
...
@@ -104,7 +104,7 @@ async function build (args, api, options) {
log
()
if
(
!
runByHBuilderX
&&
!
runByAliIde
)
{
logWithSpinner
(
`开始编译当前项目至
${
process
.
env
.
UNI_PLATFORM
}
平台...`
)
logWithSpinner
(
`开始编译当前项目至
${
process
.
env
.
UNI_
SUB_PLATFORM
||
process
.
env
.
UNI_
PLATFORM
}
平台...`
)
}
const
targetDir
=
api
.
resolve
(
options
.
outputDir
)
...
...
packages/vue-cli-plugin-uni/generator.js
浏览文件 @
d8deaaf8
...
...
@@ -15,12 +15,14 @@ module.exports = (api, options, rootOptions) => {
'
dev:mp-baidu
'
:
'
cross-env NODE_ENV=development UNI_PLATFORM=mp-baidu vue-cli-service uni-build --watch
'
,
'
dev:mp-alipay
'
:
'
cross-env NODE_ENV=development UNI_PLATFORM=mp-alipay vue-cli-service uni-build --watch
'
,
'
dev:mp-toutiao
'
:
'
cross-env NODE_ENV=development UNI_PLATFORM=mp-toutiao vue-cli-service uni-build --watch
'
,
'
dev:mp-360
'
:
'
cross-env NODE_ENV=development UNI_PLATFORM=mp-360 vue-cli-service uni-build --watch
'
,
'
build:h5
'
:
'
cross-env NODE_ENV=production UNI_PLATFORM=h5 vue-cli-service uni-build
'
,
'
build:mp-qq
'
:
'
cross-env NODE_ENV=production UNI_PLATFORM=mp-qq vue-cli-service uni-build
'
,
'
build:mp-weixin
'
:
'
cross-env NODE_ENV=production UNI_PLATFORM=mp-weixin vue-cli-service uni-build
'
,
'
build:mp-baidu
'
:
'
cross-env NODE_ENV=production UNI_PLATFORM=mp-baidu vue-cli-service uni-build
'
,
'
build:mp-alipay
'
:
'
cross-env NODE_ENV=production UNI_PLATFORM=mp-alipay vue-cli-service uni-build
'
,
'
build:mp-toutiao
'
:
'
cross-env NODE_ENV=production UNI_PLATFORM=mp-toutiao vue-cli-service uni-build
'
,
'
build:mp-360
'
:
'
cross-env NODE_ENV=production UNI_PLATFORM=mp-360 vue-cli-service uni-build
'
,
'
dev:custom
'
:
'
cross-env NODE_ENV=development uniapp-cli custom
'
,
'
build:custom
'
:
'
cross-env NODE_ENV=production uniapp-cli custom
'
},
...
...
packages/vue-cli-plugin-uni/lib/env.js
浏览文件 @
d8deaaf8
...
...
@@ -3,6 +3,11 @@ const path = require('path')
const
mkdirp
=
require
(
'
mkdirp
'
)
const
loaderUtils
=
require
(
'
loader-utils
'
)
if
(
process
.
env
.
UNI_PLATFORM
===
'
mp-360
'
)
{
process
.
env
.
UNI_PLATFORM
=
'
h5
'
process
.
env
.
UNI_SUB_PLATFORM
=
'
mp-360
'
}
// 初始化环境变量
const
defaultInputDir
=
'
../../../../src
'
const
defaultOutputDir
=
'
../../../../dist/
'
+
...
...
@@ -21,6 +26,11 @@ process.env.VUE_APP_PLATFORM = process.env.UNI_PLATFORM
process
.
env
.
UNI_INPUT_DIR
=
process
.
env
.
UNI_INPUT_DIR
||
path
.
resolve
(
__dirname
,
defaultInputDir
)
process
.
env
.
UNI_OUTPUT_DIR
=
process
.
env
.
UNI_OUTPUT_DIR
||
path
.
resolve
(
__dirname
,
defaultOutputDir
)
if
(
process
.
env
.
UNI_SUB_PLATFORM
===
'
mp-360
'
)
{
const
outputDir
=
process
.
env
.
UNI_OUTPUT_DIR
process
.
env
.
UNI_OUTPUT_DIR
=
path
.
resolve
(
outputDir
.
substr
(
0
,
outputDir
.
lastIndexOf
(
'
h5
'
)),
'
mp-360/dist
'
)
}
if
(
process
.
env
.
UNI_PLATFORM
===
'
app-plus
'
)
{
process
.
env
.
UNI_OUTPUT_TMP_DIR
=
path
.
resolve
(
process
.
env
.
UNI_OUTPUT_DIR
,
'
../.tmp/app-plus
'
)
}
...
...
packages/vue-cli-plugin-uni/lib/h5/index.js
浏览文件 @
d8deaaf8
...
...
@@ -102,13 +102,23 @@ module.exports = {
const
beforeCode
=
(
useBuiltIns
===
'
entry
'
?
`import '@babel/polyfill';`
:
''
)
+
`import 'uni-pages';import 'uni-
${
process
.
env
.
UNI_PLATFORM
}
';`
const
qihooCode
=
process
.
env
.
UNI_SUB_PLATFORM
===
'
mp-360
'
?
`
import 'uni-touch-emulator';
import qh from 'uni-qh';
global.qh = qh;
global.onAppShow = function(){};
`
:
''
return
{
devtool
:
process
.
env
.
NODE_ENV
===
'
production
'
?
false
:
'
source-map
'
,
resolve
:
{
extensions
:
[
'
.nvue
'
],
alias
:
{
'
vue-router
'
:
resolve
(
'
packages/h5-vue-router
'
),
'
uni-h5
'
:
require
.
resolve
(
'
@dcloudio/uni-h5
'
)
'
uni-h5
'
:
require
.
resolve
(
'
@dcloudio/uni-h5
'
),
'
uni-qh
'
:
path
.
resolve
(
__dirname
,
'
qh-api.js
'
),
'
uni-touch-emulator
'
:
path
.
resolve
(
__dirname
,
'
touch-emulator.js
'
)
}
},
module
:
{
...
...
@@ -118,7 +128,7 @@ module.exports = {
loader
:
'
wrap-loader
'
,
options
:
{
before
:
[
beforeCode
+
statCode
+
getGlobalUsingComponentsCode
()
qihooCode
+
beforeCode
+
statCode
+
getGlobalUsingComponentsCode
()
]
}
}]
...
...
packages/vue-cli-plugin-uni/lib/h5/qh-api.js
0 → 100644
浏览文件 @
d8deaaf8
此差异已折叠。
点击以展开。
packages/vue-cli-plugin-uni/lib/h5/touch-emulator.js
0 → 100644
浏览文件 @
d8deaaf8
(
function
(
window
,
document
,
exportName
,
undefined
)
{
'
use strict
'
var
isMultiTouch
=
false
var
multiTouchStartPos
var
eventTarget
var
touchElements
=
{}
// polyfills
if
(
!
document
.
createTouch
)
{
document
.
createTouch
=
function
(
view
,
target
,
identifier
,
pageX
,
pageY
,
screenX
,
screenY
,
clientX
,
clientY
)
{
// auto set
if
(
clientX
==
undefined
||
clientY
==
undefined
)
{
clientX
=
pageX
-
window
.
pageXOffset
clientY
=
pageY
-
window
.
pageYOffset
}
return
new
Touch
(
target
,
identifier
,
{
pageX
:
pageX
,
pageY
:
pageY
,
screenX
:
screenX
,
screenY
:
screenY
,
clientX
:
clientX
,
clientY
:
clientY
})
}
}
if
(
!
document
.
createTouchList
)
{
document
.
createTouchList
=
function
()
{
var
touchList
=
new
TouchList
()
for
(
var
i
=
0
;
i
<
arguments
.
length
;
i
++
)
{
touchList
[
i
]
=
arguments
[
i
]
}
touchList
.
length
=
arguments
.
length
return
touchList
}
}
/**
* create an touch point
* @constructor
* @param target
* @param identifier
* @param pos
* @param deltaX
* @param deltaY
* @returns {Object} touchPoint
*/
function
Touch
(
target
,
identifier
,
pos
,
deltaX
,
deltaY
)
{
deltaX
=
deltaX
||
0
deltaY
=
deltaY
||
0
this
.
identifier
=
identifier
this
.
target
=
target
this
.
clientX
=
pos
.
clientX
+
deltaX
this
.
clientY
=
pos
.
clientY
+
deltaY
this
.
screenX
=
pos
.
screenX
+
deltaX
this
.
screenY
=
pos
.
screenY
+
deltaY
this
.
pageX
=
pos
.
pageX
+
deltaX
this
.
pageY
=
pos
.
pageY
+
deltaY
}
/**
* create empty touchlist with the methods
* @constructor
* @returns touchList
*/
function
TouchList
()
{
var
touchList
=
[]
touchList
.
item
=
function
(
index
)
{
return
this
[
index
]
||
null
}
// specified by Mozilla
touchList
.
identifiedTouch
=
function
(
id
)
{
return
this
[
id
+
1
]
||
null
}
return
touchList
}
/**
* Simple trick to fake touch event support
* this is enough for most libraries like Modernizr and Hammer
*/
function
fakeTouchSupport
()
{
var
objs
=
[
window
,
document
.
documentElement
]
var
props
=
[
'
ontouchstart
'
,
'
ontouchmove
'
,
'
ontouchcancel
'
,
'
ontouchend
'
]
for
(
var
o
=
0
;
o
<
objs
.
length
;
o
++
)
{
for
(
var
p
=
0
;
p
<
props
.
length
;
p
++
)
{
if
(
objs
[
o
]
&&
objs
[
o
][
props
[
p
]]
==
undefined
)
{
objs
[
o
][
props
[
p
]]
=
null
}
}
}
}
/**
* we don't have to emulate on a touch device
* @returns {boolean}
*/
function
hasTouchSupport
()
{
return
(
'
ontouchstart
'
in
window
)
||
// touch events
(
window
.
Modernizr
&&
window
.
Modernizr
.
touch
)
||
// modernizr
(
navigator
.
msMaxTouchPoints
||
navigator
.
maxTouchPoints
)
>
2
// pointer events
}
/**
* disable mouseevents on the page
* @param ev
*/
function
preventMouseEvents
(
ev
)
{
ev
.
preventDefault
()
ev
.
stopPropagation
()
}
/**
* only trigger touches when the left mousebutton has been pressed
* @param touchType
* @returns {Function}
*/
function
onMouse
(
touchType
)
{
return
function
(
ev
)
{
// prevent mouse events
// 过滤 输入框 和 可编辑元素
// preventMouseEvents(ev);
ev
.
stopPropagation
()
var
computedStyle
var
target
=
ev
.
target
if
(
target
.
tagName
!==
'
INPUT
'
&&
target
.
tagName
!==
'
TEXTAREA
'
&&
(
computedStyle
=
window
.
getComputedStyle
(
target
))
&&
(
computedStyle
[
'
user-modify
'
]
||
computedStyle
[
'
-webkit-user-modify
'
]).
indexOf
(
'
write
'
)
<
0
)
{
ev
.
preventDefault
()
}
if
(
ev
.
which
!==
1
)
{
return
}
// The EventTarget on which the touch point started when it was first placed on the surface,
// even if the touch point has since moved outside the interactive area of that element.
// also, when the target doesnt exist anymore, we update it
if
(
ev
.
type
==
'
mousedown
'
||
!
eventTarget
||
(
eventTarget
&&
!
eventTarget
.
dispatchEvent
))
{
eventTarget
=
ev
.
target
}
// shiftKey has been lost, so trigger a touchend
if
(
isMultiTouch
&&
!
ev
.
shiftKey
)
{
triggerTouch
(
'
touchend
'
,
ev
)
isMultiTouch
=
false
}
triggerTouch
(
touchType
,
ev
)
// we're entering the multi-touch mode!
if
(
!
isMultiTouch
&&
ev
.
shiftKey
)
{
isMultiTouch
=
true
multiTouchStartPos
=
{
pageX
:
ev
.
pageX
,
pageY
:
ev
.
pageY
,
clientX
:
ev
.
clientX
,
clientY
:
ev
.
clientY
,
screenX
:
ev
.
screenX
,
screenY
:
ev
.
screenY
}
triggerTouch
(
'
touchstart
'
,
ev
)
}
// reset
if
(
ev
.
type
==
'
mouseup
'
)
{
multiTouchStartPos
=
null
isMultiTouch
=
false
eventTarget
=
null
}
}
}
/**
* trigger a touch event
* @param eventName
* @param mouseEv
*/
function
triggerTouch
(
eventName
,
mouseEv
)
{
var
touchEvent
=
document
.
createEvent
(
'
Event
'
)
touchEvent
.
initEvent
(
eventName
,
true
,
true
)
touchEvent
.
altKey
=
mouseEv
.
altKey
touchEvent
.
ctrlKey
=
mouseEv
.
ctrlKey
touchEvent
.
metaKey
=
mouseEv
.
metaKey
touchEvent
.
shiftKey
=
mouseEv
.
shiftKey
touchEvent
.
touches
=
getActiveTouches
(
mouseEv
,
eventName
)
touchEvent
.
targetTouches
=
getActiveTouches
(
mouseEv
,
eventName
)
touchEvent
.
changedTouches
=
getChangedTouches
(
mouseEv
,
eventName
)
eventTarget
.
dispatchEvent
(
touchEvent
)
}
/**
* create a touchList based on the mouse event
* @param mouseEv
* @returns {TouchList}
*/
function
createTouchList
(
mouseEv
)
{
var
touchList
=
new
TouchList
()
if
(
isMultiTouch
)
{
var
f
=
TouchEmulator
.
multiTouchOffset
var
deltaX
=
multiTouchStartPos
.
pageX
-
mouseEv
.
pageX
var
deltaY
=
multiTouchStartPos
.
pageY
-
mouseEv
.
pageY
touchList
.
push
(
new
Touch
(
eventTarget
,
1
,
multiTouchStartPos
,
(
deltaX
*
-
1
)
-
f
,
(
deltaY
*
-
1
)
+
f
))
touchList
.
push
(
new
Touch
(
eventTarget
,
2
,
multiTouchStartPos
,
deltaX
+
f
,
deltaY
-
f
))
}
else
{
touchList
.
push
(
new
Touch
(
eventTarget
,
1
,
mouseEv
,
0
,
0
))
}
return
touchList
}
/**
* receive all active touches
* @param mouseEv
* @returns {TouchList}
*/
function
getActiveTouches
(
mouseEv
,
eventName
)
{
// empty list
if
(
mouseEv
.
type
==
'
mouseup
'
)
{
return
new
TouchList
()
}
var
touchList
=
createTouchList
(
mouseEv
)
if
(
isMultiTouch
&&
mouseEv
.
type
!=
'
mouseup
'
&&
eventName
==
'
touchend
'
)
{
touchList
.
splice
(
1
,
1
)
}
return
touchList
}
/**
* receive a filtered set of touches with only the changed pointers
* @param mouseEv
* @param eventName
* @returns {TouchList}
*/
function
getChangedTouches
(
mouseEv
,
eventName
)
{
var
touchList
=
createTouchList
(
mouseEv
)
// we only want to return the added/removed item on multitouch
// which is the second pointer, so remove the first pointer from the touchList
//
// but when the mouseEv.type is mouseup, we want to send all touches because then
// no new input will be possible
if
(
isMultiTouch
&&
mouseEv
.
type
!=
'
mouseup
'
&&
(
eventName
==
'
touchstart
'
||
eventName
==
'
touchend
'
))
{
touchList
.
splice
(
0
,
1
)
}
return
touchList
}
/**
* show the touchpoints on the screen
*/
function
showTouches
(
ev
)
{
var
touch
,
i
,
el
,
styles
// first all visible touches
for
(
i
=
0
;
i
<
ev
.
touches
.
length
;
i
++
)
{
touch
=
ev
.
touches
[
i
]
el
=
touchElements
[
touch
.
identifier
]
if
(
!
el
)
{
el
=
touchElements
[
touch
.
identifier
]
=
document
.
createElement
(
'
div
'
)
document
.
body
.
appendChild
(
el
)
}
styles
=
TouchEmulator
.
template
(
touch
)
for
(
var
prop
in
styles
)
{
el
.
style
[
prop
]
=
styles
[
prop
]
}
}
// remove all ended touches
if
(
ev
.
type
==
'
touchend
'
||
ev
.
type
==
'
touchcancel
'
)
{
for
(
i
=
0
;
i
<
ev
.
changedTouches
.
length
;
i
++
)
{
touch
=
ev
.
changedTouches
[
i
]
el
=
touchElements
[
touch
.
identifier
]
if
(
el
)
{
el
.
parentNode
.
removeChild
(
el
)
delete
touchElements
[
touch
.
identifier
]
}
}
}
}
/**
* TouchEmulator initializer
*/
function
TouchEmulator
()
{
if
(
hasTouchSupport
())
{
return
}
fakeTouchSupport
()
window
.
addEventListener
(
'
mousedown
'
,
onMouse
(
'
touchstart
'
),
true
)
window
.
addEventListener
(
'
mousemove
'
,
onMouse
(
'
touchmove
'
),
true
)
window
.
addEventListener
(
'
mouseup
'
,
onMouse
(
'
touchend
'
),
true
)
window
.
addEventListener
(
'
mouseenter
'
,
preventMouseEvents
,
true
)
window
.
addEventListener
(
'
mouseleave
'
,
preventMouseEvents
,
true
)
window
.
addEventListener
(
'
mouseout
'
,
preventMouseEvents
,
true
)
window
.
addEventListener
(
'
mouseover
'
,
preventMouseEvents
,
true
)
// it uses itself!
// 关闭触摸显示
// window.addEventListener("touchstart", showTouches, false);
// window.addEventListener("touchmove", showTouches, false);
// window.addEventListener("touchend", showTouches, false);
// window.addEventListener("touchcancel", showTouches, false);
}
// start distance when entering the multitouch mode
TouchEmulator
.
multiTouchOffset
=
75
/**
* css template for the touch rendering
* @param touch
* @returns object
*/
TouchEmulator
.
template
=
function
(
touch
)
{
var
size
=
30
var
transform
=
'
translate(
'
+
(
touch
.
clientX
-
(
size
/
2
))
+
'
px,
'
+
(
touch
.
clientY
-
(
size
/
2
))
+
'
px)
'
return
{
position
:
'
fixed
'
,
left
:
0
,
top
:
0
,
background
:
'
#fff
'
,
border
:
'
solid 1px #999
'
,
opacity
:
0.6
,
borderRadius
:
'
100%
'
,
height
:
size
+
'
px
'
,
width
:
size
+
'
px
'
,
padding
:
0
,
margin
:
0
,
display
:
'
block
'
,
overflow
:
'
hidden
'
,
pointerEvents
:
'
none
'
,
webkitUserSelect
:
'
none
'
,
mozUserSelect
:
'
none
'
,
userSelect
:
'
none
'
,
webkitTransform
:
transform
,
mozTransform
:
transform
,
transform
:
transform
}
}
// export
// 直接启用
// if (typeof define == "function" && define.amd) {
// define(function() {
// return TouchEmulator;
// });
// } else if (typeof module != "undefined" && module.exports) {
// module.exports = TouchEmulator;
// } else {
// window[exportName] = TouchEmulator;
// }
TouchEmulator
()
})(
window
,
document
,
'
TouchEmulator
'
)
packages/webpack-uni-pages-loader/lib/platforms/h5.js
浏览文件 @
d8deaaf8
...
...
@@ -5,7 +5,8 @@ const {
getPlatforms
,
getH5Options
,
getFlexDirection
,
getNetworkTimeout
getNetworkTimeout
,
normalizePath
}
=
require
(
'
@dcloudio/uni-cli-shared
'
)
const
{
...
...
@@ -14,9 +15,6 @@ const {
const
PLATFORMS
=
getPlatforms
()
const
isWin
=
/^win/
.
test
(
process
.
platform
)
const
normalizePath
=
path
=>
(
isWin
?
path
.
replace
(
/
\\
/g
,
'
/
'
)
:
path
)
const
removePlatformStyle
=
function
(
style
)
{
Object
.
keys
(
style
).
forEach
(
name
=>
{
if
(
PLATFORMS
.
includes
(
name
))
{
...
...
@@ -60,11 +58,21 @@ const getPageComponents = function (inputDir, pagesJson) {
pagesJson
.
tabBar
.
borderStyle
=
pagesJson
.
tabBar
.
borderStyle
||
'
black
'
}
const
globalStyle
=
pagesJson
.
globalStyle
||
{}
const
globalStyle
=
Object
.
assign
({},
pagesJson
.
globalStyle
||
{})
Object
.
assign
(
globalStyle
,
globalStyle
[
'
app-plus
'
]
||
{},
globalStyle
[
'
h5
'
]
||
{}
)
if
(
process
.
env
.
UNI_SUB_PLATFORM
===
'
mp-360
'
)
{
Object
.
assign
(
globalStyle
,
globalStyle
[
'
mp-360
'
]
||
{})
}
process
.
UNI_H5_PAGES_JSON
=
{
pages
:
{},
globalStyle
:
Object
.
assign
({},
globalStyle
,
globalStyle
[
'
app-plus
'
]
||
{},
globalStyle
[
'
h5
'
]
||
{})
globalStyle
}
removePlatformStyle
(
process
.
UNI_H5_PAGES_JSON
.
globalStyle
)
...
...
@@ -86,6 +94,10 @@ const getPageComponents = function (inputDir, pagesJson) {
// 解析 titleNView,pullToRefresh
const
h5Options
=
Object
.
assign
({},
props
[
'
app-plus
'
]
||
{},
props
[
'
h5
'
]
||
{})
if
(
process
.
env
.
UNI_SUB_PLATFORM
===
'
mp-360
'
)
{
Object
.
assign
(
h5Options
,
props
[
'
mp-360
'
]
||
{})
Object
.
assign
(
props
,
props
[
'
mp-360
'
]
||
{})
}
removePlatformStyle
(
h5Options
)
if
(
h5Options
.
hasOwnProperty
(
'
titleNView
'
))
{
...
...
@@ -118,6 +130,7 @@ const getPageComponents = function (inputDir, pagesJson) {
// 删除 app-plus 平台配置
delete
props
[
'
app-plus
'
]
delete
props
[
'
h5
'
]
delete
props
[
'
mp-360
'
]
process
.
UNI_H5_PAGES_JSON
.
pages
[
page
.
path
]
=
props
...
...
src/core/service/api/context/create-map-context.js
浏览文件 @
d8deaaf8
...
...
@@ -35,8 +35,8 @@ export class MapContext {
}
}
MapContext
.
prototype
.
$getAppMap
=
function
()
{
return
plus
.
maps
.
getMapById
(
this
.
pageVm
.
$page
.
id
+
'
-map-
'
+
this
.
id
)
;
MapContext
.
prototype
.
$getAppMap
=
function
()
{
return
plus
.
maps
.
getMapById
(
this
.
pageVm
.
$page
.
id
+
'
-map-
'
+
this
.
id
)
}
methods
.
forEach
(
function
(
method
)
{
...
...
src/core/service/plugins/app/router-guard.js
浏览文件 @
d8deaaf8
...
...
@@ -202,6 +202,20 @@ function afterEach (to, from) {
if
(
toVm
)
{
// 目标页面若已存在,则触发 onShow
// 延迟执行 onShow,防止与 UniServiceJSBridge.emit('onHidePopup') 冲突。
setTimeout
(
function
()
{
if
(
__PLATFORM__
===
'
h5
'
)
{
const
navigationBar
=
toVm
.
$parent
.
$parent
.
navigationBar
if
(
typeof
qh
!==
'
undefined
'
)
{
qh
.
setNavigationBarTitle
({
title
:
document
.
title
})
qh
.
setNavigationBarColor
({
backgroundColor
:
navigationBar
.
backgroundColor
})
qh
.
setNavigationBarTextStyle
({
textStyle
:
navigationBar
.
textColor
===
'
#000
'
?
'
black
'
:
'
white
'
})
}
}
callPageHook
(
toVm
,
'
onShow
'
)
},
0
)
if
(
__PLATFORM__
===
'
h5
'
)
{
...
...
src/platforms/h5/components/page/index.vue
浏览文件 @
d8deaaf8
...
...
@@ -7,15 +7,13 @@
v-if=
"enablePullDownRefresh"
ref=
"refresh"
:color=
"refreshOptions.color"
:offset=
"refreshOptions.offset"
/>
:offset=
"refreshOptions.offset"
/>
<page-body
v-if=
"enablePullDownRefresh"
@
touchstart.native=
"_touchstart"
@
touchmove.native=
"_touchmove"
@
touchend.native=
"_touchend"
@
touchcancel.native=
"_touchend"
>
@
touchcancel.native=
"_touchend"
>
<slot
name=
"page"
/>
</page-body>
<page-body
v-else
>
...
...
@@ -24,11 +22,11 @@
</uni-page>
</
template
>
<
style
>
uni-page
{
uni-page
{
display
:
block
;
width
:
100%
;
height
:
100%
;
}
}
</
style
>
<
script
>
import
{
...
...
@@ -210,7 +208,19 @@ export default {
},
created
()
{
if
(
__PLATFORM__
===
'
h5
'
)
{
document
.
title
=
this
.
navigationBar
.
titleText
const
navigationBar
=
this
.
navigationBar
document
.
title
=
navigationBar
.
titleText
if
(
typeof
qh
!==
'
undefined
'
)
{
qh
.
setNavigationBarTitle
({
title
:
document
.
title
})
qh
.
setNavigationBarColor
({
backgroundColor
:
navigationBar
.
backgroundColor
})
qh
.
setNavigationBarTextStyle
({
textStyle
:
navigationBar
.
textColor
===
'
#000
'
?
'
black
'
:
'
white
'
})
}
}
}
}
...
...
src/platforms/h5/components/system-routes/system-header.vue
浏览文件 @
d8deaaf8
...
...
@@ -34,6 +34,11 @@ export default {
created
()
{
if
(
__PLATFORM__
===
'
h5
'
)
{
document
.
title
=
this
.
$slots
.
default
[
0
].
text
if
(
typeof
qh
!==
'
undefined
'
)
{
qh
.
setNavigationBarTitle
({
title
:
document
.
title
})
}
}
},
methods
:
{
...
...
src/platforms/h5/service/api/ui/navigation-bar.js
浏览文件 @
d8deaaf8
...
...
@@ -18,9 +18,23 @@ function setNavigationBar (type, args) {
if
(
frontColor
)
{
page
.
navigationBar
.
textColor
=
frontColor
===
'
#000000
'
?
'
black
'
:
'
white
'
if
(
__PLATFORM__
===
'
h5
'
)
{
if
(
typeof
qh
!==
'
undefined
'
)
{
qh
.
setNavigationBarTextStyle
({
textStyle
:
page
.
navigationBar
.
textColor
})
}
}
}
if
(
backgroundColor
)
{
page
.
navigationBar
.
backgroundColor
=
backgroundColor
if
(
__PLATFORM__
===
'
h5
'
)
{
if
(
typeof
qh
!==
'
undefined
'
)
{
qh
.
setNavigationBarColor
({
backgroundColor
})
}
}
}
page
.
navigationBar
.
duration
=
duration
+
'
ms
'
page
.
navigationBar
.
timingFunc
=
timingFunc
...
...
@@ -38,6 +52,11 @@ function setNavigationBar (type, args) {
page
.
navigationBar
.
titleText
=
title
if
(
__PLATFORM__
===
'
h5
'
)
{
document
.
title
=
title
if
(
typeof
qh
!==
'
undefined
'
)
{
qh
.
setNavigationBarTitle
({
title
:
document
.
title
})
}
}
break
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录