提交 1099b8bd authored 作者: zs's avatar zs

zip

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