import { getDeploymentConfig } from '@/api/deployment' import visitorAdminConfig, { isFrontendMiddlePlatformEnabled, isServerIpRequired, isStandaloneMode } from '@/config/visitor-admin' const frontendStandalone = isStandaloneMode() const state = { deploymentMode: visitorAdminConfig.deploymentMode || visitorAdminConfig.frontendMode || 'cluster', standalone: frontendStandalone, cluster: !frontendStandalone, requireServerIp: isServerIpRequired(), middlePlatformEnabled: isFrontendMiddlePlatformEnabled(), loaded: false } const mutations = { SET_DEPLOYMENT_CONFIG: (state, config) => { state.deploymentMode = config.deploymentMode || 'standalone' state.standalone = !!config.standalone state.cluster = !!config.cluster state.requireServerIp = config.requireServerIp !== false state.middlePlatformEnabled = !!config.middlePlatformEnabled state.loaded = true } } const actions = { loadConfig({ commit }) { return getDeploymentConfig().then(res => { commit('SET_DEPLOYMENT_CONFIG', res.data || {}) }) } } export default { namespaced: true, state, mutations, actions }