PageSourceSearch

https://lingyuzhao.top/js/diskMirrorShareVar.js

js lingyuzhao.top collected 2026-10-06 13:16:09 UTC 3,148 bytes, 111 lines download raw bytes

1class DiskMirrorShareVar {
2    /**
3     * 盘镜资源使用量
4     * @type {number}
5     */
6    static diskMirrorUseSize = 0;
7
8    /**
9     * 当前用户的盘镜数据
10     * @type {{
11     *   "userId":int,
12     *   "type":string,
13     *   "useAgreement":boolean,
14     *   "urls":[
15     *     {
16     *       "fileName",
17     *       "url",
18     *       "lastModified",
19     *       "size"
20     *     },
21     *   ],
22     *   "res":"ok!!!!"
23     * }}
24     */
25    static diskMirrorSystem = undefined;
26
27    /**
28     * 初始化盘镜数据
29     * @param diskMirror 初始化操作需要使用的盘镜客户端对象
30     * @param callback 回调函数
31     */
32    static initDiskMirrorSystem(diskMirror, callback = (e) => {
33        console.error(e);
34        jokerBoxPopUp.show("⚠️ 无法连接到盘镜云服务器!暂时无法使用哦~");
35    }) {
36        diskMirror.getUrls(my.id, 'Binary', (res) => {
37            this.diskMirrorSystem = res;
38            this.getDiskMirrorSystem().urls = this.getDiskMirrorSystem().urls.sort((a, b) => b.lastModified - a.lastModified)
39            let urls = this.getDiskMirrorSystem().urls;
40            if (urls === undefined) {
41                this.diskMirrorSystem.urls = [];
42            }
43            DiskMirrorShareVar.setDiskMirrorUseSize(res['useSize'])
44            if (callback !== undefined) {
45                callback(this.getDiskMirrorSystem())
46            }
47        }, (e) => {
48            if ('res' in e) {
49                if (e['res'].endsWith("不可读!!!")) {
50                    // 这里代表用户是第一次使用 盘镜 所以可能没有目录 但并不代表是发生了错误!!!
51                    this.diskMirrorSystem = {};
52                    this.diskMirrorSystem.urls = [];
53                    if (callback !== undefined) {
54                        callback(this.getDiskMirrorSystem())
55                    }
56                    return;
57                }
58                alert(e['res'])
59                return;
60            }
61            alert(e)
62        })
63    }
64
65    /**
66     * 返回盘镜数据
67     * @return {{
68     *   "userId":int,
69     *   "type":string,
70     *   "useAgreement":boolean,
71     *   "urls":[
72     *     {
73     *       "fileName",
74     *       "url",
75     *       "lastModified",
76     *       "size"
77     *     },
78     *   ],
79     *   "res":"ok!!!!"
80     * }}
81     */
82    static getDiskMirrorSystem() {
83        return this.diskMirrorSystem;
84    }
85
86    /**
87     * 获取盘镜资源使用量
88     * @return {number}
89     */
90    static getDiskMirrorUseSize() {
91        return DiskMirrorShareVar.diskMirrorUseSize;
92    }
93
94    /**
95     * 更新盘镜资源使用量
96     * @param size
97     */
98    static setDiskMirrorUseSize(size) {
99        DiskMirrorShareVar.diskMirrorUseSize = size;
100        return size;
101    }
102
103    /**
104     * 获取盘镜资源使用量占比
105     * @return {number}
106     */
107    static getDiskMirrorUseSizeProportion() {
108        return DiskMirrorShareVar.diskMirrorUseSize / WEB_CONF['user_disk_mirror_space_quota'];
109    }
110
111}

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.