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.

159 lines
3.4 KiB

9 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
9 months ago
9 months ago
8 months ago
9 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
8 months ago
9 months ago
8 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
8 months ago
9 months ago
8 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
8 months ago
9 months ago
8 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
8 months ago
9 months ago
8 months ago
9 months ago
9 months ago
8 months ago
9 months ago
9 months ago
  1. import { reactive, ref } from 'vue'
  2. import { defineStore } from 'pinia'
  3. import type { homePageInterface } from '@/api'
  4. import { get } from '@/tools/request'
  5. export const mainWrapperStore = defineStore("mainWrapper", () => {
  6. })
  7. export const homePageStore = defineStore("homePage", () => {
  8. const idShow = reactive({
  9. show_menu: false,
  10. show_carousel: true,
  11. show_author: true,
  12. show_anchornDown: true
  13. })
  14. const isEmpty=ref(false)
  15. const homepagelist = ref<homePageInterface[]>([]);
  16. const fetchHomePageList = async (query: string="") => {
  17. // const response = await get(`/statistics/searchtitle?title=${query}`);
  18. // homepagelist.value = response.data.data;
  19. get(`/statistics/searchtitle?title=${query}`).then(res => {
  20. homepagelist.value = res.data.data;
  21. if (res.data.data.length === 0) {
  22. isEmpty.value=true
  23. }else{
  24. isEmpty.value=false
  25. }
  26. })
  27. };
  28. return { idShow, homepagelist,isEmpty,fetchHomePageList }
  29. })
  30. export const blogStore = defineStore("blog", () => {
  31. const delControl = reactive({
  32. open: false,
  33. ids: ""
  34. })
  35. return { delControl }
  36. })
  37. export const useContentStore = defineStore('content', () => {
  38. const content = ref({ text: "" });
  39. const getTitle = ref("")
  40. const showCatalogue = ref(false)
  41. const titles = ref<{ title: string; lineIndex: string; indent: number }[]>([]);
  42. function setContent(newContent: string) {
  43. content.value.text = newContent;
  44. }
  45. function setTitles(newTitles: { title: string; lineIndex: string; indent: number }[]) {
  46. titles.value = newTitles;
  47. }
  48. return { content, titles, setContent, setTitles, getTitle, showCatalogue };
  49. });
  50. export const diaryStore = defineStore("diary", () => {
  51. const delControl = reactive({
  52. open: false,
  53. ids: ""
  54. })
  55. return { delControl }
  56. })
  57. export const classticStore = defineStore("classtic", () => {
  58. const addControl = reactive({
  59. open: false,
  60. title: "",
  61. mode: "",
  62. ids: ""
  63. })
  64. const delControl = reactive({
  65. open: false,
  66. ids: ""
  67. })
  68. const editControl = reactive({
  69. open: false,
  70. ids: "",
  71. title: ""
  72. })
  73. return { addControl, delControl, editControl }
  74. })
  75. export const comLinkStore = defineStore("comLink", () => {
  76. const addControl = reactive({
  77. open: false,
  78. title: "",
  79. mode: "",
  80. ids: ""
  81. })
  82. const delControl = reactive({
  83. open: false,
  84. ids: ""
  85. })
  86. const editControl = reactive({
  87. open: false,
  88. ids: "",
  89. title: ""
  90. })
  91. return { addControl, delControl, editControl }
  92. })
  93. export const typeStore = defineStore("type", () => {
  94. const addControl = reactive({
  95. open: false,
  96. title: "",
  97. ids: ""
  98. })
  99. const delControl = reactive({
  100. open: false,
  101. ids: ""
  102. })
  103. const editControl = reactive({
  104. open: false,
  105. ids: "",
  106. title: ""
  107. })
  108. return { addControl, delControl, editControl }
  109. })
  110. export const labelStore = defineStore("label", () => {
  111. const addControl = reactive({
  112. open: false,
  113. title: "",
  114. ids: ""
  115. })
  116. const delControl = reactive({
  117. open: false,
  118. ids: ""
  119. })
  120. const editControl = reactive({
  121. open: false,
  122. ids: "",
  123. title: ""
  124. })
  125. return { addControl, delControl, editControl }
  126. })
  127. export const useAuthStore = defineStore("auth", () => {
  128. const tokenValue = ref("")
  129. function setToken(token: string) {
  130. tokenValue.value = token
  131. }
  132. function removeToken() {
  133. localStorage.removeItem('token');
  134. }
  135. return { setToken, removeToken }
  136. })