diff --git a/src/views/demo/form-design/components/VFormDesign/components/ComponentProps.vue b/src/views/demo/form-design/components/VFormDesign/components/ComponentProps.vue
index 515e3cdb..b015b62d 100644
--- a/src/views/demo/form-design/components/VFormDesign/components/ComponentProps.vue
+++ b/src/views/demo/form-design/components/VFormDesign/components/ComponentProps.vue
@@ -94,7 +94,7 @@
/>
- 点击脚本
+ 点击脚本
@@ -84,7 +83,6 @@
@@ -92,7 +90,6 @@
@@ -100,7 +97,6 @@
@@ -209,11 +205,9 @@
}
// 脚本窗口提交
function handleSubmit() {
- if (formContent.value.indexOf('=>') != -1) {
- // 表示是老版本,提示其修改为新的版本
- message.warning('脚本没有更新为最新的版本!');
+ if (!checkChinese(formContent.value)) {
+ message.warning('脚本的代码部分不能含有中文字符!');
return;
- // } else if() {
}
if (btnClickEvent_now) {
if (btnClickEvent_now == 'beforeSetData') {
@@ -228,6 +222,33 @@
}
closeModal();
}
+
+ function checkChinese(str) {
+ // 分割字符串为多行
+ const lines = str.split('\n');
+ let flag = true;
+
+ // 遍历每一行
+ for (const line of lines) {
+ // 先检查并移除console.log及其后的内容
+ const consoleIndex = line.indexOf('console.log');
+ let partToCheck = line;
+ if (consoleIndex !== -1) {
+ partToCheck = line.substring(0, consoleIndex).trim(); // 移除console.log及其后的内容,并去掉前导空格
+ }
+
+ // 再检查'//'
+ const commentIndex = partToCheck.indexOf('//');
+ // 如果有'//',检查'//'前的部分并去掉前导空格;如果没有,保留原部分
+ partToCheck =
+ commentIndex !== -1 ? partToCheck.substring(0, commentIndex).trim() : partToCheck;
+ // 代码部分不能含有中文字符
+ if (!/[\u4e00-\u9fa5]/.test(partToCheck)) {
+ flag = false;
+ }
+ }
+ return flag;
+ }