提交 66c704c2 authored 作者: JaxBBLL's avatar JaxBBLL

fix

上级 1b17254f
<script> <script>
import { import {
BASE_PATH, BASE_PATH,
SYNCHRONIZE_DATA_PATH, SYNCHRONIZE_DATA_PATH,
SYNCHRONIZE_DATA_PAD, SYNCHRONIZE_DATA_PAD,
checkAndCreateDirectory, checkAndCreateDirectory,
checkFileExists, checkFileExists,
createFileWithPlusIO, createFileWithPlusIO,
readFileContent, readFileContent,
USER_LiST, USER_LiST,
USER_FILE_NAME, USER_FILE_NAME,
} from "./utils/systemCofig"; } from "./utils/systemCofig";
import { import { Base64 } from "js-base64";
Base64 import { differenceBy } from "lodash";
} from "js-base64";
import { import { readDirectoryData } from "@/utils/IoReadingAndWriting.js";
differenceBy import initService from "@/api/sqllite/init.js";
} from "lodash"; export default {
onLaunch: function () {
import { // #ifdef APP-PLUS
readDirectoryData plus.screen.lockOrientation("landscape-primary"); //锁定横屏
} from "@/utils/IoReadingAndWriting.js"; // #endif
import initService from '@/api/sqllite/init.js'
export default { // this.init();
onLaunch: function() {
// #ifdef APP-PLUS // #ifdef APP-PLUS
plus.screen.lockOrientation("landscape-primary"); //锁定横屏 plus.android.requestPermissions(
// #endif ["android.permission.WRITE_EXTERNAL_STORAGE"],
function (e) {
// this.init(); if (e.deniedAlways.length > 0) {
//权限被永久拒绝
// #ifdef APP-PLUS // 弹出提示框解释为何需要读写手机储存权限,引导用户打开设置页面开启
plus.android.requestPermissions( uni.showModal({
["android.permission.WRITE_EXTERNAL_STORAGE"], title: "存储权限",
function(e) { content: "您拒绝了存储权限,请去设置-应用开启存储权限。",
if (e.deniedAlways.length > 0) { success: function (res) {
//权限被永久拒绝 if (res.confirm) {
// 弹出提示框解释为何需要读写手机储存权限,引导用户打开设置页面开启 } else if (res.cancel) {
uni.showModal({ }
title: "存储权限", },
content: "您拒绝了存储权限,请去设置-应用开启存储权限。", });
success: function(res) { }
if (res.confirm) {} else if (res.cancel) {} if (e.deniedPresent.length > 0) {
}, //权限被临时拒绝
}); // 弹出提示框解释为何需要读写手机储存权限,可再次调用plus.android.requestPermissions申请权限
} plus.android.requestPermissions([
if (e.deniedPresent.length > 0) { "android.permission.WRITE_EXTERNAL_STORAGE",
//权限被临时拒绝 ]);
// 弹出提示框解释为何需要读写手机储存权限,可再次调用plus.android.requestPermissions申请权限 }
plus.android.requestPermissions([ if (e.granted.length > 0) {
"android.permission.WRITE_EXTERNAL_STORAGE", //权限被允许
]); init();
} }
if (e.granted.length > 0) { },
//权限被允许 function (e) {}
init(); );
} // #endif
}, },
function(e) {} onShow: function () {
); const now_user = uni.getStorageSync("now_user") || {};
// #endif if (now_user.user) {
}, this.$store.commit("SET_USER", now_user);
onShow: function() { }
const now_user = uni.getStorageSync("now_user") || {}; this.init();
if (now_user.user) { },
this.$store.commit("SET_USER", now_user); onLoad: function (query) {
} console.log("即将开始初始化app");
this.init(); },
}, onHide: function () {
onLoad: function(query) { // app关闭时将数据存储到本地缓存
console.log('即将开始初始化app') uni.setStorageSync("now_user", this.$store.state.now_user);
}, uni.setStorageSync(
onHide: function() { "last_time",
// app关闭时将数据存储到本地缓存 this.$store.state.now_user.LastSynchronizationTime
uni.setStorageSync("now_user", this.$store.state.now_user); );
uni.setStorageSync("last_time", this.$store.state.now_user.LastSynchronizationTime);
// 清除store 数据
// 清除store 数据 this.$store.commit("SET_DARF_DATA", {});
this.$store.commit("SET_DARF_DATA", {}); this.$store.commit("SET_LOG_LIST", []);
this.$store.commit("SET_LOG_LIST", []); this.$store.commit("SET_ALL_DATA", []);
this.$store.commit("SET_ALL_DATA", []); },
}, onUnload() {},
onUnload() {}, methods: {
methods: { /**
/** * 第一步: 检查目录是否存在,如果没有就创建
* 第一步: 检查目录是否存在,如果没有就创建 * 第二步:检查指定文件是否存在,如果存在就读取内容;否则就创建文件,并写入初始化数据
* 第二步:检查指定文件是否存在,如果存在就读取内容;否则就创建文件,并写入初始化数据 * 第三步:存储读取到的数据
* 第三步:存储读取到的数据 */
*/ async init() {
async init() { initService.init();
initService.init() return;
return checkAndCreateDirectory(SYNCHRONIZE_DATA_PAD)
checkAndCreateDirectory(SYNCHRONIZE_DATA_PAD) .then(() => {
.then(() => { return new Promise((resolve, reject) => {
return new Promise((resolve, reject) => { // 检查目录下的文件是否存在
// 检查目录下的文件是否存在 checkFileExists(SYNCHRONIZE_DATA_PAD, USER_FILE_NAME)
checkFileExists(SYNCHRONIZE_DATA_PAD, USER_FILE_NAME) .then((fileEntry) => {
.then((fileEntry) => { // 文件存在,
// 文件存在, return readFileContent(fileEntry)
return readFileContent(fileEntry) .then((res) => {
.then((res) => { resolve(res);
resolve(res); })
}) .catch((error) => {
.catch((error) => { reject(error);
reject(error); });
}); })
}) .catch((error) => {
.catch((error) => { // 文件不存在, 写入文件
// 文件不存在, 写入文件 const fileContent = JSON.stringify(
const fileContent = JSON.stringify( Base64.encode(JSON.stringify(USER_LiST))
Base64.encode(JSON.stringify(USER_LiST)) );
); createFileWithPlusIO(
createFileWithPlusIO( SYNCHRONIZE_DATA_PAD,
SYNCHRONIZE_DATA_PAD, USER_FILE_NAME,
USER_FILE_NAME, fileContent
fileContent )
) .then((res) => {
.then((res) => { resolve(res);
resolve(res); })
}) .catch((error) => {
.catch((error) => { reject(error);
reject(error); });
}); });
}); })
}) .then(async (res) => {
.then(async (res) => { // 获取文件数据
let userData = Base64.decode(res);
// 获取文件数据
let userData = Base64.decode(res); const diffUserList = await this.diffUserList(userData);
if (diffUserList.length) {
const diffUserList = await this.diffUserList(userData) this.updateIpadUsetList([...USER_LiST, ...diffUserList]);
if (diffUserList.length) {
this.updateIpadUsetList([...USER_LiST, ...diffUserList]) userData = JSON.stringify([...USER_LiST, ...diffUserList]);
}
userData = JSON.stringify([...USER_LiST, ...diffUserList])
} uni.setStorage({
key: "user_data",
uni.setStorage({ data: userData,
key: "user_data", fail: (error) => {
data: userData, console.log("APP.vue 存储数据失败", error);
fail: (error) => { },
console.log("APP.vue 存储数据失败", error); });
}, })
}); .catch((error) => {
}) console.log("---", error);
.catch((error) => { });
console.log("---", error); })
}); .catch((error) => {
}) console.log("---目录创建失败", error);
.catch((error) => { });
console.log("---目录创建失败", error); },
});
}, // 比较代码中的用户列表 和 ipad中存储用户的 差异
async diffUserList(ipadUserList = []) {
// 比较代码中的用户列表 和 ipad中存储用户的 差异 const temp = eval(ipadUserList);
async diffUserList(ipadUserList = []) { const diffResult = differenceBy(USER_LiST, temp, "userId");
const temp = eval(ipadUserList)
const diffResult = differenceBy(USER_LiST, temp, "userId") return diffResult;
},
return diffResult
}, // 更新 ipad 用户信息
updateIpadUsetList(tempPersonList) {
const temp = JSON.stringify(tempPersonList);
// 更新 ipad 用户信息
updateIpadUsetList(tempPersonList) { const fileContent = JSON.stringify(Base64.encode(temp));
const temp = JSON.stringify(tempPersonList); createFileWithPlusIO(SYNCHRONIZE_DATA_PAD, USER_FILE_NAME, fileContent);
},
const fileContent = JSON.stringify(Base64.encode(temp)); },
createFileWithPlusIO( };
SYNCHRONIZE_DATA_PAD,
USER_FILE_NAME,
fileContent
)
}
},
};
</script> </script>
<style lang="less"> <style lang="less">
@import "./common/global.css"; @import "./common/atom.less";
@import "~@/static/iconFont/iconfont.css"; @import "./common/base.less";
@import "./common/global.css";
@font-face { @import "~@/static/iconFont/iconfont.css";
font-family: AlibabaPuHuiTi-Medium;
src: url("~@/static/font/Alibaba-PuHuiTi-Medium.ttf"); @font-face {
} font-family: AlibabaPuHuiTi-Medium;
src: url("~@/static/font/Alibaba-PuHuiTi-Medium.ttf");
@font-face { }
font-family: "iconfont";
/* Project id 4374193 */ @font-face {
src: url("~@/static/iconFont/iconfont.woff2?t=1725876968366") format("woff2"), font-family: "iconfont";
url("~@/static/iconFont/iconfont.woff?t=1725876968366") format("woff"), /* Project id 4374193 */
url("~@/static/iconFont/iconfont.ttf?t=1725876968366") format("truetype"); src: url("~@/static/iconFont/iconfont.woff2?t=1725876968366") format("woff2"),
} url("~@/static/iconFont/iconfont.woff?t=1725876968366") format("woff"),
url("~@/static/iconFont/iconfont.ttf?t=1725876968366") format("truetype");
// @font-face { }
// font-family: "iconfont"; /* Project id 4374193 */
// src: url('iconfont.woff2?t=1725876968365') format('woff2'), // @font-face {
// url('iconfont.woff?t=1725876968365') format('woff'), // font-family: "iconfont"; /* Project id 4374193 */
// url('iconfont.ttf?t=1725876968365') format('truetype'); // src: url('iconfont.woff2?t=1725876968365') format('woff2'),
// } // url('iconfont.woff?t=1725876968365') format('woff'),
@font-face { // url('iconfont.ttf?t=1725876968365') format('truetype');
font-family: AlibabaPuHuiTi; // }
src: url("~@/static/font/Alibaba-PuHuiTi-Regular.ttf"); @font-face {
} font-family: AlibabaPuHuiTi;
src: url("~@/static/font/Alibaba-PuHuiTi-Regular.ttf");
@font-face { }
font-family: YouSheBiaoTiHei;
src: url("~@/static/font/YouSheBiaoTiHei.ttf"); @font-face {
} font-family: YouSheBiaoTiHei;
src: url("~@/static/font/YouSheBiaoTiHei.ttf");
body { }
width: 100vw;
// height: calc(100vh - 44px); body {
height: 100vh; width: 100vw;
background-color: #f3f6fa; // height: calc(100vh - 44px);
height: 100vh;
/* background-color: red; */ background-color: #f3f6fa;
}
/* background-color: red; */
* { }
box-sizing: border-box;
font-family: AlibabaPuHuiTi; * {
/* font-size: 9.41rpx; */ box-sizing: border-box;
} font-family: AlibabaPuHuiTi;
/* font-size: 9.41rpx; */
image { }
will-change: transform;
/* 解决加载时瞬间拉伸问题 */ image {
width: auto; will-change: transform;
/* 解决加载时瞬间拉伸问题 */ /* 解决加载时瞬间拉伸问题 */
height: auto; width: auto;
/* 解决加载时瞬间拉伸问题 */ /* 解决加载时瞬间拉伸问题 */
image-rendering: -moz-crisp-edges; height: auto;
image-rendering: -o-crisp-edges; /* 解决加载时瞬间拉伸问题 */
image-rendering: -webkit-optimize-contrast; image-rendering: -moz-crisp-edges;
image-rendering: crisp-edges; image-rendering: -o-crisp-edges;
-ms-interpolation-mode: nearest-neighbor; image-rendering: -webkit-optimize-contrast;
} image-rendering: crisp-edges;
-ms-interpolation-mode: nearest-neighbor;
.uni-nav-bar-text { }
/* 导航栏文字大小 */
font-size: 24px !important; .uni-nav-bar-text {
letter-spacing: 1px; /* 导航栏文字大小 */
} font-size: 24px !important;
letter-spacing: 1px;
.uni-navbar--shadow { }
box-shadow: none !important;
} .uni-navbar--shadow {
box-shadow: none !important;
.uni-data-checklist .checklist-group { }
flex-wrap: nowrap !important;
} .uni-data-checklist .checklist-group {
flex-wrap: nowrap !important;
/*每个页面公共css */ }
</style>
\ No newline at end of file /*每个页面公共css */
</style>
...@@ -87,21 +87,12 @@ ...@@ -87,21 +87,12 @@
"style": { "style": {
"navigationBarTitleText": "" "navigationBarTitleText": ""
} }
<<<<<<< HEAD
=======
},
{
"path": "api/api",
"style": {
"navigationBarTitleText": ""
}
}, },
{ {
"path": "pages/test/index", "path": "pages/test/index",
"style": { "style": {
"navigationBarTitleText": "" "navigationBarTitleText": ""
} }
>>>>>>> master
} }
// { // {
// "path" : "api/api", // "path" : "api/api",
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论