Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
yangkaifeng
uni-app
提交
e2fc7700
U
uni-app
项目概览
yangkaifeng
/
uni-app
与 Fork 源项目一致
Fork自
DCloud / uni-app
通知
3
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,发现更多精彩内容 >>
提交
e2fc7700
编写于
2月 16, 2022
作者:
fxy060608
浏览文件
操作
浏览文件
下载
差异文件
chore: merge
上级
4cf23077
0c0fd7bd
变更
15
展开全部
隐藏空白更改
内联
并排
Showing
15 changed file
with
609 addition
and
160 deletion
+609
-160
packages/uni-app-plus/dist/uni-app-view.umd.js
packages/uni-app-plus/dist/uni-app-view.umd.js
+2
-2
packages/uni-app-plus/dist/uni.runtime.esm.js
packages/uni-app-plus/dist/uni.runtime.esm.js
+9
-9
packages/uni-app-plus/src/helpers/file.ts
packages/uni-app-plus/src/helpers/file.ts
+74
-0
packages/uni-app-plus/src/platform/index.ts
packages/uni-app-plus/src/platform/index.ts
+1
-3
packages/uni-app-plus/src/platform/saveImage.ts
packages/uni-app-plus/src/platform/saveImage.ts
+43
-34
packages/uni-components/dist/components.js
packages/uni-components/dist/components.js
+181
-3
packages/uni-components/src/components/progress.ts
packages/uni-components/src/components/progress.ts
+61
-0
packages/uni-components/src/nvue/components.ts
packages/uni-components/src/nvue/components.ts
+2
-0
packages/uni-components/src/nvue/progress/index.tsx
packages/uni-components/src/nvue/progress/index.tsx
+161
-0
packages/uni-components/src/vue/progress/index.tsx
packages/uni-components/src/vue/progress/index.tsx
+6
-59
packages/uni-h5/dist/uni-h5.cjs.js
packages/uni-h5/dist/uni-h5.cjs.js
+30
-25
packages/uni-h5/dist/uni-h5.es.js
packages/uni-h5/dist/uni-h5.es.js
+30
-25
packages/uni-shared/dist/uni-shared.cjs.js
packages/uni-shared/dist/uni-shared.cjs.js
+3
-0
packages/uni-shared/dist/uni-shared.es.js
packages/uni-shared/dist/uni-shared.es.js
+3
-0
packages/uni-shared/src/tags.ts
packages/uni-shared/src/tags.ts
+3
-0
未找到文件。
packages/uni-app-plus/dist/uni-app-view.umd.js
浏览文件 @
e2fc7700
此差异已折叠。
点击以展开。
packages/uni-app-plus/dist/uni.runtime.esm.js
浏览文件 @
e2fc7700
...
...
@@ -2135,6 +2135,15 @@ function removeMediaQueryObserver({ reqId, component }, _pageId) {
UniServiceJSBridge.unsubscribe(getEventName(reqId));
}
function getFileName(path) {
const array = path.split('/');
return array[array.length - 1];
}
function getExtName(path) {
const array = path.split('.');
return array.length > 1 ? '.' + array[array.length - 1] : '';
}
const DEVICE_FREQUENCY = 200;
const NETWORK_TYPES = [
'unknown',
...
...
@@ -12691,15 +12700,6 @@ const openDocument = defineAsyncApi(API_OPEN_DOCUMENT, ({ filePath, fileType },
plus.runtime.openDocument(getRealPath(filePath), undefined, resolve, errorCallback);
}, OpenDocumentProtocol, OpenDocumentOptions);
function getFileName(path) {
const array = path.split('/');
return array[array.length - 1];
}
function getExtName(path) {
const array = path.split('.');
return array.length > 1 ? '.' + array[array.length - 1] : '';
}
let index$1 = 0;
const SAVED_DIR = 'uniapp_save';
const SAVE_PATH = `_doc/${SAVED_DIR}`;
...
...
packages/uni-app-plus/src/helpers/file.ts
浏览文件 @
e2fc7700
...
...
@@ -7,3 +7,77 @@ export function getExtName(path: string) {
const
array
=
path
.
split
(
'
.
'
)
return
array
.
length
>
1
?
'
.
'
+
array
[
array
.
length
-
1
]
:
''
}
function
getBase64
(
path
:
string
):
Promise
<
string
>
{
return
new
Promise
(
function
(
resolve
,
reject
)
{
// H5+ 沙箱外路径在iOS无法使用 plus.io 读取
function
onError
()
{
const
bitmap
=
new
plus
.
nativeObj
.
Bitmap
!
(
`bitmap_
${
Date
.
now
()}
_
${
Math
.
random
()}
}`
)
bitmap
.
load
(
path
,
function
()
{
resolve
(
bitmap
.
toBase64Data
())
bitmap
.
clear
()
},
function
(
err
)
{
bitmap
.
clear
()
reject
(
err
)
}
)
}
plus
.
io
.
resolveLocalFileSystemURL
(
path
,
function
(
entry
)
{
;(
entry
as
unknown
as
PlusIoFileEntry
).
file
(
function
(
file
)
{
var
fileReader
=
new
plus
.
io
.
FileReader
!
()
fileReader
.
onload
=
function
(
data
)
{
resolve
((
data
.
target
as
unknown
as
PlusIoFileReader
).
result
!
)
}
fileReader
.
onerror
=
onError
fileReader
.
readAsDataURL
(
file
)
},
onError
)
},
onError
)
})
}
function
download
(
url
:
string
):
Promise
<
string
>
{
return
new
Promise
(
function
(
resolve
,
reject
)
{
if
(
url
.
indexOf
(
'
http://
'
)
!==
0
&&
url
.
indexOf
(
'
https://
'
)
!==
0
)
{
resolve
(
url
)
return
}
plus
.
downloader
.
createDownload
(
url
,
{
filename
:
'
_doc/uniapp_temp/download/
'
,
},
function
(
d
,
status
)
{
if
(
status
===
200
)
{
resolve
(
d
.
filename
!
)
}
else
{
reject
(
new
Error
(
'
network fail
'
))
}
}
)
.
start
()
})
}
export
function
getSameOriginUrl
(
url
:
string
)
{
return
download
(
url
).
then
(
function
(
url
)
{
// WKWebView
interface
WindowExt
extends
Window
{
webkit
?:
{
messageHandlers
:
any
}
}
const
g
=
window
as
WindowExt
if
(
g
.
webkit
&&
g
.
webkit
.
messageHandlers
)
{
return
getBase64
(
url
)
}
return
plus
.
io
.
convertLocalFileSystemURL
(
url
)
})
}
packages/uni-app-plus/src/platform/index.ts
浏览文件 @
e2fc7700
...
...
@@ -16,9 +16,7 @@ export {
}
from
'
../service/api/ui/mediaQueryObserver
'
export
{
saveImage
}
from
'
./saveImage
'
export
function
getSameOriginUrl
(
url
:
string
):
Promise
<
string
>
{
return
Promise
.
resolve
(
url
)
}
export
{
getSameOriginUrl
}
from
'
../helpers/file
'
export
{
TEMP_PATH
}
from
'
../service/api/constants
'
export
{
...
...
packages/uni-app-plus/src/platform/saveImage.ts
浏览文件 @
e2fc7700
let
index
=
0
type
Format
=
'
jpg
'
|
'
png
'
|
undefined
export
function
saveImage
(
base64
:
string
,
dataURL
:
string
,
dirname
:
string
,
callback
:
(
error
:
Error
|
null
,
tempFilePath
?:
string
)
=>
void
callback
:
(
error
:
any
,
tempFilePath
?:
string
)
=>
void
)
{
const
id
=
`
${
Date
.
now
()}${
index
++
}
`
const
bitmap
=
new
plus
.
nativeObj
.
Bitmap
!
(
`bitmap
${
id
}
`
)
bitmap
.
loadBase64Data
(
base64
,
function
()
{
const
base64Match
=
base64
.
match
(
/data:image
\/(\S
+
?)
;/
)
||
[
null
,
'
png
'
]
let
format
if
(
base64Match
[
1
])
{
format
=
base64Match
[
1
].
replace
(
'
jpeg
'
,
'
jpg
'
)
as
Format
}
const
tempFilePath
=
`
${
dirname
}
/
${
id
}
.
${
format
}
`
bitmap
.
save
(
tempFilePath
,
const
array
=
dataURL
.
split
(
'
,
'
)
const
scheme
=
array
[
0
]
const
base64
=
array
[
1
]
const
format
=
(
scheme
.
match
(
/data:image
\/(\S
+
?)
;/
)
||
[
''
,
'
png
'
,
])[
1
].
replace
(
'
jpeg
'
,
'
jpg
'
)
const
fileName
=
`
${
id
}
.
${
format
}
`
const
tempFilePath
=
`
${
dirname
}
/
${
fileName
}
`
const
i
=
dirname
.
indexOf
(
'
/
'
)
const
basePath
=
dirname
.
substring
(
0
,
i
)
const
dirPath
=
dirname
.
substring
(
i
+
1
)
plus
.
io
.
resolveLocalFileSystemURL
(
basePath
,
function
(
entry
:
PlusIoDirectoryEntry
)
{
entry
.
getDirectory
(
dirPath
,
{
overwrite
:
true
,
quality
:
100
,
format
,
create
:
true
,
exclusive
:
false
,
},
function
()
{
clear
()
callback
(
null
,
tempFilePath
)
function
(
entry
)
{
entry
.
getFile
(
fileName
,
{
create
:
true
,
exclusive
:
false
,
},
function
(
entry
)
{
entry
.
createWriter
(
function
(
writer
)
{
writer
.
onwrite
=
function
()
{
callback
(
null
,
tempFilePath
)
}
writer
.
onerror
=
callback
writer
.
seek
(
0
)
writer
.
writeAsBinary
(
base64
)
},
callback
)
},
callback
)
},
function
(
error
)
{
clear
()
callback
(
error
)
}
callback
)
},
function
(
error
)
{
clear
()
callback
(
error
)
}
callback
)
function
clear
()
{
bitmap
.
clear
()
}
}
packages/uni-components/dist/components.js
浏览文件 @
e2fc7700
import
{
createElementVNode
,
defineComponent
,
createVNode
,
mergeProps
,
getCurrentInstance
,
provide
,
watch
,
onUnmounted
,
shallowRef
,
reactive
,
watchEffect
,
ref
,
inject
,
onBeforeUnmount
,
computed
,
Text
,
isVNode
,
Fragment
,
onMounted
}
from
"
vue
"
;
import
{
hasOwn
,
extend
,
isPlainObject
}
from
"
@vue/shared
"
;
import
{
cacheStringFunction
}
from
"
@dcloudio/uni-shared
"
;
import
{
extend
,
hasOwn
,
isPlainObject
}
from
"
@vue/shared
"
;
import
{
cacheStringFunction
,
PRIMARY_COLOR
}
from
"
@dcloudio/uni-shared
"
;
const
OPEN_TYPES
=
[
"
navigate
"
,
"
redirect
"
,
...
...
@@ -1751,11 +1751,189 @@ function useMovableViewState(props, trigger, rootRef, setTouchMovableViewContext
};
return
touchStart
;
}
const
FONT_SIZE
=
16
;
const
PROGRESS_VALUES
=
{
activeColor
:
PRIMARY_COLOR
,
backgroundColor
:
"
#EBEBEB
"
,
activeMode
:
"
backwards
"
};
const
progressProps
=
{
percent
:
{
type
:
[
Number
,
String
],
default
:
0
,
validator
(
value
)
{
return
!
isNaN
(
parseFloat
(
value
));
}
},
fontSize
:
{
type
:
[
String
,
Number
],
default
:
FONT_SIZE
},
showInfo
:
{
type
:
[
Boolean
,
String
],
default
:
false
},
strokeWidth
:
{
type
:
[
Number
,
String
],
default
:
6
,
validator
(
value
)
{
return
!
isNaN
(
parseFloat
(
value
));
}
},
color
:
{
type
:
String
,
default
:
PROGRESS_VALUES
.
activeColor
},
activeColor
:
{
type
:
String
,
default
:
PROGRESS_VALUES
.
activeColor
},
backgroundColor
:
{
type
:
String
,
default
:
PROGRESS_VALUES
.
backgroundColor
},
active
:
{
type
:
[
Boolean
,
String
],
default
:
false
},
activeMode
:
{
type
:
String
,
default
:
PROGRESS_VALUES
.
activeMode
},
duration
:
{
type
:
[
Number
,
String
],
default
:
30
,
validator
(
value
)
{
return
!
isNaN
(
parseFloat
(
value
));
}
}
};
const
progressStyles
=
[{
"
uni-progress
"
:
{
flex
:
1
,
flexDirection
:
"
row
"
,
alignItems
:
"
center
"
},
"
uni-progress-bar
"
:
{
flex
:
1
},
"
uni-progress-inner-bar
"
:
{
position
:
"
absolute
"
},
"
uni-progress-info
"
:
{
marginLeft
:
"
15px
"
}
}];
var
Progress
=
defineComponent
({
name
:
"
Progress
"
,
props
:
progressProps
,
styles
:
progressStyles
,
emits
:
[
"
activeend
"
],
setup
(
props
,
{
emit
})
{
const
progressRef
=
ref
(
null
);
const
progressBarRef
=
ref
(
null
);
const
trigger
=
useCustomEvent
(
progressRef
,
emit
);
const
state
=
useProgressState
(
props
);
watch
(()
=>
state
.
realPercent
,
(
newValue
,
oldValue
)
=>
{
state
.
lastPercent
=
oldValue
||
0
;
_activeAnimation
(
state
,
props
,
trigger
);
});
onMounted
(()
=>
{
setTimeout
(()
=>
{
getComponentSize
(
progressBarRef
.
value
).
then
(({
width
})
=>
{
state
.
progressWidth
=
width
||
0
;
_activeAnimation
(
state
,
props
,
trigger
);
});
},
50
);
});
return
()
=>
{
const
{
showInfo
,
fontSize
}
=
props
;
const
{
outerBarStyle
,
innerBarStyle
,
currentPercent
}
=
state
;
return
createVNode
(
"
div
"
,
{
"
ref
"
:
progressRef
,
"
class
"
:
"
uni-progress
"
},
[
createVNode
(
"
div
"
,
{
"
ref
"
:
progressBarRef
,
"
style
"
:
outerBarStyle
,
"
class
"
:
"
uni-progress-bar
"
},
[
createVNode
(
"
div
"
,
{
"
style
"
:
innerBarStyle
,
"
class
"
:
"
uni-progress-inner-bar
"
},
null
)]),
showInfo
?
createNVueTextVNode
(
currentPercent
+
"
%
"
,
{
class
:
"
uni-progress-info
"
,
style
:
{
fontSize
}
})
:
null
]);
};
}
});
function
useProgressState
(
props
)
{
const
currentPercent
=
ref
(
0
);
const
progressWidth
=
ref
(
0
);
const
outerBarStyle
=
computed
(()
=>
({
backgroundColor
:
props
.
backgroundColor
,
height
:
props
.
strokeWidth
}));
const
innerBarStyle
=
computed
(()
=>
{
const
backgroundColor
=
props
.
color
!==
PROGRESS_VALUES
.
activeColor
&&
props
.
activeColor
===
PROGRESS_VALUES
.
activeColor
?
props
.
color
:
props
.
activeColor
;
return
{
width
:
currentPercent
.
value
*
progressWidth
.
value
/
100
,
height
:
props
.
strokeWidth
,
backgroundColor
};
});
const
realPercent
=
computed
(()
=>
{
let
realValue
=
parseFloat
(
props
.
percent
);
realValue
<
0
&&
(
realValue
=
0
);
realValue
>
100
&&
(
realValue
=
100
);
return
realValue
;
});
const
state
=
reactive
({
outerBarStyle
,
innerBarStyle
,
realPercent
,
currentPercent
,
strokeTimer
:
0
,
lastPercent
:
0
,
progressWidth
});
return
state
;
}
function
_activeAnimation
(
state
,
props
,
trigger
)
{
state
.
strokeTimer
&&
clearInterval
(
state
.
strokeTimer
);
if
(
props
.
active
)
{
state
.
currentPercent
=
props
.
activeMode
===
PROGRESS_VALUES
.
activeMode
?
0
:
state
.
lastPercent
;
state
.
strokeTimer
=
setInterval
(()
=>
{
if
(
state
.
currentPercent
+
1
>
state
.
realPercent
)
{
state
.
currentPercent
=
state
.
realPercent
;
state
.
strokeTimer
&&
clearInterval
(
state
.
strokeTimer
);
trigger
(
"
activeend
"
,
{});
}
else
{
state
.
currentPercent
+=
1
;
}
},
parseFloat
(
props
.
duration
));
}
else
{
state
.
currentPercent
=
state
.
realPercent
;
}
}
var
components
=
{
Navigator
,
Label
,
Button
,
MovableArea
,
MovableView
MovableView
,
Progress
};
export
{
components
as
default
};
packages/uni-components/src/components/progress.ts
0 → 100644
浏览文件 @
e2fc7700
import
{
PRIMARY_COLOR
}
from
'
@dcloudio/uni-shared
'
const
FONT_SIZE
=
16
export
const
PROGRESS_VALUES
=
{
activeColor
:
PRIMARY_COLOR
,
backgroundColor
:
'
#EBEBEB
'
,
activeMode
:
'
backwards
'
,
}
export
const
progressProps
=
{
percent
:
{
type
:
[
Number
,
String
],
default
:
0
,
validator
(
value
:
number
|
string
)
{
return
!
isNaN
(
parseFloat
(
value
as
string
))
},
},
fontSize
:
{
type
:
[
String
,
Number
],
default
:
FONT_SIZE
,
},
showInfo
:
{
type
:
[
Boolean
,
String
],
default
:
false
,
},
strokeWidth
:
{
type
:
[
Number
,
String
],
default
:
6
,
validator
(
value
:
number
|
string
)
{
return
!
isNaN
(
parseFloat
(
value
as
string
))
},
},
color
:
{
type
:
String
,
default
:
PROGRESS_VALUES
.
activeColor
,
},
activeColor
:
{
type
:
String
,
default
:
PROGRESS_VALUES
.
activeColor
,
},
backgroundColor
:
{
type
:
String
,
default
:
PROGRESS_VALUES
.
backgroundColor
,
},
active
:
{
type
:
[
Boolean
,
String
],
default
:
false
,
},
activeMode
:
{
type
:
String
,
default
:
PROGRESS_VALUES
.
activeMode
,
},
duration
:
{
type
:
[
Number
,
String
],
default
:
30
,
validator
(
value
:
number
|
string
)
{
return
!
isNaN
(
parseFloat
(
value
as
string
))
},
},
}
packages/uni-components/src/nvue/components.ts
浏览文件 @
e2fc7700
...
...
@@ -3,10 +3,12 @@ import Label from './label'
import
Button
from
'
./button
'
import
MovableArea
from
'
./movable-area
'
import
MovableView
from
'
./movable-view
'
import
Progress
from
'
./progress
'
export
default
{
Navigator
,
Label
,
Button
,
MovableArea
,
MovableView
,
Progress
,
}
packages/uni-components/src/nvue/progress/index.tsx
0 → 100644
浏览文件 @
e2fc7700
import
{
defineComponent
,
Ref
,
ref
,
reactive
,
watch
,
computed
,
onMounted
,
ExtractPropTypes
,
}
from
'
vue
'
import
{
useCustomEvent
,
EmitEvent
,
CustomEventTrigger
,
}
from
'
../../helpers/useNVueEvent
'
import
{
getComponentSize
}
from
'
../helpers
'
import
{
createNVueTextVNode
}
from
'
../utils
'
import
{
PROGRESS_VALUES
,
progressProps
}
from
'
../../components/progress
'
const
progressStyles
:
Record
<
string
,
Record
<
string
,
string
|
number
>>
[]
=
[
{
'
uni-progress
'
:
{
flex
:
1
,
flexDirection
:
'
row
'
,
alignItems
:
'
center
'
,
},
'
uni-progress-bar
'
:
{
flex
:
1
,
},
'
uni-progress-inner-bar
'
:
{
position
:
'
absolute
'
,
},
'
uni-progress-info
'
:
{
marginLeft
:
'
15px
'
,
},
},
]
type
ProgressProps
=
ExtractPropTypes
<
typeof
progressProps
>
type
ProgerssState
=
ReturnType
<
typeof
useProgressState
>
export
default
defineComponent
({
name
:
'
Progress
'
,
props
:
progressProps
,
styles
:
progressStyles
,
emits
:
[
'
activeend
'
],
setup
(
props
,
{
emit
})
{
const
progressRef
:
Ref
<
HTMLElement
|
null
>
=
ref
(
null
)
const
progressBarRef
:
Ref
<
HTMLElement
|
null
>
=
ref
(
null
)
const
trigger
=
useCustomEvent
<
EmitEvent
<
typeof
emit
>>
(
progressRef
,
emit
)
const
state
=
useProgressState
(
props
)
watch
(
()
=>
state
.
realPercent
,
(
newValue
,
oldValue
)
=>
{
state
.
lastPercent
=
oldValue
||
0
_activeAnimation
(
state
,
props
,
trigger
)
}
)
onMounted
(()
=>
{
setTimeout
(()
=>
{
getComponentSize
(
progressBarRef
.
value
!
).
then
(({
width
})
=>
{
state
.
progressWidth
=
width
||
0
_activeAnimation
(
state
,
props
,
trigger
)
})
},
50
)
})
return
()
=>
{
const
{
showInfo
,
fontSize
}
=
props
const
{
outerBarStyle
,
innerBarStyle
,
currentPercent
}
=
state
return
(
<
div
ref
=
{
progressRef
}
class
=
"uni-progress"
>
<
div
ref
=
{
progressBarRef
}
style
=
{
outerBarStyle
}
class
=
"uni-progress-bar"
>
<
div
style
=
{
innerBarStyle
}
class
=
"uni-progress-inner-bar"
></
div
>
</
div
>
{
showInfo
?
createNVueTextVNode
(
currentPercent
+
'
%
'
,
{
class
:
'
uni-progress-info
'
,
style
:
{
fontSize
,
},
})
:
null
}
</
div
>
)
}
},
})
function
useProgressState
(
props
:
ProgressProps
)
{
const
currentPercent
=
ref
<
number
>
(
0
)
const
progressWidth
=
ref
<
number
>
(
0
)
const
outerBarStyle
=
computed
(()
=>
({
backgroundColor
:
props
.
backgroundColor
,
height
:
props
.
strokeWidth
,
}))
const
innerBarStyle
=
computed
(()
=>
{
// 兼容下不推荐的属性,activeColor 优先级高于 color。
// nvue 不支持百分比,宽度必须为数值。
const
backgroundColor
=
props
.
color
!==
PROGRESS_VALUES
.
activeColor
&&
props
.
activeColor
===
PROGRESS_VALUES
.
activeColor
?
props
.
color
:
props
.
activeColor
return
{
width
:
(
currentPercent
.
value
*
progressWidth
.
value
)
/
100
,
height
:
props
.
strokeWidth
,
backgroundColor
:
backgroundColor
,
}
})
const
realPercent
=
computed
(()
=>
{
// 确保最终计算时使用的是 Number 类型的值,并且在有效范围内。
let
realValue
=
parseFloat
(
props
.
percent
as
string
)
realValue
<
0
&&
(
realValue
=
0
)
realValue
>
100
&&
(
realValue
=
100
)
return
realValue
})
const
state
=
reactive
({
outerBarStyle
,
innerBarStyle
,
realPercent
,
currentPercent
,
strokeTimer
:
0
,
lastPercent
:
0
,
progressWidth
,
})
return
state
}
function
_activeAnimation
(
state
:
ProgerssState
,
props
:
ProgressProps
,
trigger
:
CustomEventTrigger
)
{
state
.
strokeTimer
&&
clearInterval
(
state
.
strokeTimer
)
if
(
props
.
active
)
{
state
.
currentPercent
=
props
.
activeMode
===
PROGRESS_VALUES
.
activeMode
?
0
:
state
.
lastPercent
state
.
strokeTimer
=
setInterval
(()
=>
{
if
(
state
.
currentPercent
+
1
>
state
.
realPercent
)
{
state
.
currentPercent
=
state
.
realPercent
state
.
strokeTimer
&&
clearInterval
(
state
.
strokeTimer
)
trigger
(
'
activeend
'
,
{})
}
else
{
state
.
currentPercent
+=
1
}
},
parseFloat
(
props
.
duration
as
string
))
as
unknown
as
number
}
else
{
state
.
currentPercent
=
state
.
realPercent
}
}
packages/uni-components/src/vue/progress/index.tsx
浏览文件 @
e2fc7700
import
{
PRIMARY_COLOR
}
from
'
@dcloudio/uni-shared
'
import
{
ref
,
reactive
,
watch
,
computed
,
ExtractPropTypes
}
from
'
vue
'
import
{
defineBuiltInComponent
}
from
'
../../helpers/component
'
const
VALUES
=
{
activeColor
:
PRIMARY_COLOR
,
backgroundColor
:
'
#EBEBEB
'
,
activeMode
:
'
backwards
'
,
}
const
props
=
{
percent
:
{
type
:
[
Number
,
String
],
default
:
0
,
validator
(
value
:
number
|
string
)
{
return
!
isNaN
(
parseFloat
(
value
as
string
))
},
},
showInfo
:
{
type
:
[
Boolean
,
String
],
default
:
false
,
},
strokeWidth
:
{
type
:
[
Number
,
String
],
default
:
6
,
validator
(
value
:
number
|
string
)
{
return
!
isNaN
(
parseFloat
(
value
as
string
))
},
},
color
:
{
type
:
String
,
default
:
VALUES
.
activeColor
,
},
activeColor
:
{
type
:
String
,
default
:
VALUES
.
activeColor
,
},
backgroundColor
:
{
type
:
String
,
default
:
VALUES
.
backgroundColor
,
},
active
:
{
type
:
[
Boolean
,
String
],
default
:
false
,
},
activeMode
:
{
type
:
String
,
default
:
VALUES
.
activeMode
,
},
duration
:
{
type
:
[
Number
,
String
],
default
:
30
,
validator
(
value
:
number
|
string
)
{
return
!
isNaN
(
parseFloat
(
value
as
string
))
},
},
}
import
{
PROGRESS_VALUES
,
progressProps
}
from
'
../../components/progress
'
type
ProgressProps
=
ExtractPropTypes
<
typeof
props
>
type
ProgressProps
=
ExtractPropTypes
<
typeof
pro
gressPro
ps
>
type
ProgerssState
=
ReturnType
<
typeof
useProgressState
>
export
default
/*#__PURE__*/
defineBuiltInComponent
({
name
:
'
Progress
'
,
props
,
props
:
progressProps
,
setup
(
props
)
{
const
state
=
useProgressState
(
props
)
...
...
@@ -107,8 +54,8 @@ function useProgressState(props: ProgressProps) {
const
innerBarStyle
=
computed
(()
=>
{
// 兼容下不推荐的属性,activeColor 优先级高于 color。
const
backgroundColor
=
props
.
color
!==
VALUES
.
activeColor
&&
props
.
activeColor
===
VALUES
.
activeColor
props
.
color
!==
PROGRESS_
VALUES
.
activeColor
&&
props
.
activeColor
===
PROGRESS_
VALUES
.
activeColor
?
props
.
color
:
props
.
activeColor
return
`width:
${
currentPercent
.
value
}
%;background-color:
${
backgroundColor
}
`
...
...
@@ -136,7 +83,7 @@ function useProgressState(props: ProgressProps) {
function
_activeAnimation
(
state
:
ProgerssState
,
props
:
ProgressProps
)
{
if
(
props
.
active
)
{
state
.
currentPercent
=
props
.
activeMode
===
VALUES
.
activeMode
?
0
:
state
.
lastPercent
props
.
activeMode
===
PROGRESS_
VALUES
.
activeMode
?
0
:
state
.
lastPercent
state
.
strokeTimer
=
setInterval
(()
=>
{
if
(
state
.
currentPercent
+
1
>
state
.
realPercent
)
{
state
.
currentPercent
=
state
.
realPercent
...
...
packages/uni-h5/dist/uni-h5.cjs.js
浏览文件 @
e2fc7700
...
...
@@ -1626,7 +1626,7 @@ function getTempCanvas(width = 0, height = 0) {
tempCanvas
.
height
=
height
;
return
tempCanvas
;
}
const
props$
q
=
{
const
props$
p
=
{
canvasId
:
{
type
:
String
,
default
:
""
...
...
@@ -1646,7 +1646,7 @@ var index$B = /* @__PURE__ */ defineBuiltInComponent({
compatConfig
:
{
MODE
:
3
},
props
:
props$
q
,
props
:
props$
p
,
computed
:
{
id
()
{
return
this
.
canvasId
;
...
...
@@ -2104,7 +2104,7 @@ function useMethods(props2, canvasRef, actionsWaiting) {
});
}
const
uniCheckGroupKey
=
PolySymbol
(
process
.
env
.
NODE_ENV
!==
"
production
"
?
"
uniCheckGroup
"
:
"
ucg
"
);
const
props$
p
=
{
const
props$
o
=
{
name
:
{
type
:
String
,
default
:
""
...
...
@@ -2112,7 +2112,7 @@ const props$p = {
};
var
index$A
=
/* @__PURE__ */
defineBuiltInComponent
({
name
:
"
CheckboxGroup
"
,
props
:
props$
p
,
props
:
props$
o
,
emits
:
[
"
change
"
],
setup
(
props2
,
{
emit
:
emit2
,
...
...
@@ -2164,7 +2164,7 @@ function useProvideCheckGroup(props2, trigger) {
}
return
getFieldsValue
;
}
const
props$
o
=
{
const
props$
n
=
{
checked
:
{
type
:
[
Boolean
,
String
],
default
:
false
...
...
@@ -2188,7 +2188,7 @@ const props$o = {
};
var
index$z
=
/* @__PURE__ */
defineBuiltInComponent
({
name
:
"
Checkbox
"
,
props
:
props$
o
,
props
:
props$
n
,
setup
(
props2
,
{
slots
})
{
...
...
@@ -2255,7 +2255,7 @@ function useCheckboxInject(checkboxChecked, checkboxValue, reset) {
let
resetTimer
;
function
iosHideKeyboard
()
{
}
const
props$
n
=
{
const
props$
m
=
{
cursorSpacing
:
{
type
:
[
Number
,
String
],
default
:
0
...
...
@@ -2427,7 +2427,7 @@ function useQuill(props2, rootRef, trigger) {
useContextInfo
();
useSubscribe
();
}
const
props$
m
=
/* @__PURE__ */
shared
.
extend
({},
props$n
,
{
const
props$
l
=
/* @__PURE__ */
shared
.
extend
({},
props$m
,
{
id
:
{
type
:
String
,
default
:
""
...
...
@@ -2455,7 +2455,7 @@ const props$m = /* @__PURE__ */ shared.extend({}, props$n, {
});
var
index$y
=
/* @__PURE__ */
defineBuiltInComponent
({
name
:
"
Editor
"
,
props
:
props$
m
,
props
:
props$
l
,
emit
:
[
"
ready
"
,
"
focus
"
,
"
blur
"
,
"
input
"
,
"
statuschange
"
,
...
emit$1
],
setup
(
props2
,
{
emit
:
emit2
...
...
@@ -2541,7 +2541,7 @@ var index$x = /* @__PURE__ */ defineBuiltInComponent({
};
}
});
const
props$
l
=
{
const
props$
k
=
{
src
:
{
type
:
String
,
default
:
""
...
...
@@ -2580,7 +2580,7 @@ const IMAGE_MODES = {
};
var
index$w
=
/* @__PURE__ */
defineBuiltInComponent
({
name
:
"
Image
"
,
props
:
props$
l
,
props
:
props$
k
,
setup
(
props2
,
{
emit
:
emit2
})
{
...
...
@@ -2829,7 +2829,7 @@ const UniViewJSBridgeSubscribe = function() {
function
getValueString
(
value
)
{
return
value
===
null
?
""
:
String
(
value
);
}
const
props$
k
=
/* @__PURE__ */
shared
.
extend
({},
{
const
props$
j
=
/* @__PURE__ */
shared
.
extend
({},
{
name
:
{
type
:
String
,
default
:
""
...
...
@@ -2898,7 +2898,7 @@ const props$k = /* @__PURE__ */ shared.extend({}, {
type
:
Boolean
,
default
:
false
}
},
props$
n
);
},
props$
m
);
const
emit
=
[
"
input
"
,
"
focus
"
,
...
...
@@ -3093,7 +3093,7 @@ function useField(props2, rootRef, emit2, beforeInput) {
trigger
};
}
const
props$
j
=
/* @__PURE__ */
shared
.
extend
({},
props$k
,
{
const
props$
i
=
/* @__PURE__ */
shared
.
extend
({},
props$j
,
{
placeholderClass
:
{
type
:
String
,
default
:
"
input-placeholder
"
...
...
@@ -3105,7 +3105,7 @@ const props$j = /* @__PURE__ */ shared.extend({}, props$k, {
});
var
Input
=
/* @__PURE__ */
defineBuiltInComponent
({
name
:
"
Input
"
,
props
:
props$
j
,
props
:
props$
i
,
emits
:
[
"
confirm
"
,
...
emit
],
setup
(
props2
,
{
emit
:
emit2
...
...
@@ -4550,12 +4550,13 @@ var PickerViewColumn = /* @__PURE__ */ defineBuiltInComponent({
};
}
});
const
VALUES
=
{
const
FONT_SIZE
=
16
;
const
PROGRESS_VALUES
=
{
activeColor
:
uniShared
.
PRIMARY_COLOR
,
backgroundColor
:
"
#EBEBEB
"
,
activeMode
:
"
backwards
"
};
const
pro
ps$i
=
{
const
pro
gressProps
=
{
percent
:
{
type
:
[
Number
,
String
],
default
:
0
,
...
...
@@ -4563,6 +4564,10 @@ const props$i = {
return
!
isNaN
(
parseFloat
(
value
));
}
},
fontSize
:
{
type
:
[
String
,
Number
],
default
:
FONT_SIZE
},
showInfo
:
{
type
:
[
Boolean
,
String
],
default
:
false
...
...
@@ -4576,15 +4581,15 @@ const props$i = {
},
color
:
{
type
:
String
,
default
:
VALUES
.
activeColor
default
:
PROGRESS_
VALUES
.
activeColor
},
activeColor
:
{
type
:
String
,
default
:
VALUES
.
activeColor
default
:
PROGRESS_
VALUES
.
activeColor
},
backgroundColor
:
{
type
:
String
,
default
:
VALUES
.
backgroundColor
default
:
PROGRESS_
VALUES
.
backgroundColor
},
active
:
{
type
:
[
Boolean
,
String
],
...
...
@@ -4592,7 +4597,7 @@ const props$i = {
},
activeMode
:
{
type
:
String
,
default
:
VALUES
.
activeMode
default
:
PROGRESS_
VALUES
.
activeMode
},
duration
:
{
type
:
[
Number
,
String
],
...
...
@@ -4604,7 +4609,7 @@ const props$i = {
};
var
index$s
=
/* @__PURE__ */
defineBuiltInComponent
({
name
:
"
Progress
"
,
props
:
pro
ps$i
,
props
:
pro
gressProps
,
setup
(
props2
)
{
const
state
=
useProgressState
(
props2
);
_activeAnimation
(
state
,
props2
);
...
...
@@ -4640,7 +4645,7 @@ function useProgressState(props2) {
const
currentPercent
=
vue
.
ref
(
0
);
const
outerBarStyle
=
vue
.
computed
(()
=>
`background-color:
${
props2
.
backgroundColor
}
; height:
${
props2
.
strokeWidth
}
px;`
);
const
innerBarStyle
=
vue
.
computed
(()
=>
{
const
backgroundColor
=
props2
.
color
!==
VALUES
.
activeColor
&&
props2
.
activeColor
===
VALUES
.
activeColor
?
props2
.
color
:
props2
.
activeColor
;
const
backgroundColor
=
props2
.
color
!==
PROGRESS_VALUES
.
activeColor
&&
props2
.
activeColor
===
PROGRESS_
VALUES
.
activeColor
?
props2
.
color
:
props2
.
activeColor
;
return
`width:
${
currentPercent
.
value
}
%;background-color:
${
backgroundColor
}
`
;
});
const
realPercent
=
vue
.
computed
(()
=>
{
...
...
@@ -4661,7 +4666,7 @@ function useProgressState(props2) {
}
function
_activeAnimation
(
state
,
props2
)
{
if
(
props2
.
active
)
{
state
.
currentPercent
=
props2
.
activeMode
===
VALUES
.
activeMode
?
0
:
state
.
lastPercent
;
state
.
currentPercent
=
props2
.
activeMode
===
PROGRESS_
VALUES
.
activeMode
?
0
:
state
.
lastPercent
;
state
.
strokeTimer
=
setInterval
(()
=>
{
if
(
state
.
currentPercent
+
1
>
state
.
realPercent
)
{
state
.
currentPercent
=
state
.
realPercent
;
...
...
@@ -6370,7 +6375,7 @@ var index$j = /* @__PURE__ */ defineBuiltInComponent({
};
}
});
const
props$9
=
/* @__PURE__ */
shared
.
extend
({},
props$
k
,
{
const
props$9
=
/* @__PURE__ */
shared
.
extend
({},
props$
j
,
{
placeholderClass
:
{
type
:
String
,
default
:
"
input-placeholder
"
...
...
packages/uni-h5/dist/uni-h5.es.js
浏览文件 @
e2fc7700
...
...
@@ -6416,7 +6416,7 @@ function getTempCanvas(width = 0, height = 0) {
tempCanvas.height = height;
return tempCanvas;
}
const props$
x
= {
const props$
w
= {
canvasId: {
type: String,
default: ""
...
...
@@ -6436,7 +6436,7 @@ var index$w = /* @__PURE__ */ defineBuiltInComponent({
compatConfig: {
MODE: 3
},
props: props$
x
,
props: props$
w
,
computed: {
id() {
return this.canvasId;
...
...
@@ -6897,7 +6897,7 @@ function useMethods(props2, canvasRef, actionsWaiting) {
});
}
const uniCheckGroupKey = PolySymbol(process.env.NODE_ENV !== "production" ? "uniCheckGroup" : "ucg");
const props$
w
= {
const props$
v
= {
name: {
type: String,
default: ""
...
...
@@ -6905,7 +6905,7 @@ const props$w = {
};
var index$v = /* @__PURE__ */ defineBuiltInComponent({
name: "CheckboxGroup",
props: props$
w
,
props: props$
v
,
emits: ["change"],
setup(props2, {
emit: emit2,
...
...
@@ -6957,7 +6957,7 @@ function useProvideCheckGroup(props2, trigger) {
}
return getFieldsValue;
}
const props$
v
= {
const props$
u
= {
checked: {
type: [Boolean, String],
default: false
...
...
@@ -6981,7 +6981,7 @@ const props$v = {
};
var index$u = /* @__PURE__ */ defineBuiltInComponent({
name: "Checkbox",
props: props$
v
,
props: props$
u
,
setup(props2, {
slots
}) {
...
...
@@ -7058,7 +7058,7 @@ function useCheckboxInject(checkboxChecked, checkboxValue, reset) {
let resetTimer;
function iosHideKeyboard() {
}
const props$
u
= {
const props$
t
= {
cursorSpacing: {
type: [Number, String],
default: 0
...
...
@@ -7835,7 +7835,7 @@ function useQuill(props2, rootRef, trigger) {
}
}, id2, true);
}
const props$
t = /* @__PURE__ */ extend({}, props$u
, {
const props$
s = /* @__PURE__ */ extend({}, props$t
, {
id: {
type: String,
default: ""
...
...
@@ -7863,7 +7863,7 @@ const props$t = /* @__PURE__ */ extend({}, props$u, {
});
var index$t = /* @__PURE__ */ defineBuiltInComponent({
name: "Editor",
props: props$
t
,
props: props$
s
,
emit: ["ready", "focus", "blur", "input", "statuschange", ...emit$1],
setup(props2, {
emit: emit2
...
...
@@ -7950,7 +7950,7 @@ var index$s = /* @__PURE__ */ defineBuiltInComponent({
};
}
});
const props$
s
= {
const props$
r
= {
src: {
type: String,
default: ""
...
...
@@ -7989,7 +7989,7 @@ const IMAGE_MODES = {
};
var index$r = /* @__PURE__ */ defineBuiltInComponent({
name: "Image",
props: props$
s
,
props: props$
r
,
setup(props2, {
emit: emit2
}) {
...
...
@@ -8303,7 +8303,7 @@ const UniViewJSBridgeSubscribe = function() {
function getValueString(value) {
return value === null ? "" : String(value);
}
const props$
r
= /* @__PURE__ */ extend({}, {
const props$
q
= /* @__PURE__ */ extend({}, {
name: {
type: String,
default: ""
...
...
@@ -8372,7 +8372,7 @@ const props$r = /* @__PURE__ */ extend({}, {
type: Boolean,
default: false
}
}, props$
u
);
}, props$
t
);
const emit = [
"input",
"focus",
...
...
@@ -8576,7 +8576,7 @@ function useField(props2, rootRef, emit2, beforeInput) {
trigger
};
}
const props$
q = /* @__PURE__ */ extend({}, props$r
, {
const props$
p = /* @__PURE__ */ extend({}, props$q
, {
placeholderClass: {
type: String,
default: "input-placeholder"
...
...
@@ -8588,7 +8588,7 @@ const props$q = /* @__PURE__ */ extend({}, props$r, {
});
var Input = /* @__PURE__ */ defineBuiltInComponent({
name: "Input",
props: props$
q
,
props: props$
p
,
emits: ["confirm", ...emit],
setup(props2, {
emit: emit2
...
...
@@ -11136,12 +11136,13 @@ var PickerViewColumn = /* @__PURE__ */ defineBuiltInComponent({
};
}
});
const VALUES = {
const FONT_SIZE = 16;
const PROGRESS_VALUES = {
activeColor: PRIMARY_COLOR,
backgroundColor: "#EBEBEB",
activeMode: "backwards"
};
const pro
ps$p
= {
const pro
gressProps
= {
percent: {
type: [Number, String],
default: 0,
...
...
@@ -11149,6 +11150,10 @@ const props$p = {
return !isNaN(parseFloat(value));
}
},
fontSize: {
type: [String, Number],
default: FONT_SIZE
},
showInfo: {
type: [Boolean, String],
default: false
...
...
@@ -11162,15 +11167,15 @@ const props$p = {
},
color: {
type: String,
default: VALUES.activeColor
default:
PROGRESS_
VALUES.activeColor
},
activeColor: {
type: String,
default: VALUES.activeColor
default:
PROGRESS_
VALUES.activeColor
},
backgroundColor: {
type: String,
default: VALUES.backgroundColor
default:
PROGRESS_
VALUES.backgroundColor
},
active: {
type: [Boolean, String],
...
...
@@ -11178,7 +11183,7 @@ const props$p = {
},
activeMode: {
type: String,
default: VALUES.activeMode
default:
PROGRESS_
VALUES.activeMode
},
duration: {
type: [Number, String],
...
...
@@ -11190,7 +11195,7 @@ const props$p = {
};
var index$p = /* @__PURE__ */ defineBuiltInComponent({
name: "Progress",
props: pro
ps$p
,
props: pro
gressProps
,
setup(props2) {
const state2 = useProgressState(props2);
_activeAnimation(state2, props2);
...
...
@@ -11226,7 +11231,7 @@ function useProgressState(props2) {
const currentPercent = ref(0);
const outerBarStyle = computed(() => `background-color: ${props2.backgroundColor}; height: ${props2.strokeWidth}px;`);
const innerBarStyle = computed(() => {
const backgroundColor = props2.color !==
VALUES.activeColor && props2.activeColor ===
VALUES.activeColor ? props2.color : props2.activeColor;
const backgroundColor = props2.color !==
PROGRESS_VALUES.activeColor && props2.activeColor === PROGRESS_
VALUES.activeColor ? props2.color : props2.activeColor;
return `width: ${currentPercent.value}%;background-color: ${backgroundColor}`;
});
const realPercent = computed(() => {
...
...
@@ -11247,7 +11252,7 @@ function useProgressState(props2) {
}
function _activeAnimation(state2, props2) {
if (props2.active) {
state2.currentPercent = props2.activeMode === VALUES.activeMode ? 0 : state2.lastPercent;
state2.currentPercent = props2.activeMode ===
PROGRESS_
VALUES.activeMode ? 0 : state2.lastPercent;
state2.strokeTimer = setInterval(() => {
if (state2.currentPercent + 1 > state2.realPercent) {
state2.currentPercent = state2.realPercent;
...
...
@@ -13280,7 +13285,7 @@ var index$j = /* @__PURE__ */ defineBuiltInComponent({
};
}
});
const props$g = /* @__PURE__ */ extend({}, props$
r
, {
const props$g = /* @__PURE__ */ extend({}, props$
q
, {
placeholderClass: {
type: String,
default: "input-placeholder"
...
...
packages/uni-shared/dist/uni-shared.cjs.js
浏览文件 @
e2fc7700
...
...
@@ -104,6 +104,7 @@ const NVUE_BUILT_IN_TAGS = [
'
timepicker
'
,
'
marquee
'
,
'
countdown
'
,
'
dc-switch
'
,
];
const
NVUE_U_BUILT_IN_TAGS
=
[
'
text
'
,
...
...
@@ -113,6 +114,8 @@ const NVUE_U_BUILT_IN_TAGS = [
'
video
'
,
'
web-view
'
,
'
slider
'
,
'
ad
'
,
'
ad-draw
'
,
];
function
isBuiltInComponent
(
tag
)
{
// h5 平台会被转换为 v-uni-
...
...
packages/uni-shared/dist/uni-shared.es.js
浏览文件 @
e2fc7700
...
...
@@ -100,6 +100,7 @@ const NVUE_BUILT_IN_TAGS = [
'
timepicker
'
,
'
marquee
'
,
'
countdown
'
,
'
dc-switch
'
,
];
const
NVUE_U_BUILT_IN_TAGS
=
[
'
text
'
,
...
...
@@ -109,6 +110,8 @@ const NVUE_U_BUILT_IN_TAGS = [
'
video
'
,
'
web-view
'
,
'
slider
'
,
'
ad
'
,
'
ad-draw
'
,
];
function
isBuiltInComponent
(
tag
)
{
// h5 平台会被转换为 v-uni-
...
...
packages/uni-shared/src/tags.ts
浏览文件 @
e2fc7700
...
...
@@ -103,6 +103,7 @@ export const NVUE_BUILT_IN_TAGS = [
'
timepicker
'
,
'
marquee
'
,
'
countdown
'
,
'
dc-switch
'
,
]
export
const
NVUE_U_BUILT_IN_TAGS
=
[
...
...
@@ -113,6 +114,8 @@ export const NVUE_U_BUILT_IN_TAGS = [
'
video
'
,
'
web-view
'
,
'
slider
'
,
'
ad
'
,
'
ad-draw
'
,
]
export
function
isBuiltInComponent
(
tag
:
string
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录