update widget name

This commit is contained in:
Qiuxia Fan 2022-07-08 11:25:36 +08:00
parent ae294d48e8
commit 7330443f64
4 changed files with 5 additions and 2 deletions

View File

@ -146,6 +146,7 @@ const msg = {
widget: "Widget", widget: "Widget",
nameTip: nameTip:
"The name only supports Chinese and English, horizontal lines and underscores", "The name only supports Chinese and English, horizontal lines and underscores",
duplicateName: "Duplicate name",
seconds: "Seconds", seconds: "Seconds",
hourTip: "Select Hour", hourTip: "Select Hour",
minuteTip: "Select Minute", minuteTip: "Select Minute",

View File

@ -144,6 +144,7 @@ const msg = {
begin: "Inicio", begin: "Inicio",
associateOptions: "Opciones de asociación", associateOptions: "Opciones de asociación",
widget: "Dispositivo pequeño", widget: "Dispositivo pequeño",
duplicateName: "Nombre duplicado",
nameTip: 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 cruzadas y subrayado",
seconds: "Segundos", seconds: "Segundos",

View File

@ -143,6 +143,7 @@ const msg = {
associateOptions: "关联选项", associateOptions: "关联选项",
widget: "部件", widget: "部件",
nameTip: "该名称仅支持中文和英文、横线和下划线", nameTip: "该名称仅支持中文和英文、横线和下划线",
duplicateName: "重复的名称",
seconds: "秒", seconds: "秒",
hourTip: "选择小时", hourTip: "选择小时",
minuteTip: "选择分钟", minuteTip: "选择分钟",

View File

@ -76,7 +76,7 @@ function updateWidgetName(param: { [key: string]: string }) {
const n = decodeURIComponent(param[key]); const n = decodeURIComponent(param[key]);
const pattern = /^[A-Za-z0-9-_\u4e00-\u9fa5]{1,30}$/; const pattern = /^[A-Za-z0-9-_\u4e00-\u9fa5]{1,30}$/;
if (!pattern.test(n)) { if (!pattern.test(n)) {
ElMessage.warning(t("nameTip")); ElMessage.error(t("nameTip"));
return; return;
} }
const { widgets } = getDashboard(dashboardStore.currentDashboard); const { widgets } = getDashboard(dashboardStore.currentDashboard);
@ -84,7 +84,7 @@ function updateWidgetName(param: { [key: string]: string }) {
(d: LayoutConfig) => d.widget && d.widget.name === n (d: LayoutConfig) => d.widget && d.widget.name === n
); );
if (item) { if (item) {
ElMessage.warning("Duplicate name"); ElMessage.error("Duplicate name");
return; return;
} }
updateWidgetConfig(param); updateWidgetConfig(param);