Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
uni-app
提交
e83c65a5
U
uni-app
项目概览
DCloud
/
uni-app
6 个月 前同步成功
通知
750
Star
38709
Fork
3642
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
8
列表
看板
标记
里程碑
合并请求
1
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
U
uni-app
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
8
Issue
8
列表
看板
标记
里程碑
合并请求
1
合并请求
1
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
e83c65a5
编写于
6月 20, 2024
作者:
D
DCloud_LXH
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix: input 在给 value 赋值后输入小数点会清空输入框
上级
7a92b5a7
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
320 addition
and
101 deletion
+320
-101
packages/uni-components/src/vue/input/index.tsx
packages/uni-components/src/vue/input/index.tsx
+72
-35
packages/uni-h5/dist-x/uni-h5.cjs.js
packages/uni-h5/dist-x/uni-h5.cjs.js
+51
-14
packages/uni-h5/dist-x/uni-h5.es.js
packages/uni-h5/dist-x/uni-h5.es.js
+61
-16
packages/uni-h5/dist/uni-h5.cjs.js
packages/uni-h5/dist/uni-h5.cjs.js
+57
-17
packages/uni-h5/dist/uni-h5.es.js
packages/uni-h5/dist/uni-h5.es.js
+67
-19
packages/uni-h5/src/platform/index.ts
packages/uni-h5/src/platform/index.ts
+12
-0
未找到文件。
packages/uni-components/src/vue/input/index.tsx
浏览文件 @
e83c65a5
import
{
extend
,
hyphenate
}
from
'
@vue/shared
'
import
{
type
ComputedRef
,
type
ExtractPropTypes
,
type
HTMLAttributes
,
type
Ref
,
computed
,
...
...
@@ -31,38 +33,71 @@ function resolveDigitDecimalPoint(
event
:
InputEvent
,
cache
:
Ref
<
string
>
,
state
:
State
,
input
:
HTMLInputElement
input
:
HTMLInputElement
,
resetCache
?:
ResetCache
)
{
if
((
event
as
InputEvent
).
data
===
'
.
'
)
{
// 解决可重复输入小数点的问题
if
(
cache
.
value
.
slice
(
-
1
)
===
'
.
'
)
{
state
.
value
=
input
.
value
=
cache
.
value
=
cache
.
value
.
slice
(
0
,
-
1
)
return
false
}
else
if
(
cache
.
value
.
includes
(
'
.
'
))
{
state
.
value
=
input
.
value
=
cache
.
value
return
false
}
if
(
cache
.
value
&&
!
cache
.
value
.
includes
(
'
.
'
))
{
cache
.
value
+=
'
.
'
return
false
}
}
else
if
((
event
as
InputEvent
).
inputType
===
'
deleteContentBackward
'
)
{
// ios 16 无法删除小数
if
(
(
__PLATFORM__
===
'
app
'
&&
plus
.
os
.
name
===
'
iOS
'
&&
plus
.
os
.
version
&&
parseInt
(
plus
.
os
.
version
)
===
16
)
||
(
__PLATFORM__
===
'
h5
'
&&
navigator
.
userAgent
.
includes
(
'
iPhone OS 16
'
))
)
{
if
(
cache
.
value
.
slice
(
-
2
,
-
1
)
===
'
.
'
)
{
cache
.
value
=
state
.
value
=
input
.
value
=
cache
.
value
.
slice
(
0
,
-
2
)
return
true
if
(
cache
.
value
)
{
if
((
event
as
InputEvent
).
data
===
'
.
'
)
{
// 解决可重复输入小数点的问题
if
(
cache
.
value
.
slice
(
-
1
)
===
'
.
'
)
{
state
.
value
=
input
.
value
=
cache
.
value
=
cache
.
value
.
slice
(
0
,
-
1
)
return
false
}
if
(
cache
.
value
&&
!
cache
.
value
.
includes
(
'
.
'
))
{
cache
.
value
+=
'
.
'
if
(
resetCache
)
{
resetCache
.
fn
=
()
=>
{
state
.
value
=
input
.
value
=
cache
.
value
=
cache
.
value
.
slice
(
0
,
-
1
)
input
.
removeEventListener
(
'
blur
'
,
resetCache
.
fn
!
)
}
input
.
addEventListener
(
'
blur
'
,
resetCache
.
fn
)
}
return
false
}
}
else
if
((
event
as
InputEvent
).
inputType
===
'
deleteContentBackward
'
)
{
// ios 16 无法删除小数
if
(
(
__PLATFORM__
===
'
app
'
&&
plus
.
os
.
name
===
'
iOS
'
&&
plus
.
os
.
version
&&
parseInt
(
plus
.
os
.
version
)
===
16
)
||
(
__PLATFORM__
===
'
h5
'
&&
navigator
.
userAgent
.
includes
(
'
iPhone OS 16
'
))
)
{
if
(
cache
.
value
.
slice
(
-
2
,
-
1
)
===
'
.
'
)
{
cache
.
value
=
state
.
value
=
input
.
value
=
cache
.
value
.
slice
(
0
,
-
2
)
return
true
}
}
}
}
}
type
Props
=
ExtractPropTypes
<
typeof
props
>
type
ResetCache
=
{
fn
:
(()
=>
void
)
|
null
}
function
useCache
(
props
:
Props
,
type
:
ComputedRef
<
string
>
)
{
if
(
type
.
value
===
'
number
'
)
{
const
value
=
props
.
modelValue
??
props
.
value
const
cache
=
ref
(
typeof
value
!==
'
undefined
'
?
value
.
toLocaleString
()
:
''
)
watch
(
()
=>
props
.
modelValue
,
(
value
)
=>
{
cache
.
value
=
typeof
value
!==
'
undefined
'
?
value
.
toLocaleString
()
:
''
}
)
watch
(
()
=>
props
.
value
,
(
value
)
=>
{
cache
.
value
=
typeof
value
!==
'
undefined
'
?
value
.
toLocaleString
()
:
''
}
)
return
cache
}
else
{
return
ref
(
''
)
}
}
export
class
UniInputElement
extends
UniElement
{
focus
(
options
?:
FocusOptions
|
undefined
):
void
{
this
.
querySelector
(
'
input
'
)?.
focus
(
options
)
...
...
@@ -116,8 +151,8 @@ export default /*#__PURE__*/ defineBuiltInComponent({
:
0
return
AUTOCOMPLETES
[
index
]
})
let
cache
=
ref
(
''
)
let
resetCache
:
(()
=>
void
)
|
null
let
cache
=
useCache
(
props
,
type
)
let
resetCache
:
ResetCache
=
{
fn
:
null
}
const
rootRef
:
Ref
<
HTMLElement
|
null
>
=
ref
(
null
)
const
{
fieldRef
,
state
,
scopedAttrsState
,
fixDisabledColor
,
trigger
}
=
useField
(
props
,
rootRef
,
emit
,
(
event
,
state
)
=>
{
...
...
@@ -125,9 +160,9 @@ export default /*#__PURE__*/ defineBuiltInComponent({
if
(
type
.
value
===
'
number
'
)
{
// 数字类型输入错误时无法获取具体的值,自定义校验和纠正。
if
(
resetCache
)
{
input
.
removeEventListener
(
'
blur
'
,
resetCache
)
resetCache
=
null
if
(
resetCache
.
fn
)
{
input
.
removeEventListener
(
'
blur
'
,
resetCache
.
fn
)
resetCache
.
fn
=
null
}
if
(
input
.
validity
&&
!
input
.
validity
.
valid
)
{
if
(
...
...
@@ -138,10 +173,10 @@ export default /*#__PURE__*/ defineBuiltInComponent({
)
{
cache
.
value
=
'
-
'
state
.
value
=
''
resetCache
=
()
=>
{
resetCache
.
fn
=
()
=>
{
cache
.
value
=
input
.
value
=
''
}
input
.
addEventListener
(
'
blur
'
,
resetCache
)
input
.
addEventListener
(
'
blur
'
,
resetCache
.
fn
)
return
false
}
// 处理小数点
...
...
@@ -149,7 +184,8 @@ export default /*#__PURE__*/ defineBuiltInComponent({
event
as
InputEvent
,
cache
,
state
,
input
input
,
resetCache
)
if
(
typeof
res
===
'
boolean
'
)
return
res
cache
.
value
=
...
...
@@ -164,7 +200,8 @@ export default /*#__PURE__*/ defineBuiltInComponent({
event
as
InputEvent
,
cache
,
state
,
input
input
,
resetCache
)
if
(
typeof
res
===
'
boolean
'
)
return
res
...
...
packages/uni-h5/dist-x/uni-h5.cjs.js
浏览文件 @
e83c65a5
...
...
@@ -3544,14 +3544,49 @@ const props$k = /* @__PURE__ */ shared.extend({}, props$l, {
default
:
""
}
});
function
resolveDigitDecimalPoint
(
event
,
cache
,
state
,
input
)
{
if
(
event
.
data
===
"
.
"
)
{
if
(
cache
.
value
)
{
cache
.
value
+=
"
.
"
;
return
false
;
function
resolveDigitDecimalPoint
(
event
,
cache
,
state
,
input
,
resetCache
)
{
if
(
cache
.
value
)
{
if
(
event
.
data
===
"
.
"
)
{
if
(
cache
.
value
.
slice
(
-
1
)
===
"
.
"
)
{
state
.
value
=
input
.
value
=
cache
.
value
=
cache
.
value
.
slice
(
0
,
-
1
);
return
false
;
}
if
(
cache
.
value
&&
!
cache
.
value
.
includes
(
"
.
"
))
{
cache
.
value
+=
"
.
"
;
if
(
resetCache
)
{
resetCache
.
fn
=
()
=>
{
state
.
value
=
input
.
value
=
cache
.
value
=
cache
.
value
.
slice
(
0
,
-
1
);
input
.
removeEventListener
(
"
blur
"
,
resetCache
.
fn
);
};
input
.
addEventListener
(
"
blur
"
,
resetCache
.
fn
);
}
return
false
;
}
}
else
if
(
event
.
inputType
===
"
deleteContentBackward
"
)
{
if
(
navigator
.
userAgent
.
includes
(
"
iPhone OS 16
"
))
{
if
(
cache
.
value
.
slice
(
-
2
,
-
1
)
===
"
.
"
)
{
cache
.
value
=
state
.
value
=
input
.
value
=
cache
.
value
.
slice
(
0
,
-
2
);
return
true
;
}
}
}
}
}
function
useCache
(
props2
,
type
)
{
if
(
type
.
value
===
"
number
"
)
{
const
value
=
props2
.
modelValue
??
props2
.
value
;
const
cache
=
vue
.
ref
(
typeof
value
!==
"
undefined
"
?
value
.
toLocaleString
()
:
""
);
vue
.
watch
(()
=>
props2
.
modelValue
,
(
value2
)
=>
{
cache
.
value
=
typeof
value2
!==
"
undefined
"
?
value2
.
toLocaleString
()
:
""
;
});
vue
.
watch
(()
=>
props2
.
value
,
(
value2
)
=>
{
cache
.
value
=
typeof
value2
!==
"
undefined
"
?
value2
.
toLocaleString
()
:
""
;
});
return
cache
;
}
else
{
return
vue
.
ref
(
""
);
}
}
const
Input
=
/* @__PURE__ */
defineBuiltInComponent
({
name
:
"
Input
"
,
props
:
props$k
,
...
...
@@ -3588,8 +3623,10 @@ const Input = /* @__PURE__ */ defineBuiltInComponent({
const
index2
=
camelizeIndex
!==
-
1
?
camelizeIndex
:
kebabCaseIndex
!==
-
1
?
kebabCaseIndex
:
0
;
return
AUTOCOMPLETES
[
index2
];
});
let
cache
=
vue
.
ref
(
""
);
let
resetCache
;
let
cache
=
useCache
(
props2
,
type
);
let
resetCache
=
{
fn
:
null
};
const
rootRef
=
vue
.
ref
(
null
);
const
{
fieldRef
,
...
...
@@ -3600,27 +3637,27 @@ const Input = /* @__PURE__ */ defineBuiltInComponent({
}
=
useField
(
props2
,
rootRef
,
emit2
,
(
event
,
state2
)
=>
{
const
input
=
event
.
target
;
if
(
type
.
value
===
"
number
"
)
{
if
(
resetCache
)
{
input
.
removeEventListener
(
"
blur
"
,
resetCache
);
resetCache
=
null
;
if
(
resetCache
.
fn
)
{
input
.
removeEventListener
(
"
blur
"
,
resetCache
.
fn
);
resetCache
.
fn
=
null
;
}
if
(
input
.
validity
&&
!
input
.
validity
.
valid
)
{
if
((
!
cache
.
value
||
!
input
.
value
)
&&
event
.
data
===
"
-
"
||
cache
.
value
[
0
]
===
"
-
"
&&
event
.
inputType
===
"
deleteContentBackward
"
)
{
cache
.
value
=
"
-
"
;
state2
.
value
=
""
;
resetCache
=
()
=>
{
resetCache
.
fn
=
()
=>
{
cache
.
value
=
input
.
value
=
""
;
};
input
.
addEventListener
(
"
blur
"
,
resetCache
);
input
.
addEventListener
(
"
blur
"
,
resetCache
.
fn
);
return
false
;
}
const
res
=
resolveDigitDecimalPoint
(
event
,
cache
);
const
res
=
resolveDigitDecimalPoint
(
event
,
cache
,
state2
,
input
,
resetCache
);
if
(
typeof
res
===
"
boolean
"
)
return
res
;
cache
.
value
=
state2
.
value
=
input
.
value
=
cache
.
value
===
"
-
"
?
""
:
cache
.
value
;
return
false
;
}
else
{
const
res
=
resolveDigitDecimalPoint
(
event
,
cache
);
const
res
=
resolveDigitDecimalPoint
(
event
,
cache
,
state2
,
input
,
resetCache
);
if
(
typeof
res
===
"
boolean
"
)
return
res
;
cache
.
value
=
input
.
value
;
...
...
packages/uni-h5/dist-x/uni-h5.es.js
浏览文件 @
e83c65a5
...
...
@@ -3382,6 +3382,7 @@ function useKeyboard$1(props2, elRef, trigger) {
(el) => el && initKeyboard(el)
);
}
const TEMP_PATH = "";
function findElem(vm) {
return vm.$el;
}
...
...
@@ -5007,6 +5008,13 @@ class TextMetrics {
this.width = width;
}
}
const getTempPath = () => {
let _TEMP_PATH = TEMP_PATH;
if (!__PLUS__) {
typeof getEnv !== "undefined" && (_TEMP_PATH = getEnv().TEMP_PATH);
}
return _TEMP_PATH;
};
class CanvasContext {
constructor(id2, pageId) {
this.id = id2;
...
...
@@ -5678,7 +5686,7 @@ const canvasToTempFilePath = /* @__PURE__ */ defineAsyncApi(
reject();
return;
}
const dirname = `${TEMP_PATH
}/canvas`;
let dirname = `${getTempPath()
}/canvas`;
operateCanvas(
canvasId,
pageId,
...
...
@@ -8047,7 +8055,6 @@ function removeMediaQueryObserver({ reqId, component }, _pageId) {
delete mediaQueryObservers[reqId];
}
}
const TEMP_PATH = "";
const files = {};
function urlToFile(url, local) {
const file = files[url];
...
...
@@ -8146,6 +8153,7 @@ function initLaunchOptions({
extend(enterOptions, launchOptions);
return extend({}, launchOptions);
}
const getEnv = () => ({ TEMP_PATH, CACHE_PATH: "", USER_DATA_PATH: "" });
var startTag = /^<([-A-Za-z0-9_]+)((?:\s+[a-zA-Z_:][-a-zA-Z0-9_:.]*(?:\s*=\s*(?:(?:"[^"]*")|(?:'[^']*')|[^>\s]+))?)*)\s*(\/?)>/;
var endTag = /^<\/([-A-Za-z0-9_]+)[^>]*>/;
var attr = /([a-zA-Z_:][-a-zA-Z0-9_:.]*)(?:\s*=\s*(?:(?:"((?:\\.|[^"])*)")|(?:'((?:\\.|[^'])*)')|([^>\s]+)))?/g;
...
...
@@ -9892,14 +9900,49 @@ const props$r = /* @__PURE__ */ extend({}, props$s, {
default: ""
}
});
function resolveDigitDecimalPoint(event, cache, state2, input) {
if (event.data === ".") {
if (cache.value) {
cache.value += ".";
return false;
function resolveDigitDecimalPoint(event, cache, state2, input, resetCache) {
if (cache.value) {
if (event.data === ".") {
if (cache.value.slice(-1) === ".") {
state2.value = input.value = cache.value = cache.value.slice(0, -1);
return false;
}
if (cache.value && !cache.value.includes(".")) {
cache.value += ".";
if (resetCache) {
resetCache.fn = () => {
state2.value = input.value = cache.value = cache.value.slice(0, -1);
input.removeEventListener("blur", resetCache.fn);
};
input.addEventListener("blur", resetCache.fn);
}
return false;
}
} else if (event.inputType === "deleteContentBackward") {
if (navigator.userAgent.includes("iPhone OS 16")) {
if (cache.value.slice(-2, -1) === ".") {
cache.value = state2.value = input.value = cache.value.slice(0, -2);
return true;
}
}
}
}
}
function useCache(props2, type) {
if (type.value === "number") {
const value = props2.modelValue ?? props2.value;
const cache = ref(typeof value !== "undefined" ? value.toLocaleString() : "");
watch(() => props2.modelValue, (value2) => {
cache.value = typeof value2 !== "undefined" ? value2.toLocaleString() : "";
});
watch(() => props2.value, (value2) => {
cache.value = typeof value2 !== "undefined" ? value2.toLocaleString() : "";
});
return cache;
} else {
return ref("");
}
}
class UniInputElement extends UniElement {
focus(options) {
var _a;
...
...
@@ -9946,8 +9989,10 @@ const Input = /* @__PURE__ */ defineBuiltInComponent({
const index2 = camelizeIndex !== -1 ? camelizeIndex : kebabCaseIndex !== -1 ? kebabCaseIndex : 0;
return AUTOCOMPLETES[index2];
});
let cache = ref("");
let resetCache;
let cache = useCache(props2, type);
let resetCache = {
fn: null
};
const rootRef = ref(null);
const {
fieldRef,
...
...
@@ -9958,27 +10003,27 @@ const Input = /* @__PURE__ */ defineBuiltInComponent({
} = useField(props2, rootRef, emit2, (event, state22) => {
const input = event.target;
if (type.value === "number") {
if (resetCache) {
input.removeEventListener("blur", resetCache);
resetCache = null;
if (resetCache
.fn
) {
input.removeEventListener("blur", resetCache
.fn
);
resetCache
.fn
= null;
}
if (input.validity && !input.validity.valid) {
if ((!cache.value || !input.value) && event.data === "-" || cache.value[0] === "-" && event.inputType === "deleteContentBackward") {
cache.value = "-";
state22.value = "";
resetCache = () => {
resetCache
.fn
= () => {
cache.value = input.value = "";
};
input.addEventListener("blur", resetCache);
input.addEventListener("blur", resetCache
.fn
);
return false;
}
const res = resolveDigitDecimalPoint(event, cache);
const res = resolveDigitDecimalPoint(event, cache
, state22, input, resetCache
);
if (typeof res === "boolean")
return res;
cache.value = state22.value = input.value = cache.value === "-" ? "" : cache.value;
return false;
} else {
const res = resolveDigitDecimalPoint(event, cache);
const res = resolveDigitDecimalPoint(event, cache
, state22, input, resetCache
);
if (typeof res === "boolean")
return res;
cache.value = input.value;
...
...
packages/uni-h5/dist/uni-h5.cjs.js
浏览文件 @
e83c65a5
...
...
@@ -2080,9 +2080,9 @@ function useMethods(props2, canvasRef, actionsWaiting) {
if
(
image
)
{
c2d
.
drawImage
.
apply
(
c2d
,
// @ts-
ignore
// @ts-
expect-error
[
image
].
concat
(
// @ts-
ignore
// @ts-
expect-error
[...
otherData
.
slice
(
4
,
8
)],
[...
otherData
.
slice
(
0
,
4
)]
)
...
...
@@ -2189,6 +2189,9 @@ function useMethods(props2, canvasRef, actionsWaiting) {
destWidth
=
Math
.
round
(
width
*
_pixelRatio
.
value
);
destHeight
=
Math
.
round
(
height
*
_pixelRatio
.
value
);
}
else
if
(
!
destWidth
)
{
if
(
!
destHeight
)
{
destHeight
=
Math
.
round
(
height
*
_pixelRatio
.
value
);
}
destWidth
=
Math
.
round
(
width
/
height
*
destHeight
);
}
else
if
(
!
destHeight
)
{
destHeight
=
Math
.
round
(
height
/
width
*
destWidth
);
...
...
@@ -2290,7 +2293,7 @@ function useMethods(props2, canvasRef, actionsWaiting) {
type
:
fileType
,
quality
});
if
(
!
res
.
data
||
!
res
.
data
.
length
)
{
if
(
res
.
errMsg
)
{
resolve
({
errMsg
:
res
.
errMsg
.
replace
(
"
canvasPutImageData
"
,
"
toTempFilePath
"
)
});
...
...
@@ -3514,14 +3517,49 @@ const props$j = /* @__PURE__ */ shared.extend({}, props$k, {
default
:
""
}
});
function
resolveDigitDecimalPoint
(
event
,
cache
,
state
,
input
)
{
if
(
event
.
data
===
"
.
"
)
{
if
(
cache
.
value
)
{
cache
.
value
+=
"
.
"
;
return
false
;
function
resolveDigitDecimalPoint
(
event
,
cache
,
state
,
input
,
resetCache
)
{
if
(
cache
.
value
)
{
if
(
event
.
data
===
"
.
"
)
{
if
(
cache
.
value
.
slice
(
-
1
)
===
"
.
"
)
{
state
.
value
=
input
.
value
=
cache
.
value
=
cache
.
value
.
slice
(
0
,
-
1
);
return
false
;
}
if
(
cache
.
value
&&
!
cache
.
value
.
includes
(
"
.
"
))
{
cache
.
value
+=
"
.
"
;
if
(
resetCache
)
{
resetCache
.
fn
=
()
=>
{
state
.
value
=
input
.
value
=
cache
.
value
=
cache
.
value
.
slice
(
0
,
-
1
);
input
.
removeEventListener
(
"
blur
"
,
resetCache
.
fn
);
};
input
.
addEventListener
(
"
blur
"
,
resetCache
.
fn
);
}
return
false
;
}
}
else
if
(
event
.
inputType
===
"
deleteContentBackward
"
)
{
if
(
navigator
.
userAgent
.
includes
(
"
iPhone OS 16
"
))
{
if
(
cache
.
value
.
slice
(
-
2
,
-
1
)
===
"
.
"
)
{
cache
.
value
=
state
.
value
=
input
.
value
=
cache
.
value
.
slice
(
0
,
-
2
);
return
true
;
}
}
}
}
}
function
useCache
(
props2
,
type
)
{
if
(
type
.
value
===
"
number
"
)
{
const
value
=
props2
.
modelValue
??
props2
.
value
;
const
cache
=
vue
.
ref
(
typeof
value
!==
"
undefined
"
?
value
.
toLocaleString
()
:
""
);
vue
.
watch
(()
=>
props2
.
modelValue
,
(
value2
)
=>
{
cache
.
value
=
typeof
value2
!==
"
undefined
"
?
value2
.
toLocaleString
()
:
""
;
});
vue
.
watch
(()
=>
props2
.
value
,
(
value2
)
=>
{
cache
.
value
=
typeof
value2
!==
"
undefined
"
?
value2
.
toLocaleString
()
:
""
;
});
return
cache
;
}
else
{
return
vue
.
ref
(
""
);
}
}
const
Input
=
/* @__PURE__ */
defineBuiltInComponent
({
name
:
"
Input
"
,
props
:
props$j
,
...
...
@@ -3558,8 +3596,10 @@ const Input = /* @__PURE__ */ defineBuiltInComponent({
const
index2
=
camelizeIndex
!==
-
1
?
camelizeIndex
:
kebabCaseIndex
!==
-
1
?
kebabCaseIndex
:
0
;
return
AUTOCOMPLETES
[
index2
];
});
let
cache
=
vue
.
ref
(
""
);
let
resetCache
;
let
cache
=
useCache
(
props2
,
type
);
let
resetCache
=
{
fn
:
null
};
const
rootRef
=
vue
.
ref
(
null
);
const
{
fieldRef
,
...
...
@@ -3570,27 +3610,27 @@ const Input = /* @__PURE__ */ defineBuiltInComponent({
}
=
useField
(
props2
,
rootRef
,
emit2
,
(
event
,
state2
)
=>
{
const
input
=
event
.
target
;
if
(
type
.
value
===
"
number
"
)
{
if
(
resetCache
)
{
input
.
removeEventListener
(
"
blur
"
,
resetCache
);
resetCache
=
null
;
if
(
resetCache
.
fn
)
{
input
.
removeEventListener
(
"
blur
"
,
resetCache
.
fn
);
resetCache
.
fn
=
null
;
}
if
(
input
.
validity
&&
!
input
.
validity
.
valid
)
{
if
((
!
cache
.
value
||
!
input
.
value
)
&&
event
.
data
===
"
-
"
||
cache
.
value
[
0
]
===
"
-
"
&&
event
.
inputType
===
"
deleteContentBackward
"
)
{
cache
.
value
=
"
-
"
;
state2
.
value
=
""
;
resetCache
=
()
=>
{
resetCache
.
fn
=
()
=>
{
cache
.
value
=
input
.
value
=
""
;
};
input
.
addEventListener
(
"
blur
"
,
resetCache
);
input
.
addEventListener
(
"
blur
"
,
resetCache
.
fn
);
return
false
;
}
const
res
=
resolveDigitDecimalPoint
(
event
,
cache
);
const
res
=
resolveDigitDecimalPoint
(
event
,
cache
,
state2
,
input
,
resetCache
);
if
(
typeof
res
===
"
boolean
"
)
return
res
;
cache
.
value
=
state2
.
value
=
input
.
value
=
cache
.
value
===
"
-
"
?
""
:
cache
.
value
;
return
false
;
}
else
{
const
res
=
resolveDigitDecimalPoint
(
event
,
cache
);
const
res
=
resolveDigitDecimalPoint
(
event
,
cache
,
state2
,
input
,
resetCache
);
if
(
typeof
res
===
"
boolean
"
)
return
res
;
cache
.
value
=
input
.
value
;
...
...
packages/uni-h5/dist/uni-h5.es.js
浏览文件 @
e83c65a5
...
...
@@ -2353,6 +2353,7 @@ const index$x = /* @__PURE__ */ defineBuiltInComponent({
};
}
});
const TEMP_PATH = "";
function findElem(vm) {
return vm.$el;
}
...
...
@@ -3968,6 +3969,13 @@ class TextMetrics {
this.width = width;
}
}
const getTempPath = () => {
let _TEMP_PATH = TEMP_PATH;
if (!__PLUS__) {
typeof getEnv !== "undefined" && (_TEMP_PATH = getEnv().TEMP_PATH);
}
return _TEMP_PATH;
};
class CanvasContext {
constructor(id2, pageId) {
this.id = id2;
...
...
@@ -4639,7 +4647,7 @@ const canvasToTempFilePath = /* @__PURE__ */ defineAsyncApi(
reject();
return;
}
const dirname = `${TEMP_PATH
}/canvas`;
let dirname = `${getTempPath()
}/canvas`;
operateCanvas(
canvasId,
pageId,
...
...
@@ -7010,7 +7018,6 @@ function removeMediaQueryObserver({ reqId, component }, _pageId) {
function saveImage(base64, dirname, callback) {
callback(null, base64);
}
const TEMP_PATH = "";
const files = {};
function urlToFile(url, local) {
const file = files[url];
...
...
@@ -7121,6 +7128,7 @@ const inflateRaw = (...args) => {
};
const deflateRaw = (...args) => {
};
const getEnv = () => ({ TEMP_PATH, CACHE_PATH: "", USER_DATA_PATH: "" });
const ResizeSensor = /* @__PURE__ */ defineBuiltInComponent({
name: "ResizeSensor",
props: {
...
...
@@ -7607,9 +7615,9 @@ function useMethods(props2, canvasRef, actionsWaiting) {
if (image2) {
c2d.drawImage.apply(
c2d,
// @ts-
ignore
// @ts-
expect-error
[image2].concat(
// @ts-
ignore
// @ts-
expect-error
[...otherData.slice(4, 8)],
[...otherData.slice(0, 4)]
)
...
...
@@ -7716,6 +7724,9 @@ function useMethods(props2, canvasRef, actionsWaiting) {
destWidth = Math.round(width * _pixelRatio.value);
destHeight = Math.round(height * _pixelRatio.value);
} else if (!destWidth) {
if (!destHeight) {
destHeight = Math.round(height * _pixelRatio.value);
}
destWidth = Math.round(width / height * destHeight);
} else if (!destHeight) {
destHeight = Math.round(height / width * destWidth);
...
...
@@ -7817,7 +7828,7 @@ function useMethods(props2, canvasRef, actionsWaiting) {
type: fileType,
quality
});
if (
!res.data || !res.data.length
) {
if (
res.errMsg
) {
resolve({
errMsg: res.errMsg.replace("canvasPutImageData", "toTempFilePath")
});
...
...
@@ -9765,14 +9776,49 @@ const props$q = /* @__PURE__ */ extend({}, props$r, {
default: ""
}
});
function resolveDigitDecimalPoint(event, cache, state2, input) {
if (event.data === ".") {
if (cache.value) {
cache.value += ".";
return false;
function resolveDigitDecimalPoint(event, cache, state2, input, resetCache) {
if (cache.value) {
if (event.data === ".") {
if (cache.value.slice(-1) === ".") {
state2.value = input.value = cache.value = cache.value.slice(0, -1);
return false;
}
if (cache.value && !cache.value.includes(".")) {
cache.value += ".";
if (resetCache) {
resetCache.fn = () => {
state2.value = input.value = cache.value = cache.value.slice(0, -1);
input.removeEventListener("blur", resetCache.fn);
};
input.addEventListener("blur", resetCache.fn);
}
return false;
}
} else if (event.inputType === "deleteContentBackward") {
if (navigator.userAgent.includes("iPhone OS 16")) {
if (cache.value.slice(-2, -1) === ".") {
cache.value = state2.value = input.value = cache.value.slice(0, -2);
return true;
}
}
}
}
}
function useCache(props2, type) {
if (type.value === "number") {
const value = props2.modelValue ?? props2.value;
const cache = ref(typeof value !== "undefined" ? value.toLocaleString() : "");
watch(() => props2.modelValue, (value2) => {
cache.value = typeof value2 !== "undefined" ? value2.toLocaleString() : "";
});
watch(() => props2.value, (value2) => {
cache.value = typeof value2 !== "undefined" ? value2.toLocaleString() : "";
});
return cache;
} else {
return ref("");
}
}
const Input = /* @__PURE__ */ defineBuiltInComponent({
name: "Input",
props: props$q,
...
...
@@ -9809,8 +9855,10 @@ const Input = /* @__PURE__ */ defineBuiltInComponent({
const index2 = camelizeIndex !== -1 ? camelizeIndex : kebabCaseIndex !== -1 ? kebabCaseIndex : 0;
return AUTOCOMPLETES[index2];
});
let cache = ref("");
let resetCache;
let cache = useCache(props2, type);
let resetCache = {
fn: null
};
const rootRef = ref(null);
const {
fieldRef,
...
...
@@ -9821,27 +9869,27 @@ const Input = /* @__PURE__ */ defineBuiltInComponent({
} = useField(props2, rootRef, emit2, (event, state22) => {
const input = event.target;
if (type.value === "number") {
if (resetCache) {
input.removeEventListener("blur", resetCache);
resetCache = null;
if (resetCache
.fn
) {
input.removeEventListener("blur", resetCache
.fn
);
resetCache
.fn
= null;
}
if (input.validity && !input.validity.valid) {
if ((!cache.value || !input.value) && event.data === "-" || cache.value[0] === "-" && event.inputType === "deleteContentBackward") {
cache.value = "-";
state22.value = "";
resetCache = () => {
resetCache
.fn
= () => {
cache.value = input.value = "";
};
input.addEventListener("blur", resetCache);
input.addEventListener("blur", resetCache
.fn
);
return false;
}
const res = resolveDigitDecimalPoint(event, cache);
const res = resolveDigitDecimalPoint(event, cache
, state22, input, resetCache
);
if (typeof res === "boolean")
return res;
cache.value = state22.value = input.value = cache.value === "-" ? "" : cache.value;
return false;
} else {
const res = resolveDigitDecimalPoint(event, cache);
const res = resolveDigitDecimalPoint(event, cache
, state22, input, resetCache
);
if (typeof res === "boolean")
return res;
cache.value = input.value;
...
...
packages/uni-h5/src/platform/index.ts
浏览文件 @
e83c65a5
import
{
TEMP_PATH
}
from
'
./constants
'
export
*
from
'
./dom
'
export
{
getBaseSystemInfo
}
from
'
../service/api/base/getBaseSystemInfo
'
export
{
operateVideoPlayer
}
from
'
../service/api/context/operateVideoPlayer
'
...
...
@@ -19,3 +21,13 @@ export { getEnterOptions, getLaunchOptions } from '../framework/setup/utils'
export
const
inflateRaw
=
(...
args
:
any
[]):
any
=>
{}
export
const
deflateRaw
=
(...
args
:
any
[]):
any
=>
{}
interface
Env
{
USER_DATA_PATH
:
string
TEMP_PATH
:
string
CACHE_PATH
:
string
}
export
const
getEnv
:
(()
=>
Env
)
|
undefined
=
()
=>
({
TEMP_PATH
,
CACHE_PATH
:
''
,
USER_DATA_PATH
:
''
,
})
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录