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

fix: 修复文件配置全没勾选的情况下还能上传文件的问题 #1702

Merged
merged 1 commit into from
Nov 27, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,9 @@ const getAcceptList = () => {
accepts = [...accepts, ...videoExtensions]
}
// console.log(accepts)
if (accepts.length === 0) {
return '.请在文件上传配置中选择文件类型'
}
return accepts.map((ext: any) => '.' + ext).join(',')
}

Choose a reason for hiding this comment

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

代码看起来是一段用于处理文件上传时需要接受的扩展名的JavaScript函数。然而,在提供的两个版本之间没有明显的差异,似乎只是简单地增加了videoExtensions数组的内容并返回其转义后的字符串。

这个实现功能基本准确,但由于缺少注释和描述性的文档(如用途、输入参数示例以及正确情况下的预期输出等),可能难以理解或维护。

因此,我给出的修改建议是补充一些基本信息:

  • 增加注释以解释变量含义,
  • 更好地对传入值做限制或校验(例如使用类型断言来确保所有的字符串都是可读的字符)。

具体来说,可以按照以下方式改动此部分代码:

/**
 * @description 得到允许使用的拓展名列表,如果该列表为空,则提供默认提示信息。
 * @returns 简要的用户指南:若指定的文件扩展现已过期,应重新选择其他兼容性更好的文件类型。"
 */
const acceptLst = (e: React.FormEvent<HTMLInputElement>) => {

此外,请根据您的需求或API的实际行为调整上述内容中的相关函数,并参考最佳实践添加必要的逻辑断言语句以提高代码阅读性和可读性。

Expand Down