提交 8e7824a0 authored 作者: JaxBBLL's avatar JaxBBLL
...@@ -7,11 +7,7 @@ ...@@ -7,11 +7,7 @@
<view class="header-buttons"> <view class="header-buttons">
<view class="log-button" @click="lookLog" v-if="isAdmin">操作日志</view> <view class="log-button" @click="lookLog" v-if="isAdmin">操作日志</view>
<div class="exit-button" @click="logOut"> <div class="exit-button" @click="logOut">
<image <image class="logout" src="@/static/img/logout.svg" mode="aspectFit"></image>
class="logout"
src="@/static/img/logout.svg"
mode="aspectFit"
></image>
</div> </div>
</view> </view>
</view> </view>
...@@ -21,13 +17,8 @@ ...@@ -21,13 +17,8 @@
<view class="profile-box"> <view class="profile-box">
<view class="profile-left"> <view class="profile-left">
<view class="avatar"> <view class="avatar">
<image <image src="@/static/img/add-img/defaultAvatar.png" mode="aspectFit"></image>
src="@/static/img/add-img/defaultAvatar.png" <view class="change-password" @click="updatePassword">修改密码</view>
mode="aspectFit"
></image>
<view class="change-password" @click="updatePassword"
>修改密码</view
>
</view> </view>
<view class="username">{{ userName }}</view> <view class="username">{{ userName }}</view>
</view> </view>
...@@ -45,36 +36,25 @@ ...@@ -45,36 +36,25 @@
<!-- 第三个模块 --> <!-- 第三个模块 -->
<view class="card-section"> <view class="card-section">
<view class="card-container"> <view class="card-container">
<view <view class="card" v-for="(card, index) in cards" :key="index"
class="card" :style="{ backgroundImage: `url(${card.image})` }" @click="toList(card.url)">
v-for="(card, index) in cards"
:key="index"
:style="{ backgroundImage: `url(${card.image})` }"
@click="toList(card.url)"
>
<view class="card-text">{{ card.text }}</view> <view class="card-text">{{ card.text }}</view>
</view> </view>
</view> </view>
</view> </view>
<!-- 退出账号弹出 --> <!-- 退出账号弹出 -->
<uni-popup ref="inputDialog2" type="dialog"> <uni-popup ref="inputDialog2" type="dialog">
<uni-popup-dialog <uni-popup-dialog ref="inputClose2" mode="base" title="确定退出该账号?" @confirm="dialogInputConfirm2">
ref="inputClose2"
mode="base"
title="确定退出该账号?"
@confirm="dialogInputConfirm2"
>
</uni-popup-dialog> </uni-popup-dialog>
</uni-popup> </uni-popup>
</view> </view>
</template> </template>
<script> <script>
export default { export default {
data() { data() {
return { return {
cards: [ cards: [{
{
image: "../../static/img/jf.png", image: "../../static/img/jf.png",
text: "机房巡检", text: "机房巡检",
url: "/pages/inspectionContent/inspectionContentList?backValue=home", url: "/pages/inspectionContent/inspectionContentList?backValue=home",
...@@ -102,6 +82,7 @@ export default { ...@@ -102,6 +82,7 @@ export default {
console.log(this.$store.state); console.log(this.$store.state);
}, },
methods: { methods: {
// 修改密码 // 修改密码
updatePassword() { updatePassword() {
uni.navigateTo({ uni.navigateTo({
...@@ -156,11 +137,11 @@ export default { ...@@ -156,11 +137,11 @@ export default {
}); });
}, },
}, },
}; };
</script> </script>
<style scoped lang="less"> <style scoped lang="less">
.container { .container {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
align-items: center; align-items: center;
...@@ -168,9 +149,9 @@ export default { ...@@ -168,9 +149,9 @@ export default {
height: 100vh; height: 100vh;
background-image: linear-gradient(115deg, #e8f0fb 0%, #e1ebfa 100%); background-image: linear-gradient(115deg, #e8f0fb 0%, #e1ebfa 100%);
z-index: 1; z-index: 1;
} }
.header { .header {
width: 100%; width: 100%;
display: flex; display: flex;
justify-content: space-between; justify-content: space-between;
...@@ -227,9 +208,9 @@ export default { ...@@ -227,9 +208,9 @@ export default {
} }
} }
} }
} }
.profile-section { .profile-section {
width: 720px; width: 720px;
.profile-box { .profile-box {
...@@ -312,9 +293,9 @@ export default { ...@@ -312,9 +293,9 @@ export default {
} }
} }
} }
} }
.card-section { .card-section {
width: 720px; width: 720px;
margin-top: 20px; margin-top: 20px;
...@@ -343,5 +324,5 @@ export default { ...@@ -343,5 +324,5 @@ export default {
} }
} }
} }
} }
</style> </style>
\ No newline at end of file
import { Base64 } from "js-base64"; import {
Base64
} from "js-base64";
export const BASE_PATH = "_documents/data/asmzx"; // 基础路径 export const BASE_PATH = "_documents/data/asmzx"; // 基础路径
export const SYNCHRONIZE_DATA_PATH = "_documents/data/asmzx"; // 同步数据 export const SYNCHRONIZE_DATA_PATH = "_documents/data/asmzx"; // 同步数据
...@@ -116,12 +118,13 @@ export function checkAndCreateDirectory(directoryPath) { ...@@ -116,12 +118,13 @@ export function checkAndCreateDirectory(directoryPath) {
// 请求文件系统 // 请求文件系统
plus.io.requestFileSystem( plus.io.requestFileSystem(
plus.io.PUBLIC_DOCUMENTS, plus.io.PUBLIC_DOCUMENTS,
function (fs) { function(fs) {
// 获取指定目录的目录条目 // 获取指定目录的目录条目
fs.root.getDirectory( fs.root.getDirectory(
directoryPath, directoryPath, {
{ create: false }, create: false
function (dirEntry) { },
function(dirEntry) {
// 目录存在 // 目录存在
console.log( console.log(
"systemCofig.js_checkAndCreateDirectory_目录已存在:", "systemCofig.js_checkAndCreateDirectory_目录已存在:",
...@@ -131,14 +134,15 @@ export function checkAndCreateDirectory(directoryPath) { ...@@ -131,14 +134,15 @@ export function checkAndCreateDirectory(directoryPath) {
resolve(dirEntry); resolve(dirEntry);
return return
}, },
function (error) { function(error) {
// 目录不存在,创建目录 // 目录不存在,创建目录
if (error.code === 1) { if (error.code === 1) {
// DOM Exception: NOT_FOUND_ERR (1) // DOM Exception: NOT_FOUND_ERR (1)
fs.root.getDirectory( fs.root.getDirectory(
directoryPath, directoryPath, {
{ create: true }, create: true
function (newDirEntry) { },
function(newDirEntry) {
console.log( console.log(
"systemCofig.js_checkAndCreateDirectory_目录创建成功:", "systemCofig.js_checkAndCreateDirectory_目录创建成功:",
newDirEntry.fullPath newDirEntry.fullPath
...@@ -146,7 +150,7 @@ export function checkAndCreateDirectory(directoryPath) { ...@@ -146,7 +150,7 @@ export function checkAndCreateDirectory(directoryPath) {
resolve(newDirEntry); resolve(newDirEntry);
}, },
function (error) { function(error) {
reject({ reject({
...error, ...error,
msg: "systemCofig.js_checkAndCreateDirectory__创建目录失败:", msg: "systemCofig.js_checkAndCreateDirectory__创建目录失败:",
...@@ -160,9 +164,10 @@ export function checkAndCreateDirectory(directoryPath) { ...@@ -160,9 +164,10 @@ export function checkAndCreateDirectory(directoryPath) {
); );
fs.root.getDirectory( fs.root.getDirectory(
directoryPath, directoryPath, {
{ create: true }, create: true
function (newDirEntry) { },
function(newDirEntry) {
console.log( console.log(
"systemCofig.js_checkAndCreateDirectory_目录创建成功:", "systemCofig.js_checkAndCreateDirectory_目录创建成功:",
newDirEntry.fullPath newDirEntry.fullPath
...@@ -175,7 +180,7 @@ export function checkAndCreateDirectory(directoryPath) { ...@@ -175,7 +180,7 @@ export function checkAndCreateDirectory(directoryPath) {
} }
); );
}, },
function (error) { function(error) {
reject({ reject({
...error, ...error,
msg: "systemCofig.js_checkAndCreateDirectory_请求文件系统失败:", msg: "systemCofig.js_checkAndCreateDirectory_请求文件系统失败:",
...@@ -191,23 +196,25 @@ export async function checkFileExists(directoryPath, fileName) { ...@@ -191,23 +196,25 @@ export async function checkFileExists(directoryPath, fileName) {
// 请求文件系统 // 请求文件系统
plus.io.requestFileSystem( plus.io.requestFileSystem(
plus.io.PUBLIC_DOCUMENTS, plus.io.PUBLIC_DOCUMENTS,
function (fs) { function(fs) {
// 获取指定目录的目录条目 // 获取指定目录的目录条目
fs.root.getDirectory( fs.root.getDirectory(
directoryPath, directoryPath, {
{ create: false }, create: false
function (dirEntry) { },
function(dirEntry) {
// 尝试获取文件 // 尝试获取文件
dirEntry.getFile( dirEntry.getFile(
fileName, fileName, {
{ create: false }, create: false
function (fileEntry) { },
function(fileEntry) {
// 文件存在 // 文件存在
console.log("文件存在:", fileEntry.fullPath); console.log("文件存在:", fileEntry.fullPath);
resolve(fileEntry); resolve(fileEntry);
}, },
function (error) { function(error) {
// 文件不存在 // 文件不存在
reject({ reject({
...error, ...error,
...@@ -219,7 +226,7 @@ export async function checkFileExists(directoryPath, fileName) { ...@@ -219,7 +226,7 @@ export async function checkFileExists(directoryPath, fileName) {
} }
); );
}, },
function (error) { function(error) {
console.error("获取目录失败:", error.message); console.error("获取目录失败:", error.message);
reject({ reject({
...error, ...error,
...@@ -229,7 +236,7 @@ export async function checkFileExists(directoryPath, fileName) { ...@@ -229,7 +236,7 @@ export async function checkFileExists(directoryPath, fileName) {
} }
); );
}, },
function (error) { function(error) {
console.error("请求文件系统失败:", error.message); console.error("请求文件系统失败:", error.message);
reject({ reject({
...error, ...error,
...@@ -247,21 +254,23 @@ export const readFilesInDirectory = async (directoryPath) => { ...@@ -247,21 +254,23 @@ export const readFilesInDirectory = async (directoryPath) => {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
plus.io.requestFileSystem( plus.io.requestFileSystem(
plus.io.PRIVATE_DOC, plus.io.PRIVATE_DOC,
function (fs) { function(fs) {
fs.root.getDirectory( fs.root.getDirectory(
directoryPath, directoryPath, {
{ create: false }, create: false
function (dirEntry) { },
function(dirEntry) {
let directoryReader = dirEntry.createReader(); let directoryReader = dirEntry.createReader();
directoryReader.readEntries( directoryReader.readEntries(
function (entries) { function(entries) {
entries.forEach((entry) => { entries.forEach((entry) => {
if (entry.isFile) { if (entry.isFile) {
// 读取文件内容 // 读取文件内容
promiseArr.push(readFileContent(entry)); promiseArr.push(readFileContent(entry));
} else if (entry.isDirectory) { } else if (entry.isDirectory) {
// 递归读取子目录内容 // 递归读取子目录内容
promiseArr.push(readFilesInDirectory(entry.fullPath)); promiseArr.push(readFilesInDirectory(entry
.fullPath));
} }
}); });
...@@ -275,11 +284,12 @@ export const readFilesInDirectory = async (directoryPath) => { ...@@ -275,11 +284,12 @@ export const readFilesInDirectory = async (directoryPath) => {
console.log("readFilesInDirectory:", error); console.log("readFilesInDirectory:", error);
reject({ reject({
...FILE_ENUM.getFileError, ...FILE_ENUM.getFileError,
message: "读取文件内容失败:" + error.message, message: "读取文件内容失败:" + error
.message,
}); });
}); });
}, },
function (error) { function(error) {
console.log("readFilesInDirectory:", error); console.log("readFilesInDirectory:", error);
reject({ reject({
...FILE_ENUM.readDirectoryError, ...FILE_ENUM.readDirectoryError,
...@@ -288,7 +298,7 @@ export const readFilesInDirectory = async (directoryPath) => { ...@@ -288,7 +298,7 @@ export const readFilesInDirectory = async (directoryPath) => {
} }
); );
}, },
function (error) { function(error) {
console.log("readFilesInDirectory:", error, directoryPath); console.log("readFilesInDirectory:", error, directoryPath);
reject({ reject({
...FILE_ENUM.getDirectoryError, ...FILE_ENUM.getDirectoryError,
...@@ -297,7 +307,7 @@ export const readFilesInDirectory = async (directoryPath) => { ...@@ -297,7 +307,7 @@ export const readFilesInDirectory = async (directoryPath) => {
} }
); );
}, },
function (error) { function(error) {
console.log("readFilesInDirectory:", error); console.log("readFilesInDirectory:", error);
reject({ reject({
...FILE_ENUM.fileSystemError, ...FILE_ENUM.fileSystemError,
...@@ -315,10 +325,10 @@ export async function readFileContent(fileEntry) { ...@@ -315,10 +325,10 @@ export async function readFileContent(fileEntry) {
// 创建FileReader对象 // 创建FileReader对象
const reader = new plus.io.FileReader(); const reader = new plus.io.FileReader();
// 读取文件 // 读取文件
reader.onload = function (e) { reader.onload = function(e) {
resolve(e.target.result); resolve(e.target.result);
}; };
reader.onerror = function (e) { reader.onerror = function(e) {
console.error( console.error(
"systemCofig.js_readFileContent_读取文件失败:", "systemCofig.js_readFileContent_读取文件失败:",
e.target.error e.target.error
...@@ -347,24 +357,26 @@ export function createFileWithPlusIO(directoryPath, fileName, fileContent) { ...@@ -347,24 +357,26 @@ export function createFileWithPlusIO(directoryPath, fileName, fileContent) {
// 请求文件系统 // 请求文件系统
plus.io.requestFileSystem( plus.io.requestFileSystem(
plus.io.PUBLIC_DOCUMENTS, plus.io.PUBLIC_DOCUMENTS,
function (fs) { function(fs) {
// 获取或创建目录 // 获取或创建目录
fs.root.getDirectory( fs.root.getDirectory(
directoryPath, directoryPath, {
{ create: true }, create: true
function (dirEntry) { },
function(dirEntry) {
// 创建文件 // 创建文件
dirEntry.getFile( dirEntry.getFile(
fileName, fileName, {
{ create: true }, create: true
function (fileEntry) { },
function(fileEntry) {
// 写入文件 // 写入文件
fileEntry.createWriter( fileEntry.createWriter(
function (fileWriter) { function(fileWriter) {
fileWriter.onwriteend = function () { fileWriter.onwriteend = function() {
resolve(fileContent); resolve(fileContent);
}; };
fileWriter.onerror = function (error) { fileWriter.onerror = function(error) {
console.log( console.log(
"createFileWithPlusIO_文件创建或写入失败:", "createFileWithPlusIO_文件创建或写入失败:",
error error
...@@ -378,7 +390,7 @@ export function createFileWithPlusIO(directoryPath, fileName, fileContent) { ...@@ -378,7 +390,7 @@ export function createFileWithPlusIO(directoryPath, fileName, fileContent) {
// 向文件中写入数据 // 向文件中写入数据
fileWriter.write(fileContent); fileWriter.write(fileContent);
}, },
function (error) { function(error) {
console.log( console.log(
"createFileWithPlusIO_创建文件写入器失败:", "createFileWithPlusIO_创建文件写入器失败:",
error error
...@@ -391,7 +403,7 @@ export function createFileWithPlusIO(directoryPath, fileName, fileContent) { ...@@ -391,7 +403,7 @@ export function createFileWithPlusIO(directoryPath, fileName, fileContent) {
} }
); );
}, },
function (error) { function(error) {
console.log("createFileWithPlusIO_获取文件失败:", error); console.log("createFileWithPlusIO_获取文件失败:", error);
reject({ reject({
...@@ -401,7 +413,7 @@ export function createFileWithPlusIO(directoryPath, fileName, fileContent) { ...@@ -401,7 +413,7 @@ export function createFileWithPlusIO(directoryPath, fileName, fileContent) {
} }
); );
}, },
function (error) { function(error) {
console.log("createFileWithPlusIO_获取目录失败:", error); console.log("createFileWithPlusIO_获取目录失败:", error);
reject({ reject({
...@@ -411,7 +423,7 @@ export function createFileWithPlusIO(directoryPath, fileName, fileContent) { ...@@ -411,7 +423,7 @@ export function createFileWithPlusIO(directoryPath, fileName, fileContent) {
} }
); );
}, },
function (error) { function(error) {
reject({ reject({
...error, ...error,
...FILE_ENUM.fileSystemError, ...FILE_ENUM.fileSystemError,
...@@ -448,7 +460,7 @@ export function getUserList() { ...@@ -448,7 +460,7 @@ export function getUserList() {
} else { } else {
uni.getStorage({ uni.getStorage({
key: "user_data", key: "user_data",
success: function (res) { success: function(res) {
resolve(eval(value)); resolve(eval(value));
}, },
}); });
...@@ -458,3 +470,26 @@ export function getUserList() { ...@@ -458,3 +470,26 @@ export function getUserList() {
} }
}); });
} }
export function zipCompress(name) {
const BASE_PATH = "_documents/data";
const targetPath = plus.io.convertLocalFileSystemURL(BASE_PATH + '/photos');
const zipfile = plus.io.convertLocalFileSystemURL(BASE_PATH + `/${name}.zip`);
plus.zip.compress(
targetPath,
zipfile, {
recursive: true,
overwrite: true
},
function() {
plus.io.resolveLocalFileSystemURL(zipfile, function(zipEntry) {
zipEntry.file(function(file) {
console.log("ZIP 文件大小: " + file.size + " 字节");
});
});
},
function(error) {
alert("压缩失败: " + error.message);
}
);
}
\ No newline at end of file
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论