Keldos commited on
Commit
41f3f9d
·
1 Parent(s): 21d7bfc

fix: 增加用户取消重命名的判断

Browse files
Files changed (1) hide show
  1. web_assets/javascript/chat-list.js +9 -4
web_assets/javascript/chat-list.js CHANGED
@@ -59,14 +59,19 @@ function saveChatHistory(a, b, c, d) {
59
  var fileName = b;
60
 
61
  while (true) {
62
- fileName = prompt(renameChat_i18n, fileName);
63
-
64
- if (isValidFileName(fileName)) {
65
- return [a, fileName, c, d];
 
 
 
 
66
  } else {
67
  alert(validFileName_i18n + "!@#$%^&*()<>?/\\|}{~:");
68
  }
69
  }
 
70
  }
71
 
72
  function isValidFileName(fileName) {
 
59
  var fileName = b;
60
 
61
  while (true) {
62
+ var result = prompt(renameChat_i18n, fileName);
63
+
64
+ if (result === null) {
65
+ throw new Error("rename operation cancelled");
66
+ // 不返回原文件名,而是使用 throw new Error() 打断程序,避免 gradio 进行保存操作
67
+ // break;
68
+ } else if (isValidFileName(result)) {
69
+ return [a, result, c, d];
70
  } else {
71
  alert(validFileName_i18n + "!@#$%^&*()<>?/\\|}{~:");
72
  }
73
  }
74
+ return [a, b, c, d]; // 兜底保障
75
  }
76
 
77
  function isValidFileName(fileName) {