Files
FirstUI-vue/store/index.js
2023-08-17 21:28:49 +08:00

86 lines
1.9 KiB
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// 本文件由FirstUI授权予新疆天衡创新研究院有限公司手机号186 1 4 0725 49身份证尾号5A07X5专用请尊重知识产权勿私下传播违者追究法律责任。
// #ifdef MP
import http from '../common/fui-request'
// #endif
// #ifndef VUE3
import Vue from 'vue'
import Vuex from 'vuex'
Vue.use(Vuex)
const store = new Vuex.Store({
// #endif
// #ifdef VUE3
import {
createStore
} from 'vuex'
const store = createStore({
// #endif
state: {
//当前版本
version: "2.0.0",
//主题 light、dark
theme: uni.getStorageSync('fui_theme') || 'light',
status: 0
},
mutations: {
setTheme(state, theme) {
state.theme = theme || 'light'
},
setStatus(state, status) {
state.status = status
}
},
actions: {
getStatus: async function({
commit,
state
}) {
return await new Promise((resolve, reject) => {
// #ifndef MP
commit('setStatus', 1)
resolve(true)
// #endif
// #ifdef MP
if (state.status == 1) {
resolve(true)
} else {
//wxalibaidutoutiaoqq
let platform = 'wx';
// #ifdef MP-ALIPAY
platform = 'ali';
// #endif
// #ifdef MP-BAIDU
platform = 'baidu';
// #endif
// #ifdef MP-TOUTIAO
platform = 'toutiao';
// #endif
// #ifdef MP-QQ
platform = 'qq';
// #endif
http.get(`/api/main/site-status/${platform}`, {
brief: true,
showLoading: false,
errorMsg: ''
}).then(res => {
if (res.succeeded && res.data == 1) {
commit('setStatus', 1)
resolve(true)
} else {
resolve(false)
}
}).catch(e => {
reject(false)
})
}
// #endif
})
}
}
})
export default store