diff --git a/lib/authkey.js b/lib/authkey.js index 40d4b16..8c4957d 100644 --- a/lib/authkey.js +++ b/lib/authkey.js @@ -28,8 +28,8 @@ export const getStoken = (e, mysid = '') => { // 解析文件 const cks = YAML.parse(file); for (const ck in cks) { - if (cks?.[ck]?.['stuid'] && cks[ck]['stuid'] === mysid) { - // 如果 ck 存在并且 stuid 与 mysid 相同则返回(这两者都是字符串,不需要类型转换,因此不需要使用弱比较,强比较速度更快,没有隐式转换一步骤,注意代码规范与代码风格) + if (cks?.[ck]?.['stuid'] && String(cks[ck]['stuid']) === String(mysid)) { + // 如果 ck 存在并且 stuid 与 mysid 相同则返回 return cks[ck]; } }