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.

194 lines
4.7 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
7 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
7 months ago
8 months ago
7 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
7 months ago
8 months ago
7 months ago
8 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
7 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. imglink: items.imglink || 'https://www.wuruilin.cn/personself/暂无图片.jpg',
  24. create_at:dayjs(items.create_at).format('YYYY-MM-DD HH:mm:ss'),
  25. update_at: dayjs(items.update_at).format('YYYY-MM-DD HH:mm:ss'),
  26. }));
  27. if (res.data.data.length === 0) {
  28. isEmpty.value=true
  29. }else{
  30. isEmpty.value=false
  31. }
  32. })
  33. };
  34. const fetchHomeLabelPageList= async (query:any) => {
  35. // const response = await get(`/statistics/searchtitle?title=${query}`);
  36. // homepagelist.value = response.data.data;
  37. get(
  38. "/blogs/search/label/",
  39. {labelname:query}
  40. ).then(res => {
  41. homepagelist.value = res.data.data.map((items:any)=>({
  42. ...items,
  43. create_at:dayjs(items.create_at).format('YYYY-MM-DD HH:mm:ss'),
  44. update_at: dayjs(items.update_at).format('YYYY-MM-DD HH:mm:ss'),
  45. }));
  46. if (res.data.data.length === 0) {
  47. isEmpty.value=true
  48. }else{
  49. isEmpty.value=false
  50. }
  51. })
  52. };
  53. return { idShow, homepagelist,isEmpty,fetchHomePageList,fetchHomeLabelPageList }
  54. })
  55. export const blogStore = defineStore("blog", () => {
  56. const delControl = reactive({
  57. open: false,
  58. ids: "",
  59. title:""
  60. })
  61. const isEmpty=ref(false)
  62. const isPage=ref(true)
  63. const formControl = ref({
  64. open: false,
  65. ids: null
  66. })
  67. const readcount=ref(0)
  68. const setReadCount=(num:number)=>{
  69. readcount.value+=num
  70. }
  71. return { delControl,formControl,readcount,isEmpty,isPage,setReadCount }
  72. })
  73. export const useContentStore = defineStore('content', () => {
  74. const content = ref({ text: "" });
  75. const getTitle = ref("")
  76. const showCatalogue = ref(false)
  77. const titles = ref<{ title: string; lineIndex: string; indent: number }[]>([]);
  78. function setContent(newContent: string) {
  79. content.value.text = newContent;
  80. }
  81. function setTitles(newTitles: { title: string; lineIndex: string; indent: number }[]) {
  82. titles.value = newTitles;
  83. }
  84. return { content, titles, setContent, setTitles, getTitle, showCatalogue };
  85. });
  86. export const diaryStore = defineStore("diary", () => {
  87. const delControl = reactive({
  88. open: false,
  89. ids: null,
  90. title:""
  91. })
  92. const isEmpty=ref(false)
  93. const isPage=ref(true)
  94. return { delControl,isEmpty,isPage }
  95. })
  96. export const classticStore = defineStore("classtic", () => {
  97. const addControl = reactive({
  98. open: false,
  99. title: "",
  100. mode: "",
  101. ids: ""
  102. })
  103. const delControl = reactive({
  104. open: false,
  105. ids: "",
  106. })
  107. const editControl = reactive({
  108. open: false,
  109. ids: "",
  110. title: ""
  111. })
  112. return { addControl, delControl, editControl }
  113. })
  114. export const comLinkStore = defineStore("comLink", () => {
  115. const addControl = reactive({
  116. open: false,
  117. title: "",
  118. mode: "",
  119. ids: ""
  120. })
  121. const delControl = reactive({
  122. open: false,
  123. ids: ""
  124. })
  125. const editControl = reactive({
  126. open: false,
  127. ids: "",
  128. title: ""
  129. })
  130. return { addControl, delControl, editControl }
  131. })
  132. export const typeStore = defineStore("type", () => {
  133. const addControl = reactive({
  134. open: false,
  135. title: "",
  136. ids: ""
  137. })
  138. const delControl = reactive({
  139. open: false,
  140. ids: ""
  141. })
  142. const editControl = reactive({
  143. open: false,
  144. ids: "",
  145. title: ""
  146. })
  147. return { addControl, delControl, editControl }
  148. })
  149. export const labelStore = defineStore("label", () => {
  150. const addControl = reactive({
  151. open: false,
  152. title: "",
  153. ids: ""
  154. })
  155. const delControl = reactive({
  156. open: false,
  157. ids: ""
  158. })
  159. const editControl = reactive({
  160. open: false,
  161. ids: "",
  162. title: ""
  163. })
  164. return { addControl, delControl, editControl }
  165. })
  166. export const useAuthStore = defineStore("auth", () => {
  167. const tokenValue = ref("")
  168. function setToken(token: string) {
  169. tokenValue.value = token
  170. }
  171. function removeToken() {
  172. localStorage.removeItem('token');
  173. }
  174. return { setToken, removeToken }
  175. })