mirror of
https://github.com/kuaifan/dootask.git
synced 2026-03-17 11:13:26 +00:00
perf: 优化加载状态
This commit is contained in:
parent
52464e232b
commit
a6425c2859
@ -261,7 +261,7 @@ export default {
|
|||||||
console.log('ws', this.ws, this.ws ? this.ws.readyState : null);
|
console.log('ws', this.ws, this.ws ? this.ws.readyState : null);
|
||||||
}
|
}
|
||||||
if (num > 0) {
|
if (num > 0) {
|
||||||
this.$store.dispatch("getBasicData", 1000)
|
this.$store.dispatch("getBasicData", 600)
|
||||||
if (this.ws === null) {
|
if (this.ws === null) {
|
||||||
this.$store.dispatch("websocketConnection");
|
this.$store.dispatch("websocketConnection");
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@ -3,7 +3,12 @@
|
|||||||
<PageTitle :title="$L('项目')"/>
|
<PageTitle :title="$L('项目')"/>
|
||||||
<div class="list-search">
|
<div class="list-search">
|
||||||
<div class="search-wrapper">
|
<div class="search-wrapper">
|
||||||
<Input prefix="ios-search" v-model="projectKeyValue" :placeholder="$L('搜索...')" clearable />
|
<Input v-model="projectKeyValue" :placeholder="$L(loadProjects || projectKeyLoading ? '读取中...' : '搜索...')" clearable>
|
||||||
|
<div class="search-pre" slot="prefix">
|
||||||
|
<Loading v-if="loadProjects || projectKeyLoading"/>
|
||||||
|
<Icon v-else type="ios-search" />
|
||||||
|
</div>
|
||||||
|
</Input>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<ul>
|
<ul>
|
||||||
@ -47,9 +52,7 @@ export default {
|
|||||||
},
|
},
|
||||||
|
|
||||||
computed: {
|
computed: {
|
||||||
...mapState([
|
...mapState(['cacheProjects', 'loadProjects']),
|
||||||
'cacheProjects',
|
|
||||||
]),
|
|
||||||
|
|
||||||
projectLists() {
|
projectLists() {
|
||||||
const {projectKeyValue, cacheProjects} = this;
|
const {projectKeyValue, cacheProjects} = this;
|
||||||
|
|||||||
@ -3,7 +3,10 @@
|
|||||||
<PageTitle :title="$L('仪表盘')"/>
|
<PageTitle :title="$L('仪表盘')"/>
|
||||||
<div class="dashboard-wrapper">
|
<div class="dashboard-wrapper">
|
||||||
<div class="dashboard-hello">{{$L('欢迎您,' + userInfo.nickname)}}</div>
|
<div class="dashboard-hello">{{$L('欢迎您,' + userInfo.nickname)}}</div>
|
||||||
<div class="dashboard-desc">{{$L('以下是你当前的任务统计数据')}}</div>
|
<div class="dashboard-desc">
|
||||||
|
{{$L('以下是你当前的任务统计数据')}}
|
||||||
|
<div v-if="loadDashboardTasks" class="dashboard-load"><Loading/></div>
|
||||||
|
</div>
|
||||||
<ul class="dashboard-block">
|
<ul class="dashboard-block">
|
||||||
<li @click="scrollTo('today')">
|
<li @click="scrollTo('today')">
|
||||||
<div class="block-title">{{getTitle('today')}}</div>
|
<div class="block-title">{{getTitle('today')}}</div>
|
||||||
@ -107,7 +110,7 @@ export default {
|
|||||||
},
|
},
|
||||||
|
|
||||||
activated() {
|
activated() {
|
||||||
this.$store.dispatch("getTaskForDashboard");
|
this.$store.dispatch("getTaskForDashboard", 600);
|
||||||
},
|
},
|
||||||
|
|
||||||
deactivated() {
|
deactivated() {
|
||||||
@ -115,7 +118,7 @@ export default {
|
|||||||
},
|
},
|
||||||
|
|
||||||
computed: {
|
computed: {
|
||||||
...mapState(['userInfo']),
|
...mapState(['userInfo', 'loadDashboardTasks']),
|
||||||
|
|
||||||
...mapGetters(['dashboardTask', 'transforTasks']),
|
...mapGetters(['dashboardTask', 'transforTasks']),
|
||||||
|
|
||||||
|
|||||||
@ -5,7 +5,12 @@
|
|||||||
<div class="messenger-select">
|
<div class="messenger-select">
|
||||||
<div class="messenger-search">
|
<div class="messenger-search">
|
||||||
<div class="search-wrapper">
|
<div class="search-wrapper">
|
||||||
<Input v-if="tabActive==='dialog'" prefix="ios-search" v-model="dialogKey" :placeholder="$L('搜索...')" clearable />
|
<Input v-if="tabActive==='dialog'" v-model="dialogKey" :placeholder="$L(loadDialogs ? '读取中...' : '搜索...')" clearable >
|
||||||
|
<div class="search-pre" slot="prefix">
|
||||||
|
<Loading v-if="loadDialogs"/>
|
||||||
|
<Icon v-else type="ios-search" />
|
||||||
|
</div>
|
||||||
|
</Input>
|
||||||
<Input v-else prefix="ios-search" v-model="contactsKey" :placeholder="$L('搜索...')" clearable />
|
<Input v-else prefix="ios-search" v-model="contactsKey" :placeholder="$L('搜索...')" clearable />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -168,7 +173,7 @@ export default {
|
|||||||
},
|
},
|
||||||
|
|
||||||
computed: {
|
computed: {
|
||||||
...mapState(['userId', 'cacheDialogs']),
|
...mapState(['userId', 'cacheDialogs', 'loadDialogs']),
|
||||||
|
|
||||||
dialogId() {
|
dialogId() {
|
||||||
const {dialogId} = this.$route.params;
|
const {dialogId} = this.$route.params;
|
||||||
|
|||||||
53
resources/assets/js/store/actions.js
vendored
53
resources/assets/js/store/actions.js
vendored
@ -338,7 +338,7 @@ export default {
|
|||||||
* @param data {userid}
|
* @param data {userid}
|
||||||
*/
|
*/
|
||||||
getUserBasic({state, dispatch}, data) {
|
getUserBasic({state, dispatch}, data) {
|
||||||
if (state.cacheLoading["loadUserBasic"] === true) {
|
if (state.loadUserBasic === true) {
|
||||||
data && state.cacheUserWait.push(data);
|
data && state.cacheUserWait.push(data);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -370,7 +370,7 @@ export default {
|
|||||||
array = array.slice(0, 30)
|
array = array.slice(0, 30)
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
state.cacheLoading["loadUserBasic"] = true;
|
state.loadUserBasic = true;
|
||||||
dispatch("call", {
|
dispatch("call", {
|
||||||
url: 'users/basic',
|
url: 'users/basic',
|
||||||
data: {
|
data: {
|
||||||
@ -383,11 +383,11 @@ export default {
|
|||||||
data._time = time;
|
data._time = time;
|
||||||
dispatch("saveUserBasic", data);
|
dispatch("saveUserBasic", data);
|
||||||
});
|
});
|
||||||
state.cacheLoading["loadUserBasic"] = false;
|
state.loadUserBasic = false;
|
||||||
dispatch("getUserBasic");
|
dispatch("getUserBasic");
|
||||||
}).catch(e => {
|
}).catch(e => {
|
||||||
console.warn(e);
|
console.warn(e);
|
||||||
state.cacheLoading["loadUserBasic"] = false;
|
state.loadUserBasic = false;
|
||||||
dispatch("getUserBasic");
|
dispatch("getUserBasic");
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
@ -711,6 +711,7 @@ export default {
|
|||||||
reject({msg: 'Parameter error'});
|
reject({msg: 'Parameter error'});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
state.loadProjects++;
|
||||||
dispatch("call", {
|
dispatch("call", {
|
||||||
url: 'project/lists',
|
url: 'project/lists',
|
||||||
data: data || {}
|
data: data || {}
|
||||||
@ -721,6 +722,8 @@ export default {
|
|||||||
}).catch(e => {
|
}).catch(e => {
|
||||||
console.warn(e);
|
console.warn(e);
|
||||||
reject(e)
|
reject(e)
|
||||||
|
}).finally(_ => {
|
||||||
|
state.loadProjects--;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
@ -1204,12 +1207,22 @@ export default {
|
|||||||
* @param state
|
* @param state
|
||||||
* @param dispatch
|
* @param dispatch
|
||||||
* @param getters
|
* @param getters
|
||||||
|
* @param timeout
|
||||||
*/
|
*/
|
||||||
getTaskForDashboard({state, dispatch, getters}) {
|
getTaskForDashboard({state, dispatch, getters}, timeout) {
|
||||||
if (state.cacheLoading["loadDashboardTasks"] === true) {
|
if (typeof timeout === "number") {
|
||||||
|
window.__getTaskForDashboard && clearTimeout(window.__getTaskForDashboard)
|
||||||
|
if (timeout > -1) {
|
||||||
|
window.__getTaskForDashboard = setTimeout(() => {
|
||||||
|
dispatch("getTaskForDashboard", null)
|
||||||
|
}, timeout)
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
state.cacheLoading["loadDashboardTasks"] = true;
|
if (state.loadDashboardTasks === true) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
state.loadDashboardTasks = true;
|
||||||
//
|
//
|
||||||
const time = $A.Time()
|
const time = $A.Time()
|
||||||
const {today, overdue,all} = getters.dashboardTask;
|
const {today, overdue,all} = getters.dashboardTask;
|
||||||
@ -1220,7 +1233,7 @@ export default {
|
|||||||
let loadIng = 3;
|
let loadIng = 3;
|
||||||
let call = () => {
|
let call = () => {
|
||||||
if (loadIng <= 0) {
|
if (loadIng <= 0) {
|
||||||
state.cacheLoading["loadDashboardTasks"] = false;
|
state.loadDashboardTasks = false;
|
||||||
//
|
//
|
||||||
const {today, overdue,all} = getters.dashboardTask;
|
const {today, overdue,all} = getters.dashboardTask;
|
||||||
const newIds = today.filter(task => task._time >= time).map(({id}) => id)
|
const newIds = today.filter(task => task._time >= time).map(({id}) => id)
|
||||||
@ -1935,14 +1948,18 @@ export default {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let data = {};
|
let data = {};
|
||||||
if (atAfter === true && state.cacheDialogs.length > 0) {
|
if (atAfter === true) {
|
||||||
const tmpList = state.cacheDialogs.sort((a, b) => {
|
if (state.cacheDialogs.length > 0) {
|
||||||
if (a.top_at || b.top_at) {
|
const tmpList = state.cacheDialogs.sort((a, b) => {
|
||||||
return $A.Date(b.top_at) - $A.Date(a.top_at);
|
if (a.top_at || b.top_at) {
|
||||||
}
|
return $A.Date(b.top_at) - $A.Date(a.top_at);
|
||||||
return $A.Date(b.last_at) - $A.Date(a.last_at);
|
}
|
||||||
})
|
return $A.Date(b.last_at) - $A.Date(a.last_at);
|
||||||
data.at_after = tmpList[0].last_at;
|
})
|
||||||
|
data.at_after = tmpList[0].last_at;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
state.loadDialogs++;
|
||||||
}
|
}
|
||||||
dispatch("call", {
|
dispatch("call", {
|
||||||
url: 'dialog/lists',
|
url: 'dialog/lists',
|
||||||
@ -1953,6 +1970,10 @@ export default {
|
|||||||
}).catch(e => {
|
}).catch(e => {
|
||||||
console.warn(e);
|
console.warn(e);
|
||||||
reject(e)
|
reject(e)
|
||||||
|
}).finally(_ => {
|
||||||
|
if (atAfter !== true) {
|
||||||
|
state.loadDialogs--;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|||||||
7
resources/assets/js/store/state.js
vendored
7
resources/assets/js/store/state.js
vendored
@ -6,8 +6,11 @@ const stateData = {
|
|||||||
// 浏览器宽度≤768返回true
|
// 浏览器宽度≤768返回true
|
||||||
windowMax768: window.innerWidth <= 768,
|
windowMax768: window.innerWidth <= 768,
|
||||||
|
|
||||||
// 数据缓存
|
// 加载状态
|
||||||
cacheLoading: {},
|
loadDashboardTasks: false,
|
||||||
|
loadUserBasic: false,
|
||||||
|
loadProjects: 0,
|
||||||
|
loadDialogs: 0,
|
||||||
|
|
||||||
// User
|
// User
|
||||||
cacheUserActive: {},
|
cacheUserActive: {},
|
||||||
|
|||||||
@ -23,6 +23,19 @@
|
|||||||
border-radius: 12px;
|
border-radius: 12px;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
|
|
||||||
|
.search-pre {
|
||||||
|
width: 32px;
|
||||||
|
height: 32px;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
.common-loading {
|
||||||
|
width: 16px;
|
||||||
|
height: 16px;
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
.ivu-input {
|
.ivu-input {
|
||||||
border-color: transparent;
|
border-color: transparent;
|
||||||
background-color: transparent;
|
background-color: transparent;
|
||||||
|
|||||||
10
resources/assets/sass/pages/page-dashboard.scss
vendored
10
resources/assets/sass/pages/page-dashboard.scss
vendored
@ -30,10 +30,20 @@
|
|||||||
word-wrap: break-word;
|
word-wrap: break-word;
|
||||||
}
|
}
|
||||||
.dashboard-desc {
|
.dashboard-desc {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
margin-top: 18px;
|
margin-top: 18px;
|
||||||
padding: 0 12px;
|
padding: 0 12px;
|
||||||
color: #888888;
|
color: #888888;
|
||||||
font-size: 13px;
|
font-size: 13px;
|
||||||
|
.dashboard-load {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
width: 14px;
|
||||||
|
height: 14px;
|
||||||
|
margin: 0 0 0 4px;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
.dashboard-block {
|
.dashboard-block {
|
||||||
margin-top: 18px;
|
margin-top: 18px;
|
||||||
|
|||||||
12
resources/assets/sass/pages/page-messenger.scss
vendored
12
resources/assets/sass/pages/page-messenger.scss
vendored
@ -36,6 +36,18 @@
|
|||||||
margin: 0 4px;
|
margin: 0 4px;
|
||||||
border-radius: 12px;
|
border-radius: 12px;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
|
.search-pre {
|
||||||
|
width: 32px;
|
||||||
|
height: 32px;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
.common-loading {
|
||||||
|
width: 16px;
|
||||||
|
height: 16px;
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
.ivu-input {
|
.ivu-input {
|
||||||
border-color: transparent;
|
border-color: transparent;
|
||||||
background-color: transparent;
|
background-color: transparent;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user