mirror of
https://github.com/kuaifan/dootask.git
synced 2026-03-06 09:27:05 +00:00
perf: 优化本地数据
This commit is contained in:
parent
51d878469f
commit
1b23b4621a
14
electron/drawio.js
vendored
14
electron/drawio.js
vendored
File diff suppressed because one or more lines are too long
@ -31,6 +31,7 @@
|
||||
"le5le-store": "^1.0.7",
|
||||
"less": "^4.1.2",
|
||||
"less-loader": "^10.2.0",
|
||||
"localforage": "^1.10.0",
|
||||
"lodash": "^4.17.21",
|
||||
"moment": "^2.29.1",
|
||||
"node-sass": "^6.0.1",
|
||||
|
||||
@ -118,22 +118,25 @@ export default {
|
||||
}, 6000)
|
||||
}
|
||||
//
|
||||
if ($A.openLog) {
|
||||
$A.loadScript('js/vconsole.min.js', (e) => {
|
||||
if (e !== null || typeof window.VConsole !== 'function') {
|
||||
$A.modalError("vConsole 组件加载失败!");
|
||||
return;
|
||||
}
|
||||
window.vConsole = new window.VConsole({
|
||||
onReady: () => {
|
||||
console.log('vConsole: onReady');
|
||||
},
|
||||
onClearLog: () => {
|
||||
console.log('vConsole: onClearLog');
|
||||
$A.IDBString("logOpen").then(r => {
|
||||
$A.openLog = r === "open"
|
||||
if ($A.openLog) {
|
||||
$A.loadScript('js/vconsole.min.js', (e) => {
|
||||
if (e !== null || typeof window.VConsole !== 'function') {
|
||||
$A.modalError("vConsole 组件加载失败!");
|
||||
return;
|
||||
}
|
||||
window.vConsole = new window.VConsole({
|
||||
onReady: () => {
|
||||
console.log('vConsole: onReady');
|
||||
},
|
||||
onClearLog: () => {
|
||||
console.log('vConsole: onClearLog');
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
},
|
||||
immediate: true
|
||||
@ -237,7 +240,7 @@ export default {
|
||||
key: 'manifest',
|
||||
url: $A.apiUrl("../manifest")
|
||||
})
|
||||
$A.bindScreenshotKey($A.jsonParse(window.localStorage['__keyboard:data__'] || {}));
|
||||
$A.bindScreenshotKey($A.jsonParse(window.localStorage.getItem("__keyboard:data__") || {}));
|
||||
},
|
||||
|
||||
eeuiEvents() {
|
||||
|
||||
29
resources/assets/js/app.js
vendored
29
resources/assets/js/app.js
vendored
@ -141,7 +141,7 @@ $A.Platform = "web";
|
||||
$A.isMainElectron = false;
|
||||
$A.isSubElectron = false;
|
||||
$A.isEEUiApp = isEEUiApp;
|
||||
$A.openLog = $A.getStorageString("log::open") === "open";
|
||||
$A.openLog = false;
|
||||
if (isElectron) {
|
||||
$A.Electron = electron;
|
||||
$A.Platform = /macintosh|mac os x/i.test(navigator.userAgent) ? "mac" : "win";
|
||||
@ -193,16 +193,19 @@ Vue.prototype.$isEEUiApp = $A.isEEUiApp;
|
||||
Vue.config.productionTip = false;
|
||||
Vue.mixin(mixin)
|
||||
|
||||
const app = new Vue({
|
||||
el: '#app',
|
||||
router,
|
||||
store,
|
||||
template: '<App/>',
|
||||
components: { App }
|
||||
});
|
||||
let app;
|
||||
store.dispatch("init").then(_ => {
|
||||
app = new Vue({
|
||||
el: '#app',
|
||||
router,
|
||||
store,
|
||||
template: '<App/>',
|
||||
components: { App }
|
||||
});
|
||||
|
||||
$A.goForward = app.goForward;
|
||||
$A.goBack = app.goBack;
|
||||
$A.Message = app.$Message;
|
||||
$A.Notice = app.$Notice;
|
||||
$A.Modal = app.$Modal;
|
||||
$A.goForward = app.goForward;
|
||||
$A.goBack = app.goBack;
|
||||
$A.Message = app.$Message;
|
||||
$A.Notice = app.$Notice;
|
||||
$A.Modal = app.$Modal;
|
||||
})
|
||||
|
||||
@ -44,7 +44,7 @@ export default {
|
||||
},
|
||||
|
||||
computed: {
|
||||
...mapState(['files']),
|
||||
...mapState(['fileLists']),
|
||||
|
||||
style() {
|
||||
const offset = 135;
|
||||
@ -127,9 +127,9 @@ export default {
|
||||
return;
|
||||
}
|
||||
if (this.fileFolderId > 0) {
|
||||
const file = this.files.find(({id, permission}) => id == this.fileFolderId && permission > -1)
|
||||
const file = this.fileLists.find(({id, permission}) => id == this.fileFolderId && permission > -1)
|
||||
if (file) {
|
||||
const prevFile = this.files.find(({id, permission}) => id == file.pid && permission > -1)
|
||||
const prevFile = this.fileLists.find(({id, permission}) => id == file.pid && permission > -1)
|
||||
if (prevFile) {
|
||||
this.goForward({name: 'manage-file', params: {folderId: prevFile.id, fileId: null}});
|
||||
return;
|
||||
|
||||
@ -255,22 +255,24 @@ export default {
|
||||
if (/\/hideenOfficeTitle\//.test(window.navigator.userAgent)) {
|
||||
config.document.title = " ";
|
||||
}
|
||||
if (this.readOnly || this.historyId > 0) {
|
||||
config.editorConfig.mode = "view";
|
||||
config.editorConfig.callbackUrl = null;
|
||||
if (!config.editorConfig.user.id) {
|
||||
let viewer = $A.getStorageInt("viewer")
|
||||
if (!viewer) {
|
||||
viewer = $A.randNum(1000, 99999);
|
||||
$A.setStorage("viewer", viewer)
|
||||
(async _ => {
|
||||
if (this.readOnly || this.historyId > 0) {
|
||||
config.editorConfig.mode = "view";
|
||||
config.editorConfig.callbackUrl = null;
|
||||
if (!config.editorConfig.user.id) {
|
||||
let officeViewer = await $A.IDBInt("officeViewer")
|
||||
if (!officeViewer) {
|
||||
officeViewer = $A.randNum(1000, 99999);
|
||||
await $A.IDBSet("officeViewer", officeViewer)
|
||||
}
|
||||
config.editorConfig.user.id = "viewer_" + officeViewer;
|
||||
config.editorConfig.user.name = "Viewer_" + officeViewer
|
||||
}
|
||||
config.editorConfig.user.id = "viewer_" + viewer;
|
||||
config.editorConfig.user.name = "Viewer_" + viewer
|
||||
}
|
||||
}
|
||||
this.$nextTick(() => {
|
||||
this.docEditor = new DocsAPI.DocEditor(this.id, config);
|
||||
})
|
||||
this.$nextTick(() => {
|
||||
this.docEditor = new DocsAPI.DocEditor(this.id, config);
|
||||
})
|
||||
})()
|
||||
},
|
||||
|
||||
onDocumentReady() {
|
||||
|
||||
@ -169,29 +169,31 @@ export default {
|
||||
break;
|
||||
|
||||
case 'github':
|
||||
let key = "cacheAppdown::" + this.apiVersion
|
||||
let cache = $A.getStorageJson(key);
|
||||
let timeout = 600;
|
||||
if (cache.time && cache.time + timeout > Math.round(new Date().getTime() / 1000)) {
|
||||
this.downloadUrl = cache.data.html_url;
|
||||
return;
|
||||
}
|
||||
//
|
||||
if (this.loadIng > 0) {
|
||||
return;
|
||||
}
|
||||
this.loadIng++;
|
||||
axios.get(`https://api.github.com/repos/${publish.owner}/${publish.repo}/releases`).then(({status, data}) => {
|
||||
this.loadIng--;
|
||||
if (status === 200 && $A.isArray(data)) {
|
||||
cache.time = Math.round(new Date().getTime() / 1000)
|
||||
cache.data = data.find(({tag_name}) => this.compareVersion(this.tagVersion(tag_name), this.apiVersion) === 0) || {}
|
||||
$A.setStorage(key, cache);
|
||||
(async _ => {
|
||||
let key = "cacheAppdown::" + this.apiVersion
|
||||
let cache = await $A.IDBJson(key);
|
||||
let timeout = 600;
|
||||
if (cache.time && cache.time + timeout > Math.round(new Date().getTime() / 1000)) {
|
||||
this.downloadUrl = cache.data.html_url;
|
||||
return;
|
||||
}
|
||||
}).catch(() => {
|
||||
this.loadIng--;
|
||||
});
|
||||
//
|
||||
if (this.loadIng > 0) {
|
||||
return;
|
||||
}
|
||||
this.loadIng++;
|
||||
axios.get(`https://api.github.com/repos/${publish.owner}/${publish.repo}/releases`).then(({status, data}) => {
|
||||
this.loadIng--;
|
||||
if (status === 200 && $A.isArray(data)) {
|
||||
cache.time = Math.round(new Date().getTime() / 1000)
|
||||
cache.data = data.find(({tag_name}) => this.compareVersion(this.tagVersion(tag_name), this.apiVersion) === 0) || {}
|
||||
$A.IDBSave(key, cache);
|
||||
this.downloadUrl = cache.data.html_url;
|
||||
}
|
||||
}).catch(() => {
|
||||
this.loadIng--;
|
||||
});
|
||||
})()
|
||||
break;
|
||||
}
|
||||
},
|
||||
|
||||
109
resources/assets/js/functions/common.js
vendored
109
resources/assets/js/functions/common.js
vendored
@ -1,9 +1,12 @@
|
||||
const localforage = require("localforage");
|
||||
|
||||
/**
|
||||
* 基础函数
|
||||
*/
|
||||
(function (window, $, undefined) {
|
||||
window.systemInfo = window.systemInfo || {};
|
||||
window.modalTransferIndex = 1000;
|
||||
localforage.config({name: 'DooTask', storeName: 'common'});
|
||||
|
||||
/**
|
||||
* =============================================================================
|
||||
@ -1213,90 +1216,68 @@
|
||||
|
||||
/**
|
||||
* =============================================================================
|
||||
* ***************************** localStorage ******************************
|
||||
* ***************************** localForage ******************************
|
||||
* =============================================================================
|
||||
*/
|
||||
$.extend({
|
||||
setStorage(key, value) {
|
||||
return this.operationStorage(key, value);
|
||||
__IDBTimer: {},
|
||||
|
||||
IDBSave(key, value, delay = 0) {
|
||||
if (typeof this.__IDBTimer[key] !== "undefined") {
|
||||
clearTimeout(this.__IDBTimer[key])
|
||||
delete this.__IDBTimer[key]
|
||||
}
|
||||
if (delay > 0) {
|
||||
this.__IDBTimer[key] = setTimeout(_ => this.IDBSave(key, value, 0), delay)
|
||||
} else {
|
||||
localforage.setItem(key, value).then(_ => {})
|
||||
}
|
||||
},
|
||||
|
||||
getStorage(key, def = null) {
|
||||
let value = this.operationStorage(key);
|
||||
return value || def;
|
||||
IDBDel(key) {
|
||||
localforage.removeItem(key).then(_ => {})
|
||||
},
|
||||
|
||||
getStorageString(key, def = '') {
|
||||
let value = this.operationStorage(key);
|
||||
IDBSet(key, value) {
|
||||
return localforage.setItem(key, value).then(_ => {})
|
||||
},
|
||||
|
||||
IDBRemove(key) {
|
||||
return localforage.removeItem(key)
|
||||
},
|
||||
|
||||
IDBClear() {
|
||||
return localforage.clear()
|
||||
},
|
||||
|
||||
IDBValue(key) {
|
||||
return localforage.getItem(key)
|
||||
},
|
||||
|
||||
async IDBString(key, def = "") {
|
||||
const value = await this.IDBValue(key)
|
||||
return typeof value === "string" || typeof value === "number" ? value : def;
|
||||
},
|
||||
|
||||
getStorageInt(key, def = 0) {
|
||||
let value = this.operationStorage(key);
|
||||
async IDBInt(key, def = 0) {
|
||||
const value = await this.IDBValue(key)
|
||||
return typeof value === "number" ? value : def;
|
||||
},
|
||||
|
||||
getStorageBoolean(key, def = false) {
|
||||
let value = this.operationStorage(key);
|
||||
async IDBBoolean(key, def = false) {
|
||||
const value = await this.IDBValue(key)
|
||||
return typeof value === "boolean" ? value : def;
|
||||
},
|
||||
|
||||
getStorageArray(key, def = []) {
|
||||
let value = this.operationStorage(key);
|
||||
async IDBArray(key, def = []) {
|
||||
const value = await this.IDBValue(key)
|
||||
return this.isArray(value) ? value : def;
|
||||
},
|
||||
|
||||
getStorageJson(key, def = {}) {
|
||||
let value = this.operationStorage(key);
|
||||
async IDBJson(key, def = {}) {
|
||||
const value = await this.IDBValue(key)
|
||||
return this.isJson(value) ? value : def;
|
||||
},
|
||||
|
||||
operationStorage(key, value) {
|
||||
if (!key) {
|
||||
return;
|
||||
}
|
||||
let keyName = '__state__';
|
||||
if (key.substring(0, 5) === 'cache') {
|
||||
keyName = '__state:' + key + '__';
|
||||
}
|
||||
if (typeof value === 'undefined') {
|
||||
return this.loadFromlLocal(key, '', keyName);
|
||||
} else {
|
||||
this.savaToLocal(key, value, keyName);
|
||||
}
|
||||
},
|
||||
|
||||
savaToLocal(key, value, keyName) {
|
||||
try {
|
||||
if (typeof keyName === 'undefined') keyName = '__seller__';
|
||||
let seller = window.localStorage[keyName];
|
||||
if (!seller) {
|
||||
seller = {};
|
||||
} else {
|
||||
seller = JSON.parse(seller);
|
||||
}
|
||||
seller[key] = value;
|
||||
window.localStorage[keyName] = JSON.stringify(seller);
|
||||
} catch (e) {
|
||||
}
|
||||
},
|
||||
|
||||
loadFromlLocal(key, def, keyName) {
|
||||
try {
|
||||
if (typeof keyName === 'undefined') keyName = '__seller__';
|
||||
let seller = window.localStorage[keyName];
|
||||
if (!seller) {
|
||||
return def;
|
||||
}
|
||||
seller = JSON.parse(seller);
|
||||
if (!seller || typeof seller[key] === 'undefined') {
|
||||
return def;
|
||||
}
|
||||
return seller[key];
|
||||
} catch (e) {
|
||||
return def;
|
||||
}
|
||||
},
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
|
||||
13
resources/assets/js/language/index.js
vendored
13
resources/assets/js/language/index.js
vendored
@ -70,8 +70,8 @@ let languageUtils = {
|
||||
* @returns {string}
|
||||
*/
|
||||
getLanguage() {
|
||||
if (typeof window.localStorage['__language:type__'] === "string") {
|
||||
return window.localStorage['__language:type__'];
|
||||
if (typeof window.localStorage.getItem("__language:type__") === "string") {
|
||||
return window.localStorage.getItem("__language:type__");
|
||||
}
|
||||
let lang = 'EN';
|
||||
let navLang = ((window.navigator.language || navigator.userLanguage) + "").toUpperCase();
|
||||
@ -92,7 +92,8 @@ let languageUtils = {
|
||||
lang = 'TC'
|
||||
break;
|
||||
}
|
||||
return window.localStorage['__language:type__'] = lang;
|
||||
window.localStorage.setItem("__language:type__", lang)
|
||||
return lang
|
||||
}
|
||||
};
|
||||
let languageInit = false;
|
||||
@ -133,7 +134,7 @@ function setLanguage(language) {
|
||||
cancelText: '取消',
|
||||
okText: '确定',
|
||||
onOk: () => {
|
||||
window.localStorage['__language:type__'] = language;
|
||||
window.localStorage.setItem("__language:type__", language)
|
||||
$A.reloadUrl()
|
||||
}
|
||||
});
|
||||
@ -201,7 +202,7 @@ function switchLanguage(text) {
|
||||
setTimeout(_ => {
|
||||
try {
|
||||
let key = '__language:Undefined__';
|
||||
let languageTmp = JSON.parse(window.localStorage[key] || '[]');
|
||||
let languageTmp = JSON.parse(window.localStorage.getItem(key) || '[]');
|
||||
if (!languageUtils.isArray(languageTmp)) {
|
||||
languageTmp = [];
|
||||
}
|
||||
@ -212,7 +213,7 @@ function switchLanguage(text) {
|
||||
});
|
||||
if (!tmpData) {
|
||||
languageTmp.push(text);
|
||||
window.localStorage[key] = JSON.stringify(languageTmp);
|
||||
window.localStorage.setItem(key, JSON.stringify(languageTmp));
|
||||
}
|
||||
} catch (e) { }
|
||||
}, 10)
|
||||
|
||||
@ -17,7 +17,7 @@
|
||||
size="large"
|
||||
readonly
|
||||
clearable
|
||||
@on-clear="clearServerUrl"/>
|
||||
@on-clear="setServerUrl('')"/>
|
||||
|
||||
<Input
|
||||
v-model="email"
|
||||
@ -160,7 +160,7 @@ export default {
|
||||
loginType: 'login',
|
||||
loginJump: false,
|
||||
|
||||
email: $A.getStorageString("cacheLoginEmail") || '',
|
||||
email: '',
|
||||
password: '',
|
||||
password2: '',
|
||||
code: '',
|
||||
@ -172,17 +172,21 @@ export default {
|
||||
|
||||
subscribe: null,
|
||||
|
||||
privacyShow: !!this.$isEEUiApp && $A.getStorageString("cachePrivacyShow") !== "no",
|
||||
privacyShow: false,
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
|
||||
async mounted() {
|
||||
this.privacyShow = !!this.$isEEUiApp && (await $A.IDBString("cachePrivacyShow")) !== "no";
|
||||
this.email = await $A.IDBString("cacheLoginEmail") || ''
|
||||
//
|
||||
this.getDemoAccount();
|
||||
this.getNeedStartHome();
|
||||
//
|
||||
if (this.isSoftware) {
|
||||
this.chackServerUrl().catch(_ => {});
|
||||
} else {
|
||||
this.clearServerUrl();
|
||||
this.setServerUrl('').catch(_ => {});
|
||||
}
|
||||
//
|
||||
this.subscribe = Store.subscribe('useSSOLogin', () => {
|
||||
@ -347,8 +351,8 @@ export default {
|
||||
this.$store.dispatch("call", {
|
||||
url: `${url}system/setting`,
|
||||
checkNetwork: false,
|
||||
}).then(() => {
|
||||
this.setServerUrl(url)
|
||||
}).then(async () => {
|
||||
await this.setServerUrl(url)
|
||||
resolve()
|
||||
}).catch(({ret, msg}) => {
|
||||
if (ret === -1001) {
|
||||
@ -366,10 +370,8 @@ export default {
|
||||
chackServerUrl(tip) {
|
||||
return new Promise((resolve, reject) => {
|
||||
if (this.isNotServer()) {
|
||||
if (tip === true) {
|
||||
$A.messageWarning("请设置服务器")
|
||||
}
|
||||
this.inputServerUrl()
|
||||
tip === true && this.$nextTick(_ => $A.messageWarning("请设置服务器"))
|
||||
reject()
|
||||
} else {
|
||||
resolve()
|
||||
@ -377,19 +379,15 @@ export default {
|
||||
})
|
||||
},
|
||||
|
||||
setServerUrl(value) {
|
||||
$A.setStorage("cachePrivacyShow", value ? "no" : "yes")
|
||||
async setServerUrl(value) {
|
||||
await $A.IDBSet("cachePrivacyShow", value ? "no" : "yes")
|
||||
//
|
||||
if (value != this.cacheServerUrl) {
|
||||
$A.setStorage("cacheServerUrl", value)
|
||||
await $A.IDBSet("cacheServerUrl", value)
|
||||
$A.reloadUrl();
|
||||
}
|
||||
},
|
||||
|
||||
clearServerUrl() {
|
||||
this.setServerUrl("")
|
||||
},
|
||||
|
||||
isNotServer() {
|
||||
let apiHome = $A.getDomain(window.systemInfo.apiUrl)
|
||||
return this.isSoftware && (apiHome == "" || apiHome == "public")
|
||||
@ -461,8 +459,8 @@ export default {
|
||||
invite: this.invite,
|
||||
},
|
||||
}).then(({data}) => {
|
||||
$A.IDBSave("cacheLoginEmail", this.email)
|
||||
this.codeNeed = false;
|
||||
$A.setStorage("cacheLoginEmail", this.email)
|
||||
this.$store.dispatch("handleClearCache", data).then(() => {
|
||||
this.goNext();
|
||||
}).catch(_ => {
|
||||
|
||||
@ -408,11 +408,7 @@ export default {
|
||||
},
|
||||
|
||||
mounted() {
|
||||
if ($A.getStorageString("clearCache")) {
|
||||
$A.setStorage("clearCache", "")
|
||||
$A.messageSuccess("清除成功");
|
||||
}
|
||||
//
|
||||
this.chackClear();
|
||||
this.notificationInit();
|
||||
//
|
||||
this.addTaskSubscribe = Store.subscribe('addTask', this.onAddTask);
|
||||
@ -700,17 +696,26 @@ export default {
|
||||
},
|
||||
|
||||
methods: {
|
||||
async chackClear() {
|
||||
const val = await $A.IDBString("clearCache")
|
||||
if (val) {
|
||||
await $A.IDBRemove("clearCache")
|
||||
$A.messageSuccess("清除成功");
|
||||
}
|
||||
},
|
||||
|
||||
chackPass() {
|
||||
if (this.userInfo.changepass === 1) {
|
||||
this.goForward({name: 'manage-setting-password'});
|
||||
}
|
||||
},
|
||||
|
||||
toggleRoute(path, params) {
|
||||
async toggleRoute(path, params) {
|
||||
this.show768Menu = false;
|
||||
let location = {name: 'manage-' + path, params: params || {}};
|
||||
if (path === 'file' && $A.getStorageInt("file::folderId") > 0) {
|
||||
location.params.folderId = $A.getStorageInt("file::folderId")
|
||||
let fileFolderId = await $A.IDBInt("fileFolderId");
|
||||
if (path === 'file' && fileFolderId > 0) {
|
||||
location.params.folderId = fileFolderId
|
||||
}
|
||||
this.goForward(location);
|
||||
},
|
||||
@ -743,8 +748,8 @@ export default {
|
||||
Store.set('updateNotification', null);
|
||||
return;
|
||||
case 'clearCache':
|
||||
this.$store.dispatch("handleClearCache", null).then(() => {
|
||||
$A.setStorage("clearCache", $A.randomString(6))
|
||||
this.$store.dispatch("handleClearCache", null).then(async () => {
|
||||
await $A.IDBSet("clearCache", $A.randomString(6))
|
||||
$A.reloadUrl()
|
||||
}).catch(() => {
|
||||
$A.reloadUrl()
|
||||
|
||||
@ -791,10 +791,8 @@ export default {
|
||||
} else {
|
||||
this.$store.state.dialogInputCache.push(data)
|
||||
}
|
||||
this.__setInputCache && clearTimeout(this.__setInputCache);
|
||||
this.__setInputCache = setTimeout(_ => {
|
||||
$A.setStorage("cacheDialogInput", this.$store.state.dialogInputCache);
|
||||
}, 600)
|
||||
//
|
||||
$A.IDBSave("dialogInputCache", this.$store.state.dialogInputCache, 600);
|
||||
},
|
||||
|
||||
onClickEditor() {
|
||||
|
||||
@ -229,9 +229,9 @@ export default {
|
||||
}
|
||||
},
|
||||
|
||||
mounted() {
|
||||
async mounted() {
|
||||
this.initCascaderData();
|
||||
this.initProjectData();
|
||||
await this.initProjectData();
|
||||
this.$nextTick(() => this.$refs.input.focus())
|
||||
},
|
||||
|
||||
@ -265,12 +265,12 @@ export default {
|
||||
watch: {
|
||||
'addData.project_id'(projectId) {
|
||||
if (projectId > 0) {
|
||||
$A.setStorage("cacheAddTaskProjectId", projectId);
|
||||
$A.IDBSave("cacheAddTaskProjectId", projectId);
|
||||
}
|
||||
},
|
||||
'addData.column_id'(columnId) {
|
||||
if (columnId > 0) {
|
||||
$A.setStorage("cacheAddTaskColumnId", columnId);
|
||||
$A.IDBSave("cacheAddTaskColumnId", columnId);
|
||||
}
|
||||
const {project_id} = this.addData;
|
||||
if (project_id && columnId) {
|
||||
@ -314,14 +314,14 @@ export default {
|
||||
/**
|
||||
* 初始化项目、列表、优先级
|
||||
*/
|
||||
initProjectData() {
|
||||
async initProjectData() {
|
||||
// 项目、列表
|
||||
let cacheAddTaskProjectId = $A.getStorageInt("cacheAddTaskProjectId");
|
||||
let cacheAddTaskProjectId = await $A.IDBInt("cacheAddTaskProjectId");
|
||||
let project = this.cacheProjects.find(({id}) => id == this.projectId)
|
||||
|| this.cacheProjects.find(({id}) => id == cacheAddTaskProjectId)
|
||||
|| this.cacheProjects.find(({id}) => id > 0);
|
||||
if (project) {
|
||||
let cacheAddTaskColumnId = $A.getStorageInt("cacheAddTaskColumnId");
|
||||
let cacheAddTaskColumnId = await $A.IDBInt("cacheAddTaskColumnId");
|
||||
let column = this.cacheColumns.find(({project_id, id}) => project_id == project.id && id == cacheAddTaskColumnId)
|
||||
|| this.cacheColumns.find(({project_id}) => project_id == project.id);
|
||||
if (column) {
|
||||
|
||||
@ -398,6 +398,7 @@ import DialogSelect from "./components/DialogSelect";
|
||||
|
||||
const FilePreview = () => import('./components/FilePreview');
|
||||
const FileContent = () => import('./components/FileContent');
|
||||
const FileObject = {sort: null, mode: null};
|
||||
|
||||
export default {
|
||||
components: {DialogSelect, PreviewImage, FilePreview, DrawerOverlay, UserInput, FileContent},
|
||||
@ -459,7 +460,7 @@ export default {
|
||||
}
|
||||
],
|
||||
|
||||
tableMode: $A.getStorageString("fileTableMode"),
|
||||
tableMode: "",
|
||||
columns: [],
|
||||
|
||||
shareShow: false,
|
||||
@ -510,8 +511,15 @@ export default {
|
||||
}
|
||||
},
|
||||
|
||||
async beforeRouteEnter(to, from, next) {
|
||||
FileObject.sort = await $A.IDBJson("cacheFileSort")
|
||||
FileObject.mode = await $A.IDBString("fileTableMode")
|
||||
next()
|
||||
},
|
||||
|
||||
|
||||
created() {
|
||||
const sort = $A.getStorageJson("cacheFileSort")
|
||||
this.tableMode = FileObject.mode
|
||||
this.columns = [
|
||||
{
|
||||
type: 'selection',
|
||||
@ -543,14 +551,14 @@ export default {
|
||||
row.newname = event.target.value;
|
||||
},
|
||||
'on-blur': () => {
|
||||
const file = this.files.find(({id}) => id == row.id);
|
||||
const file = this.fileLists.find(({id}) => id == row.id);
|
||||
if (file) {
|
||||
file.newname = row.newname;
|
||||
this.onBlur(file)
|
||||
}
|
||||
},
|
||||
'on-enter': () => {
|
||||
const file = this.files.find(({id}) => id == row.id);
|
||||
const file = this.fileLists.find(({id}) => id == row.id);
|
||||
if (file) {
|
||||
file.newname = row.newname;
|
||||
this.onEnter(file)
|
||||
@ -575,7 +583,7 @@ export default {
|
||||
},
|
||||
on: {
|
||||
'on-edit-change': (b) => {
|
||||
const file = this.files.find(({id}) => id == row.id);
|
||||
const file = this.fileLists.find(({id}) => id == row.id);
|
||||
if (file) {
|
||||
setTimeout(() => {
|
||||
this.setEdit(file.id, b)
|
||||
@ -583,7 +591,7 @@ export default {
|
||||
}
|
||||
},
|
||||
'on-update': (val, cb) => {
|
||||
const file = this.files.find(({id}) => id == row.id);
|
||||
const file = this.fileLists.find(({id}) => id == row.id);
|
||||
if (file) {
|
||||
file.newname = val
|
||||
this.onEnter(file);
|
||||
@ -695,8 +703,8 @@ export default {
|
||||
sortable: true,
|
||||
},
|
||||
].map(item => {
|
||||
if (item.key === sort.key) {
|
||||
item.sortType = sort.order
|
||||
if (item.key === FileObject.sort.key) {
|
||||
item.sortType = FileObject.sort.order
|
||||
}
|
||||
return item;
|
||||
});
|
||||
@ -716,7 +724,7 @@ export default {
|
||||
},
|
||||
|
||||
computed: {
|
||||
...mapState(['userIsAdmin', 'userInfo', 'files', 'wsOpenNum']),
|
||||
...mapState(['userIsAdmin', 'userInfo', 'fileLists', 'wsOpenNum']),
|
||||
|
||||
pid() {
|
||||
const {folderId} = this.$route.params;
|
||||
@ -748,8 +756,8 @@ export default {
|
||||
},
|
||||
|
||||
fileList() {
|
||||
const {files, searchKey, pid, selectIds} = this;
|
||||
const list = $A.cloneJSON(sortBy(files.filter((file) => {
|
||||
const {fileLists, searchKey, pid, selectIds} = this;
|
||||
const list = $A.cloneJSON(sortBy(fileLists.filter((file) => {
|
||||
if (searchKey) {
|
||||
return file.name.indexOf(searchKey) !== -1;
|
||||
}
|
||||
@ -764,18 +772,18 @@ export default {
|
||||
},
|
||||
|
||||
shearFirst() {
|
||||
const {files, shearIds} = this;
|
||||
const {fileLists, shearIds} = this;
|
||||
if (shearIds.length === 0) {
|
||||
return null;
|
||||
}
|
||||
return files.find(item => item.id == shearIds[0])
|
||||
return fileLists.find(item => item.id == shearIds[0])
|
||||
},
|
||||
|
||||
navigator() {
|
||||
let {pid, files} = this;
|
||||
let {pid, fileLists} = this;
|
||||
let array = [];
|
||||
while (pid > 0) {
|
||||
let file = files.find(({id, permission}) => id == pid && permission > -1);
|
||||
let file = fileLists.find(({id, permission}) => id == pid && permission > -1);
|
||||
if (file) {
|
||||
array.unshift(file);
|
||||
pid = file.pid;
|
||||
@ -835,7 +843,7 @@ export default {
|
||||
},
|
||||
|
||||
tableMode(val) {
|
||||
$A.setStorage("fileTableMode", val)
|
||||
$A.IDBSave("fileTableMode", val)
|
||||
},
|
||||
|
||||
fileShow(val) {
|
||||
@ -897,10 +905,10 @@ export default {
|
||||
return;
|
||||
}
|
||||
this.loadIng++;
|
||||
this.$store.dispatch("getFiles", this.pid).then(() => {
|
||||
this.$store.dispatch("getFiles", this.pid).then(async () => {
|
||||
this.loadIng--;
|
||||
this.openFileJudge()
|
||||
$A.setStorage("file::folderId", this.pid)
|
||||
await $A.IDBSet("fileFolderId", this.pid)
|
||||
}).catch(({msg}) => {
|
||||
this.loadIng--;
|
||||
$A.modalError({
|
||||
@ -925,7 +933,7 @@ export default {
|
||||
return;
|
||||
}
|
||||
let id = $A.randomString(8);
|
||||
this.files.push({
|
||||
this.fileLists.push({
|
||||
_edit: true,
|
||||
pid: this.pid,
|
||||
id: id,
|
||||
@ -1077,7 +1085,7 @@ export default {
|
||||
},
|
||||
|
||||
handleContextMenu(row, event) {
|
||||
this.handleRightClick(event, this.files.find(({id}) => id === row.id) || {});
|
||||
this.handleRightClick(event, this.fileLists.find(({id}) => id === row.id) || {});
|
||||
},
|
||||
|
||||
handleContextClick(command) {
|
||||
@ -1093,7 +1101,7 @@ export default {
|
||||
},
|
||||
|
||||
handleVisibleChangeMenu(visible) {
|
||||
let file = this.files.find(({_highlight}) => !!_highlight)
|
||||
let file = this.fileLists.find(({_highlight}) => !!_highlight)
|
||||
if (file) {
|
||||
this.$set(file, '_highlight', false);
|
||||
}
|
||||
@ -1300,7 +1308,7 @@ export default {
|
||||
return;
|
||||
}
|
||||
if (this.isParentShare) {
|
||||
const tmpFile = this.files.find(({id, share}) => share && this.shearIds.includes(id));
|
||||
const tmpFile = this.fileLists.find(({id, share}) => share && this.shearIds.includes(id));
|
||||
if (tmpFile) {
|
||||
$A.modalError(`${tmpFile.name} 当前正在共享,无法移动到另一个共享文件夹内`)
|
||||
return;
|
||||
@ -1325,9 +1333,9 @@ export default {
|
||||
if (ids.length === 0) {
|
||||
return
|
||||
}
|
||||
const firstFile = this.files.find(item => item.id == ids[0]) || {};
|
||||
const firstFile = this.fileLists.find(item => item.id == ids[0]) || {};
|
||||
const allFolder = !ids.find(id => {
|
||||
return this.files.find(item => item.type != 'folder' && item.id == id)
|
||||
return this.fileLists.find(item => item.type != 'folder' && item.id == id)
|
||||
});
|
||||
let typeName = allFolder ? "文件夹" : "文件"
|
||||
let fileName = `【${firstFile.name}】等${ids.length}个${typeName}`
|
||||
@ -1373,7 +1381,7 @@ export default {
|
||||
},
|
||||
|
||||
onBlur(item) {
|
||||
if (this.files.find(({id, _edit}) => id == item.id && !_edit)) {
|
||||
if (this.fileLists.find(({id, _edit}) => id == item.id && !_edit)) {
|
||||
return;
|
||||
}
|
||||
this.onEnter(item);
|
||||
@ -1439,7 +1447,7 @@ export default {
|
||||
},
|
||||
|
||||
setEdit(fileId, is) {
|
||||
let item = this.$store.state.files.find(({id}) => id == fileId)
|
||||
const item = this.$store.state.fileLists.find(({id}) => id == fileId)
|
||||
if (item) {
|
||||
this.$set(item, '_edit', is);
|
||||
if (is) {
|
||||
@ -1449,7 +1457,7 @@ export default {
|
||||
},
|
||||
|
||||
setLoad(fileId, is) {
|
||||
let item = this.$store.state.files.find(({id}) => id == fileId)
|
||||
const item = this.$store.state.fileLists.find(({id}) => id == fileId)
|
||||
if (item) {
|
||||
this.$set(item, '_load', is);
|
||||
}
|
||||
@ -1580,7 +1588,7 @@ export default {
|
||||
},
|
||||
|
||||
handleTableSort({key, order}) {
|
||||
$A.setStorage("cacheFileSort", ['asc', 'desc'].includes(order) ? {key, order} : {});
|
||||
$A.IDBSave("cacheFileSort", ['asc', 'desc'].includes(order) ? {key, order} : {});
|
||||
},
|
||||
|
||||
handleTableSelect(selection) {
|
||||
|
||||
@ -397,14 +397,12 @@ export default {
|
||||
case 'log.open':
|
||||
case 'log:open':
|
||||
case 'eruda:open':
|
||||
$A.setStorage("log::open", "open");
|
||||
$A.reloadUrl();
|
||||
$A.IDBSet("logOpen", "open").then(_ => $A.reloadUrl());
|
||||
break;
|
||||
case 'log.close':
|
||||
case 'log:close':
|
||||
case 'eruda:close':
|
||||
$A.setStorage("log::open", "close");
|
||||
$A.reloadUrl();
|
||||
$A.IDBSet("logOpen", "close").then(_ => $A.reloadUrl());
|
||||
break;
|
||||
}
|
||||
//
|
||||
|
||||
@ -137,8 +137,8 @@ export default {
|
||||
toggleRoute(path) {
|
||||
switch (path) {
|
||||
case 'clearCache':
|
||||
this.$store.dispatch("handleClearCache", null).then(() => {
|
||||
$A.setStorage("clearCache", $A.randomString(6))
|
||||
this.$store.dispatch("handleClearCache", null).then(async () => {
|
||||
await $A.IDBSet("clearCache", $A.randomString(6))
|
||||
$A.reloadUrl()
|
||||
}).catch(() => {
|
||||
$A.reloadUrl()
|
||||
|
||||
@ -67,7 +67,7 @@ export default {
|
||||
screenshot_mate: true,
|
||||
screenshot_shift: true,
|
||||
screenshot_key: '',
|
||||
}, $A.jsonParse(window.localStorage['__keyboard:data__'] || {}));
|
||||
}, $A.jsonParse(window.localStorage.getItem("__keyboard:data__") || {}));
|
||||
//
|
||||
this.formData_bak = $A.cloneJSON(this.formData);
|
||||
},
|
||||
@ -84,7 +84,7 @@ export default {
|
||||
submitForm() {
|
||||
this.$refs.formData.validate((valid) => {
|
||||
if (valid) {
|
||||
window.localStorage['__keyboard:data__'] = $A.jsonStringify(this.formData);
|
||||
window.localStorage.setItem("__keyboard:data__", $A.jsonStringify(this.formData));
|
||||
$A.bindScreenshotKey(this.formData);
|
||||
$A.messageSuccess('保存成功');
|
||||
}
|
||||
|
||||
174
resources/assets/js/store/actions.js
vendored
174
resources/assets/js/store/actions.js
vendored
@ -2,6 +2,60 @@ import {Store} from 'le5le-store';
|
||||
import {languageType} from "../language";
|
||||
|
||||
export default {
|
||||
/**
|
||||
* 初始化
|
||||
* @param state
|
||||
* @param dispatch
|
||||
* @returns {Promise<unknown>}
|
||||
*/
|
||||
init({state, dispatch}) {
|
||||
return new Promise(async resolve => {
|
||||
// 读取缓存
|
||||
state.cacheServerUrl = await $A.IDBString("cacheServerUrl")
|
||||
state.cacheUserBasic = await $A.IDBArray("cacheUserBasic")
|
||||
state.cacheDialogs = (await $A.IDBArray("cacheDialogs")).map(item => Object.assign(item, {loading: false}))
|
||||
state.cacheProjects = await $A.IDBArray("cacheProjects")
|
||||
state.cacheColumns = await $A.IDBArray("cacheColumns")
|
||||
state.cacheTasks = await $A.IDBArray("cacheTasks")
|
||||
state.cacheProjectParameter = await $A.IDBArray("cacheProjectParameter")
|
||||
state.cacheTaskBrowse = await $A.IDBArray("cacheTaskBrowse")
|
||||
state.dialogMsgs = await $A.IDBArray("dialogMsgs")
|
||||
state.dialogInputCache = await $A.IDBArray("dialogInputCache")
|
||||
state.fileLists = await $A.IDBArray("fileLists")
|
||||
state.userInfo = await $A.IDBJson("userInfo")
|
||||
|
||||
// 会员信息
|
||||
if (state.userInfo.userid) {
|
||||
state.userId = state.userInfo.userid = $A.runNum(state.userInfo.userid)
|
||||
state.userToken = state.userInfo.token
|
||||
state.userIsAdmin = $A.inArray("admin", state.userInfo.identity)
|
||||
}
|
||||
|
||||
// ServerUrl
|
||||
if (state.cacheServerUrl) {
|
||||
window.systemInfo.apiUrl = state.cacheServerUrl
|
||||
}
|
||||
|
||||
// 主题皮肤
|
||||
switch (state.themeMode) {
|
||||
case 'dark':
|
||||
$A.dark.enableDarkMode()
|
||||
break;
|
||||
case 'light':
|
||||
$A.dark.disableDarkMode()
|
||||
break;
|
||||
default:
|
||||
state.themeMode = "auto"
|
||||
$A.dark.autoDarkMode()
|
||||
break;
|
||||
}
|
||||
state.themeIsDark = $A.dark.isDarkEnabled()
|
||||
|
||||
//
|
||||
resolve()
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* 访问接口
|
||||
* @param state
|
||||
@ -227,9 +281,8 @@ export default {
|
||||
key = {[key]: value || !cache[key]};
|
||||
}
|
||||
state.cacheProjectParameter.splice(index, 1, Object.assign(cache, key))
|
||||
setTimeout(() => {
|
||||
$A.setStorage("cacheProjectParameter", state.cacheProjectParameter);
|
||||
});
|
||||
//
|
||||
$A.IDBSave("cacheProjectParameter", state.cacheProjectParameter);
|
||||
}
|
||||
},
|
||||
|
||||
@ -267,7 +320,7 @@ export default {
|
||||
}
|
||||
state.themeMode = mode;
|
||||
state.themeIsDark = $A.dark.isDarkEnabled();
|
||||
window.localStorage['__theme:mode__'] = mode;
|
||||
window.localStorage.setItem("__theme:mode__", mode);
|
||||
resolve(true)
|
||||
});
|
||||
},
|
||||
@ -328,7 +381,7 @@ export default {
|
||||
* @returns {Promise<unknown>}
|
||||
*/
|
||||
saveUserInfo({state, dispatch}, info) {
|
||||
return new Promise(function (resolve) {
|
||||
return new Promise(async resolve => {
|
||||
const userInfo = $A.cloneJSON(info);
|
||||
userInfo.userid = $A.runNum(userInfo.userid);
|
||||
userInfo.token = userInfo.userid > 0 ? (userInfo.token || state.userToken) : '';
|
||||
@ -336,7 +389,8 @@ export default {
|
||||
state.userId = userInfo.userid;
|
||||
state.userToken = userInfo.token;
|
||||
state.userIsAdmin = $A.inArray('admin', userInfo.identity);
|
||||
$A.setStorage("userInfo", state.userInfo);
|
||||
await $A.IDBSet("userInfo", state.userInfo);
|
||||
//
|
||||
dispatch("getBasicData", null);
|
||||
if (state.userId > 0) {
|
||||
dispatch("saveUserBasic", state.userInfo);
|
||||
@ -436,9 +490,8 @@ export default {
|
||||
}
|
||||
state.cacheUserActive = Object.assign(data, {__:Math.random()});
|
||||
Store.set('cacheUserActive', data);
|
||||
setTimeout(() => {
|
||||
$A.setStorage("cacheUserBasic", state.cacheUserBasic);
|
||||
})
|
||||
//
|
||||
$A.IDBSave("cacheUserBasic", state.cacheUserBasic)
|
||||
},
|
||||
|
||||
/**
|
||||
@ -515,30 +568,31 @@ export default {
|
||||
* @returns {Promise<unknown>}
|
||||
*/
|
||||
handleClearCache({state, dispatch}, userInfo) {
|
||||
return new Promise(function (resolve) {
|
||||
return new Promise(async resolve => {
|
||||
try {
|
||||
const cacheLoginEmail = $A.getStorageString("cacheLoginEmail");
|
||||
const cacheFileSort = $A.getStorageJson("cacheFileSort");
|
||||
const languageType = window.localStorage['__language:type__'];
|
||||
const keyboardData = window.localStorage['__keyboard:data__'];
|
||||
const themeMode = window.localStorage['__theme:mode__'];
|
||||
//
|
||||
window.localStorage.clear();
|
||||
//
|
||||
state.cacheUserBasic = [];
|
||||
state.cacheDialogs = [];
|
||||
state.cacheProjects = [];
|
||||
state.cacheColumns = [];
|
||||
state.cacheTasks = [];
|
||||
//
|
||||
window.localStorage['__language:type__'] = languageType;
|
||||
window.localStorage['__keyboard:data__'] = keyboardData;
|
||||
window.localStorage['__theme:mode__'] = themeMode;
|
||||
$A.setStorage("cacheProjectParameter", state.cacheProjectParameter);
|
||||
$A.setStorage("cacheServerUrl", state.cacheServerUrl);
|
||||
$A.setStorage("cacheLoginEmail", cacheLoginEmail);
|
||||
$A.setStorage("cacheFileSort", cacheFileSort);
|
||||
$A.setStorage("cacheTaskBrowse", state.cacheTaskBrowse);
|
||||
const cacheLoginEmail = await $A.IDBString("cacheLoginEmail");
|
||||
const cacheFileSort = await $A.IDBJson("cacheFileSort");
|
||||
const languageType = window.localStorage.getItem("__language:type__");
|
||||
const keyboardData = window.localStorage.getItem("__keyboard:data__");
|
||||
const themeMode = window.localStorage.getItem("__theme:mode__");
|
||||
//
|
||||
window.localStorage.clear();
|
||||
await $A.IDBClear();
|
||||
//
|
||||
window.localStorage.setItem("__language:type__", languageType)
|
||||
window.localStorage.setItem("__keyboard:data__", keyboardData)
|
||||
window.localStorage.setItem("__theme:mode__", themeMode)
|
||||
await $A.IDBSet("cacheServerUrl", state.cacheServerUrl);
|
||||
await $A.IDBSet("cacheProjectParameter", state.cacheProjectParameter);
|
||||
await $A.IDBSet("cacheLoginEmail", cacheLoginEmail);
|
||||
await $A.IDBSet("cacheFileSort", cacheFileSort);
|
||||
await $A.IDBSet("cacheTaskBrowse", state.cacheTaskBrowse);
|
||||
dispatch("saveUserInfo", $A.isJson(userInfo) ? userInfo : state.userInfo);
|
||||
//
|
||||
resolve()
|
||||
@ -567,12 +621,13 @@ export default {
|
||||
});
|
||||
} else if ($A.isJson(data)) {
|
||||
let base = {_load: false, _edit: false};
|
||||
const index = state.files.findIndex(({id}) => id == data.id);
|
||||
const index = state.fileLists.findIndex(({id}) => id == data.id);
|
||||
if (index > -1) {
|
||||
state.files.splice(index, 1, Object.assign(base, state.files[index], data));
|
||||
state.fileLists.splice(index, 1, Object.assign(base, state.fileLists[index], data));
|
||||
} else {
|
||||
state.files.push(Object.assign(base, data))
|
||||
state.fileLists.push(Object.assign(base, data))
|
||||
}
|
||||
$A.IDBSave("fileLists", state.fileLists, 600)
|
||||
}
|
||||
},
|
||||
|
||||
@ -587,12 +642,13 @@ export default {
|
||||
//
|
||||
let ids = $A.isArray(file_id) ? file_id : [file_id];
|
||||
ids.some(id => {
|
||||
state.files = state.files.filter(file => file.id != id);
|
||||
state.files.some(file => {
|
||||
state.fileLists = state.fileLists.filter(file => file.id != id);
|
||||
state.fileLists.some(file => {
|
||||
if (file.pid == id) {
|
||||
dispatch("forgetFile", file.id);
|
||||
}
|
||||
});
|
||||
$A.IDBSave("fileLists", state.fileLists, 600)
|
||||
})
|
||||
},
|
||||
|
||||
@ -612,7 +668,8 @@ export default {
|
||||
},
|
||||
}).then((result) => {
|
||||
const ids = result.data.map(({id}) => id)
|
||||
state.files = state.files.filter((item) => item.pid != pid || ids.includes(item.id));
|
||||
state.fileLists = state.fileLists.filter((item) => item.pid != pid || ids.includes(item.id));
|
||||
$A.IDBSave("fileLists", state.fileLists, 600)
|
||||
//
|
||||
dispatch("saveFile", result.data);
|
||||
resolve(result)
|
||||
@ -692,9 +749,7 @@ export default {
|
||||
}
|
||||
})
|
||||
//
|
||||
setTimeout(() => {
|
||||
$A.setStorage("cacheProjects", state.cacheProjects);
|
||||
})
|
||||
$A.IDBSave("cacheProjects", state.cacheProjects);
|
||||
}
|
||||
},
|
||||
|
||||
@ -727,9 +782,8 @@ export default {
|
||||
$A.goForward({name: 'manage-dashboard'});
|
||||
}
|
||||
}
|
||||
setTimeout(() => {
|
||||
$A.setStorage("cacheProjects", state.cacheProjects);
|
||||
})
|
||||
//
|
||||
$A.IDBSave("cacheProjects", state.cacheProjects);
|
||||
},
|
||||
|
||||
/**
|
||||
@ -910,9 +964,8 @@ export default {
|
||||
} else {
|
||||
state.cacheColumns.push(data);
|
||||
}
|
||||
setTimeout(() => {
|
||||
$A.setStorage("cacheColumns", state.cacheColumns);
|
||||
})
|
||||
//
|
||||
$A.IDBSave("cacheColumns", state.cacheColumns);
|
||||
}
|
||||
},
|
||||
|
||||
@ -937,9 +990,7 @@ export default {
|
||||
})
|
||||
Array.from(new Set(project_ids)).some(id => dispatch("getProjectOne", id).catch(() => {}))
|
||||
//
|
||||
setTimeout(() => {
|
||||
$A.setStorage("cacheColumns", state.cacheColumns);
|
||||
})
|
||||
$A.IDBSave("cacheColumns", state.cacheColumns);
|
||||
},
|
||||
|
||||
/**
|
||||
@ -1088,9 +1139,7 @@ export default {
|
||||
}
|
||||
})
|
||||
//
|
||||
setTimeout(() => {
|
||||
$A.setStorage("cacheTasks", state.cacheTasks);
|
||||
})
|
||||
$A.IDBSave("cacheTasks", state.cacheTasks);
|
||||
}
|
||||
},
|
||||
|
||||
@ -1129,9 +1178,8 @@ export default {
|
||||
if (ids.includes(state.taskId)) {
|
||||
state.taskId = 0;
|
||||
}
|
||||
setTimeout(() => {
|
||||
$A.setStorage("cacheTasks", state.cacheTasks);
|
||||
})
|
||||
//
|
||||
$A.IDBSave("cacheTasks", state.cacheTasks);
|
||||
},
|
||||
|
||||
/**
|
||||
@ -1926,9 +1974,8 @@ export default {
|
||||
if (state.cacheTaskBrowse.length > 200) {
|
||||
state.cacheTaskBrowse.splice(200);
|
||||
}
|
||||
setTimeout(() => {
|
||||
$A.setStorage("cacheTaskBrowse", state.cacheTaskBrowse);
|
||||
})
|
||||
//
|
||||
$A.IDBSave("cacheTaskBrowse", state.cacheTaskBrowse);
|
||||
},
|
||||
|
||||
/** *****************************************************************************************/
|
||||
@ -1961,9 +2008,8 @@ export default {
|
||||
} else {
|
||||
state.cacheDialogs.push(data);
|
||||
}
|
||||
setTimeout(() => {
|
||||
$A.setStorage("cacheDialogs", state.cacheDialogs);
|
||||
})
|
||||
//
|
||||
$A.IDBSave("cacheDialogs", state.cacheDialogs);
|
||||
}
|
||||
},
|
||||
|
||||
@ -2167,9 +2213,7 @@ export default {
|
||||
state.dialogId = 0
|
||||
}
|
||||
//
|
||||
setTimeout(() => {
|
||||
$A.setStorage("cacheDialogs", state.cacheDialogs);
|
||||
})
|
||||
$A.IDBSave("cacheDialogs", state.cacheDialogs);
|
||||
},
|
||||
|
||||
/**
|
||||
@ -2187,9 +2231,9 @@ export default {
|
||||
} else {
|
||||
state.dialogIns.push(data);
|
||||
}
|
||||
// 会话消息总数量大于1000时只保留最近打开的20个会话
|
||||
const msg_max = 1000
|
||||
const retain_num = 20
|
||||
// 会话消息总数量大于1500时只保留最近打开的30个会话
|
||||
const msg_max = 1500
|
||||
const retain_num = 30
|
||||
state.dialogHistory = state.dialogHistory.filter(id => id != data.dialog_id)
|
||||
state.dialogHistory.push(data.dialog_id)
|
||||
if (state.dialogMsgs.length > msg_max && state.dialogHistory.length > retain_num) {
|
||||
@ -2205,6 +2249,7 @@ export default {
|
||||
})
|
||||
if (delIds.length > 0) {
|
||||
state.dialogMsgs = state.dialogMsgs.filter(item => !delIds.includes(item.dialog_id));
|
||||
$A.IDBSave("dialogMsgs", state.dialogMsgs, 600)
|
||||
}
|
||||
state.dialogHistory = newIds
|
||||
}
|
||||
@ -2245,6 +2290,7 @@ export default {
|
||||
return b.id - a.id
|
||||
}).splice(retain).map(item => item.id)
|
||||
state.dialogMsgs = state.dialogMsgs.filter(item => !delIds.includes(item.id))
|
||||
$A.IDBSave("dialogMsgs", state.dialogMsgs, 600)
|
||||
}
|
||||
},
|
||||
|
||||
@ -2311,6 +2357,7 @@ export default {
|
||||
} else {
|
||||
state.dialogMsgs.push(data);
|
||||
}
|
||||
$A.IDBSave("dialogMsgs", state.dialogMsgs, 600)
|
||||
//
|
||||
const dialog = state.cacheDialogs.find(({id, last_msg}) => id == data.dialog_id && last_msg && last_msg.id === data.id);
|
||||
if (dialog) {
|
||||
@ -2338,6 +2385,7 @@ export default {
|
||||
dispatch("decrementMsgReplyNum", state.dialogMsgs[index]);
|
||||
Store.set('audioSubscribe', id);
|
||||
state.dialogMsgs.splice(index, 1);
|
||||
$A.IDBSave("dialogMsgs", state.dialogMsgs, 600)
|
||||
}
|
||||
})
|
||||
dispatch("forgetDialogTodoForMsgId", msg_id)
|
||||
@ -2378,6 +2426,7 @@ export default {
|
||||
//
|
||||
if (clearBefore) {
|
||||
state.dialogMsgs = state.dialogMsgs.filter(({dialog_id}) => dialog_id !== data.dialog_id)
|
||||
$A.IDBSave("dialogMsgs", state.dialogMsgs, 600)
|
||||
}
|
||||
//
|
||||
const callTime = $A.Time();
|
||||
@ -2394,6 +2443,7 @@ export default {
|
||||
//
|
||||
const ids = resData.list.map(({id}) => id)
|
||||
state.dialogMsgs = state.dialogMsgs.filter(item => item.dialog_id != data.dialog_id || ids.includes(item.id) || $A.Time(item.created_at) >= callTime);
|
||||
$A.IDBSave("dialogMsgs", state.dialogMsgs, 600)
|
||||
}
|
||||
if ($A.isArray(resData.todo)) {
|
||||
state.dialogTodos = state.dialogTodos.filter(item => item.dialog_id != data.dialog_id)
|
||||
|
||||
55
resources/assets/js/store/state.js
vendored
55
resources/assets/js/store/state.js
vendored
@ -1,4 +1,4 @@
|
||||
const stateData = {
|
||||
export default {
|
||||
// 浏览器尺寸信息
|
||||
windowWidth: $A(window).width(),
|
||||
windowHeight: $A(window).height(),
|
||||
@ -34,20 +34,20 @@ const stateData = {
|
||||
// User
|
||||
cacheUserActive: {},
|
||||
cacheUserWait: [],
|
||||
cacheUserBasic: $A.getStorageArray("cacheUserBasic"),
|
||||
cacheUserBasic: [],
|
||||
|
||||
// Dialog
|
||||
cacheDialogs: $A.getStorageArray("cacheDialogs").map(item => Object.assign(item, {loading: false})),
|
||||
cacheDialogs: [],
|
||||
|
||||
// Project
|
||||
cacheProjects: $A.getStorageArray("cacheProjects"),
|
||||
cacheColumns: $A.getStorageArray("cacheColumns"),
|
||||
cacheTasks: $A.getStorageArray("cacheTasks"),
|
||||
cacheProjectParameter: $A.getStorageArray("cacheProjectParameter"),
|
||||
cacheTaskBrowse: $A.getStorageArray("cacheTaskBrowse"),
|
||||
cacheProjects: [],
|
||||
cacheColumns: [],
|
||||
cacheTasks: [],
|
||||
cacheProjectParameter: [],
|
||||
cacheTaskBrowse: [],
|
||||
|
||||
// ServerUrl
|
||||
cacheServerUrl: $A.getStorageString("cacheServerUrl"),
|
||||
cacheServerUrl: "",
|
||||
|
||||
// Ajax
|
||||
ajaxWsReady: false,
|
||||
@ -66,7 +66,7 @@ const stateData = {
|
||||
wsReadWaitList: [],
|
||||
|
||||
// 会员信息
|
||||
userInfo: $A.getStorageJson("userInfo"),
|
||||
userInfo: {},
|
||||
userId: 0,
|
||||
userToken: '',
|
||||
userIsAdmin: false,
|
||||
@ -80,11 +80,11 @@ const stateData = {
|
||||
dialogMsgs: [],
|
||||
dialogTodos: [],
|
||||
dialogHistory: [],
|
||||
dialogInputCache: $A.getStorageArray("cacheDialogInput"),
|
||||
dialogInputCache: [],
|
||||
dialogMsgTransfer: {time: 0},
|
||||
|
||||
// 文件
|
||||
files: [],
|
||||
fileLists: [],
|
||||
|
||||
// 项目任务
|
||||
projectId: 0,
|
||||
@ -136,7 +136,7 @@ const stateData = {
|
||||
],
|
||||
|
||||
// 主题皮肤
|
||||
themeMode: window.localStorage['__theme:mode__'],
|
||||
themeMode: window.localStorage.getItem("__theme:mode__"),
|
||||
themeList: [
|
||||
{name: '跟随系统', value: 'auto'},
|
||||
{name: '明亮', value: 'light'},
|
||||
@ -151,32 +151,3 @@ const stateData = {
|
||||
previewImageIndex: 0,
|
||||
previewImageList: [],
|
||||
};
|
||||
|
||||
// 会员信息
|
||||
if (stateData.userInfo.userid) {
|
||||
stateData.userId = stateData.userInfo.userid = $A.runNum(stateData.userInfo.userid);
|
||||
stateData.userToken = stateData.userInfo.token;
|
||||
stateData.userIsAdmin = $A.inArray("admin", stateData.userInfo.identity);
|
||||
}
|
||||
|
||||
// ServerUrl
|
||||
if (stateData.cacheServerUrl) {
|
||||
window.systemInfo.apiUrl = stateData.cacheServerUrl;
|
||||
}
|
||||
|
||||
// 主题皮肤
|
||||
switch (stateData.themeMode) {
|
||||
case 'dark':
|
||||
$A.dark.enableDarkMode()
|
||||
break;
|
||||
case 'light':
|
||||
$A.dark.disableDarkMode()
|
||||
break;
|
||||
default:
|
||||
stateData.themeMode = "auto"
|
||||
$A.dark.autoDarkMode()
|
||||
break;
|
||||
}
|
||||
stateData.themeIsDark = $A.dark.isDarkEnabled();
|
||||
|
||||
export default stateData
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
<script>
|
||||
@if ($theme)
|
||||
window.localStorage['__theme:mode__'] = "{{ $theme }}";
|
||||
window.localStorage.setItem("__theme:mode__", "{{ $theme }}");
|
||||
@endif
|
||||
@if ($language)
|
||||
window.localStorage['__language:type__'] = "{{ $language }}";
|
||||
window.localStorage.setItem("__language:type__", "{{ $language }}");
|
||||
@endif
|
||||
</script>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user