feat:代码上传
This commit is contained in:
@ -1,4 +1,3 @@
|
||||
|
||||
import config from '@/common/config.js';
|
||||
import Vue from 'vue'
|
||||
import Vuex from 'vuex'
|
||||
@ -6,20 +5,22 @@ Vue.use(Vuex)
|
||||
|
||||
let lifeData = {};
|
||||
|
||||
try{
|
||||
try {
|
||||
// 尝试获取本地是否存在lifeData变量,第一次启动APP时是不存在的
|
||||
lifeData = uni.getStorageSync('lifeData');
|
||||
}catch(e){
|
||||
|
||||
} catch (e) {
|
||||
|
||||
}
|
||||
|
||||
// 需要永久存储,且下次APP启动需要取出的,在state中的变量名
|
||||
let saveStateKeys = ['vuex_user', 'vuex_token', 'vuex_remember', 'vuex_locale','vuex_isAgent','vuex_language','vuex_stationValue'];
|
||||
let saveStateKeys = ['vuex_user', 'vuex_token', 'vuex_remember', 'vuex_locale', 'vuex_isAgent', 'vuex_language',
|
||||
'vuex_stationValue'
|
||||
];
|
||||
|
||||
// 保存变量到本地存储中
|
||||
const saveLifeData = function(key, value){
|
||||
const saveLifeData = function(key, value) {
|
||||
// 判断变量名是否在需要存储的数组中
|
||||
if(saveStateKeys.indexOf(key) != -1) {
|
||||
if (saveStateKeys.indexOf(key) != -1) {
|
||||
// 获取本地存储的lifeData对象,将变量添加到对象中
|
||||
let tmp = uni.getStorageSync('lifeData');
|
||||
// 第一次打开APP,不存在lifeData变量,故放一个{}空对象
|
||||
@ -49,47 +50,46 @@ const store = new Vuex.Store({
|
||||
vuex_isAgent: lifeData.vuex_isAgent ? lifeData.vuex_isAgent : '',
|
||||
vuex_iv: lifeData.vuex_iv ? lifeData.vuex_iv : '',
|
||||
vuex_psdkey: lifeData.vuex_psdkey ? lifeData.vuex_psdkey : '',
|
||||
vuex_StationShow:lifeData.vuex_StationShow ? lifeData.vuex_StationShow : [0,0,0],
|
||||
vuex_StationShow: lifeData.vuex_StationShow ? lifeData.vuex_StationShow : [0, 0, 0],
|
||||
tabbar_current: 0,
|
||||
vuex_stationValue:lifeData.vuex_stationValue ? lifeData.vuex_stationValue : '',
|
||||
vuex_inverterFlag:lifeData.vuex_inverterFlag ? lifeData.vuex_inverterFlag : 0,
|
||||
tabbarList: [
|
||||
{
|
||||
"icon": "warning",
|
||||
"text": "告警",
|
||||
'name': 'Alarm'
|
||||
},
|
||||
// {
|
||||
// "icon": "order",
|
||||
// "text": "设备",
|
||||
// 'name': 'Device'
|
||||
vuex_stationValue: lifeData.vuex_stationValue ? lifeData.vuex_stationValue : '',
|
||||
vuex_inverterFlag: lifeData.vuex_inverterFlag ? lifeData.vuex_inverterFlag : 0,
|
||||
tabbarList: [{
|
||||
"icon": "warning",
|
||||
"text": "告警",
|
||||
'name': 'Alarm'
|
||||
},
|
||||
// {
|
||||
// "icon": "order",
|
||||
// "text": "设备",
|
||||
// 'name': 'Device'
|
||||
|
||||
// },
|
||||
{
|
||||
"icon": "moments",
|
||||
"text": "数据",
|
||||
'name': 'Data'
|
||||
},
|
||||
{
|
||||
"icon": "attach",
|
||||
"text": "收益",
|
||||
'name': 'Earnings'
|
||||
},
|
||||
{
|
||||
"icon": "attach",
|
||||
"text": "策略",
|
||||
'name': 'Policy'
|
||||
},
|
||||
{
|
||||
"icon": "account",
|
||||
"text": "我的",
|
||||
'name': 'My'
|
||||
},
|
||||
// },
|
||||
{
|
||||
"icon": "moments",
|
||||
"text": "数据",
|
||||
'name': 'Data'
|
||||
},
|
||||
{
|
||||
"icon": "attach",
|
||||
"text": "收益",
|
||||
'name': 'Earnings'
|
||||
},
|
||||
{
|
||||
"icon": "attach",
|
||||
"text": "策略",
|
||||
'name': 'Policy'
|
||||
},
|
||||
{
|
||||
"icon": "account",
|
||||
"text": "我的",
|
||||
'name': 'My'
|
||||
},
|
||||
],
|
||||
vuex_language:"en_US",
|
||||
vuex_language: "en_US",
|
||||
// 如果vuex_version无需保存到本地永久存储,无需lifeData.vuex_version方式
|
||||
vuex_config: config,
|
||||
vuex_currentComponent:'Data'
|
||||
vuex_currentComponent: 'Data'
|
||||
},
|
||||
mutations: {
|
||||
$uStore(state, payload) {
|
||||
@ -97,9 +97,9 @@ const store = new Vuex.Store({
|
||||
let nameArr = payload.name.split('.');
|
||||
let saveKey = '';
|
||||
let len = nameArr.length;
|
||||
if(len >= 2) {
|
||||
if (len >= 2) {
|
||||
let obj = state[nameArr[0]];
|
||||
for(let i = 1; i < len - 1; i ++) {
|
||||
for (let i = 1; i < len - 1; i++) {
|
||||
obj = obj[nameArr[i]];
|
||||
}
|
||||
obj[nameArr[len - 1]] = payload.value;
|
||||
@ -115,4 +115,4 @@ const store = new Vuex.Store({
|
||||
}
|
||||
})
|
||||
|
||||
export default store
|
||||
export default store
|
||||
Reference in New Issue
Block a user