Repository navigation
Expand file tree
/
Copy path子页面-观看历史.js
More file actions
67 lines (67 loc) · 2.1 KB
/
Copy path子页面-观看历史.js
File metadata and controls
67 lines (67 loc) · 2.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
js:
var d = [];
setPageTitle('Alist|观影历史');
const {color,small} = $.require('hiker://page/utils');
d.push({
title: "清空",
url: $('确认清空历史记录?').confirm(() => {
// deleteFile('view_history.json');
saveFile('view_history.json','[]',0);
refreshPage(false);
return "toast://观影历史已清空!"
}),
col_type: "text_3"
});
let hisPath = `hiker://files/rules/files/${MY_RULE.title}/view_history.json`;
d.push({
title: "编辑",
url: $('#noLoading#').lazyRule((hisPath)=>{
if(!fileExist(hisPath)){
saveFile('view_history.json','[]',0);
}
return 'editFile://'+hisPath
},hisPath),
col_type: "text_3"
});
let option = getItem('his_click','播放');
d.push({
title: option==='播放'?option:color(option,'#ab2415'),
url: $('#noLoading#').lazyRule((color)=>{
let option = getItem('his_click','播放');
let nextOption = option === '播放'?'删除':'播放';
setItem('his_click',nextOption);
updateItem("his_click", {
title:nextOption==='播放'?nextOption:color(nextOption,'#ab2415')
});
refreshPage(false);
return 'hiker://empty'
},color),
col_type: "text_3",
extra:{
id:'his_click'
}
});
let view_history = JSON.parse(readFile('view_history.json', 0) || '[]');
if(view_history.length > 0){
view_history.forEach((it)=>{
it.col_type = 'text_1';
if(option==='删除'){
it.url = $('#noLoading#').lazyRule((id)=>{
let view_history = JSON.parse(readFile('view_history.json', 0) || '[]');
let idex = view_history.findIndex(x=>x.extra.id === id);
view_history.splice(idex,1);
saveFile('view_history.json', JSON.stringify(view_history),0);
refreshPage(false);
return 'hiker://empty'
},it.extra.id);
}
d.push(it);
});
}else{
d.push({
title:'暂无观影记录,先去观看一个视频吧!',
col_type:'text_center_1',
url:'hiker://empty'
});
}
setResult(d);