Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
陈庄旺
uni-app
提交
f7f4602a
U
uni-app
项目概览
陈庄旺
/
uni-app
与 Fork 源项目一致
Fork自
DCloud / uni-app
通知
1
Star
0
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,发现更多精彩内容 >>
提交
f7f4602a
编写于
5月 10, 2021
作者:
D
DCloud_LXH
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat: navigator
上级
e1d3fd44
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
85 addition
and
212 deletion
+85
-212
packages/uni-components/src/components/navigator/index.vue
packages/uni-components/src/components/navigator/index.vue
+44
-40
packages/uni-h5/dist/uni-h5.cjs.js
packages/uni-h5/dist/uni-h5.cjs.js
+20
-85
packages/uni-h5/dist/uni-h5.es.js
packages/uni-h5/dist/uni-h5.es.js
+20
-85
packages/uni-h5/vite.config.ts
packages/uni-h5/vite.config.ts
+1
-2
未找到文件。
packages/uni-components/src/components/navigator/index.vue
浏览文件 @
f7f4602a
...
...
@@ -2,9 +2,7 @@
<uni-navigator
v-if=
"hoverClass && hoverClass !== 'none'"
:class=
"[hovering ? hoverClass : '']"
@
touchstart=
"_hoverTouchStart"
@
touchend=
"_hoverTouchEnd"
@
touchcancel=
"_hoverTouchCancel"
v-bind=
"binding"
@
click=
"_onClick"
>
<slot
/>
...
...
@@ -14,33 +12,26 @@
</uni-navigator>
</
template
>
<
script
>
import
hover
from
'
../../mixins/hover
'
import
{
useHover
}
from
"
../../helpers/useHover
"
;
const
OPEN_TYPES
=
[
'
navigate
'
,
'
redirect
'
,
'
switchTab
'
,
'
reLaunch
'
,
'
navigateBack
'
,
]
const
OPEN_TYPES
=
[
"
navigate
"
,
"
redirect
"
,
"
switchTab
"
,
"
reLaunch
"
,
"
navigateBack
"
];
export
default
{
name
:
'
Navigator
'
,
mixins
:
[
hover
],
name
:
"
Navigator
"
,
props
:
{
hoverClass
:
{
type
:
String
,
default
:
'
navigator-hover
'
,
default
:
"
navigator-hover
"
,
},
url
:
{
type
:
String
,
default
:
''
,
default
:
""
,
},
openType
:
{
type
:
String
,
default
:
'
navigate
'
,
default
:
"
navigate
"
,
validator
(
value
)
{
return
~
OPEN_TYPES
.
indexOf
(
value
)
return
~
OPEN_TYPES
.
indexOf
(
value
)
;
},
},
delta
:
{
...
...
@@ -49,7 +40,7 @@ export default {
},
hoverStartTime
:
{
type
:
[
Number
,
String
],
default
:
2
0
,
default
:
5
0
,
},
hoverStayTime
:
{
type
:
[
Number
,
String
],
...
...
@@ -57,50 +48,63 @@ export default {
},
exists
:
{
type
:
String
,
default
:
''
,
default
:
""
,
},
hoverStopPropagation
:
{
type
:
Boolean
,
default
:
false
,
},
},
methods
:
{
_onClick
(
$event
)
{
if
(
this
.
openType
!==
'
navigateBack
'
&&
!
this
.
url
)
{
if
(
this
.
openType
!==
"
navigateBack
"
&&
!
this
.
url
)
{
console
.
error
(
'
<navigator/> should have url attribute when using navigateTo, redirectTo, reLaunch or switchTab
'
)
return
"
<navigator/> should have url attribute when using navigateTo, redirectTo, reLaunch or switchTab
"
)
;
return
;
}
switch
(
this
.
openType
)
{
case
'
navigate
'
:
case
"
navigate
"
:
uni
.
navigateTo
({
url
:
this
.
url
,
})
break
case
'
redirect
'
:
})
;
break
;
case
"
redirect
"
:
uni
.
redirectTo
({
url
:
this
.
url
,
exists
:
this
.
exists
,
})
break
case
'
switchTab
'
:
})
;
break
;
case
"
switchTab
"
:
uni
.
switchTab
({
url
:
this
.
url
,
})
break
case
'
reLaunch
'
:
})
;
break
;
case
"
reLaunch
"
:
uni
.
reLaunch
({
url
:
this
.
url
,
})
break
case
'
navigateBack
'
:
})
;
break
;
case
"
navigateBack
"
:
uni
.
navigateBack
({
delta
:
this
.
delta
,
})
break
})
;
break
;
default
:
break
break
;
}
},
},
}
setup
(
props
)
{
const
{
hovering
,
binding
}
=
useHover
(
props
);
return
{
hovering
,
binding
,
};
},
};
</
script
>
packages/uni-h5/dist/uni-h5.cjs.js
浏览文件 @
f7f4602a
...
...
@@ -1206,73 +1206,6 @@ function setupApp(comp) {
}
});
}
var
hover
=
{
data
()
{
return
{
hovering
:
false
};
},
props
:
{
hoverClass
:
{
type
:
String
,
default
:
"
none
"
},
hoverStopPropagation
:
{
type
:
Boolean
,
default
:
false
},
hoverStartTime
:
{
type
:
[
Number
,
String
],
default
:
50
},
hoverStayTime
:
{
type
:
[
Number
,
String
],
default
:
400
}
},
methods
:
{
_hoverTouchStart
(
evt
)
{
if
(
evt
.
_hoverPropagationStopped
)
{
return
;
}
if
(
!
this
.
hoverClass
||
this
.
hoverClass
===
"
none
"
||
this
.
disabled
)
{
return
;
}
if
(
evt
.
touches
.
length
>
1
)
{
return
;
}
if
(
this
.
hoverStopPropagation
)
{
evt
.
_hoverPropagationStopped
=
true
;
}
this
.
_hoverTouch
=
true
;
this
.
_hoverStartTimer
=
setTimeout
(()
=>
{
this
.
hovering
=
true
;
if
(
!
this
.
_hoverTouch
)
{
this
.
_hoverReset
();
}
},
this
.
hoverStartTime
);
},
_hoverTouchEnd
(
evt
)
{
this
.
_hoverTouch
=
false
;
if
(
this
.
hovering
)
{
this
.
_hoverReset
();
}
},
_hoverReset
()
{
requestAnimationFrame
(()
=>
{
clearTimeout
(
this
.
_hoverStayTimer
);
this
.
_hoverStayTimer
=
setTimeout
(()
=>
{
this
.
hovering
=
false
;
},
this
.
hoverStayTime
);
});
},
_hoverTouchCancel
(
evt
)
{
this
.
_hoverTouch
=
false
;
this
.
hovering
=
false
;
clearTimeout
(
this
.
_hoverStartTimer
);
}
}
};
var
subscriber
=
{
mounted
()
{
this
.
_toggleListeners
(
"
subscribe
"
,
this
.
id
);
...
...
@@ -4386,16 +4319,9 @@ function _sfc_render$7(_ctx, _cache, $props, $setup, $data, $options) {
],
16
);
}
_sfc_main$7
.
render
=
_sfc_render$7
;
const
OPEN_TYPES
=
[
"
navigate
"
,
"
redirect
"
,
"
switchTab
"
,
"
reLaunch
"
,
"
navigateBack
"
];
const
OPEN_TYPES
=
[
"
navigate
"
,
"
redirect
"
,
"
switchTab
"
,
"
reLaunch
"
,
"
navigateBack
"
];
const
_sfc_main$6
=
{
name
:
"
Navigator
"
,
mixins
:
[
hover
],
props
:
{
hoverClass
:
{
type
:
String
,
...
...
@@ -4418,7 +4344,7 @@ const _sfc_main$6 = {
},
hoverStartTime
:
{
type
:
[
Number
,
String
],
default
:
2
0
default
:
5
0
},
hoverStayTime
:
{
type
:
[
Number
,
String
],
...
...
@@ -4427,6 +4353,10 @@ const _sfc_main$6 = {
exists
:
{
type
:
String
,
default
:
""
},
hoverStopPropagation
:
{
type
:
Boolean
,
default
:
false
}
},
methods
:
{
...
...
@@ -4464,21 +4394,26 @@ const _sfc_main$6 = {
break
;
}
}
},
setup
(
props2
)
{
const
{
hovering
,
binding
}
=
useHover
(
props2
);
return
{
hovering
,
binding
};
}
};
function
_sfc_render$6
(
_ctx
,
_cache
,
$props
,
$setup
,
$data
,
$options
)
{
return
$props
.
hoverClass
&&
$props
.
hoverClass
!==
"
none
"
?
(
vue
.
openBlock
(),
vue
.
createBlock
(
"
uni-navigator
"
,
{
return
$props
.
hoverClass
&&
$props
.
hoverClass
!==
"
none
"
?
(
vue
.
openBlock
(),
vue
.
createBlock
(
"
uni-navigator
"
,
vue
.
mergeProps
(
{
key
:
0
,
class
:
[
_ctx
.
hovering
?
$props
.
hoverClass
:
""
],
onTouchstart
:
_cache
[
1
]
||
(
_cache
[
1
]
=
(...
args
)
=>
_ctx
.
_hoverTouchStart
&&
_ctx
.
_hoverTouchStart
(...
args
)),
onTouchend
:
_cache
[
2
]
||
(
_cache
[
2
]
=
(...
args
)
=>
_ctx
.
_hoverTouchEnd
&&
_ctx
.
_hoverTouchEnd
(...
args
)),
onTouchcancel
:
_cache
[
3
]
||
(
_cache
[
3
]
=
(...
args
)
=>
_ctx
.
_hoverTouchCancel
&&
_ctx
.
_hoverTouchCancel
(...
args
)),
onClick
:
_cache
[
4
]
||
(
_cache
[
4
]
=
(...
args
)
=>
$options
.
_onClick
&&
$options
.
_onClick
(...
args
))
},
[
class
:
[
$setup
.
hovering
?
$props
.
hoverClass
:
""
]
},
$setup
.
binding
,
{
onClick
:
_cache
[
1
]
||
(
_cache
[
1
]
=
(...
args
)
=>
$options
.
_onClick
&&
$options
.
_onClick
(...
args
))
}),
[
vue
.
renderSlot
(
_ctx
.
$slots
,
"
default
"
)
],
34
))
:
(
vue
.
openBlock
(),
vue
.
createBlock
(
"
uni-navigator
"
,
{
],
16
))
:
(
vue
.
openBlock
(),
vue
.
createBlock
(
"
uni-navigator
"
,
{
key
:
1
,
onClick
:
_cache
[
5
]
||
(
_cache
[
5
]
=
(...
args
)
=>
$options
.
_onClick
&&
$options
.
_onClick
(...
args
))
onClick
:
_cache
[
2
]
||
(
_cache
[
2
]
=
(...
args
)
=>
$options
.
_onClick
&&
$options
.
_onClick
(...
args
))
},
[
vue
.
renderSlot
(
_ctx
.
$slots
,
"
default
"
)
]));
...
...
packages/uni-h5/dist/uni-h5.es.js
浏览文件 @
f7f4602a
...
...
@@ -4794,73 +4794,6 @@ function setupApp(comp) {
}
});
}
var
hover
=
{
data
()
{
return
{
hovering
:
false
};
},
props
:
{
hoverClass
:
{
type
:
String
,
default
:
"
none
"
},
hoverStopPropagation
:
{
type
:
Boolean
,
default
:
false
},
hoverStartTime
:
{
type
:
[
Number
,
String
],
default
:
50
},
hoverStayTime
:
{
type
:
[
Number
,
String
],
default
:
400
}
},
methods
:
{
_hoverTouchStart
(
evt
)
{
if
(
evt
.
_hoverPropagationStopped
)
{
return
;
}
if
(
!
this
.
hoverClass
||
this
.
hoverClass
===
"
none
"
||
this
.
disabled
)
{
return
;
}
if
(
evt
.
touches
.
length
>
1
)
{
return
;
}
if
(
this
.
hoverStopPropagation
)
{
evt
.
_hoverPropagationStopped
=
true
;
}
this
.
_hoverTouch
=
true
;
this
.
_hoverStartTimer
=
setTimeout
(()
=>
{
this
.
hovering
=
true
;
if
(
!
this
.
_hoverTouch
)
{
this
.
_hoverReset
();
}
},
this
.
hoverStartTime
);
},
_hoverTouchEnd
(
evt
)
{
this
.
_hoverTouch
=
false
;
if
(
this
.
hovering
)
{
this
.
_hoverReset
();
}
},
_hoverReset
()
{
requestAnimationFrame
(()
=>
{
clearTimeout
(
this
.
_hoverStayTimer
);
this
.
_hoverStayTimer
=
setTimeout
(()
=>
{
this
.
hovering
=
false
;
},
this
.
hoverStayTime
);
});
},
_hoverTouchCancel
(
evt
)
{
this
.
_hoverTouch
=
false
;
this
.
hovering
=
false
;
clearTimeout
(
this
.
_hoverStartTimer
);
}
}
};
var
subscriber
=
{
mounted
()
{
this
.
_toggleListeners
(
"
subscribe
"
,
this
.
id
);
...
...
@@ -8835,16 +8768,9 @@ function _sfc_render$7(_ctx, _cache, $props, $setup, $data, $options) {
],
16
);
}
_sfc_main$7
.
render
=
_sfc_render$7
;
const
OPEN_TYPES
=
[
"
navigate
"
,
"
redirect
"
,
"
switchTab
"
,
"
reLaunch
"
,
"
navigateBack
"
];
const
OPEN_TYPES
=
[
"
navigate
"
,
"
redirect
"
,
"
switchTab
"
,
"
reLaunch
"
,
"
navigateBack
"
];
const
_sfc_main$6
=
{
name
:
"
Navigator
"
,
mixins
:
[
hover
],
props
:
{
hoverClass
:
{
type
:
String
,
...
...
@@ -8867,7 +8793,7 @@ const _sfc_main$6 = {
},
hoverStartTime
:
{
type
:
[
Number
,
String
],
default
:
2
0
default
:
5
0
},
hoverStayTime
:
{
type
:
[
Number
,
String
],
...
...
@@ -8876,6 +8802,10 @@ const _sfc_main$6 = {
exists
:
{
type
:
String
,
default
:
""
},
hoverStopPropagation
:
{
type
:
Boolean
,
default
:
false
}
},
methods
:
{
...
...
@@ -8913,21 +8843,26 @@ const _sfc_main$6 = {
break
;
}
}
},
setup
(
props2
)
{
const
{
hovering
,
binding
}
=
useHover
(
props2
);
return
{
hovering
,
binding
};
}
};
function
_sfc_render$6
(
_ctx
,
_cache
,
$props
,
$setup
,
$data
,
$options
)
{
return
$props
.
hoverClass
&&
$props
.
hoverClass
!==
"
none
"
?
(
openBlock
(),
createBlock
(
"
uni-navigator
"
,
{
return
$props
.
hoverClass
&&
$props
.
hoverClass
!==
"
none
"
?
(
openBlock
(),
createBlock
(
"
uni-navigator
"
,
mergeProps
(
{
key
:
0
,
class
:
[
_ctx
.
hovering
?
$props
.
hoverClass
:
""
],
onTouchstart
:
_cache
[
1
]
||
(
_cache
[
1
]
=
(...
args
)
=>
_ctx
.
_hoverTouchStart
&&
_ctx
.
_hoverTouchStart
(...
args
)),
onTouchend
:
_cache
[
2
]
||
(
_cache
[
2
]
=
(...
args
)
=>
_ctx
.
_hoverTouchEnd
&&
_ctx
.
_hoverTouchEnd
(...
args
)),
onTouchcancel
:
_cache
[
3
]
||
(
_cache
[
3
]
=
(...
args
)
=>
_ctx
.
_hoverTouchCancel
&&
_ctx
.
_hoverTouchCancel
(...
args
)),
onClick
:
_cache
[
4
]
||
(
_cache
[
4
]
=
(...
args
)
=>
$options
.
_onClick
&&
$options
.
_onClick
(...
args
))
},
[
class
:
[
$setup
.
hovering
?
$props
.
hoverClass
:
""
]
},
$setup
.
binding
,
{
onClick
:
_cache
[
1
]
||
(
_cache
[
1
]
=
(...
args
)
=>
$options
.
_onClick
&&
$options
.
_onClick
(...
args
))
}),
[
renderSlot
(
_ctx
.
$slots
,
"
default
"
)
],
34
))
:
(
openBlock
(),
createBlock
(
"
uni-navigator
"
,
{
],
16
))
:
(
openBlock
(),
createBlock
(
"
uni-navigator
"
,
{
key
:
1
,
onClick
:
_cache
[
5
]
||
(
_cache
[
5
]
=
(...
args
)
=>
$options
.
_onClick
&&
$options
.
_onClick
(...
args
))
onClick
:
_cache
[
2
]
||
(
_cache
[
2
]
=
(...
args
)
=>
$options
.
_onClick
&&
$options
.
_onClick
(...
args
))
},
[
renderSlot
(
_ctx
.
$slots
,
"
default
"
)
]));
...
...
packages/uni-h5/vite.config.ts
浏览文件 @
f7f4602a
...
...
@@ -5,7 +5,6 @@ import vue from '@vitejs/plugin-vue'
import
jscc
from
'
rollup-plugin-jscc
'
import
strip
from
'
@rollup/plugin-strip
'
import
replace
from
'
@rollup/plugin-replace
'
import
minimatch
from
'
minimatch
'
import
{
stripOptions
}
from
'
@dcloudio/uni-cli-shared
'
import
{
isCustomElement
}
from
'
../uni-shared
'
...
...
@@ -40,7 +39,7 @@ const rollupPlugins = [
// 该插件限制了不能以__开头
_NODE_JS_
:
FORMAT
===
'
cjs
'
?
1
:
0
,
},
//
exclude: ['pako.esm.mjs'],
//
忽略 pako 内部条件编译
exclude
:
[
resolve
(
'
../../node_modules/pako/**
'
)],
}),
]
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录