123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141 |
- import { createStore } from "vuex";
- const taskList = [
- {
- id: 1,
- label: "发送一条消息",
- status: false,
- },
- {
- id: 2,
- label: "撤回一条消息",
- status: false,
- },
- {
- id: 3,
- label: "修改一次我的昵称",
- status: false,
- },
- {
- id: 4,
- label: "发起一个群聊",
- status: false,
- },
- {
- id: 5,
- label: "开启一次群禁言",
- status: false,
- },
- {
- id: 6,
- label: "解散一个群聊",
- status: false,
- },
- {
- id: 7,
- label: "发起一次通话",
- status: false,
- },
- ];
- const state: any = {
- taskList,
- userInfo: {},
- platform: "classroom", // 平台
- imConnent: true, // IM是否连接
- token: "", //
- isMsgNeedReadReceipt: true,
- displayOnlineStatus: true,
- allowNotification: true,
- _isTIMCallKit: true,
- };
- if (localStorage.getItem("TUIKit-userInfo")) {
- const localUserInfoStorage: any = localStorage.getItem("TUIKit-userInfo") || {};
- try {
- state.userInfo = JSON.parse(localUserInfoStorage);
- } catch (error) {
- state.userInfo = {};
- }
- }
- if (sessionStorage.getItem("isMsgNeedReadReceipt")) {
- const localNeedReadReceipt: string = sessionStorage.getItem("isMsgNeedReadReceipt") || "";
- try {
- state.isMsgNeedReadReceipt = JSON.parse(localNeedReadReceipt);
- } catch (error) {
- state.isMsgNeedReadReceipt = false;
- }
- }
- if (sessionStorage.getItem("displayOnlineStatus")) {
- const localDisplayOnlineStatus: string = sessionStorage.getItem("displayOnlineStatus") || "";
- try {
- state.displayOnlineStatus = JSON.parse(localDisplayOnlineStatus);
- } catch (error) {
- state.displayOnlineStatus = false;
- }
- }
- if (sessionStorage.getItem("allowNotification")) {
- const localAllowNotification: string = sessionStorage.getItem("allowNotification") || "";
- try {
- state.allowNotification = JSON.parse(localAllowNotification);
- } catch (error) {
- state.allowNotification = false;
- }
- }
- // 平台
- if (sessionStorage.getItem("platform")) {
- const platform: string = sessionStorage.getItem("platform") || "";
- try {
- state.platform = JSON.parse(platform);
- } catch (error) {
- state.platform = false;
- }
- }
- // 平台
- if (sessionStorage.getItem("token")) {
- const token: string = sessionStorage.getItem("token") || "";
- try {
- state.token = JSON.parse(token);
- } catch (error) {
- state.token = false;
- }
- }
- export default createStore({
- state,
- mutations: {
- handleTask(state: any, index: number) {
- state.taskList[index].status = true;
- },
- setUserInfo(state: any, userInfo: any) {
- state.userInfo = userInfo;
- localStorage.setItem("TUIKit-userInfo", JSON.stringify(userInfo));
- },
- setNeedReadReceipt(state: any, isMsgNeedReadReceipt: boolean) {
- state.isMsgNeedReadReceipt = isMsgNeedReadReceipt;
- sessionStorage.setItem("isMsgNeedReadReceipt", JSON.stringify(isMsgNeedReadReceipt));
- },
- setDisplayOnlineStatus(state: any, displayOnlineStatus: boolean) {
- state.displayOnlineStatus = displayOnlineStatus;
- sessionStorage.setItem("displayOnlineStatus", JSON.stringify(displayOnlineStatus));
- },
- setNotification(state: any, allowNotification: boolean) {
- state.allowNotification = allowNotification;
- sessionStorage.setItem("allowNotification", JSON.stringify(allowNotification));
- },
- setPlatform(state: any, platform: string) {
- state.platform = platform;
- sessionStorage.setItem("platform", platform);
- },
- setImConnent(state: any, connent: boolean) {
- state.imConnent = connent;
- },
- },
- actions: {},
- modules: {},
- });
|