feat: 快速消息支持备注

This commit is contained in:
2026-07-21 23:36:22 +08:00
parent 9723495f12
commit 0f89e142e9
+27
View File
@@ -15,6 +15,7 @@ const oldStorageKey = 'mqtt-client.quick-send-list';
* @typedef {Object} QuickSendItem * @typedef {Object} QuickSendItem
* @property {string} id * @property {string} id
* @property {string} topic * @property {string} topic
* @property {string} comment
* @property {string} payload * @property {string} payload
* @property {0|1|2} qos * @property {0|1|2} qos
* @property {boolean} retain * @property {boolean} retain
@@ -34,6 +35,7 @@ const isEdit = ref(false);
// 表单数据 // 表单数据
const formId = ref(''); const formId = ref('');
const formTopic = ref(''); const formTopic = ref('');
const formComment = ref('');
const formPayload = ref(''); const formPayload = ref('');
const formQos = ref(1); const formQos = ref(1);
const formRetain = ref(false); const formRetain = ref(false);
@@ -121,6 +123,7 @@ function handleAdd() {
isEdit.value = false; isEdit.value = false;
formId.value = ''; formId.value = '';
formTopic.value = ''; formTopic.value = '';
formComment.value = '';
formPayload.value = ''; formPayload.value = '';
formQos.value = 1; formQos.value = 1;
formRetain.value = false; formRetain.value = false;
@@ -135,6 +138,7 @@ function handleEdit(item) {
isEdit.value = true; isEdit.value = true;
formId.value = item.id; formId.value = item.id;
formTopic.value = item.topic; formTopic.value = item.topic;
formComment.value = item.comment || '';
formPayload.value = item.payload; formPayload.value = item.payload;
formQos.value = item.qos; formQos.value = item.qos;
formRetain.value = item.retain; formRetain.value = item.retain;
@@ -153,6 +157,7 @@ function handleSave() {
return; return;
} }
let comment = formComment.value.trim();
let payload = formPayload.value; let payload = formPayload.value;
let qos = formQos.value; let qos = formQos.value;
let retain = formRetain.value; let retain = formRetain.value;
@@ -165,6 +170,7 @@ function handleSave() {
quickList.value[idx] = { quickList.value[idx] = {
...quickList.value[idx], ...quickList.value[idx],
topic, topic,
comment,
payload, payload,
qos, qos,
retain, retain,
@@ -176,6 +182,7 @@ function handleSave() {
quickList.value.push({ quickList.value.push({
id: generateId(), id: generateId(),
topic, topic,
comment,
payload, payload,
qos, qos,
retain, retain,
@@ -608,6 +615,11 @@ onUnmounted(() => {
>删除</n-button> >删除</n-button>
</n-space> </n-space>
</div> </div>
<div
v-if="item.comment"
class="quick-comment"
:title="item.comment"
>{{ item.comment }}</div>
<pre <pre
v-if="item.payload" v-if="item.payload"
class="quick-payload" class="quick-payload"
@@ -642,6 +654,12 @@ onUnmounted(() => {
placeholder="例如: sensor/device01/temperature" placeholder="例如: sensor/device01/temperature"
/> />
</n-form-item> </n-form-item>
<n-form-item label="备注">
<n-input
v-model:value="formComment"
placeholder="可选,用于标识该快速消息的用途"
/>
</n-form-item>
<n-grid <n-grid
cols="2" cols="2"
x-gap="12" x-gap="12"
@@ -827,6 +845,15 @@ onUnmounted(() => {
font-family: monospace; font-family: monospace;
} }
.quick-comment {
margin-top: 8px;
color: var(--frost-color-text-secondary);
font-size: 12px;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.quick-payload { .quick-payload {
margin: 10px 0 0; margin: 10px 0 0;
padding: 8px 10px; padding: 8px 10px;