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.

190 lines
4.5 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
8 months ago
8 months ago
8 months ago
7 months ago
9 months ago
9 months ago
8 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
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
9 months ago
  1. import { reactive, ref } from 'vue'
  2. import { defineStore } from 'pinia'
  3. import type { homePageInterface } from '@/api'
  4. import dayjs from 'dayjs';
  5. import { get } from '@/tools/request'
  6. export const mainWrapperStore = defineStore("mainWrapper", () => {
  7. })
  8. export const homePageStore = defineStore("homePage", () => {
  9. const idShow = reactive({
  10. show_menu: false,
  11. show_carousel: true,
  12. show_author: true,
  13. show_anchornDown: true
  14. })
  15. const isEmpty=ref(false)
  16. const homepagelist = ref<homePageInterface[]>([]);
  17. const fetchHomePageList = async (query: string="") => {
  18. // const response = await get(`/statistics/searchtitle?title=${query}`);
  19. // homepagelist.value = response.data.data;
  20. get(`/statistics/searchtitle?title=${query}`).then(res => {
  21. homepagelist.value = res.data.data.map((items:any)=>({
  22. ...items,
  23. create_at:dayjs(items.create_at).format('YYYY-MM-DD HH:mm:ss'),
  24. update_at: dayjs(items.update_at).format('YYYY-MM-DD HH:mm:ss'),
  25. }));
  26. if (res.data.data.length === 0) {
  27. isEmpty.value=true
  28. }else{
  29. isEmpty.value=false
  30. }
  31. })
  32. };
  33. const fetchHomeLabelPageList= async (query:any) => {
  34. // const response = await get(`/statistics/searchtitle?title=${query}`);
  35. // homepagelist.value = response.data.data;
  36. get(
  37. "/blogs/search/label/",
  38. {labelname:query}
  39. ).then(res => {
  40. homepagelist.value = res.data.data.map((items:any)=>({
  41. ...items,
  42. create_at:dayjs(items.create_at).format('YYYY-MM-DD HH:mm:ss'),
  43. update_at: dayjs(items.update_at).format('YYYY-MM-DD HH:mm:ss'),
  44. }));
  45. if (res.data.data.length === 0) {
  46. isEmpty.value=true
  47. }else{
  48. isEmpty.value=false
  49. }
  50. })
  51. };
  52. return { idShow, homepagelist,isEmpty,fetchHomePageList,fetchHomeLabelPageList }
  53. })
  54. export const blogStore = defineStore("blog", () => {
  55. const delControl = reactive({
  56. open: false,
  57. ids: "",
  58. title:""
  59. })
  60. const formControl = ref({
  61. open: false,
  62. ids: null
  63. })
  64. const readcount=ref(0)
  65. const setReadCount=(num:number)=>{
  66. readcount.value+=num
  67. }
  68. return { delControl,formControl,readcount,setReadCount }
  69. })
  70. export const useContentStore = defineStore('content', () => {
  71. const content = ref({ text: "" });
  72. const getTitle = ref("")
  73. const showCatalogue = ref(false)
  74. const titles = ref<{ title: string; lineIndex: string; indent: number }[]>([]);
  75. function setContent(newContent: string) {
  76. content.value.text = newContent;
  77. }
  78. function setTitles(newTitles: { title: string; lineIndex: string; indent: number }[]) {
  79. titles.value = newTitles;
  80. }
  81. return { content, titles, setContent, setTitles, getTitle, showCatalogue };
  82. });
  83. export const diaryStore = defineStore("diary", () => {
  84. const delControl = reactive({
  85. open: false,
  86. ids: null,
  87. title:""
  88. })
  89. return { delControl }
  90. })
  91. export const classticStore = defineStore("classtic", () => {
  92. const addControl = reactive({
  93. open: false,
  94. title: "",
  95. mode: "",
  96. ids: ""
  97. })
  98. const delControl = reactive({
  99. open: false,
  100. ids: ""
  101. })
  102. const editControl = reactive({
  103. open: false,
  104. ids: "",
  105. title: ""
  106. })
  107. return { addControl, delControl, editControl }
  108. })
  109. export const comLinkStore = defineStore("comLink", () => {
  110. const addControl = reactive({
  111. open: false,
  112. title: "",
  113. mode: "",
  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 typeStore = defineStore("type", () => {
  128. const addControl = reactive({
  129. open: false,
  130. title: "",
  131. ids: ""
  132. })
  133. const delControl = reactive({
  134. open: false,
  135. ids: ""
  136. })
  137. const editControl = reactive({
  138. open: false,
  139. ids: "",
  140. title: ""
  141. })
  142. return { addControl, delControl, editControl }
  143. })
  144. export const labelStore = defineStore("label", () => {
  145. const addControl = reactive({
  146. open: false,
  147. title: "",
  148. ids: ""
  149. })
  150. const delControl = reactive({
  151. open: false,
  152. ids: ""
  153. })
  154. const editControl = reactive({
  155. open: false,
  156. ids: "",
  157. title: ""
  158. })
  159. return { addControl, delControl, editControl }
  160. })
  161. export const useAuthStore = defineStore("auth", () => {
  162. const tokenValue = ref("")
  163. function setToken(token: string) {
  164. tokenValue.value = token
  165. }
  166. function removeToken() {
  167. localStorage.removeItem('token');
  168. }
  169. return { setToken, removeToken }
  170. })