global.ts 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. import { defineStore } from 'pinia';
  2. export const useGlobalStore = defineStore('global', {
  3. state: () => ({
  4. spread: false,
  5. inputLine: 1,
  6. menuSwitch: false,
  7. paddingTop: 0,
  8. basic: {},
  9. service: [],
  10. chatList: [],
  11. chatLoading: false,
  12. playChatId: '',
  13. networkIsConnected: true,
  14. appHide: false
  15. }),
  16. actions: {
  17. toggleSpread() {
  18. this.spread = !this.spread;
  19. },
  20. setSpread(val: boolean) {
  21. this.spread = val;
  22. },
  23. setInputLine(val: number) {
  24. this.inputLine = val;
  25. },
  26. toggleMenuSwitch() {
  27. this.menuSwitch = !this.menuSwitch;
  28. },
  29. setMenuSwitch(val: boolean) {
  30. this.menuSwitch = val;
  31. },
  32. setPaddingTop(val: number) {
  33. this.paddingTop = val;
  34. },
  35. setBasic(val: boolean) {
  36. this.basic = val;
  37. },
  38. setService(val: object[]) {
  39. this.service = val;
  40. },
  41. pushChatList(val: object) {
  42. this.chatList.push(val);
  43. },
  44. setChatList(val: object[]) {
  45. this.chatList = val;
  46. },
  47. replyChatList(word: string, chatId: string = '') {
  48. let temp = JSON.parse(JSON.stringify(this.chatList));
  49. let lastChild = temp.pop();
  50. if (chatId != '') lastChild.chatId = chatId;
  51. lastChild.content += word;
  52. let lastIndex = this.chatList.length - 1;
  53. this.chatList.splice(lastIndex, 1, lastChild);
  54. },
  55. replyChatListSource(source: object[]) {
  56. let temp = JSON.parse(JSON.stringify(this.chatList));
  57. let lastChild = temp.pop();
  58. lastChild.source = source;
  59. let lastIndex = this.chatList.length - 1;
  60. this.chatList.splice(lastIndex, 1, lastChild);
  61. },
  62. setChatLoading(val: boolean) {
  63. this.chatLoading = val
  64. },
  65. setPlayChatId(val: string) {
  66. this.playChatId = val;
  67. },
  68. setNetworkIsConnected(val: boolean) {
  69. this.networkIsConnected = val;
  70. },
  71. setAppHide(val: boolean) {
  72. this.appHide = val;
  73. }
  74. }
  75. });