perf: 优化本地数据

This commit is contained in:
kuaifan 2022-12-09 22:54:15 +08:00
parent 51d878469f
commit 1b23b4621a
20 changed files with 346 additions and 323 deletions

8
electron/drawio.js vendored

File diff suppressed because one or more lines are too long

View File

@ -31,6 +31,7 @@
"le5le-store": "^1.0.7", "le5le-store": "^1.0.7",
"less": "^4.1.2", "less": "^4.1.2",
"less-loader": "^10.2.0", "less-loader": "^10.2.0",
"localforage": "^1.10.0",
"lodash": "^4.17.21", "lodash": "^4.17.21",
"moment": "^2.29.1", "moment": "^2.29.1",
"node-sass": "^6.0.1", "node-sass": "^6.0.1",

View File

@ -118,6 +118,8 @@ export default {
}, 6000) }, 6000)
} }
// //
$A.IDBString("logOpen").then(r => {
$A.openLog = r === "open"
if ($A.openLog) { if ($A.openLog) {
$A.loadScript('js/vconsole.min.js', (e) => { $A.loadScript('js/vconsole.min.js', (e) => {
if (e !== null || typeof window.VConsole !== 'function') { if (e !== null || typeof window.VConsole !== 'function') {
@ -134,6 +136,7 @@ export default {
}); });
}); });
} }
})
} }
}, },
immediate: true immediate: true
@ -237,7 +240,7 @@ export default {
key: 'manifest', key: 'manifest',
url: $A.apiUrl("../manifest") url: $A.apiUrl("../manifest")
}) })
$A.bindScreenshotKey($A.jsonParse(window.localStorage['__keyboard:data__'] || {})); $A.bindScreenshotKey($A.jsonParse(window.localStorage.getItem("__keyboard:data__") || {}));
}, },
eeuiEvents() { eeuiEvents() {

View File

@ -141,7 +141,7 @@ $A.Platform = "web";
$A.isMainElectron = false; $A.isMainElectron = false;
$A.isSubElectron = false; $A.isSubElectron = false;
$A.isEEUiApp = isEEUiApp; $A.isEEUiApp = isEEUiApp;
$A.openLog = $A.getStorageString("log::open") === "open"; $A.openLog = false;
if (isElectron) { if (isElectron) {
$A.Electron = electron; $A.Electron = electron;
$A.Platform = /macintosh|mac os x/i.test(navigator.userAgent) ? "mac" : "win"; $A.Platform = /macintosh|mac os x/i.test(navigator.userAgent) ? "mac" : "win";
@ -193,7 +193,9 @@ Vue.prototype.$isEEUiApp = $A.isEEUiApp;
Vue.config.productionTip = false; Vue.config.productionTip = false;
Vue.mixin(mixin) Vue.mixin(mixin)
const app = new Vue({ let app;
store.dispatch("init").then(_ => {
app = new Vue({
el: '#app', el: '#app',
router, router,
store, store,
@ -206,3 +208,4 @@ $A.goBack = app.goBack;
$A.Message = app.$Message; $A.Message = app.$Message;
$A.Notice = app.$Notice; $A.Notice = app.$Notice;
$A.Modal = app.$Modal; $A.Modal = app.$Modal;
})

View File

@ -44,7 +44,7 @@ export default {
}, },
computed: { computed: {
...mapState(['files']), ...mapState(['fileLists']),
style() { style() {
const offset = 135; const offset = 135;
@ -127,9 +127,9 @@ export default {
return; return;
} }
if (this.fileFolderId > 0) { 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) { 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) { if (prevFile) {
this.goForward({name: 'manage-file', params: {folderId: prevFile.id, fileId: null}}); this.goForward({name: 'manage-file', params: {folderId: prevFile.id, fileId: null}});
return; return;

View File

@ -255,22 +255,24 @@ export default {
if (/\/hideenOfficeTitle\//.test(window.navigator.userAgent)) { if (/\/hideenOfficeTitle\//.test(window.navigator.userAgent)) {
config.document.title = " "; config.document.title = " ";
} }
(async _ => {
if (this.readOnly || this.historyId > 0) { if (this.readOnly || this.historyId > 0) {
config.editorConfig.mode = "view"; config.editorConfig.mode = "view";
config.editorConfig.callbackUrl = null; config.editorConfig.callbackUrl = null;
if (!config.editorConfig.user.id) { if (!config.editorConfig.user.id) {
let viewer = $A.getStorageInt("viewer") let officeViewer = await $A.IDBInt("officeViewer")
if (!viewer) { if (!officeViewer) {
viewer = $A.randNum(1000, 99999); officeViewer = $A.randNum(1000, 99999);
$A.setStorage("viewer", viewer) await $A.IDBSet("officeViewer", officeViewer)
} }
config.editorConfig.user.id = "viewer_" + viewer; config.editorConfig.user.id = "viewer_" + officeViewer;
config.editorConfig.user.name = "Viewer_" + viewer config.editorConfig.user.name = "Viewer_" + officeViewer
} }
} }
this.$nextTick(() => { this.$nextTick(() => {
this.docEditor = new DocsAPI.DocEditor(this.id, config); this.docEditor = new DocsAPI.DocEditor(this.id, config);
}) })
})()
}, },
onDocumentReady() { onDocumentReady() {

View File

@ -169,8 +169,9 @@ export default {
break; break;
case 'github': case 'github':
(async _ => {
let key = "cacheAppdown::" + this.apiVersion let key = "cacheAppdown::" + this.apiVersion
let cache = $A.getStorageJson(key); let cache = await $A.IDBJson(key);
let timeout = 600; let timeout = 600;
if (cache.time && cache.time + timeout > Math.round(new Date().getTime() / 1000)) { if (cache.time && cache.time + timeout > Math.round(new Date().getTime() / 1000)) {
this.downloadUrl = cache.data.html_url; this.downloadUrl = cache.data.html_url;
@ -186,12 +187,13 @@ export default {
if (status === 200 && $A.isArray(data)) { if (status === 200 && $A.isArray(data)) {
cache.time = Math.round(new Date().getTime() / 1000) cache.time = Math.round(new Date().getTime() / 1000)
cache.data = data.find(({tag_name}) => this.compareVersion(this.tagVersion(tag_name), this.apiVersion) === 0) || {} cache.data = data.find(({tag_name}) => this.compareVersion(this.tagVersion(tag_name), this.apiVersion) === 0) || {}
$A.setStorage(key, cache); $A.IDBSave(key, cache);
this.downloadUrl = cache.data.html_url; this.downloadUrl = cache.data.html_url;
} }
}).catch(() => { }).catch(() => {
this.loadIng--; this.loadIng--;
}); });
})()
break; break;
} }
}, },

View File

@ -1,9 +1,12 @@
const localforage = require("localforage");
/** /**
* 基础函数 * 基础函数
*/ */
(function (window, $, undefined) { (function (window, $, undefined) {
window.systemInfo = window.systemInfo || {}; window.systemInfo = window.systemInfo || {};
window.modalTransferIndex = 1000; window.modalTransferIndex = 1000;
localforage.config({name: 'DooTask', storeName: 'common'});
/** /**
* ============================================================================= * =============================================================================
@ -1213,90 +1216,68 @@
/** /**
* ============================================================================= * =============================================================================
* ***************************** localStorage ****************************** * ***************************** localForage ******************************
* ============================================================================= * =============================================================================
*/ */
$.extend({ $.extend({
setStorage(key, value) { __IDBTimer: {},
return this.operationStorage(key, value);
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) { IDBDel(key) {
let value = this.operationStorage(key); localforage.removeItem(key).then(_ => {})
return value || def;
}, },
getStorageString(key, def = '') { IDBSet(key, value) {
let value = this.operationStorage(key); 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; return typeof value === "string" || typeof value === "number" ? value : def;
}, },
getStorageInt(key, def = 0) { async IDBInt(key, def = 0) {
let value = this.operationStorage(key); const value = await this.IDBValue(key)
return typeof value === "number" ? value : def; return typeof value === "number" ? value : def;
}, },
getStorageBoolean(key, def = false) { async IDBBoolean(key, def = false) {
let value = this.operationStorage(key); const value = await this.IDBValue(key)
return typeof value === "boolean" ? value : def; return typeof value === "boolean" ? value : def;
}, },
getStorageArray(key, def = []) { async IDBArray(key, def = []) {
let value = this.operationStorage(key); const value = await this.IDBValue(key)
return this.isArray(value) ? value : def; return this.isArray(value) ? value : def;
}, },
getStorageJson(key, def = {}) { async IDBJson(key, def = {}) {
let value = this.operationStorage(key); const value = await this.IDBValue(key)
return this.isJson(value) ? value : def; 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;
}
},
}); });
/** /**

View File

@ -70,8 +70,8 @@ let languageUtils = {
* @returns {string} * @returns {string}
*/ */
getLanguage() { getLanguage() {
if (typeof window.localStorage['__language:type__'] === "string") { if (typeof window.localStorage.getItem("__language:type__") === "string") {
return window.localStorage['__language:type__']; return window.localStorage.getItem("__language:type__");
} }
let lang = 'EN'; let lang = 'EN';
let navLang = ((window.navigator.language || navigator.userLanguage) + "").toUpperCase(); let navLang = ((window.navigator.language || navigator.userLanguage) + "").toUpperCase();
@ -92,7 +92,8 @@ let languageUtils = {
lang = 'TC' lang = 'TC'
break; break;
} }
return window.localStorage['__language:type__'] = lang; window.localStorage.setItem("__language:type__", lang)
return lang
} }
}; };
let languageInit = false; let languageInit = false;
@ -133,7 +134,7 @@ function setLanguage(language) {
cancelText: '取消', cancelText: '取消',
okText: '确定', okText: '确定',
onOk: () => { onOk: () => {
window.localStorage['__language:type__'] = language; window.localStorage.setItem("__language:type__", language)
$A.reloadUrl() $A.reloadUrl()
} }
}); });
@ -201,7 +202,7 @@ function switchLanguage(text) {
setTimeout(_ => { setTimeout(_ => {
try { try {
let key = '__language:Undefined__'; let key = '__language:Undefined__';
let languageTmp = JSON.parse(window.localStorage[key] || '[]'); let languageTmp = JSON.parse(window.localStorage.getItem(key) || '[]');
if (!languageUtils.isArray(languageTmp)) { if (!languageUtils.isArray(languageTmp)) {
languageTmp = []; languageTmp = [];
} }
@ -212,7 +213,7 @@ function switchLanguage(text) {
}); });
if (!tmpData) { if (!tmpData) {
languageTmp.push(text); languageTmp.push(text);
window.localStorage[key] = JSON.stringify(languageTmp); window.localStorage.setItem(key, JSON.stringify(languageTmp));
} }
} catch (e) { } } catch (e) { }
}, 10) }, 10)

View File

@ -17,7 +17,7 @@
size="large" size="large"
readonly readonly
clearable clearable
@on-clear="clearServerUrl"/> @on-clear="setServerUrl('')"/>
<Input <Input
v-model="email" v-model="email"
@ -160,7 +160,7 @@ export default {
loginType: 'login', loginType: 'login',
loginJump: false, loginJump: false,
email: $A.getStorageString("cacheLoginEmail") || '', email: '',
password: '', password: '',
password2: '', password2: '',
code: '', code: '',
@ -172,17 +172,21 @@ export default {
subscribe: null, 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.getDemoAccount();
this.getNeedStartHome(); this.getNeedStartHome();
// //
if (this.isSoftware) { if (this.isSoftware) {
this.chackServerUrl().catch(_ => {}); this.chackServerUrl().catch(_ => {});
} else { } else {
this.clearServerUrl(); this.setServerUrl('').catch(_ => {});
} }
// //
this.subscribe = Store.subscribe('useSSOLogin', () => { this.subscribe = Store.subscribe('useSSOLogin', () => {
@ -347,8 +351,8 @@ export default {
this.$store.dispatch("call", { this.$store.dispatch("call", {
url: `${url}system/setting`, url: `${url}system/setting`,
checkNetwork: false, checkNetwork: false,
}).then(() => { }).then(async () => {
this.setServerUrl(url) await this.setServerUrl(url)
resolve() resolve()
}).catch(({ret, msg}) => { }).catch(({ret, msg}) => {
if (ret === -1001) { if (ret === -1001) {
@ -366,10 +370,8 @@ export default {
chackServerUrl(tip) { chackServerUrl(tip) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
if (this.isNotServer()) { if (this.isNotServer()) {
if (tip === true) {
$A.messageWarning("请设置服务器")
}
this.inputServerUrl() this.inputServerUrl()
tip === true && this.$nextTick(_ => $A.messageWarning("请设置服务器"))
reject() reject()
} else { } else {
resolve() resolve()
@ -377,19 +379,15 @@ export default {
}) })
}, },
setServerUrl(value) { async setServerUrl(value) {
$A.setStorage("cachePrivacyShow", value ? "no" : "yes") await $A.IDBSet("cachePrivacyShow", value ? "no" : "yes")
// //
if (value != this.cacheServerUrl) { if (value != this.cacheServerUrl) {
$A.setStorage("cacheServerUrl", value) await $A.IDBSet("cacheServerUrl", value)
$A.reloadUrl(); $A.reloadUrl();
} }
}, },
clearServerUrl() {
this.setServerUrl("")
},
isNotServer() { isNotServer() {
let apiHome = $A.getDomain(window.systemInfo.apiUrl) let apiHome = $A.getDomain(window.systemInfo.apiUrl)
return this.isSoftware && (apiHome == "" || apiHome == "public") return this.isSoftware && (apiHome == "" || apiHome == "public")
@ -461,8 +459,8 @@ export default {
invite: this.invite, invite: this.invite,
}, },
}).then(({data}) => { }).then(({data}) => {
$A.IDBSave("cacheLoginEmail", this.email)
this.codeNeed = false; this.codeNeed = false;
$A.setStorage("cacheLoginEmail", this.email)
this.$store.dispatch("handleClearCache", data).then(() => { this.$store.dispatch("handleClearCache", data).then(() => {
this.goNext(); this.goNext();
}).catch(_ => { }).catch(_ => {

View File

@ -408,11 +408,7 @@ export default {
}, },
mounted() { mounted() {
if ($A.getStorageString("clearCache")) { this.chackClear();
$A.setStorage("clearCache", "")
$A.messageSuccess("清除成功");
}
//
this.notificationInit(); this.notificationInit();
// //
this.addTaskSubscribe = Store.subscribe('addTask', this.onAddTask); this.addTaskSubscribe = Store.subscribe('addTask', this.onAddTask);
@ -700,17 +696,26 @@ export default {
}, },
methods: { methods: {
async chackClear() {
const val = await $A.IDBString("clearCache")
if (val) {
await $A.IDBRemove("clearCache")
$A.messageSuccess("清除成功");
}
},
chackPass() { chackPass() {
if (this.userInfo.changepass === 1) { if (this.userInfo.changepass === 1) {
this.goForward({name: 'manage-setting-password'}); this.goForward({name: 'manage-setting-password'});
} }
}, },
toggleRoute(path, params) { async toggleRoute(path, params) {
this.show768Menu = false; this.show768Menu = false;
let location = {name: 'manage-' + path, params: params || {}}; let location = {name: 'manage-' + path, params: params || {}};
if (path === 'file' && $A.getStorageInt("file::folderId") > 0) { let fileFolderId = await $A.IDBInt("fileFolderId");
location.params.folderId = $A.getStorageInt("file::folderId") if (path === 'file' && fileFolderId > 0) {
location.params.folderId = fileFolderId
} }
this.goForward(location); this.goForward(location);
}, },
@ -743,8 +748,8 @@ export default {
Store.set('updateNotification', null); Store.set('updateNotification', null);
return; return;
case 'clearCache': case 'clearCache':
this.$store.dispatch("handleClearCache", null).then(() => { this.$store.dispatch("handleClearCache", null).then(async () => {
$A.setStorage("clearCache", $A.randomString(6)) await $A.IDBSet("clearCache", $A.randomString(6))
$A.reloadUrl() $A.reloadUrl()
}).catch(() => { }).catch(() => {
$A.reloadUrl() $A.reloadUrl()

View File

@ -791,10 +791,8 @@ export default {
} else { } else {
this.$store.state.dialogInputCache.push(data) this.$store.state.dialogInputCache.push(data)
} }
this.__setInputCache && clearTimeout(this.__setInputCache); //
this.__setInputCache = setTimeout(_ => { $A.IDBSave("dialogInputCache", this.$store.state.dialogInputCache, 600);
$A.setStorage("cacheDialogInput", this.$store.state.dialogInputCache);
}, 600)
}, },
onClickEditor() { onClickEditor() {

View File

@ -229,9 +229,9 @@ export default {
} }
}, },
mounted() { async mounted() {
this.initCascaderData(); this.initCascaderData();
this.initProjectData(); await this.initProjectData();
this.$nextTick(() => this.$refs.input.focus()) this.$nextTick(() => this.$refs.input.focus())
}, },
@ -265,12 +265,12 @@ export default {
watch: { watch: {
'addData.project_id'(projectId) { 'addData.project_id'(projectId) {
if (projectId > 0) { if (projectId > 0) {
$A.setStorage("cacheAddTaskProjectId", projectId); $A.IDBSave("cacheAddTaskProjectId", projectId);
} }
}, },
'addData.column_id'(columnId) { 'addData.column_id'(columnId) {
if (columnId > 0) { if (columnId > 0) {
$A.setStorage("cacheAddTaskColumnId", columnId); $A.IDBSave("cacheAddTaskColumnId", columnId);
} }
const {project_id} = this.addData; const {project_id} = this.addData;
if (project_id && columnId) { 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) let project = this.cacheProjects.find(({id}) => id == this.projectId)
|| this.cacheProjects.find(({id}) => id == cacheAddTaskProjectId) || this.cacheProjects.find(({id}) => id == cacheAddTaskProjectId)
|| this.cacheProjects.find(({id}) => id > 0); || this.cacheProjects.find(({id}) => id > 0);
if (project) { 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) let column = this.cacheColumns.find(({project_id, id}) => project_id == project.id && id == cacheAddTaskColumnId)
|| this.cacheColumns.find(({project_id}) => project_id == project.id); || this.cacheColumns.find(({project_id}) => project_id == project.id);
if (column) { if (column) {

View File

@ -398,6 +398,7 @@ import DialogSelect from "./components/DialogSelect";
const FilePreview = () => import('./components/FilePreview'); const FilePreview = () => import('./components/FilePreview');
const FileContent = () => import('./components/FileContent'); const FileContent = () => import('./components/FileContent');
const FileObject = {sort: null, mode: null};
export default { export default {
components: {DialogSelect, PreviewImage, FilePreview, DrawerOverlay, UserInput, FileContent}, components: {DialogSelect, PreviewImage, FilePreview, DrawerOverlay, UserInput, FileContent},
@ -459,7 +460,7 @@ export default {
} }
], ],
tableMode: $A.getStorageString("fileTableMode"), tableMode: "",
columns: [], columns: [],
shareShow: false, 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() { created() {
const sort = $A.getStorageJson("cacheFileSort") this.tableMode = FileObject.mode
this.columns = [ this.columns = [
{ {
type: 'selection', type: 'selection',
@ -543,14 +551,14 @@ export default {
row.newname = event.target.value; row.newname = event.target.value;
}, },
'on-blur': () => { 'on-blur': () => {
const file = this.files.find(({id}) => id == row.id); const file = this.fileLists.find(({id}) => id == row.id);
if (file) { if (file) {
file.newname = row.newname; file.newname = row.newname;
this.onBlur(file) this.onBlur(file)
} }
}, },
'on-enter': () => { 'on-enter': () => {
const file = this.files.find(({id}) => id == row.id); const file = this.fileLists.find(({id}) => id == row.id);
if (file) { if (file) {
file.newname = row.newname; file.newname = row.newname;
this.onEnter(file) this.onEnter(file)
@ -575,7 +583,7 @@ export default {
}, },
on: { on: {
'on-edit-change': (b) => { 'on-edit-change': (b) => {
const file = this.files.find(({id}) => id == row.id); const file = this.fileLists.find(({id}) => id == row.id);
if (file) { if (file) {
setTimeout(() => { setTimeout(() => {
this.setEdit(file.id, b) this.setEdit(file.id, b)
@ -583,7 +591,7 @@ export default {
} }
}, },
'on-update': (val, cb) => { 'on-update': (val, cb) => {
const file = this.files.find(({id}) => id == row.id); const file = this.fileLists.find(({id}) => id == row.id);
if (file) { if (file) {
file.newname = val file.newname = val
this.onEnter(file); this.onEnter(file);
@ -695,8 +703,8 @@ export default {
sortable: true, sortable: true,
}, },
].map(item => { ].map(item => {
if (item.key === sort.key) { if (item.key === FileObject.sort.key) {
item.sortType = sort.order item.sortType = FileObject.sort.order
} }
return item; return item;
}); });
@ -716,7 +724,7 @@ export default {
}, },
computed: { computed: {
...mapState(['userIsAdmin', 'userInfo', 'files', 'wsOpenNum']), ...mapState(['userIsAdmin', 'userInfo', 'fileLists', 'wsOpenNum']),
pid() { pid() {
const {folderId} = this.$route.params; const {folderId} = this.$route.params;
@ -748,8 +756,8 @@ export default {
}, },
fileList() { fileList() {
const {files, searchKey, pid, selectIds} = this; const {fileLists, searchKey, pid, selectIds} = this;
const list = $A.cloneJSON(sortBy(files.filter((file) => { const list = $A.cloneJSON(sortBy(fileLists.filter((file) => {
if (searchKey) { if (searchKey) {
return file.name.indexOf(searchKey) !== -1; return file.name.indexOf(searchKey) !== -1;
} }
@ -764,18 +772,18 @@ export default {
}, },
shearFirst() { shearFirst() {
const {files, shearIds} = this; const {fileLists, shearIds} = this;
if (shearIds.length === 0) { if (shearIds.length === 0) {
return null; return null;
} }
return files.find(item => item.id == shearIds[0]) return fileLists.find(item => item.id == shearIds[0])
}, },
navigator() { navigator() {
let {pid, files} = this; let {pid, fileLists} = this;
let array = []; let array = [];
while (pid > 0) { 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) { if (file) {
array.unshift(file); array.unshift(file);
pid = file.pid; pid = file.pid;
@ -835,7 +843,7 @@ export default {
}, },
tableMode(val) { tableMode(val) {
$A.setStorage("fileTableMode", val) $A.IDBSave("fileTableMode", val)
}, },
fileShow(val) { fileShow(val) {
@ -897,10 +905,10 @@ export default {
return; return;
} }
this.loadIng++; this.loadIng++;
this.$store.dispatch("getFiles", this.pid).then(() => { this.$store.dispatch("getFiles", this.pid).then(async () => {
this.loadIng--; this.loadIng--;
this.openFileJudge() this.openFileJudge()
$A.setStorage("file::folderId", this.pid) await $A.IDBSet("fileFolderId", this.pid)
}).catch(({msg}) => { }).catch(({msg}) => {
this.loadIng--; this.loadIng--;
$A.modalError({ $A.modalError({
@ -925,7 +933,7 @@ export default {
return; return;
} }
let id = $A.randomString(8); let id = $A.randomString(8);
this.files.push({ this.fileLists.push({
_edit: true, _edit: true,
pid: this.pid, pid: this.pid,
id: id, id: id,
@ -1077,7 +1085,7 @@ export default {
}, },
handleContextMenu(row, event) { 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) { handleContextClick(command) {
@ -1093,7 +1101,7 @@ export default {
}, },
handleVisibleChangeMenu(visible) { handleVisibleChangeMenu(visible) {
let file = this.files.find(({_highlight}) => !!_highlight) let file = this.fileLists.find(({_highlight}) => !!_highlight)
if (file) { if (file) {
this.$set(file, '_highlight', false); this.$set(file, '_highlight', false);
} }
@ -1300,7 +1308,7 @@ export default {
return; return;
} }
if (this.isParentShare) { 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) { if (tmpFile) {
$A.modalError(`${tmpFile.name} 当前正在共享,无法移动到另一个共享文件夹内`) $A.modalError(`${tmpFile.name} 当前正在共享,无法移动到另一个共享文件夹内`)
return; return;
@ -1325,9 +1333,9 @@ export default {
if (ids.length === 0) { if (ids.length === 0) {
return 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 => { 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 typeName = allFolder ? "文件夹" : "文件"
let fileName = `${firstFile.name}】等${ids.length}${typeName}` let fileName = `${firstFile.name}】等${ids.length}${typeName}`
@ -1373,7 +1381,7 @@ export default {
}, },
onBlur(item) { onBlur(item) {
if (this.files.find(({id, _edit}) => id == item.id && !_edit)) { if (this.fileLists.find(({id, _edit}) => id == item.id && !_edit)) {
return; return;
} }
this.onEnter(item); this.onEnter(item);
@ -1439,7 +1447,7 @@ export default {
}, },
setEdit(fileId, is) { 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) { if (item) {
this.$set(item, '_edit', is); this.$set(item, '_edit', is);
if (is) { if (is) {
@ -1449,7 +1457,7 @@ export default {
}, },
setLoad(fileId, is) { 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) { if (item) {
this.$set(item, '_load', is); this.$set(item, '_load', is);
} }
@ -1580,7 +1588,7 @@ export default {
}, },
handleTableSort({key, order}) { handleTableSort({key, order}) {
$A.setStorage("cacheFileSort", ['asc', 'desc'].includes(order) ? {key, order} : {}); $A.IDBSave("cacheFileSort", ['asc', 'desc'].includes(order) ? {key, order} : {});
}, },
handleTableSelect(selection) { handleTableSelect(selection) {

View File

@ -397,14 +397,12 @@ export default {
case 'log.open': case 'log.open':
case 'log:open': case 'log:open':
case 'eruda:open': case 'eruda:open':
$A.setStorage("log::open", "open"); $A.IDBSet("logOpen", "open").then(_ => $A.reloadUrl());
$A.reloadUrl();
break; break;
case 'log.close': case 'log.close':
case 'log:close': case 'log:close':
case 'eruda:close': case 'eruda:close':
$A.setStorage("log::open", "close"); $A.IDBSet("logOpen", "close").then(_ => $A.reloadUrl());
$A.reloadUrl();
break; break;
} }
// //

View File

@ -137,8 +137,8 @@ export default {
toggleRoute(path) { toggleRoute(path) {
switch (path) { switch (path) {
case 'clearCache': case 'clearCache':
this.$store.dispatch("handleClearCache", null).then(() => { this.$store.dispatch("handleClearCache", null).then(async () => {
$A.setStorage("clearCache", $A.randomString(6)) await $A.IDBSet("clearCache", $A.randomString(6))
$A.reloadUrl() $A.reloadUrl()
}).catch(() => { }).catch(() => {
$A.reloadUrl() $A.reloadUrl()

View File

@ -67,7 +67,7 @@ export default {
screenshot_mate: true, screenshot_mate: true,
screenshot_shift: true, screenshot_shift: true,
screenshot_key: '', screenshot_key: '',
}, $A.jsonParse(window.localStorage['__keyboard:data__'] || {})); }, $A.jsonParse(window.localStorage.getItem("__keyboard:data__") || {}));
// //
this.formData_bak = $A.cloneJSON(this.formData); this.formData_bak = $A.cloneJSON(this.formData);
}, },
@ -84,7 +84,7 @@ export default {
submitForm() { submitForm() {
this.$refs.formData.validate((valid) => { this.$refs.formData.validate((valid) => {
if (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.bindScreenshotKey(this.formData);
$A.messageSuccess('保存成功'); $A.messageSuccess('保存成功');
} }

View File

@ -2,6 +2,60 @@ import {Store} from 'le5le-store';
import {languageType} from "../language"; import {languageType} from "../language";
export default { 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 * @param state
@ -227,9 +281,8 @@ export default {
key = {[key]: value || !cache[key]}; key = {[key]: value || !cache[key]};
} }
state.cacheProjectParameter.splice(index, 1, Object.assign(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.themeMode = mode;
state.themeIsDark = $A.dark.isDarkEnabled(); state.themeIsDark = $A.dark.isDarkEnabled();
window.localStorage['__theme:mode__'] = mode; window.localStorage.setItem("__theme:mode__", mode);
resolve(true) resolve(true)
}); });
}, },
@ -328,7 +381,7 @@ export default {
* @returns {Promise<unknown>} * @returns {Promise<unknown>}
*/ */
saveUserInfo({state, dispatch}, info) { saveUserInfo({state, dispatch}, info) {
return new Promise(function (resolve) { return new Promise(async resolve => {
const userInfo = $A.cloneJSON(info); const userInfo = $A.cloneJSON(info);
userInfo.userid = $A.runNum(userInfo.userid); userInfo.userid = $A.runNum(userInfo.userid);
userInfo.token = userInfo.userid > 0 ? (userInfo.token || state.userToken) : ''; userInfo.token = userInfo.userid > 0 ? (userInfo.token || state.userToken) : '';
@ -336,7 +389,8 @@ export default {
state.userId = userInfo.userid; state.userId = userInfo.userid;
state.userToken = userInfo.token; state.userToken = userInfo.token;
state.userIsAdmin = $A.inArray('admin', userInfo.identity); state.userIsAdmin = $A.inArray('admin', userInfo.identity);
$A.setStorage("userInfo", state.userInfo); await $A.IDBSet("userInfo", state.userInfo);
//
dispatch("getBasicData", null); dispatch("getBasicData", null);
if (state.userId > 0) { if (state.userId > 0) {
dispatch("saveUserBasic", state.userInfo); dispatch("saveUserBasic", state.userInfo);
@ -436,9 +490,8 @@ export default {
} }
state.cacheUserActive = Object.assign(data, {__:Math.random()}); state.cacheUserActive = Object.assign(data, {__:Math.random()});
Store.set('cacheUserActive', data); Store.set('cacheUserActive', data);
setTimeout(() => { //
$A.setStorage("cacheUserBasic", state.cacheUserBasic); $A.IDBSave("cacheUserBasic", state.cacheUserBasic)
})
}, },
/** /**
@ -515,30 +568,31 @@ export default {
* @returns {Promise<unknown>} * @returns {Promise<unknown>}
*/ */
handleClearCache({state, dispatch}, userInfo) { handleClearCache({state, dispatch}, userInfo) {
return new Promise(function (resolve) { return new Promise(async resolve => {
try { 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.cacheUserBasic = [];
state.cacheDialogs = []; state.cacheDialogs = [];
state.cacheProjects = []; state.cacheProjects = [];
state.cacheColumns = []; state.cacheColumns = [];
state.cacheTasks = []; state.cacheTasks = [];
// //
window.localStorage['__language:type__'] = languageType; const cacheLoginEmail = await $A.IDBString("cacheLoginEmail");
window.localStorage['__keyboard:data__'] = keyboardData; const cacheFileSort = await $A.IDBJson("cacheFileSort");
window.localStorage['__theme:mode__'] = themeMode; const languageType = window.localStorage.getItem("__language:type__");
$A.setStorage("cacheProjectParameter", state.cacheProjectParameter); const keyboardData = window.localStorage.getItem("__keyboard:data__");
$A.setStorage("cacheServerUrl", state.cacheServerUrl); const themeMode = window.localStorage.getItem("__theme:mode__");
$A.setStorage("cacheLoginEmail", cacheLoginEmail); //
$A.setStorage("cacheFileSort", cacheFileSort); window.localStorage.clear();
$A.setStorage("cacheTaskBrowse", state.cacheTaskBrowse); 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); dispatch("saveUserInfo", $A.isJson(userInfo) ? userInfo : state.userInfo);
// //
resolve() resolve()
@ -567,12 +621,13 @@ export default {
}); });
} else if ($A.isJson(data)) { } else if ($A.isJson(data)) {
let base = {_load: false, _edit: false}; 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) { 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 { } 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]; let ids = $A.isArray(file_id) ? file_id : [file_id];
ids.some(id => { ids.some(id => {
state.files = state.files.filter(file => file.id != id); state.fileLists = state.fileLists.filter(file => file.id != id);
state.files.some(file => { state.fileLists.some(file => {
if (file.pid == id) { if (file.pid == id) {
dispatch("forgetFile", file.id); dispatch("forgetFile", file.id);
} }
}); });
$A.IDBSave("fileLists", state.fileLists, 600)
}) })
}, },
@ -612,7 +668,8 @@ export default {
}, },
}).then((result) => { }).then((result) => {
const ids = result.data.map(({id}) => id) 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); dispatch("saveFile", result.data);
resolve(result) resolve(result)
@ -692,9 +749,7 @@ export default {
} }
}) })
// //
setTimeout(() => { $A.IDBSave("cacheProjects", state.cacheProjects);
$A.setStorage("cacheProjects", state.cacheProjects);
})
} }
}, },
@ -727,9 +782,8 @@ export default {
$A.goForward({name: 'manage-dashboard'}); $A.goForward({name: 'manage-dashboard'});
} }
} }
setTimeout(() => { //
$A.setStorage("cacheProjects", state.cacheProjects); $A.IDBSave("cacheProjects", state.cacheProjects);
})
}, },
/** /**
@ -910,9 +964,8 @@ export default {
} else { } else {
state.cacheColumns.push(data); 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(() => {})) Array.from(new Set(project_ids)).some(id => dispatch("getProjectOne", id).catch(() => {}))
// //
setTimeout(() => { $A.IDBSave("cacheColumns", state.cacheColumns);
$A.setStorage("cacheColumns", state.cacheColumns);
})
}, },
/** /**
@ -1088,9 +1139,7 @@ export default {
} }
}) })
// //
setTimeout(() => { $A.IDBSave("cacheTasks", state.cacheTasks);
$A.setStorage("cacheTasks", state.cacheTasks);
})
} }
}, },
@ -1129,9 +1178,8 @@ export default {
if (ids.includes(state.taskId)) { if (ids.includes(state.taskId)) {
state.taskId = 0; 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) { if (state.cacheTaskBrowse.length > 200) {
state.cacheTaskBrowse.splice(200); state.cacheTaskBrowse.splice(200);
} }
setTimeout(() => { //
$A.setStorage("cacheTaskBrowse", state.cacheTaskBrowse); $A.IDBSave("cacheTaskBrowse", state.cacheTaskBrowse);
})
}, },
/** *****************************************************************************************/ /** *****************************************************************************************/
@ -1961,9 +2008,8 @@ export default {
} else { } else {
state.cacheDialogs.push(data); state.cacheDialogs.push(data);
} }
setTimeout(() => { //
$A.setStorage("cacheDialogs", state.cacheDialogs); $A.IDBSave("cacheDialogs", state.cacheDialogs);
})
} }
}, },
@ -2167,9 +2213,7 @@ export default {
state.dialogId = 0 state.dialogId = 0
} }
// //
setTimeout(() => { $A.IDBSave("cacheDialogs", state.cacheDialogs);
$A.setStorage("cacheDialogs", state.cacheDialogs);
})
}, },
/** /**
@ -2187,9 +2231,9 @@ export default {
} else { } else {
state.dialogIns.push(data); state.dialogIns.push(data);
} }
// 会话消息总数量大于1000时只保留最近打开的20个会话 // 会话消息总数量大于1500时只保留最近打开的30个会话
const msg_max = 1000 const msg_max = 1500
const retain_num = 20 const retain_num = 30
state.dialogHistory = state.dialogHistory.filter(id => id != data.dialog_id) state.dialogHistory = state.dialogHistory.filter(id => id != data.dialog_id)
state.dialogHistory.push(data.dialog_id) state.dialogHistory.push(data.dialog_id)
if (state.dialogMsgs.length > msg_max && state.dialogHistory.length > retain_num) { if (state.dialogMsgs.length > msg_max && state.dialogHistory.length > retain_num) {
@ -2205,6 +2249,7 @@ export default {
}) })
if (delIds.length > 0) { if (delIds.length > 0) {
state.dialogMsgs = state.dialogMsgs.filter(item => !delIds.includes(item.dialog_id)); state.dialogMsgs = state.dialogMsgs.filter(item => !delIds.includes(item.dialog_id));
$A.IDBSave("dialogMsgs", state.dialogMsgs, 600)
} }
state.dialogHistory = newIds state.dialogHistory = newIds
} }
@ -2245,6 +2290,7 @@ export default {
return b.id - a.id return b.id - a.id
}).splice(retain).map(item => item.id) }).splice(retain).map(item => item.id)
state.dialogMsgs = state.dialogMsgs.filter(item => !delIds.includes(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 { } else {
state.dialogMsgs.push(data); 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); const dialog = state.cacheDialogs.find(({id, last_msg}) => id == data.dialog_id && last_msg && last_msg.id === data.id);
if (dialog) { if (dialog) {
@ -2338,6 +2385,7 @@ export default {
dispatch("decrementMsgReplyNum", state.dialogMsgs[index]); dispatch("decrementMsgReplyNum", state.dialogMsgs[index]);
Store.set('audioSubscribe', id); Store.set('audioSubscribe', id);
state.dialogMsgs.splice(index, 1); state.dialogMsgs.splice(index, 1);
$A.IDBSave("dialogMsgs", state.dialogMsgs, 600)
} }
}) })
dispatch("forgetDialogTodoForMsgId", msg_id) dispatch("forgetDialogTodoForMsgId", msg_id)
@ -2378,6 +2426,7 @@ export default {
// //
if (clearBefore) { if (clearBefore) {
state.dialogMsgs = state.dialogMsgs.filter(({dialog_id}) => dialog_id !== data.dialog_id) state.dialogMsgs = state.dialogMsgs.filter(({dialog_id}) => dialog_id !== data.dialog_id)
$A.IDBSave("dialogMsgs", state.dialogMsgs, 600)
} }
// //
const callTime = $A.Time(); const callTime = $A.Time();
@ -2394,6 +2443,7 @@ export default {
// //
const ids = resData.list.map(({id}) => id) 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); 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)) { if ($A.isArray(resData.todo)) {
state.dialogTodos = state.dialogTodos.filter(item => item.dialog_id != data.dialog_id) state.dialogTodos = state.dialogTodos.filter(item => item.dialog_id != data.dialog_id)

View File

@ -1,4 +1,4 @@
const stateData = { export default {
// 浏览器尺寸信息 // 浏览器尺寸信息
windowWidth: $A(window).width(), windowWidth: $A(window).width(),
windowHeight: $A(window).height(), windowHeight: $A(window).height(),
@ -34,20 +34,20 @@ const stateData = {
// User // User
cacheUserActive: {}, cacheUserActive: {},
cacheUserWait: [], cacheUserWait: [],
cacheUserBasic: $A.getStorageArray("cacheUserBasic"), cacheUserBasic: [],
// Dialog // Dialog
cacheDialogs: $A.getStorageArray("cacheDialogs").map(item => Object.assign(item, {loading: false})), cacheDialogs: [],
// Project // Project
cacheProjects: $A.getStorageArray("cacheProjects"), cacheProjects: [],
cacheColumns: $A.getStorageArray("cacheColumns"), cacheColumns: [],
cacheTasks: $A.getStorageArray("cacheTasks"), cacheTasks: [],
cacheProjectParameter: $A.getStorageArray("cacheProjectParameter"), cacheProjectParameter: [],
cacheTaskBrowse: $A.getStorageArray("cacheTaskBrowse"), cacheTaskBrowse: [],
// ServerUrl // ServerUrl
cacheServerUrl: $A.getStorageString("cacheServerUrl"), cacheServerUrl: "",
// Ajax // Ajax
ajaxWsReady: false, ajaxWsReady: false,
@ -66,7 +66,7 @@ const stateData = {
wsReadWaitList: [], wsReadWaitList: [],
// 会员信息 // 会员信息
userInfo: $A.getStorageJson("userInfo"), userInfo: {},
userId: 0, userId: 0,
userToken: '', userToken: '',
userIsAdmin: false, userIsAdmin: false,
@ -80,11 +80,11 @@ const stateData = {
dialogMsgs: [], dialogMsgs: [],
dialogTodos: [], dialogTodos: [],
dialogHistory: [], dialogHistory: [],
dialogInputCache: $A.getStorageArray("cacheDialogInput"), dialogInputCache: [],
dialogMsgTransfer: {time: 0}, dialogMsgTransfer: {time: 0},
// 文件 // 文件
files: [], fileLists: [],
// 项目任务 // 项目任务
projectId: 0, projectId: 0,
@ -136,7 +136,7 @@ const stateData = {
], ],
// 主题皮肤 // 主题皮肤
themeMode: window.localStorage['__theme:mode__'], themeMode: window.localStorage.getItem("__theme:mode__"),
themeList: [ themeList: [
{name: '跟随系统', value: 'auto'}, {name: '跟随系统', value: 'auto'},
{name: '明亮', value: 'light'}, {name: '明亮', value: 'light'},
@ -151,32 +151,3 @@ const stateData = {
previewImageIndex: 0, previewImageIndex: 0,
previewImageList: [], 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

View File

@ -1,8 +1,8 @@
<script> <script>
@if ($theme) @if ($theme)
window.localStorage['__theme:mode__'] = "{{ $theme }}"; window.localStorage.setItem("__theme:mode__", "{{ $theme }}");
@endif @endif
@if ($language) @if ($language)
window.localStorage['__language:type__'] = "{{ $language }}"; window.localStorage.setItem("__language:type__", "{{ $language }}");
@endif @endif
</script> </script>