add home state
This commit is contained in:
parent
e52f7221d2
commit
f195c4d280
@ -13,6 +13,8 @@ export default new Vuex.Store({
|
|||||||
row_pwd: '',
|
row_pwd: '',
|
||||||
// 配置信息
|
// 配置信息
|
||||||
settings: '',
|
settings: '',
|
||||||
|
// 主页状态
|
||||||
|
home_state: '',
|
||||||
},
|
},
|
||||||
mutations: {
|
mutations: {
|
||||||
// 设置用户信息
|
// 设置用户信息
|
||||||
@ -31,6 +33,10 @@ export default new Vuex.Store({
|
|||||||
SET_SETTINGS(state, settings) {
|
SET_SETTINGS(state, settings) {
|
||||||
state.settings = settings;
|
state.settings = settings;
|
||||||
},
|
},
|
||||||
|
// 设置主页状态
|
||||||
|
SET_HOMESTATE(state, home_state) {
|
||||||
|
state.home_state = home_state
|
||||||
|
},
|
||||||
},
|
},
|
||||||
actions: {
|
actions: {
|
||||||
// 设置用户信息
|
// 设置用户信息
|
||||||
@ -61,6 +67,13 @@ export default new Vuex.Store({
|
|||||||
commit('SET_SETTINGS', arg[0]);
|
commit('SET_SETTINGS', arg[0]);
|
||||||
localStorage.setItem("storeState", JSON.stringify(arg[1].$store.state));
|
localStorage.setItem("storeState", JSON.stringify(arg[1].$store.state));
|
||||||
},
|
},
|
||||||
|
// 设置主页状态
|
||||||
|
setHomeState({
|
||||||
|
commit
|
||||||
|
}, arg) {
|
||||||
|
commit('SET_HOMESTATE', arg[0]);
|
||||||
|
localStorage.setItem("storeState", JSON.stringify(arg[1].$store.state));
|
||||||
|
},
|
||||||
},
|
},
|
||||||
modules: {}
|
modules: {}
|
||||||
})
|
})
|
||||||
|
@ -294,6 +294,14 @@ export function lang() {
|
|||||||
CHS:{
|
CHS:{
|
||||||
title: '更新日志',
|
title: '更新日志',
|
||||||
timeline: [
|
timeline: [
|
||||||
|
{
|
||||||
|
label: '切换页面之后保存主页状态',
|
||||||
|
tag:'bug修复',
|
||||||
|
content: [
|
||||||
|
'正常情况下不保存主页状态进行页面跳转的时候会导致每次回到主页都是默认回顶的状态,已修复',
|
||||||
|
'2020-03-15'
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
label: '设置中的重置功能优化',
|
label: '设置中的重置功能优化',
|
||||||
tag:'功能更新',
|
tag:'功能更新',
|
||||||
@ -403,6 +411,14 @@ export function lang() {
|
|||||||
EN:{
|
EN:{
|
||||||
title: 'Update Log',
|
title: 'Update Log',
|
||||||
timeline: [
|
timeline: [
|
||||||
|
{
|
||||||
|
label: 'Save homepage status after switching pages',
|
||||||
|
tag:'Bug fix',
|
||||||
|
content: [
|
||||||
|
'Normally, when you do n’t save the homepage state, the page jump will result in the default backing state every time you return to the homepage.',
|
||||||
|
'2020-03-15'
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
label: 'Optimization of reset function in settings',
|
label: 'Optimization of reset function in settings',
|
||||||
tag:'Feature update',
|
tag:'Feature update',
|
||||||
|
@ -135,14 +135,16 @@ export default {
|
|||||||
lang: '',
|
lang: '',
|
||||||
// vcnsole模块
|
// vcnsole模块
|
||||||
lastClickTime: 0,
|
lastClickTime: 0,
|
||||||
count: 0
|
count: 0,
|
||||||
|
// 滚动记录
|
||||||
|
scrollHeight: 0,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
...mapState(['user_infos', 'row_data', 'row_pwd', 'settings'])
|
...mapState(['user_infos', 'row_data', 'row_pwd', 'settings', 'home_state'])
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
...mapActions(['setUserInfo', 'setRowData', 'setRowPwd', 'setSettings']),
|
...mapActions(['setUserInfo', 'setRowData', 'setRowPwd', 'setSettings', 'setHomeState']),
|
||||||
|
|
||||||
// 修改md-app的最小高度
|
// 修改md-app的最小高度
|
||||||
changeFixed(clientHeight) {
|
changeFixed(clientHeight) {
|
||||||
@ -188,6 +190,19 @@ export default {
|
|||||||
this.show_list = data_list;
|
this.show_list = data_list;
|
||||||
// 抽离title
|
// 抽离title
|
||||||
this.separateTitle(data_list);
|
this.separateTitle(data_list);
|
||||||
|
// 恢复原先状态
|
||||||
|
if(this.home_state) {
|
||||||
|
this.search_start = this.home_state.search_start
|
||||||
|
this.search_content = this.home_state.search_content
|
||||||
|
this.$nextTick(()=>{
|
||||||
|
this.$refs.list_placeholder.parentNode.parentNode.scrollTo({
|
||||||
|
top: this.home_state.scrollHeight
|
||||||
|
});
|
||||||
|
console.log('原状态恢复完成')
|
||||||
|
this.setHomeState(['', this])
|
||||||
|
console.log('主页状态缓存删除完成')
|
||||||
|
})
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// 空密码本
|
// 空密码本
|
||||||
this.show_list = [];
|
this.show_list = [];
|
||||||
@ -261,6 +276,8 @@ export default {
|
|||||||
|
|
||||||
// 跳转到解锁界面
|
// 跳转到解锁界面
|
||||||
turnToUnlock(type) {
|
turnToUnlock(type) {
|
||||||
|
this.setHomeState(['', this])
|
||||||
|
console.log('主页状态缓存删除完成')
|
||||||
console.log(type);
|
console.log(type);
|
||||||
this.setRowPwd(['', this]);
|
this.setRowPwd(['', this]);
|
||||||
if (type == '密码超时') this.$router.push({ name: 'Unlock', params: { msg: this.lang.unlock_msg.expired } });
|
if (type == '密码超时') this.$router.push({ name: 'Unlock', params: { msg: this.lang.unlock_msg.expired } });
|
||||||
@ -285,15 +302,33 @@ export default {
|
|||||||
this.turnToUnlock('点击新增未解锁拦截');
|
this.turnToUnlock('点击新增未解锁拦截');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
let home_state = {
|
||||||
|
search_start : this.search_start,
|
||||||
|
search_content: this.search_content,
|
||||||
|
scrollHeight: this.scrollHeight
|
||||||
|
}
|
||||||
|
this.setHomeState([home_state, this])
|
||||||
this.$router.push('/add');
|
this.$router.push('/add');
|
||||||
},
|
},
|
||||||
|
|
||||||
turnToDetail(content) {
|
turnToDetail(content) {
|
||||||
|
let home_state = {
|
||||||
|
search_start : this.search_start,
|
||||||
|
search_content: this.search_content,
|
||||||
|
scrollHeight: this.scrollHeight
|
||||||
|
}
|
||||||
|
this.setHomeState([home_state, this])
|
||||||
this.$router.push({ name: 'Detail', params: { code_content: content } });
|
this.$router.push({ name: 'Detail', params: { code_content: content } });
|
||||||
},
|
},
|
||||||
|
|
||||||
// 跳转到某页面
|
// 跳转到某页面
|
||||||
turnToPage(url) {
|
turnToPage(url) {
|
||||||
|
let home_state = {
|
||||||
|
search_start : this.search_start,
|
||||||
|
search_content: this.search_content,
|
||||||
|
scrollHeight: this.scrollHeight
|
||||||
|
}
|
||||||
|
this.setHomeState([home_state, this])
|
||||||
this.$router.push(url);
|
this.$router.push(url);
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -394,6 +429,11 @@ export default {
|
|||||||
this.toggleClass(vconDom, 'vconsole-show');
|
this.toggleClass(vconDom, 'vconsole-show');
|
||||||
this.count = 0;
|
this.count = 0;
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
// 记录滚动高度
|
||||||
|
scroll(e) {
|
||||||
|
this.scrollHeight = this.$refs.list_placeholder.parentNode.parentNode.scrollTop
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
@ -409,6 +449,7 @@ export default {
|
|||||||
this.clientHeight = `${document.documentElement.clientHeight}`;
|
this.clientHeight = `${document.documentElement.clientHeight}`;
|
||||||
setHtmlFontSize();
|
setHtmlFontSize();
|
||||||
}.bind(this);
|
}.bind(this);
|
||||||
|
this.$refs.list_placeholder.parentNode.parentNode.addEventListener('scroll', this.scroll)
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
// 如果 `clientHeight` 发生改变,这个函数就会运行
|
// 如果 `clientHeight` 发生改变,这个函数就会运行
|
||||||
@ -423,6 +464,7 @@ export default {
|
|||||||
} else {
|
} else {
|
||||||
this.show_list = JSON.parse(JSON.stringify(this.cache_list));
|
this.show_list = JSON.parse(JSON.stringify(this.cache_list));
|
||||||
this.cache_list = [];
|
this.cache_list = [];
|
||||||
|
this.search_content = ''
|
||||||
console.log('搜索阵列关闭,缓存清空完成');
|
console.log('搜索阵列关闭,缓存清空完成');
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user