Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

useMethods导出文件时,如果文件内容中存在“success”字符串时出错 #7738

Open
q060831 opened this issue Jan 16, 2025 · 0 comments

Comments

@q060831
Copy link

q060831 commented Jan 16, 2025

版本号:3.7.2

问题描述:
使用jeecgboot-vue3/src/hooks/system/useMethods.ts的exportXls方法到处文件,如果文件内容中存在“success”字符串时,直接判断是Result类型,导致JSON解析出错

async function exportXls(name, url, params, isXlsx = false) {
  .......
    reader.onload = async () => {
      if (reader.result) {
        // 这个判断不严谨,没考虑文件内容可能包含"success"字符串
        if (reader.result.toString().indexOf('success') != -1) {
          const { success, message } = JSON.parse(reader.result.toString());
          if (!success) {
            createMessage.warning('导出失败,失败原因:' + message);
          } else {
            exportExcel(name, isXlsx, data);
          }
          return;
        }
      }
      exportExcel(name, isXlsx, data);
      //update-end---author:wangshuai---date:2024-04-18---for: 导出excel失败提示,不进行导出---
    };

}

错误截图:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant