老产品前端代码
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

132 lines
3.7 KiB

4 years ago
import Vue from "vue";
import Vuex from "vuex";
import cloneDeep from "lodash/cloneDeep";
import user from "./modules/user";
import app from "./modules/app";
import tagsView from "./modules/tagsView";
3 years ago
import { requestPost } from "@/js/dai/request";
3 years ago
import { dateFormats } from "@/utils/index";
4 years ago
4 years ago
Vue.use(Vuex);
3 years ago
let interTimer = null;
4 years ago
export default new Vuex.Store({
namespaced: true,
state: {
// 导航条, 布局风格, defalut(白色) / colorful(鲜艳)
4 years ago
navbarLayoutType: "colorful",
4 years ago
// 侧边栏, 布局皮肤, default(白色) / dark(黑色)
4 years ago
sidebarLayoutSkin: "dark",
4 years ago
// 侧边栏, 折叠状态
sidebarFold: false,
// 侧边栏, 菜单
sidebarMenuList: [],
4 years ago
sidebarMenuActiveName: "",
LevelOneMenuActiveName: "",
4 years ago
sidebarActiveSubMenuList: [],
// 内容, 是否需要刷新
contentIsNeedRefresh: false,
// 内容, 标签页(默认添加首页)
contentTabs: [
{
4 years ago
...window.SITE_CONFIG["contentTabDefault"],
4 years ago
name: "indexWork",
4 years ago
title: "首页",
4 years ago
},
4 years ago
],
4 years ago
contentTabsActiveName: "indexWork",
4 years ago
mainShuju: {
menuList: [],
activeName: "",
},
3 years ago
tipsList: [],
3 years ago
tipsTime: [],
4 years ago
inIframe: window.self !== window.top,
3 years ago
fixed1920: {
height: document.documentElement.clientHeight,
},
2 years ago
fullscreen: false, //是否全屏状态
4 years ago
},
modules: {
user,
app,
4 years ago
tagsView,
4 years ago
},
mutations: {
// 重置vuex本地储存状态
4 years ago
resetStore(state) {
4 years ago
Object.keys(state).forEach((key) => {
4 years ago
state[key] = cloneDeep(window.SITE_CONFIG["storeState"][key]);
});
},
3 years ago
SET_TIPS_LIST(state, tipsList) {
3 years ago
let _list = state.tipsList;
3 years ago
// state.tipsList = _list.concat(tipsList)
3 years ago
state.tipsList = tipsList;
3 years ago
},
SET_TIPS_TIME(state, time) {
3 years ago
state.tipsTime = time;
},
4 years ago
},
3 years ago
actions: {
3 years ago
clearInter() {
3 years ago
clearInterval(interTimer);
3 years ago
},
setInterval({ commit, dispatch, state }) {
interTimer = setInterval(() => {
3 years ago
const _t = dateFormats(
"YYYY-mm-dd HH:MM",
new Date(new Date().toLocaleDateString()).getTime()
);
const _tt = new Date(_t).getTime();
console.log("230000---", _t);
const t = dateFormats("YYYY-mm-dd HH:MM", new Date().getTime());
const nt = new Date(t).getTime();
3 years ago
// 判断当前时间是否为 00:00
if (nt == _tt) {
3 years ago
dispatch("setTipsTime");
return;
3 years ago
}
3 years ago
let times = state.tipsTime;
console.log("nt---000", nt);
3 years ago
state.tipsTime.forEach((item, index) => {
3 years ago
const _t = new Date(item).getTime();
3 years ago
if (_t == nt) {
3 years ago
clearInterval(interTimer);
dispatch("setTipsList", item);
times.splice(index, 1);
commit("SET_TIPS_TIME", times);
3 years ago
}
3 years ago
});
}, 60000);
3 years ago
},
3 years ago
setTipsList({ commit }, time) {
return new Promise(async (resolve, reject) => {
3 years ago
const url = "/gov/project/memoAttr/memosToRemind";
3 years ago
const params = {
3 years ago
remindTime: time || "",
};
const { data, code, msg } = await requestPost(url, params);
3 years ago
if (code === 0) {
3 years ago
commit("SET_TIPS_LIST", data);
resolve();
} else reject(msg);
});
3 years ago
},
3 years ago
setTipsTime({ commit, dispatch }) {
3 years ago
return new Promise(async (resolve, reject) => {
3 years ago
if (interTimer) clearInterval(interTimer);
const url = "/gov/project/memoAttr/memoTime";
const { data, code, msg } = await requestPost(url);
3 years ago
if (code === 0) {
3 years ago
commit("SET_TIPS_TIME", data);
if (data.length > 0) dispatch("setInterval");
resolve();
} else reject(msg);
});
},
},
4 years ago
});