{"size": 1669, "ext": "js", "max_stars_repo_path": "packages/vue-hawesome-modal/src/modules/dialogModule.js", "max_stars_repo_name": "behawesometw/hawesome-vue-extends", "max_stars_repo_stars_event_min_datetime": "2020-07-28T13:12:27.000Z", "max_stars_repo_stars_event_max_datetime": "2021-06-28T13:23:32.000Z", "max_issues_repo_path": "packages/vue-hawesome-modal/src/modules/dialogModule.js", "max_issues_repo_name": "behawesometw/hawesome-vue-extends", "max_issues_repo_issues_event_min_datetime": "2020-10-22T02:53:55.000Z", "max_issues_repo_issues_event_max_datetime": "2022-02-26T23:36:13.000Z", "max_forks_repo_path": "packages/vue-hawesome-modal/src/modules/dialogModule.js", "max_forks_repo_name": "behawesometw/hawesome-vue-extends", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": 4, "max_issues_count": 5, "max_forks_count": null, "avg_line_length": 34.0612244898, "max_line_length": 123, "alphanum_fraction": 0.5608148592}
import DialogConfigBuilder from "../../lib/dialog/dialogConfigBuilder";

export default {
    namespaced: true,
    state: {
        config: DialogConfigBuilder.defaultConfig(),
        globalSetting: {}
    },
    mutations: {
        setGlobalSetting(state, setting) {
            if (setting.themeColor) {
                setting = { ...setting, ...{ titleBarColor: setting.themeColor, confirmBtnColor: setting.themeColor } }
            }
            state.globalSetting = { ...state.globalSetting, ...setting };
        },
        setConfig(state, config) {
            state.config = config;
        }
    },
    actions: {
        talk({ commit, state }, dialogConfigBuilderInstance) {

            if (!(dialogConfigBuilderInstance instanceof DialogConfigBuilder)) {
                throw new Error("parameter must be instance of DialogConfigBuilder.");
            }

            var configReadyToShoot = {
                ...DialogConfigBuilder.defaultConfig(),
                ...state.globalSetting,
                ...dialogConfigBuilderInstance.config
            };

            var dialogPromise = new Promise((rsv, rj) => {
                configReadyToShoot.resolve = rsv;
                configReadyToShoot.reject = rj;
            })

            configReadyToShoot.isShow = true;

            commit("setConfig", configReadyToShoot);

            return dialogPromise;
        },
        hangUp({ commit }) {
            var harmoniousHangUp = { content: "", title: "", confirmBtnTxt: "", cancelBtnTxt: "", isShowCancelBtn: false };
            commit('setConfig', { ...DialogConfigBuilder.defaultConfig(), ...harmoniousHangUp });
        }
    }
}