Variable name and key binding

This commit is contained in:
zsxeee 2021-09-17 20:40:57 +08:00
parent 66e40d9fcb
commit 2fb3c40307
No known key found for this signature in database
GPG key ID: 895CFFFD8313B3B8
2 changed files with 7 additions and 7 deletions

View file

@ -13,7 +13,7 @@
<div class="mb-3">
<label for="notification-type" class="form-label">{{ $t("Notification Type") }}</label>
<select id="notification-type" v-model="notification.type" class="form-select">
<option v-for="type in notificationTypes" :value="type">{{ $t(type) }}</option>
<option v-for="type in notificationTypes" :key="type" :value="type">{{ $t(type) }}</option>
</select>
</div>
@ -72,7 +72,7 @@ import { Modal } from "bootstrap"
import { ucfirst } from "../util.ts"
import Confirm from "./Confirm.vue";
import NotificationForm from "./notifications"
import NotificationFormList from "./notifications"
export default {
components: {
@ -85,10 +85,10 @@ export default {
model: null,
processing: false,
id: null,
notificationTypes: Object.keys(NotificationForm),
notificationTypes: Object.keys(NotificationFormList),
notification: {
name: "",
/** @type { null | keyof NotificationForm } */
/** @type { null | keyof NotificationFormList } */
type: null,
isDefault: false,
// Do not set default value here, please scroll to show()
@ -101,7 +101,7 @@ export default {
if (!this.notification.type) {
return null
}
return NotificationForm[this.notification.type]
return NotificationFormList[this.notification.type]
}
},

View file

@ -21,7 +21,7 @@ import Mattermost from "./Mattermost.vue";
*
* @type { Record<string, any> }
*/
const NotificationForm = {
const NotificationFormList = {
"telegram": Telegram,
"webhook": Webhook,
"smtp": STMP,
@ -41,4 +41,4 @@ const NotificationForm = {
"mattermost": Mattermost
}
export default NotificationForm
export default NotificationFormList