fix:字符串适配

This commit is contained in:
bietiaop 2024-07-22 13:28:52 +08:00
parent 5c26e690ef
commit 9061bcbaa7

View file

@ -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];
}
}