| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 |
- import { defineStore } from 'pinia';
- export const useGlobalStore = defineStore('global', {
- state: () => ({
- spread: false,
- inputLine: 1,
- menuSwitch: false,
- paddingTop: 0,
- basic: {},
- service: [],
- chatList: [],
- chatLoading: false,
- playChatId: '',
- networkIsConnected: true,
- appHide: false
- }),
- actions: {
- toggleSpread() {
- this.spread = !this.spread;
- },
- setSpread(val: boolean) {
- this.spread = val;
- },
- setInputLine(val: number) {
- this.inputLine = val;
- },
- toggleMenuSwitch() {
- this.menuSwitch = !this.menuSwitch;
- },
- setMenuSwitch(val: boolean) {
- this.menuSwitch = val;
- },
- setPaddingTop(val: number) {
- this.paddingTop = val;
- },
- setBasic(val: boolean) {
- this.basic = val;
- },
- setService(val: object[]) {
- this.service = val;
- },
- pushChatList(val: object) {
- this.chatList.push(val);
- },
- setChatList(val: object[]) {
- this.chatList = val;
- },
- replyChatList(word: string, chatId: string = '') {
- let temp = JSON.parse(JSON.stringify(this.chatList));
- let lastChild = temp.pop();
- if (chatId != '') lastChild.chatId = chatId;
- lastChild.content += word;
- let lastIndex = this.chatList.length - 1;
- this.chatList.splice(lastIndex, 1, lastChild);
- },
- replyChatListSource(source: object[]) {
- let temp = JSON.parse(JSON.stringify(this.chatList));
- let lastChild = temp.pop();
- lastChild.source = source;
- let lastIndex = this.chatList.length - 1;
- this.chatList.splice(lastIndex, 1, lastChild);
- },
- setChatLoading(val: boolean) {
- this.chatLoading = val
- },
- setPlayChatId(val: string) {
- this.playChatId = val;
- },
- setNetworkIsConnected(val: boolean) {
- this.networkIsConnected = val;
- },
- setAppHide(val: boolean) {
- this.appHide = val;
- }
- }
- });
|