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.

56 lines
1.3 KiB

4 weeks ago
4 weeks ago
4 weeks ago
  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. // 调用接口状态
  16. aiChatCall:false,
  17. aiEmotionCall:false,
  18. deepNineCall:false,
  19. // 输入框控制
  20. chatInput:false,
  21. emotionInput:false,
  22. deepNineInput:false,
  23. firstAPICall:false,
  24. dbqbScrollToTop:true,
  25. allowTyping:false,
  26. }),
  27. actions: {
  28. async getUserCount() {
  29. const activeTab = sessionStorage.getItem("activeTabAI");
  30. const result = await getUserCountAPI({
  31. token: localStorage.getItem("localToken"),
  32. source: activeTab == 'deepNine' ? '2' : '1',
  33. });
  34. this.UserCount = result.data;
  35. },
  36. setLoading(status) {
  37. this.isLoading = status;
  38. },
  39. isLoadingT() {
  40. this.isLoading = true;
  41. },
  42. isLoadingF() {
  43. this.isLoading = false;
  44. },
  45. addKLineData(data) {
  46. this.kLineData.push(data);
  47. },
  48. },
  49. persist: {
  50. key: "chat_messages",
  51. storage: sessionStorage,
  52. paths: ["messages", "kLineData"],
  53. },
  54. });