You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

53 lines
1.3 KiB

  1. import { defineStore } from "pinia";
  2. import { getUserCountAPI } from "@/api/AIxiaocaishen";
  3. export const useChatStore = defineStore("chat", {
  4. state: () => ({
  5. messages: [],
  6. isLoading: false, // 新增加载状态
  7. UserCount: 0,
  8. chartData: [],
  9. kLineData: [],
  10. dbqbClickRecord: {},
  11. searchRecord: false,
  12. currentUserIndex: null,
  13. inputUserIndex:null,
  14. announcementMsg: null,
  15. aiChatCall:false,
  16. aiEmotionCall:false,
  17. chatInput:false,
  18. emotionInput:false,
  19. firstAPICall:false,
  20. dbqbScrollToTop:true,
  21. allowTyping:false,
  22. }),
  23. actions: {
  24. async getUserCount() {
  25. const activeTab = sessionStorage.getItem("activeTabAI");
  26. const result = await getUserCountAPI({
  27. token: localStorage.getItem("localToken"),
  28. source: activeTab == 'deepNine' ? '2' : '1',
  29. });
  30. this.UserCount = result.data.remain_num;
  31. this.FreeCount = result.data.remain_free_num;
  32. this.PaidCount = result.data.remain_pay_num;
  33. },
  34. setLoading(status) {
  35. this.isLoading = status;
  36. },
  37. isLoadingT() {
  38. this.isLoading = true;
  39. },
  40. isLoadingF() {
  41. this.isLoading = false;
  42. },
  43. addKLineData(data) {
  44. this.kLineData.push(data);
  45. },
  46. },
  47. persist: {
  48. key: "chat_messages",
  49. storage: sessionStorage,
  50. paths: ["messages", "kLineData"],
  51. },
  52. });