Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion ui/src/views/login/components/dingtalkQrCode.vue
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ const errorShown = ref(false)
const initActive = async () => {
try {
await load(true)
errorShown.value = false
if (!isConfigReady.value) {
return
}
Expand Down Expand Up @@ -116,7 +117,7 @@ const initActive = async () => {
(errorMsg: string) => {
if (!errorShown.value) {
MsgError(errorMsg)
errorShown.value = true // 设置标志位为 true,表示错误已经显示过
errorShown.value = true
}
}
)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The provided code is generally well-written, but there are a few minor improvements and clarifications you can make:

  1. Typo: There seems to be an issue with the message being passed to MsgError. It's likely that it should not include the { errorMsg } syntax within single quotes.

  2. Redundancy: The line where errorShown.value = true; is followed by (errorMsg: string) => { ... };, which does not serve any purpose without more context about what this function does.

  3. Whitespace: Ensure consistent indentation throughout the codebase for better readability.

Here is the revised version of the code:

@@ -80,6 +80,7 @@ const errorShown = ref(false)
 const initActive = async () => {
   try {
     await load(true);
+    errorShown.value = false;
     if (!isConfigReady.value) {
       return;
     }
@@ -114,7 +115,7 @@ const initActive = async () => {
       (errorMsg: string) => {
         if (!errorShown.value) {
           MsgError(errorMsg); // Pass the error message directly
+          errorShown.value = true; // Set flag to indicate error has been shown
         }
       },
     );

Additional Comments:

  • Error Handling Flag: The errorShown.value = true; statement inside the callback ensures that each error message is only displayed once during its execution lifetime even if multiple error messages occur.

These changes improve clarity and maintainability of the code while ensuring it performs correctly.

Expand Down