You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
duoji-frontend/src/store/modules/styles.js

61 lines
1.8 KiB
JavaScript

import Vue from "vue";
const vue = new Vue();
import api from '@/plugins/axios/index'
const { httpNodeApi } = api;
import axios from "axios";
import {changeTheme} from '@/plugins/themePicker'
const store = {
state: {
data:{
"theme":{
"primary-color":"rgba(184, 68, 13, 1)"
},
"title":{
"text":"堆垛机智能视觉系统",
"style":{
"color":"rgba(255, 255, 255, 1)",
"background-color":"rgba(163, 60, 12, 1)",
"font-size":"24px"
}
},
"menu":{
"default":{
"color":"rgba(230, 224, 224, 1)",
"background-color":"rgba(163, 60, 12, 1)"
},
"select":{
"color":"rgba(255, 255, 255, 1)",
"background-color":"rgba(184, 68, 13, 1)"
}
}
}
},
mutations:{
UPDATE_STYLES(state, data) {
// for(let key in data) {
// // state[key] = data[key];
// vue.$set(state, key, data[key])
// }
state.data = data;
// 改变主题颜色
changeTheme(data.theme['primary-color']);
// setItem(data);
}
},
actions: {
// 更新样式
async updateStyles({commit}, data) {
console.log(Vue.prototype.$api);
4 years ago
// commit('UPDATE_STYLES', data);
await httpNodeApi.updateStylesAPI({data})
},
// 获取样式
async getStyles({commit}){
console.log('获取样式');
const data = await axios.get('/api/node/default_css.json');
commit('UPDATE_STYLES', data.data);
}
}
}
export default store;