fix: 输入校验统一字符串防御(数字输入不再引发 trim 类型崩溃)
This commit is contained in:
+2
-2
@@ -1,2 +1,2 @@
|
||||
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./web-C9gz15N3.js","./index-o1hiWX9Y.js","./index-B9eVtom_.css"])))=>i.map(i=>d[i]);
|
||||
import{r as s,_ as i}from"./index-o1hiWX9Y.js";var t;(function(e){e.Documents="DOCUMENTS",e.Data="DATA",e.Library="LIBRARY",e.Cache="CACHE",e.External="EXTERNAL",e.ExternalStorage="EXTERNAL_STORAGE"})(t||(t={}));var a;(function(e){e.UTF8="utf8",e.ASCII="ascii",e.UTF16="utf16"})(a||(a={}));const E=s("Filesystem",{web:()=>i(()=>import("./web-C9gz15N3.js"),__vite__mapDeps([0,1,2]),import.meta.url).then(e=>new e.FilesystemWeb)});export{t as Directory,a as Encoding,E as Filesystem};
|
||||
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./web-B9VoRh8-.js","./index-WHahwity.js","./index-_AL8y0Nb.css"])))=>i.map(i=>d[i]);
|
||||
import{r as s,_ as i}from"./index-WHahwity.js";var t;(function(e){e.Documents="DOCUMENTS",e.Data="DATA",e.Library="LIBRARY",e.Cache="CACHE",e.External="EXTERNAL",e.ExternalStorage="EXTERNAL_STORAGE"})(t||(t={}));var a;(function(e){e.UTF8="utf8",e.ASCII="ascii",e.UTF16="utf16"})(a||(a={}));const E=s("Filesystem",{web:()=>i(()=>import("./web-B9VoRh8-.js"),__vite__mapDeps([0,1,2]),import.meta.url).then(e=>new e.FilesystemWeb)});export{t as Directory,a as Encoding,E as Filesystem};
|
||||
+26
File diff suppressed because one or more lines are too long
+1
-1
File diff suppressed because one or more lines are too long
-26
File diff suppressed because one or more lines are too long
+1
-1
File diff suppressed because one or more lines are too long
Vendored
+2
-2
@@ -8,8 +8,8 @@
|
||||
<link rel="icon" href="./icons/icon.svg" type="image/svg+xml" />
|
||||
<link rel="apple-touch-icon" href="./icons/icon-192.png" />
|
||||
<title>实习工作日志</title>
|
||||
<script type="module" crossorigin src="./assets/index-o1hiWX9Y.js"></script>
|
||||
<link rel="stylesheet" crossorigin href="./assets/index-B9eVtom_.css">
|
||||
<script type="module" crossorigin src="./assets/index-WHahwity.js"></script>
|
||||
<link rel="stylesheet" crossorigin href="./assets/index-_AL8y0Nb.css">
|
||||
</head>
|
||||
<body>
|
||||
<div id="app"></div>
|
||||
|
||||
@@ -57,8 +57,9 @@ function computedCategory() {
|
||||
}
|
||||
|
||||
function save() {
|
||||
const v = Number(fAmount.value)
|
||||
if (!fAmount.value.trim() || !isFinite(v) || v <= 0) {
|
||||
const amountText = String(fAmount.value ?? '').trim()
|
||||
const v = Number(amountText)
|
||||
if (!amountText || !isFinite(v) || v <= 0) {
|
||||
fError.value = '请填写大于 0 的金额'
|
||||
return
|
||||
}
|
||||
@@ -72,7 +73,7 @@ function save() {
|
||||
category: computedCategory(),
|
||||
amount: Math.round(v * 100),
|
||||
date: fDate.value,
|
||||
note: fNote.value.trim(),
|
||||
note: String(fNote.value ?? '').trim(),
|
||||
reimbursable,
|
||||
reimbursed: reimbursable && fReimbursed.value ? 1 : 0
|
||||
})
|
||||
|
||||
@@ -120,8 +120,9 @@ watch(fAmount, () => {
|
||||
})
|
||||
|
||||
async function submit() {
|
||||
const v = Number(fAmount.value)
|
||||
if (!fAmount.value.trim() || !isFinite(v) || v <= 0) {
|
||||
const amountText = String(fAmount.value ?? '').trim()
|
||||
const v = Number(amountText)
|
||||
if (!amountText || !isFinite(v) || v <= 0) {
|
||||
fError.value = '请填写大于 0 的金额'
|
||||
return
|
||||
}
|
||||
@@ -137,7 +138,7 @@ async function submit() {
|
||||
category: fCategory.value,
|
||||
amount: Math.round(v * 100),
|
||||
date: fDate.value,
|
||||
note: fNote.value.trim(),
|
||||
note: String(fNote.value ?? '').trim(),
|
||||
reimbursable: fType.value === 'expense' && fReimb.value ? 1 : 0,
|
||||
reimbursed: 0
|
||||
})
|
||||
@@ -154,6 +155,8 @@ async function submit() {
|
||||
showToast('记账已添加')
|
||||
submitting.value = false
|
||||
}
|
||||
const formDirty = computed(() => String(fAmount.value ?? '').trim() !== '' || String(fNote.value ?? '').trim() !== '')
|
||||
|
||||
function resetForm() {
|
||||
fAmount.value = ''
|
||||
fNote.value = ''
|
||||
@@ -262,7 +265,7 @@ async function confirmDelete() {
|
||||
</div>
|
||||
<div v-if="fError" class="form-error">{{ fError }}</div>
|
||||
<div class="form-footer">
|
||||
<button class="btn btn-sm" :disabled="!(fAmount.trim() || fNote.trim())" @click="resetForm">重置</button>
|
||||
<button class="btn btn-sm" :disabled="!formDirty" @click="resetForm">重置</button>
|
||||
<button class="btn btn-primary btn-sm" :disabled="submitting" @click="submit">添加记录</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user