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]);
|
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-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};
|
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="icon" href="./icons/icon.svg" type="image/svg+xml" />
|
||||||
<link rel="apple-touch-icon" href="./icons/icon-192.png" />
|
<link rel="apple-touch-icon" href="./icons/icon-192.png" />
|
||||||
<title>实习工作日志</title>
|
<title>实习工作日志</title>
|
||||||
<script type="module" crossorigin src="./assets/index-o1hiWX9Y.js"></script>
|
<script type="module" crossorigin src="./assets/index-WHahwity.js"></script>
|
||||||
<link rel="stylesheet" crossorigin href="./assets/index-B9eVtom_.css">
|
<link rel="stylesheet" crossorigin href="./assets/index-_AL8y0Nb.css">
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div id="app"></div>
|
<div id="app"></div>
|
||||||
|
|||||||
@@ -57,8 +57,9 @@ function computedCategory() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function save() {
|
function save() {
|
||||||
const v = Number(fAmount.value)
|
const amountText = String(fAmount.value ?? '').trim()
|
||||||
if (!fAmount.value.trim() || !isFinite(v) || v <= 0) {
|
const v = Number(amountText)
|
||||||
|
if (!amountText || !isFinite(v) || v <= 0) {
|
||||||
fError.value = '请填写大于 0 的金额'
|
fError.value = '请填写大于 0 的金额'
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -72,7 +73,7 @@ function save() {
|
|||||||
category: computedCategory(),
|
category: computedCategory(),
|
||||||
amount: Math.round(v * 100),
|
amount: Math.round(v * 100),
|
||||||
date: fDate.value,
|
date: fDate.value,
|
||||||
note: fNote.value.trim(),
|
note: String(fNote.value ?? '').trim(),
|
||||||
reimbursable,
|
reimbursable,
|
||||||
reimbursed: reimbursable && fReimbursed.value ? 1 : 0
|
reimbursed: reimbursable && fReimbursed.value ? 1 : 0
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -120,8 +120,9 @@ watch(fAmount, () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
async function submit() {
|
async function submit() {
|
||||||
const v = Number(fAmount.value)
|
const amountText = String(fAmount.value ?? '').trim()
|
||||||
if (!fAmount.value.trim() || !isFinite(v) || v <= 0) {
|
const v = Number(amountText)
|
||||||
|
if (!amountText || !isFinite(v) || v <= 0) {
|
||||||
fError.value = '请填写大于 0 的金额'
|
fError.value = '请填写大于 0 的金额'
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -137,7 +138,7 @@ async function submit() {
|
|||||||
category: fCategory.value,
|
category: fCategory.value,
|
||||||
amount: Math.round(v * 100),
|
amount: Math.round(v * 100),
|
||||||
date: fDate.value,
|
date: fDate.value,
|
||||||
note: fNote.value.trim(),
|
note: String(fNote.value ?? '').trim(),
|
||||||
reimbursable: fType.value === 'expense' && fReimb.value ? 1 : 0,
|
reimbursable: fType.value === 'expense' && fReimb.value ? 1 : 0,
|
||||||
reimbursed: 0
|
reimbursed: 0
|
||||||
})
|
})
|
||||||
@@ -154,6 +155,8 @@ async function submit() {
|
|||||||
showToast('记账已添加')
|
showToast('记账已添加')
|
||||||
submitting.value = false
|
submitting.value = false
|
||||||
}
|
}
|
||||||
|
const formDirty = computed(() => String(fAmount.value ?? '').trim() !== '' || String(fNote.value ?? '').trim() !== '')
|
||||||
|
|
||||||
function resetForm() {
|
function resetForm() {
|
||||||
fAmount.value = ''
|
fAmount.value = ''
|
||||||
fNote.value = ''
|
fNote.value = ''
|
||||||
@@ -262,7 +265,7 @@ async function confirmDelete() {
|
|||||||
</div>
|
</div>
|
||||||
<div v-if="fError" class="form-error">{{ fError }}</div>
|
<div v-if="fError" class="form-error">{{ fError }}</div>
|
||||||
<div class="form-footer">
|
<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>
|
<button class="btn btn-primary btn-sm" :disabled="submitting" @click="submit">添加记录</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user