Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
小浣熊撸代码
uni-app
提交
ab57f32e
U
uni-app
项目概览
小浣熊撸代码
/
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,发现更多精彩内容 >>
提交
ab57f32e
编写于
6月 23, 2021
作者:
M
mehaotian
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat(App): previewImage
上级
b12422d2
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
99 addition
and
0 deletion
+99
-0
packages/uni-app-plus/src/service/api/index.ts
packages/uni-app-plus/src/service/api/index.ts
+1
-0
packages/uni-app-plus/src/service/api/media/previewImage.ts
packages/uni-app-plus/src/service/api/media/previewImage.ts
+98
-0
未找到文件。
packages/uni-app-plus/src/service/api/index.ts
浏览文件 @
ab57f32e
...
...
@@ -7,6 +7,7 @@ export * from './device/accelerometer'
export
*
from
'
./media/getImageInfo
'
export
*
from
'
./media/getVideoInfo
'
export
*
from
'
./media/previewImage
'
export
*
from
'
./keyboard/keyboard
'
...
...
packages/uni-app-plus/src/service/api/media/previewImage.ts
0 → 100644
浏览文件 @
ab57f32e
import
{
API_PREVIEW_IMAGE
,
API_TYPE_PREVIEW_IMAGE
,
defineAsyncApi
,
PreviewImageProtocol
,
PreviewImageOptions
,
}
from
'
@dcloudio/uni-api
'
import
{
getRealPath
}
from
'
@dcloudio/uni-platform
'
import
{
isPlainObject
}
from
'
@vue/shared
'
import
{
initI18nChooseImageMsgsOnce
,
useI18n
}
from
'
@dcloudio/uni-core
'
export
const
previewImage
=
<
API_TYPE_PREVIEW_IMAGE
>
defineAsyncApi
(
API_PREVIEW_IMAGE
,
(
{
current
=
0
,
indicator
=
'
number
'
,
loop
=
false
,
urls
,
longPressActions
},
{
resolve
,
reject
}
)
=>
{
initI18nChooseImageMsgsOnce
()
const
{
t
}
=
useI18n
()
urls
=
urls
.
map
((
url
)
=>
getRealPath
(
url
))
const
index
=
Number
(
current
)
if
(
isNaN
(
index
))
{
current
=
urls
.
indexOf
(
getRealPath
(
current
as
string
))
current
=
current
<
0
?
0
:
current
}
else
{
current
=
index
}
plus
.
nativeUI
.
previewImage
(
urls
,
{
current
,
indicator
,
loop
,
onLongPress
:
function
(
res
:
any
)
{
let
itemList
=
[]
let
itemColor
=
''
const
hasLongPressActions
=
longPressActions
&&
isPlainObject
(
longPressActions
)
if
(
!
hasLongPressActions
)
{
itemList
=
[
t
(
'
uni.previewImage.button.save
'
)]
itemColor
=
'
#000000
'
}
else
{
itemList
=
longPressActions
!
.
itemList
?
longPressActions
!
.
itemList
:
[]
itemColor
=
longPressActions
!
.
itemColor
?
longPressActions
!
.
itemColor
:
'
#000000
'
}
const
options
=
{
buttons
:
itemList
.
map
((
item
)
=>
({
title
:
item
,
color
:
itemColor
,
})),
cancel
:
t
(
'
uni.previewImage.cancel
'
),
}
plus
.
nativeUI
.
actionSheet
(
options
,
(
e
)
=>
{
if
(
e
.
index
>
0
)
{
if
(
hasLongPressActions
)
{
typeof
longPressActions
!
.
success
===
'
function
'
&&
longPressActions
!
.
success
({
tapIndex
:
e
.
index
-
1
,
index
:
res
.
index
,
})
return
}
plus
.
gallery
.
save
(
res
.
url
,
()
=>
{
plus
.
nativeUI
.
toast
(
t
(
'
uni.previewImage.save.success
'
))
},
function
()
{
plus
.
nativeUI
.
toast
(
t
(
'
uni.previewImage.save.fail
'
))
}
)
}
else
if
(
hasLongPressActions
)
{
typeof
longPressActions
!
.
fail
===
'
function
'
&&
longPressActions
!
.
fail
({
errMsg
:
'
showActionSheet:fail cancel
'
,
})
}
})
},
})
resolve
()
},
PreviewImageProtocol
,
PreviewImageOptions
)
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录