* =================================== * 工具类函数 * ===================================
(url)
| 966 | */ |
| 967 | |
| 968 | function reloadAppSubCache(url) { |
| 969 | // 地址后面拼时间缀, 避免 GET 缓存 |
| 970 | const requrl = `${url}${ |
| 971 | url.includes('?') ? '&' : '?' |
| 972 | }_=${new Date().getTime()}` |
| 973 | return $.http.get(requrl).then((resp) => { |
| 974 | try { |
| 975 | const subcaches = getAppSubCaches() |
| 976 | subcaches[url] = $.toObj(resp.body) |
| 977 | subcaches[url].updateTime = new Date() |
| 978 | // 仅缓存存在 id 的订阅 |
| 979 | Object.keys(subcaches).forEach((key) => { |
| 980 | if (!subcaches[key].hasOwnProperty('id')) { |
| 981 | delete subcaches[key] |
| 982 | } |
| 983 | }) |
| 984 | $.setjson(subcaches, $.KEY_app_subCaches) |
| 985 | $.log(`更新订阅, 成功! ${url}`) |
| 986 | } catch (e) { |
| 987 | $.logErr(e) |
| 988 | $.log(`更新订阅, 失败! ${url}`) |
| 989 | } |
| 990 | }) |
| 991 | } |
| 992 | |
| 993 | function update(obj, path, value) { |
| 994 | const keys = path.split('.') |