Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
C
computedRoomPad
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
邓文彬
computedRoomPad
Commits
66584b83
提交
66584b83
authored
9月 17, 2024
作者:
邓文彬
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix(数据获取): 增加数据权限
上级
2a537883
显示空白字符变更
内嵌
并排
正在显示
7 个修改的文件
包含
154 行增加
和
40 行删除
+154
-40
App.vue
App.vue
+3
-0
content.vue
pages/home/content.vue
+14
-0
home.vue
pages/home/home.vue
+5
-4
login.vue
pages/login/login.vue
+21
-2
index.js
request/index.js
+5
-22
IoReadingAndWriting.js
utils/IoReadingAndWriting.js
+6
-3
systemCofig.js
utils/systemCofig.js
+100
-9
没有找到文件。
App.vue
浏览文件 @
66584b83
...
...
@@ -54,6 +54,8 @@ export default {
},
function
(
e
)
{}
);
// #endif
},
onShow
:
function
()
{
const
now_user
=
uni
.
getStorageSync
(
"now_user"
)
||
{};
...
...
@@ -91,6 +93,7 @@ export default {
});
})
.
catch
((
error
)
=>
{
console
.
log
(
"--USER_LiST-"
,
USER_LiST
)
// 文件不存在, 写入文件
const
fileContent
=
JSON
.
stringify
(
Base64
.
encode
(
JSON
.
stringify
(
USER_LiST
))
...
...
pages/home/content.vue
浏览文件 @
66584b83
...
...
@@ -241,6 +241,14 @@ export default {
},
toPage
()
{
// if (this.userInfo.isAdmin) {
// uni.showToast({
// title: "暂无权限",
// icon: "none",
// });
// return;
// }
uni
.
showLoading
();
getDarft
()
...
...
@@ -263,11 +271,17 @@ export default {
uni
.
hideLoading
();
})
.
catch
((
error
)
=>
{
if
(
error
.
code
==
0
)
{
uni
.
showToast
({
title
:
error
.
msg
,
icon
:
"none"
,
duration
:
1000
,
});
}
uni
.
navigateTo
({
url
:
"/pages/inspection/inspFirst"
,
});
uni
.
hideLoading
();
});
},
...
...
pages/home/home.vue
浏览文件 @
66584b83
...
...
@@ -97,11 +97,10 @@ export default {
userName
:
this
.
$store
.
state
.
now_user
.
user
,
};
},
onLoad
(
options
=
{})
{
onLoad
(
options
=
{})
{
// options就是路由参数,它是一个对象
// this.tabIndex = ;
this
.
tabClick
({},
options
.
tabIndex
||
0
)
console
.
log
(
"---------------------"
,
options
);
// 假设路由参数中有一个名为id的参数
this
.
tabClick
({},
options
.
tabIndex
||
0
);
},
methods
:
{
// 修改密码
...
...
@@ -127,8 +126,10 @@ export default {
url
:
"/pages/login/login"
,
success
()
{
_this
.
$store
.
commit
(
"SET_USER"
,
{});
uni
.
setStorageSync
(
"now_user"
,
this
.
$store
.
state
.
now_user
);
uni
.
setStorageSync
(
"last_time"
,
this
.
$store
.
state
.
last_time
);
//
uni.clearStorage(); //测试将所有缓存清除
uni
.
clearStorage
();
//测试将所有缓存清除
},
});
},
...
...
pages/login/login.vue
浏览文件 @
66584b83
...
...
@@ -39,6 +39,7 @@ import {
getLogContent
,
addLog
,
readDirectoryData
,
readLogData
,
}
from
"@/utils/IoReadingAndWriting.js"
;
import
moment
from
"moment"
;
...
...
@@ -49,8 +50,11 @@ export default {
data
()
{
return
{
person
:
{
user
:
"
xh
qxj"
,
user
:
"
bj
qxj"
,
pd
:
"JF85250920"
,
// user: "hzsgjy", // 超管账号
// pd: "JFXJ85250920",
},
backButtonPress
:
0
,
personList
:
[],
...
...
@@ -152,9 +156,24 @@ export default {
duration
:
2000
,
});
let
log_list
=
[];
readLogData
()
.
then
((
res
)
=>
{
log_list
=
res
;
})
.
catch
((
error
)
=>
{
if
(
error
.
code
==
0
)
{
uni
.
showToast
({
title
:
error
.
msg
,
icon
:
"none"
,
duration
:
2000
,
});
return
;
}
});
// 更新日志信息
const
logContent
=
getLogContent
(
LOG_TYPE_ENUM
.
login
);
const
log_list
=
this
.
$store
.
state
.
log_list
||
[];
//
const log_list = this.$store.state.log_list || [];
log_list
.
push
(
logContent
);
this
.
$store
.
commit
(
"SET_LOG_LIST"
,
log_list
);
addLog
(
log_list
);
...
...
request/index.js
浏览文件 @
66584b83
...
...
@@ -4,7 +4,6 @@ import {
readInspectionData
,
readDarfData
}
from
"@/utils/IoReadingAndWriting.js"
;
import
{
sortTimeDesc
}
from
"@/utils/common.js"
;
import
lodash
from
"lodash"
;
...
...
@@ -14,14 +13,9 @@ import lodash from "lodash";
* @returns
*/
export
const
getAllInspections
=
()
=>
{
const
all_data
=
store
.
state
.
all_data
||
[];
return
new
Promise
((
resolve
,
reject
)
=>
{
if
(
all_data
.
length
)
{
resolve
(
all_data
)
}
else
{
readInspectionData
()
.
then
((
res
)
=>
{
// console.log("----读出来的巡检文件", res);
const
tempRes
=
lodash
.
orderBy
(
res
,
"creatTime"
,
[
'desc'
]);
store
.
commit
(
"SET_ALL_DATA"
,
tempRes
);
...
...
@@ -30,7 +24,6 @@ export const getAllInspections = () => {
.
catch
((
error
)
=>
{
reject
(
error
)
})
}
})
}
...
...
@@ -40,21 +33,18 @@ export const getAllInspections = () => {
* @returns
*/
export
const
getLogList
=
()
=>
{
const
log_list
=
store
.
state
.
log_list
||
[];
return
new
Promise
((
resolve
,
reject
)
=>
{
if
(
log_list
.
length
)
{
resolve
(
log_list
)
}
else
{
readLogData
()
.
then
((
res
)
=>
{
console
.
log
(
"----读出来的日志文件"
,
res
);
store
.
commit
(
"SET_LOG_LIST"
,
res
);
resolve
(
res
)
console
.
log
(
"-getLogList--"
,
res
)
const
tempRes
=
lodash
.
orderBy
(
res
,
"time"
,
"desc"
);
store
.
commit
(
"SET_LOG_LIST"
,
tempRes
);
resolve
(
tempRes
)
})
.
catch
((
error
)
=>
{
reject
(
error
)
})
}
})
}
...
...
@@ -69,7 +59,6 @@ export const getInspectionDetails = (uid) => {
return
new
Promise
((
resolve
,
reject
)
=>
{
getAllInspections
()
.
then
((
res
)
=>
{
console
.
log
(
"--list-"
,
res
)
const
detailsInfo
=
res
.
filter
((
item
)
=>
item
.
uid
==
uid
)[
0
]
||
{};
resolve
(
detailsInfo
)
...
...
@@ -86,11 +75,7 @@ export const getInspectionDetails = (uid) => {
* @returns
*/
export
const
getDarft
=
()
=>
{
const
darf_data
=
store
.
state
.
darf_data
||
{};
return
new
Promise
((
resolve
,
reject
)
=>
{
if
(
darf_data
.
inspectionType
)
{
resolve
(
darf_data
)
}
else
{
readDarfData
()
.
then
((
res
)
=>
{
console
.
log
(
"----读出来的草稿文件"
,
res
);
...
...
@@ -100,6 +85,5 @@ export const getDarft = () => {
.
catch
((
error
)
=>
{
reject
(
error
)
})
}
})
}
\ No newline at end of file
utils/IoReadingAndWriting.js
浏览文件 @
66584b83
...
...
@@ -75,15 +75,17 @@ export const addLog = (content) => {
// 读取日志
export
const
readLogData
=
()
=>
{
const
now_user
=
store
.
state
.
now_user
;
const
directoryPath
=
`
${
SYNCHRONIZE_DATA_PAD
}
/日志文件/
${
now_user
.
user
}
`
;
const
isAdmin
=
now_user
.
isAdmin
;
const
directoryPath
=
isAdmin
?
`
${
SYNCHRONIZE_DATA_PAD
}
/日志文件`
:
`
${
SYNCHRONIZE_DATA_PAD
}
/日志文件/
${
now_user
.
user
}
`
;
return
new
Promise
((
resolve
,
reject
)
=>
{
readFilesInDirectory
(
directoryPath
)
.
then
((
res
)
=>
{
console
.
log
(
"--读取日志-, "
,
directoryPath
,
res
)
const
temp
=
res
.
map
((
element
)
=>
{
return
JSON
.
parse
(
Base64
.
decode
(
element
));
});
// console.log("读取志文件数据--", temp);
resolve
(
lodash
.
flattenDeep
(
temp
));
})
...
...
@@ -175,7 +177,8 @@ export const writeInspectionData = (content, isEncryption = false) => {
// 读取【巡检数据】文件
export
const
readInspectionData
=
()
=>
{
const
now_user
=
store
.
state
.
now_user
;
const
directoryPath
=
`
${
SYNCHRONIZE_DATA_PAD
}
/巡检数据/
${
now_user
.
user
}
`
;
const
isAdmin
=
now_user
.
isAdmin
;
const
directoryPath
=
isAdmin
?
`
${
SYNCHRONIZE_DATA_PAD
}
/巡检数据`
:
`
${
SYNCHRONIZE_DATA_PAD
}
/巡检数据/
${
now_user
.
user
}
`
;
return
new
Promise
((
resolve
,
reject
)
=>
{
readFilesInDirectory
(
directoryPath
)
...
...
utils/systemCofig.js
浏览文件 @
66584b83
...
...
@@ -60,15 +60,15 @@ export const FILE_ENUM = { // 文件枚举
export
const
USER_LiST
=
[
{
id
:
1
,
user
:
"hzsgjy"
,
passWord
:
"JFXJ85250920"
,
areaName
:
"市本级"
,
id
:
1
,
// 有用
user
:
"hzsgjy"
,
// 有用
passWord
:
"JFXJ85250920"
,
// 有用
areaName
:
"市本级"
,
// 有用
permission
:
1
,
name
:
"超管"
,
name
:
"超管"
,
// 有用
oid
:
"scq"
,
unitName
:
"所属单位"
unitName
:
"所属单位"
,
// 所属单位
isAdmin
:
true
,
// 标识超管权限
},
{
id
:
3
,
...
...
@@ -333,7 +333,7 @@ export async function checkFileExists(directoryPath, fileName) {
}
// 读取文件夹下面所有的文件
export
const
readFilesInDirectory
=
async
(
directoryPath
)
=>
{
export
const
readFilesInDirectory
11
=
async
(
directoryPath
)
=>
{
const
promiseArr
=
[];
return
new
Promise
((
resolve
,
reject
)
=>
{
plus
.
io
.
requestFileSystem
(
...
...
@@ -390,7 +390,7 @@ export const readFilesInDirectory = async (directoryPath) => {
);
},
function
(
error
)
{
console
.
log
(
"readFilesInDirectory:"
,
error
,
directoryPath
);
console
.
log
(
"readFilesInDirectory:"
,
error
,
directoryPath
);
reject
({
...
FILE_ENUM
.
getDirectoryError
...
...
@@ -410,6 +410,97 @@ export const readFilesInDirectory = async (directoryPath) => {
);
});
};
export
const
readFilesInDirectory
=
async
(
directoryPath
)
=>
{
const
promiseArr
=
[];
return
new
Promise
((
resolve
,
reject
)
=>
{
plus
.
io
.
requestFileSystem
(
plus
.
io
.
PRIVATE_DOC
,
function
(
fs
)
{
fs
.
root
.
getDirectory
(
directoryPath
,
{
create
:
false
},
function
(
dirEntry
)
{
let
directoryReader
=
dirEntry
.
createReader
();
directoryReader
.
readEntries
(
function
(
entries
)
{
entries
.
forEach
((
entry
)
=>
{
if
(
entry
.
isFile
)
{
// 读取文件内容
promiseArr
.
push
(
readFileContent
(
entry
));
}
else
if
(
entry
.
isDirectory
)
{
// 递归读取子目录内容
promiseArr
.
push
(
readFilesInDirectory
(
entry
.
fullPath
));
}
});
Promise
.
all
(
promiseArr
)
.
then
((
results
)
=>
{
// 扁平化结果数组,因为子目录可能返回一个包含多个文件内容的数组
const
flatResults
=
results
.
flat
(
Infinity
);
resolve
(
flatResults
);
})
.
catch
((
error
)
=>
{
console
.
log
(
"readFilesInDirectory:"
,
error
);
reject
({
...
FILE_ENUM
.
getFileError
,
message
:
"读取文件内容失败:"
+
error
.
message
});
});
},
function
(
error
)
{
console
.
log
(
"readFilesInDirectory:"
,
error
);
reject
({
...
FILE_ENUM
.
readDirectoryError
,
message
:
"读取目录条目失败:"
+
error
.
message
});
}
);
},
function
(
error
)
{
console
.
log
(
"readFilesInDirectory:"
,
error
,
directoryPath
);
reject
({
...
FILE_ENUM
.
getDirectoryError
,
message
:
"获取目录失败:"
+
error
.
message
});
}
);
},
function
(
error
)
{
console
.
log
(
"readFilesInDirectory:"
,
error
);
reject
({
...
FILE_ENUM
.
fileSystemError
,
message
:
"请求文件系统失败:"
+
error
.
message
});
}
);
});
};
// // 使用封装的Promise函数
// const rootDirectoryPath = '_doc/your-root-directory'; // 替换为你的根目录路径
// readAllFilesInDirectoryPromise(rootDirectoryPath)
// .then((allFilesContent) => {
// console.log('All files content:', allFilesContent);
// // 处理所有文件内容
// })
// .catch((error) => {
// console.error('Error reading files:', error);
// });
// 使用封装的Promise函数
// const rootDirectoryPath = '_doc/your-root-directory'; // 替换为你的根目录路径
// readAllFilesInDirectoryPromise(rootDirectoryPath)
// .then((allFilesContent) => {
// console.log('All files content:', allFilesContent);
// // 处理所有文件内容
// })
// .catch((error) => {
// console.error('Error reading files:', error);
// });
// 读取【单个文件】内容
export
async
function
readFileContent
(
fileEntry
)
{
return
new
Promise
((
resolve
,
reject
)
=>
{
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论