Просмотр исходного кода

fix: 替换代码中的严格相等运算符为宽松相等

统一修复多处使用===的比较逻辑为==,避免类型转换导致的意外匹配问题
lsc 2 недель назад
Родитель
Сommit
d3e5405887
1 измененных файлов с 5 добавлено и 5 удалено
  1. 5 5
      src/views/Student/index.vue

+ 5 - 5
src/views/Student/index.vue

@@ -2913,11 +2913,11 @@ const getWork = async (isUpdate = false) => {
     const newWorkArray = props.cid
       ? res[0].filter((work: any) => {
         // 修复:使用 === 严格相等比较,避免类型转换导致的意外结果
-        // 只有当 ttype === '1' 或 (ttype === '2' 且 classid 包含 props.cid) 时才保留
+        // 只有当 ttype == '1' 或 (ttype == '2' 且 classid 包含 props.cid) 时才保留
         // 同时满足 atool === toolType 或 toolType 为空
         // return (work.ttype == '1' || (work.ttype == '2' && work.classid.includes(props.cid))) && (work.atool == toolType.value || !toolType.value)
-        const ttypeMatch = work.ttype === '1' || (work.ttype === '2' && work.classid && work.classid.includes(props.cid))
-        const toolMatch = toolType ? work.atool === toolType : true
+        const ttypeMatch = work.ttype == '1' || (work.ttype == '2' && work.classid && work.classid.includes(props.cid))
+        const toolMatch = toolType ? work.atool == toolType : true
         return ttypeMatch && toolMatch
       }).map((work: any) => {
         // 计算点赞数量:likeArray中wid等于当前work.id的记录数
@@ -3843,9 +3843,9 @@ const addOp3 = async (userTime: any, loadTime: any, object: any, status: any) =>
     accountNumber: userJson.value.accountNumber,
     org: userJson.value.orgName,
     school: userJson.value.schoolName,
-    role: userJson.value.type === '1' ? '老师' : '学生',
+    role: userJson.value.type == '1' ? '老师' : '学生',
     browser,
-    userTime: userTime === '1' ? _time : userTime, // 使用时间 1次的就1 其次传秒
+    userTime: userTime == '1' ? _time : userTime, // 使用时间 1次的就1 其次传秒
     loadTime, // load的时间没有就''
     object: JSON.stringify(object), // 执行信息传json
     status // 成功返回success。失败返回error的信息