提交 866e9232 authored 作者: 邓文彬's avatar 邓文彬

fix(用户信息):用户列表更新

上级 a2defcd4
......@@ -11,6 +11,7 @@ import {
USER_FILE_NAME,
} from "./utils/systemCofig";
import { Base64 } from "js-base64";
import {differenceBy} from "lodash";
import { readDirectoryData } from "@/utils/IoReadingAndWriting.js";
export default {
......@@ -113,10 +114,18 @@ export default {
});
});
})
.then((res) => {
.then(async (res) => {
// 获取文件数据
let userData = Base64.decode(res);
const diffUserList = await this.diffUserList(userData)
if(diffUserList.length){
this.updateIpadUsetList([...USER_LiST,...diffUserList])
userData = JSON.stringify([...USER_LiST,...diffUserList])
}
uni.setStorage({
key: "user_data",
data: userData,
......@@ -133,6 +142,27 @@ export default {
console.log("---目录创建失败", error);
});
},
// 比较代码中的用户列表 和 ipad中存储用户的 差异
async diffUserList(ipadUserList = []){
const temp = eval(ipadUserList)
const diffResult = differenceBy(USER_LiST, temp, "userId")
return diffResult
},
// 更新 ipad 用户信息
updateIpadUsetList(tempPersonList){
const temp = JSON.stringify(tempPersonList);
const fileContent = JSON.stringify(Base64.encode(temp));
createFileWithPlusIO(
SYNCHRONIZE_DATA_PAD,
USER_FILE_NAME,
fileContent
)
}
},
};
</script>
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论