Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
qianlong66
uni-app
提交
5dbb3f21
U
uni-app
项目概览
qianlong66
/
uni-app
与 Fork 源项目一致
Fork自
DCloud / uni-app
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
U
uni-app
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
5dbb3f21
编写于
4月 14, 2021
作者:
fxy060608
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix: add passive
上级
64c168c4
变更
11
隐藏空白更改
内联
并排
Showing
11 changed file
with
63 addition
and
52 deletion
+63
-52
packages/uni-api/src/protocols/network/socket.ts
packages/uni-api/src/protocols/network/socket.ts
+1
-1
packages/uni-components/src/helpers/useHover.ts
packages/uni-components/src/helpers/useHover.ts
+2
-2
packages/uni-h5/dist/uni-h5.esm.js
packages/uni-h5/dist/uni-h5.esm.js
+9
-8
packages/uni-h5/src/framework/components/page/page-refresh/index.ts
...ni-h5/src/framework/components/page/page-refresh/index.ts
+4
-4
packages/uni-h5/src/framework/plugin/page.ts
packages/uni-h5/src/framework/plugin/page.ts
+3
-2
packages/vite-plugin-uni/src/config/index.ts
packages/vite-plugin-uni/src/config/index.ts
+17
-4
packages/vite-plugin-uni/src/configResolved/plugins/copy.ts
packages/vite-plugin-uni/src/configResolved/plugins/copy.ts
+1
-1
packages/vite-plugin-uni/src/configResolved/plugins/index.ts
packages/vite-plugin-uni/src/configResolved/plugins/index.ts
+1
-1
packages/vite-plugin-uni/src/configResolved/plugins/manifestJson.ts
...ite-plugin-uni/src/configResolved/plugins/manifestJson.ts
+9
-4
packages/vite-plugin-uni/src/configResolved/plugins/pagesJson.ts
...s/vite-plugin-uni/src/configResolved/plugins/pagesJson.ts
+13
-2
packages/vite-plugin-uni/src/index.ts
packages/vite-plugin-uni/src/index.ts
+3
-23
未找到文件。
packages/uni-api/src/protocols/network/socket.ts
浏览文件 @
5dbb3f21
...
...
@@ -3,7 +3,7 @@ export const API_CONNECT_SOCKET = 'connectSocket'
export
type
API_TYPE_CONNECT_SOCKET
=
typeof
uni
.
connectSocket
export
const
ConnectSocketOptions
:
ApiOptions
<
API_TYPE_CONNECT_SOCKET
>
=
{
formatArgs
:
{
header
(
value
,
params
)
{
header
(
value
:
Record
<
string
,
any
>
,
params
:
Record
<
string
,
any
>
)
{
params
.
header
=
value
||
{}
},
method
(
value
,
params
)
{
...
...
packages/uni-components/src/helpers/useHover.ts
浏览文件 @
5dbb3f21
...
...
@@ -40,7 +40,7 @@ export function useHover(props: UseHoverOptions) {
},
parseInt
(
props
.
hoverStayTime
as
string
))
})
}
function
onTouchstart
(
evt
:
TouchEvent
)
{
function
onTouchstart
Passive
(
evt
:
TouchEvent
)
{
// TODO detect scrolling
if
((
evt
as
any
).
_hoverPropagationStopped
)
{
return
...
...
@@ -77,7 +77,7 @@ export function useHover(props: UseHoverOptions) {
return
{
hovering
,
binding
:
{
onTouchstart
,
onTouchstart
Passive
,
onTouchend
,
onTouchcancel
,
},
...
...
packages/uni-h5/dist/uni-h5.esm.js
浏览文件 @
5dbb3f21
...
...
@@ -1286,9 +1286,10 @@ function initPublicPage(route) {
}
function
initPage
(
vm
)
{
const
route
=
vm
.
$route
;
const
page
=
initPublicPage
(
route
);
vm
.
$vm
=
vm
;
vm
.
$page
=
initPublicPage
(
route
)
;
currentPagesMap
.
set
(
normalizeRouteKey
(
route
.
path
,
vm
.
$
page
.
id
),
vm
);
vm
.
$page
=
page
;
currentPagesMap
.
set
(
normalizeRouteKey
(
page
.
path
,
page
.
id
),
vm
);
}
function
normalizeRouteKey
(
path
,
id2
)
{
return
path
+
SEP
+
id2
;
...
...
@@ -2006,7 +2007,7 @@ function useHover(props) {
},
parseInt
(
props
.
hoverStayTime
));
});
}
function
onTouchstart
(
evt
)
{
function
onTouchstart
Passive
(
evt
)
{
if
(
evt
.
_hoverPropagationStopped
)
{
return
;
}
...
...
@@ -2041,7 +2042,7 @@ function useHover(props) {
return
{
hovering
,
binding
:
{
onTouchstart
,
onTouchstart
Passive
,
onTouchend
,
onTouchcancel
}
...
...
@@ -12387,7 +12388,7 @@ function usePageRefresh(refreshRef) {
refreshControllerElemStyle
.
clip
=
"
rect(
"
+
(
45
-
y
)
+
"
px,45px,45px,-5px)
"
;
refreshControllerElemStyle
.
transform
=
"
translate3d(-50%,
"
+
y
+
"
px, 0)
"
;
}
function
onTouchstart
(
ev
)
{
function
onTouchstart
Passive
(
ev
)
{
const
touch
=
ev
.
changedTouches
[
0
];
touchId
=
touch
.
identifier
;
startY
=
touch
.
pageY
;
...
...
@@ -12397,7 +12398,7 @@ function usePageRefresh(refreshRef) {
canRefresh
=
true
;
}
}
function
onTouchmove
(
ev
)
{
function
onTouchmove
Passive
(
ev
)
{
if
(
!
canRefresh
)
{
return
;
}
...
...
@@ -12500,8 +12501,8 @@ function usePageRefresh(refreshRef) {
const
timeout
=
setTimeout
(
restoreTransitionEnd
,
350
);
}
return
{
onTouchstart
,
onTouchmove
,
onTouchstart
Passive
,
onTouchmove
Passive
,
onTouchend
,
onTouchcancel
:
onTouchend
};
...
...
packages/uni-h5/src/framework/components/page/page-refresh/index.ts
浏览文件 @
5dbb3f21
...
...
@@ -113,7 +113,7 @@ export function usePageRefresh(refreshRef: Ref) {
refreshControllerElemStyle
.
transform
=
'
translate3d(-50%,
'
+
y
+
'
px, 0)
'
}
function
onTouchstart
(
ev
:
TouchEvent
)
{
function
onTouchstart
Passive
(
ev
:
TouchEvent
)
{
const
touch
=
ev
.
changedTouches
[
0
]
touchId
=
touch
.
identifier
startY
=
touch
.
pageY
...
...
@@ -124,7 +124,7 @@ export function usePageRefresh(refreshRef: Ref) {
}
}
function
onTouchmove
(
ev
:
TouchEvent
)
{
function
onTouchmove
Passive
(
ev
:
TouchEvent
)
{
if
(
!
canRefresh
)
{
return
}
...
...
@@ -258,8 +258,8 @@ export function usePageRefresh(refreshRef: Ref) {
}
return
{
onTouchstart
,
onTouchmove
,
onTouchstart
Passive
,
onTouchmove
Passive
,
onTouchend
,
onTouchcancel
:
onTouchend
,
}
...
...
packages/uni-h5/src/framework/plugin/page.ts
浏览文件 @
5dbb3f21
...
...
@@ -73,10 +73,11 @@ function initPublicPage(route: RouteLocationNormalizedLoaded) {
export
function
initPage
(
vm
:
ComponentPublicInstance
)
{
const
route
=
vm
.
$route
const
page
=
initPublicPage
(
route
)
;(
vm
as
any
).
$vm
=
vm
;(
vm
as
any
).
$page
=
initPublicPage
(
route
)
;(
vm
as
any
).
$page
=
page
currentPagesMap
.
set
(
normalizeRouteKey
(
route
.
path
,
vm
.
$
page
.
id
),
normalizeRouteKey
(
page
.
path
,
page
.
id
),
(
vm
as
unknown
)
as
Page
.
PageInstance
)
}
...
...
packages/vite-plugin-uni/src/config/index.ts
浏览文件 @
5dbb3f21
import
fs
from
'
fs
'
import
path
from
'
path
'
import
{
parse
}
from
'
jsonc-parser
'
import
{
Plugin
}
from
'
vite
'
import
{
VitePluginUniResolvedOptions
}
from
'
..
'
...
...
@@ -7,14 +11,23 @@ import { createDefine } from './define'
import
{
createServer
}
from
'
./server
'
import
{
createBuild
}
from
'
./build
'
import
{
createOptimizeDeps
}
from
'
./optimizeDeps
'
function
resolveBase
(
inputDir
:
string
)
{
const
manifest
=
parse
(
fs
.
readFileSync
(
path
.
join
(
inputDir
,
'
manifest.json
'
),
'
utf8
'
)
)
return
(
manifest
.
h5
&&
manifest
.
h5
.
router
&&
manifest
.
h5
.
router
.
base
)
||
'
/
'
}
export
function
createConfig
(
options
:
VitePluginUniResolvedOptions
):
Plugin
[
'
config
'
]
{
return
(
config
,
env
)
=>
{
if
(
config
.
root
)
{
options
.
root
=
config
.
root
}
const
root
=
config
.
root
||
process
.
cwd
()
const
inputDir
=
process
.
env
.
UNI_INPUT_DIR
||
path
.
resolve
(
root
,
'
src
'
)
const
outputDir
=
process
.
env
.
UNI_OUTPUT_DIR
||
path
.
resolve
(
root
,
'
dist
'
)
options
.
root
=
root
options
.
base
=
resolveBase
(
inputDir
)
options
.
inputDir
=
inputDir
options
.
outputDir
=
outputDir
options
.
command
=
env
.
command
return
{
base
:
options
.
base
,
...
...
packages/vite-plugin-uni/src/configResolved/plugins/copy.ts
浏览文件 @
5dbb3f21
...
...
@@ -18,7 +18,7 @@ export function uniCopyPlugin({
{
src
:
path
.
resolve
(
inputDir
,
'
uni_modules/*/
'
+
PUBLIC_DIR
),
dest
:
outputDir
,
rename
:
(
name
,
extension
,
fullPath
)
=>
{
rename
:
(
_name
,
_
extension
,
fullPath
)
=>
{
return
path
.
relative
(
inputDir
,
fullPath
)
},
},
...
...
packages/vite-plugin-uni/src/configResolved/plugins/index.ts
浏览文件 @
5dbb3f21
...
...
@@ -87,7 +87,7 @@ export function resolvePlugins(
)
addPlugin
(
plugins
,
uniMainJsPlugin
(
options
),
1
,
'
pre
'
)
addPlugin
(
plugins
,
uniPagesJsonPlugin
(
config
,
options
),
1
,
'
pre
'
)
addPlugin
(
plugins
,
uniManifestJsonPlugin
(
options
),
1
,
'
pre
'
)
addPlugin
(
plugins
,
uniManifestJsonPlugin
(
config
,
options
),
1
,
'
pre
'
)
addPlugin
(
plugins
,
...
...
packages/vite-plugin-uni/src/configResolved/plugins/manifestJson.ts
浏览文件 @
5dbb3f21
import
fs
from
'
fs
'
import
path
from
'
path
'
import
slash
from
'
slash
'
import
{
parse
}
from
'
jsonc-parser
'
import
{
Plugin
}
from
'
vite
'
import
{
Plugin
,
ResolvedConfig
}
from
'
vite
'
import
{
VitePluginUniResolvedOptions
}
from
'
../..
'
import
slash
from
'
slash
'
import
{
FEATURE_DEFINES
}
from
'
../../utils
'
const
MANIFEST_JSON_JS
=
'
manifest.json.js
'
...
...
@@ -31,6 +32,7 @@ const defaultNetworkTimeout = {
const
defaultQQMapKey
=
'
XVXBZ-NDMC4-JOGUS-XGIEE-QVHDZ-AMFV2
'
export
function
uniManifestJsonPlugin
(
config
:
ResolvedConfig
,
options
:
VitePluginUniResolvedOptions
):
Plugin
{
const
manifestJsonPath
=
slash
(
path
.
join
(
options
.
inputDir
,
'
manifest.json
'
))
...
...
@@ -43,11 +45,14 @@ export function uniManifestJsonPlugin(
},
transform
(
code
,
id
)
{
if
(
id
.
endsWith
(
MANIFEST_JSON_JS
))
{
const
define
=
config
.
define
!
as
FEATURE_DEFINES
const
manifest
=
JSON
.
parse
(
code
)
const
{
debug
,
h5
}
=
manifest
const
appid
=
(
manifest
.
appid
||
''
).
replace
(
'
__UNI__
'
,
''
)
const
router
=
{
...
defaultRouter
,
...((
h5
&&
h5
.
router
)
||
{})
}
const
async
=
{
...
defaultAsync
,
...((
h5
&&
h5
.
async
)
||
{})
}
const
async
=
define
.
__UNI_FEATURE_PAGES__
?
{
...
defaultAsync
,
...((
h5
&&
h5
.
async
)
||
{})
}
:
{}
const
networkTimeout
=
{
...
defaultNetworkTimeout
,
...
...
packages/vite-plugin-uni/src/configResolved/plugins/pagesJson.ts
浏览文件 @
5dbb3f21
...
...
@@ -54,7 +54,7 @@ function parsePagesJson(
options
:
VitePluginUniResolvedOptions
)
{
const
pagesJson
=
normalizePagesJson
(
jsonStr
,
options
.
platform
)
const
definePagesCode
=
generatePagesDefineCode
(
pagesJson
)
const
definePagesCode
=
generatePagesDefineCode
(
pagesJson
,
config
)
const
uniRoutesCode
=
generateRoutes
(
pagesJson
)
const
uniConfigCode
=
generateConfig
(
pagesJson
,
options
)
const
manifestJsonPath
=
slash
(
...
...
@@ -129,7 +129,18 @@ function generatePageDefineCode(pageOptions: UniApp.PagesJsonPageOptions) {
}
.vue?mpType=page').then(comp=>setupPage(comp))},AsyncComponentOptions))`
}
function
generatePagesDefineCode
(
pagesJson
:
UniApp
.
PagesJson
)
{
function
generatePagesDefineCode
(
pagesJson
:
UniApp
.
PagesJson
,
config
:
ResolvedConfig
)
{
const
define
=
config
.
define
!
as
FEATURE_DEFINES
if
(
!
define
.
__UNI_FEATURE_PAGES__
)
{
// single page
const
pagePath
=
pagesJson
.
pages
[
0
].
path
return
`import {default as
${
normalizePageIdentifier
(
pagePath
)}
} from './
${
pagePath
}
.vue?mpType=page'`
}
const
{
pages
}
=
pagesJson
return
(
`const AsyncComponentOptions = {
...
...
packages/vite-plugin-uni/src/index.ts
浏览文件 @
5dbb3f21
import
fs
from
'
fs
'
import
path
from
'
path
'
import
{
parse
}
from
'
jsonc-parser
'
import
{
Plugin
,
ResolvedConfig
,
ViteDevServer
}
from
'
vite
'
import
{
initEnv
}
from
'
./env
'
...
...
@@ -27,32 +23,16 @@ export interface VitePluginUniResolvedOptions extends VitePluginUniOptions {
export
*
from
'
./vue
'
function
resolveBase
(
inputDir
:
string
)
{
const
manifest
=
parse
(
fs
.
readFileSync
(
path
.
join
(
inputDir
,
'
manifest.json
'
),
'
utf8
'
)
)
return
(
manifest
.
h5
&&
manifest
.
h5
.
router
&&
manifest
.
h5
.
router
.
base
)
||
'
/
'
}
export
default
function
uniPlugin
(
rawOptions
:
VitePluginUniOptions
=
{}
):
Plugin
{
const
inputDir
=
process
.
env
.
UNI_INPUT_DIR
||
rawOptions
.
inputDir
||
path
.
resolve
(
process
.
cwd
(),
'
src
'
)
const
outputDir
=
process
.
env
.
UNI_OUTPUT_DIR
||
rawOptions
.
outputDir
||
path
.
resolve
(
process
.
cwd
(),
'
dist
'
)
const
options
:
VitePluginUniResolvedOptions
=
{
...
rawOptions
,
root
:
process
.
cwd
(),
base
:
resolveBase
(
inputDir
)
,
base
:
'
/
'
,
assetsDir
:
'
assets
'
,
inputDir
,
outputDir
,
inputDir
:
''
,
outputDir
:
''
,
command
:
'
serve
'
,
platform
:
'
h5
'
,
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录