From e395d2e129968a48b4433edc3bb9430ea03c5132 Mon Sep 17 00:00:00 2001 From: Qiuxia Fan Date: Thu, 14 Jul 2022 15:13:00 +0800 Subject: [PATCH] fix association --- src/locales/lang/en.ts | 2 +- src/locales/lang/es.ts | 2 +- src/locales/lang/zh.ts | 2 +- .../configuration/widget/AssociateOptions.vue | 10 ++++++++-- .../dashboard/configuration/widget/WidgetOptions.vue | 2 +- 5 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/locales/lang/en.ts b/src/locales/lang/en.ts index 874a2ee7..ee9df4ca 100644 --- a/src/locales/lang/en.ts +++ b/src/locales/lang/en.ts @@ -145,7 +145,7 @@ const msg = { associateOptions: "Association Options", widget: "Widget", nameTip: - "The name only supports Chinese and English, horizontal lines and underscores", + "The name only supports Chinese and English, horizontal lines and underscores and is limited to 300 characters", duplicateName: "Duplicate name", seconds: "Seconds", hourTip: "Select Hour", diff --git a/src/locales/lang/es.ts b/src/locales/lang/es.ts index c0118720..ec8d8cc1 100644 --- a/src/locales/lang/es.ts +++ b/src/locales/lang/es.ts @@ -146,7 +146,7 @@ const msg = { widget: "Dispositivo pequeño", duplicateName: "Nombre duplicado", nameTip: - "Este nombre sólo admite chino e inglés, líneas cruzadas y subrayado", + "Este nombre sólo admite chino e inglés, líneas horizontales y subrayado, y no más de 300 caracteres", seconds: "Segundos", hourTip: "Seleccione Hora", minuteTip: "Seleccione Minuto", diff --git a/src/locales/lang/zh.ts b/src/locales/lang/zh.ts index 4c2d96a3..22d03c0f 100644 --- a/src/locales/lang/zh.ts +++ b/src/locales/lang/zh.ts @@ -142,7 +142,7 @@ const msg = { begin: "开始", associateOptions: "关联选项", widget: "部件", - nameTip: "该名称仅支持中文和英文、横线和下划线", + nameTip: "该名称仅支持中文和英文、横线和下划线, 并且限制长度为300个字符", duplicateName: "重复的名称", seconds: "秒", hourTip: "选择小时", diff --git a/src/views/dashboard/configuration/widget/AssociateOptions.vue b/src/views/dashboard/configuration/widget/AssociateOptions.vue index bf846110..0e7aab97 100644 --- a/src/views/dashboard/configuration/widget/AssociateOptions.vue +++ b/src/views/dashboard/configuration/widget/AssociateOptions.vue @@ -51,9 +51,15 @@ const widgets = computed(() => { const items = widgets.filter( (d: { value: string; label: string } & LayoutConfig) => { if (dashboardStore.selectedGrid.id !== d.id) { - if (isLinear && d.type === "Widget" && d.widget && d.id) { + if ( + isLinear && + d.type === "Widget" && + d.widget && + d.widget.name && + d.id + ) { d.value = d.id; - d.label = d.widget.name || d.id; + d.label = d.widget.name; return d; } // if (isRank && d.type !== "Widget" && d.widget && d.id) { diff --git a/src/views/dashboard/configuration/widget/WidgetOptions.vue b/src/views/dashboard/configuration/widget/WidgetOptions.vue index 5f848214..6e78f331 100644 --- a/src/views/dashboard/configuration/widget/WidgetOptions.vue +++ b/src/views/dashboard/configuration/widget/WidgetOptions.vue @@ -74,7 +74,7 @@ function updateWidgetConfig(param: { [key: string]: string }) { function updateWidgetName(param: { [key: string]: string }) { const key = Object.keys(param)[0]; const n = decodeURIComponent(param[key]); - const pattern = /^[A-Za-z0-9-_\u4e00-\u9fa5]{1,30}$/; + const pattern = /^[A-Za-z0-9-_\u4e00-\u9fa5]{1,300}$/; if (!pattern.test(n)) { ElMessage.error(t("nameTip")); return;