mirror of https://gitee.com/pnoker/dc3-web.git
pull/1/head
parent
efac105b9d
commit
e842c5b055
@ -0,0 +1,7 @@
|
||||
/**
|
||||
* 全局配置文件
|
||||
*/
|
||||
export default {
|
||||
key: 'dc3',
|
||||
nav: '/'
|
||||
}
|
@ -0,0 +1,43 @@
|
||||
export default [
|
||||
/*{
|
||||
path: '/login',
|
||||
name: '登录页',
|
||||
component: () => import('@/page/login/index'),
|
||||
meta: {
|
||||
keepAlive: true,
|
||||
isTab: false,
|
||||
isAuth: false
|
||||
}
|
||||
},*/ {
|
||||
path: '/404',
|
||||
component: () => import('@/components/error/404'),
|
||||
name: '404',
|
||||
meta: {
|
||||
keepAlive: true,
|
||||
isTab: false,
|
||||
isAuth: false
|
||||
}
|
||||
|
||||
}, {
|
||||
path: '/403',
|
||||
component: () => import('@/components/error/403'),
|
||||
name: '403',
|
||||
meta: {
|
||||
keepAlive: true,
|
||||
isTab: false,
|
||||
isAuth: false
|
||||
}
|
||||
}, {
|
||||
path: '/500',
|
||||
component: () => import('@/components/error/500'),
|
||||
name: '500',
|
||||
meta: {
|
||||
keepAlive: true,
|
||||
isTab: false,
|
||||
isAuth: false
|
||||
}
|
||||
}, {
|
||||
path: '*',
|
||||
redirect: '/404'
|
||||
}
|
||||
]
|
@ -0,0 +1,5 @@
|
||||
const getters = {
|
||||
currentNav: state => state.common.currentNav
|
||||
};
|
||||
|
||||
export default getters
|
@ -0,0 +1,20 @@
|
||||
import website from '../../config/website'
|
||||
import {getStore, setStore} from '../../util/store'
|
||||
|
||||
const common = {
|
||||
|
||||
state: {
|
||||
website: website,
|
||||
currentNav: getStore({name: 'currentNav'}) || '/',
|
||||
},
|
||||
mutations: {
|
||||
SET_CURRENT_PATH: (state, currentNav) => {
|
||||
state.currentNav = currentNav;
|
||||
setStore({
|
||||
name: 'currentNav',
|
||||
content: state.currentNav,
|
||||
})
|
||||
}
|
||||
}
|
||||
};
|
||||
export default common
|
@ -1,20 +1,15 @@
|
||||
import Vue from 'vue'
|
||||
import Vuex from 'vuex'
|
||||
import common from './modules/common'
|
||||
import getters from './getters'
|
||||
|
||||
Vue.use(Vuex);
|
||||
|
||||
export default new Vuex.Store({
|
||||
state: {
|
||||
nav: '/'
|
||||
},
|
||||
mutations: {
|
||||
handleSelect(state, index) {
|
||||
state.nav = index;
|
||||
}
|
||||
},
|
||||
getters:{
|
||||
getNav(state){
|
||||
return state.nav;
|
||||
}
|
||||
}
|
||||
})
|
||||
const store = new Vuex.Store({
|
||||
modules: {
|
||||
common
|
||||
},
|
||||
getters
|
||||
});
|
||||
|
||||
export default store
|
||||
|
@ -0,0 +1,123 @@
|
||||
import {isNull} from './validate';
|
||||
import website from '../config/website'
|
||||
|
||||
const keyName = website.key + '-';
|
||||
|
||||
/**
|
||||
* 存储 localStorage
|
||||
* @param params
|
||||
*/
|
||||
export const setStore = (params = {}) => {
|
||||
let {
|
||||
name,
|
||||
content,
|
||||
type,
|
||||
} = params;
|
||||
name = keyName + name;
|
||||
let obj = {
|
||||
dataType: typeof (content),
|
||||
content: content,
|
||||
type: type,
|
||||
datetime: new Date().getTime()
|
||||
};
|
||||
if (type) window.sessionStorage.setItem(name, JSON.stringify(obj));
|
||||
else window.localStorage.setItem(name, JSON.stringify(obj));
|
||||
};
|
||||
|
||||
/**
|
||||
* 获取 localStorage
|
||||
* @param params
|
||||
*/
|
||||
export const getStore = (params = {}) => {
|
||||
let {
|
||||
name,
|
||||
debug
|
||||
} = params;
|
||||
name = keyName + name;
|
||||
let obj = {},
|
||||
content;
|
||||
obj = window.sessionStorage.getItem(name);
|
||||
if (isNull(obj)) obj = window.localStorage.getItem(name);
|
||||
if (isNull(obj)) return;
|
||||
try {
|
||||
obj = JSON.parse(obj);
|
||||
} catch {
|
||||
return obj;
|
||||
}
|
||||
if (debug) {
|
||||
return obj;
|
||||
}
|
||||
if (obj.dataType === 'string') {
|
||||
content = obj.content;
|
||||
} else if (obj.dataType === 'number') {
|
||||
content = Number(obj.content);
|
||||
} else if (obj.dataType === 'boolean') {
|
||||
content = eval(obj.content);
|
||||
} else if (obj.dataType === 'object') {
|
||||
content = obj.content;
|
||||
}
|
||||
return content;
|
||||
};
|
||||
|
||||
/**
|
||||
* 删除 localStorage
|
||||
* @param params
|
||||
*/
|
||||
export const removeStore = (params = {}) => {
|
||||
let {
|
||||
name,
|
||||
type
|
||||
} = params;
|
||||
name = keyName + name;
|
||||
if (type) {
|
||||
window.sessionStorage.removeItem(name);
|
||||
} else {
|
||||
window.localStorage.removeItem(name);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* 获取全部 localStorage
|
||||
* @param params
|
||||
*/
|
||||
export const getAllStore = (params = {}) => {
|
||||
let list = [];
|
||||
let {
|
||||
type
|
||||
} = params;
|
||||
if (type) {
|
||||
for (let i = 0; i <= window.sessionStorage.length; i++) {
|
||||
list.push({
|
||||
name: window.sessionStorage.key(i),
|
||||
content: getStore({
|
||||
name: window.sessionStorage.key(i),
|
||||
type: 'session'
|
||||
})
|
||||
})
|
||||
}
|
||||
} else {
|
||||
for (let i = 0; i <= window.localStorage.length; i++) {
|
||||
list.push({
|
||||
name: window.localStorage.key(i),
|
||||
content: getStore({
|
||||
name: window.localStorage.key(i),
|
||||
})
|
||||
})
|
||||
|
||||
}
|
||||
}
|
||||
return list;
|
||||
};
|
||||
|
||||
/**
|
||||
* 清空全部 localStorage
|
||||
* @param params
|
||||
*/
|
||||
export const clearStore = (params = {}) => {
|
||||
let {type} = params;
|
||||
if (type) {
|
||||
window.sessionStorage.clear();
|
||||
} else {
|
||||
window.localStorage.clear()
|
||||
}
|
||||
};
|
@ -1,6 +1,89 @@
|
||||
<template>
|
||||
<div class="home">
|
||||
<img alt="Vue logo" src="../assets/logo.png">
|
||||
<HelloWorld msg="Welcome to Your Vue.js App"/>
|
||||
</div>
|
||||
<div class="home">
|
||||
<base-card>
|
||||
<p>
|
||||
Welcome to Your Vue.js App
|
||||
</p>
|
||||
</base-card>
|
||||
<base-card>
|
||||
<p>
|
||||
Welcome to Your Vue.js App
|
||||
</p>
|
||||
</base-card>
|
||||
<base-card>
|
||||
<p>
|
||||
Welcome to Your Vue.js App
|
||||
</p>
|
||||
</base-card>
|
||||
<base-card>
|
||||
<p>
|
||||
Welcome to Your Vue.js App
|
||||
</p>
|
||||
</base-card>
|
||||
<base-card>
|
||||
<p>
|
||||
Welcome to Your Vue.js App
|
||||
</p>
|
||||
</base-card>
|
||||
<base-card>
|
||||
<p>
|
||||
Welcome to Your Vue.js App
|
||||
</p>
|
||||
</base-card>
|
||||
<base-card>
|
||||
<p>
|
||||
Welcome to Your Vue.js App
|
||||
</p>
|
||||
</base-card>
|
||||
<base-card>
|
||||
<p>
|
||||
Welcome to Your Vue.js App
|
||||
</p>
|
||||
</base-card>
|
||||
<base-card>
|
||||
<p>
|
||||
Welcome to Your Vue.js App
|
||||
</p>
|
||||
</base-card>
|
||||
<base-card>
|
||||
<p>
|
||||
Welcome to Your Vue.js App
|
||||
</p>
|
||||
</base-card>
|
||||
<base-card>
|
||||
<p>
|
||||
Welcome to Your Vue.js App
|
||||
</p>
|
||||
</base-card>
|
||||
<base-card>
|
||||
<p>
|
||||
Welcome to Your Vue.js App
|
||||
</p>
|
||||
</base-card>
|
||||
<base-card>
|
||||
<p>
|
||||
Welcome to Your Vue.js App
|
||||
</p>
|
||||
</base-card>
|
||||
<base-card>
|
||||
<p>
|
||||
Welcome to Your Vue.js App
|
||||
</p>
|
||||
</base-card>
|
||||
<base-card>
|
||||
<p>
|
||||
Welcome to Your Vue.js App
|
||||
</p>
|
||||
</base-card>
|
||||
<base-card>
|
||||
<p>
|
||||
Welcome to Your Vue.js App
|
||||
</p>
|
||||
</base-card>
|
||||
<base-card>
|
||||
<p>
|
||||
Welcome to Your Vue.js App
|
||||
</p>
|
||||
</base-card>
|
||||
</div>
|
||||
</template>
|
||||
|
Loading…
Reference in new issue