mirror of https://gitee.com/godoos/godoos.git
26 changed files with 1273 additions and 674 deletions
File diff suppressed because it is too large
@ -0,0 +1,36 @@ |
|||||
|
import { defineStore } from 'pinia' |
||||
|
import { OsFileWithoutContent } from '@/system/core/FileSystem'; |
||||
|
export const useShareFile = defineStore('shareFile', () =>{ |
||||
|
const currentShareFile = ref<OsFileWithoutContent[]>([]); |
||||
|
let CurrentFile = ref<OsFileWithoutContent>(); |
||||
|
const setShareFile = (file: OsFileWithoutContent[]) => { |
||||
|
currentShareFile.value = file |
||||
|
//console.log('存储文件:', currentShareFile);
|
||||
|
} |
||||
|
const setCurrentFile = (file: OsFileWithoutContent) => { |
||||
|
CurrentFile.value = file |
||||
|
//console.log('当前文件:', CurrentFile.value);
|
||||
|
} |
||||
|
const getShareFile = (): OsFileWithoutContent[] | null =>{ |
||||
|
return currentShareFile.value |
||||
|
} |
||||
|
const findServerPath = (titleName: string): OsFileWithoutContent | string => { |
||||
|
//console.log('查找文件:',getShareFile());
|
||||
|
let result = currentShareFile.value.find(item =>{ |
||||
|
return item.titleName === titleName |
||||
|
}) |
||||
|
if (!result) { |
||||
|
//console.log('回退茶砸后:',currentShareFile.value[0]);
|
||||
|
return currentShareFile.value[0].parentPath |
||||
|
} |
||||
|
return result |
||||
|
} |
||||
|
return { |
||||
|
setShareFile, |
||||
|
setCurrentFile, |
||||
|
getShareFile, |
||||
|
findServerPath, |
||||
|
currentShareFile, |
||||
|
CurrentFile |
||||
|
} |
||||
|
}) |
@ -1,97 +1,97 @@ |
|||||
|
import { fetchGet, getSystemConfig } from "@/system/config"; |
||||
import { defineStore } from "pinia"; |
import { defineStore } from "pinia"; |
||||
import { ref } from "vue"; |
import { ref } from "vue"; |
||||
import { getSystemConfig, fetchGet } from "@/system/config"; |
|
||||
import { useUpgradeStore } from "./upgrade"; |
import { useUpgradeStore } from "./upgrade"; |
||||
export const useNotifyStore = defineStore('notifyStore', () => { |
export const useNotifyStore = defineStore('notifyStore', () => { |
||||
const config = getSystemConfig(); |
const config = getSystemConfig(); |
||||
const upgradeStore = useUpgradeStore() |
const upgradeStore = useUpgradeStore() |
||||
const notifyList: any = ref([]); |
const notifyList: any = ref([]); |
||||
const readList: any = ref([]) |
const readList: any = ref([]) |
||||
const showNews = ref(false) |
const showNews = ref(false) |
||||
const newsDetail = ref({}) |
const newsDetail = ref({}) |
||||
const page = ref({ |
const page = ref({ |
||||
current: 1, |
current: 1, |
||||
size: 10, |
size: 10, |
||||
total: 0, |
total: 0, |
||||
pages: 0, |
pages: 0, |
||||
}) |
}) |
||||
async function getList() { |
async function getList() { |
||||
if (config.userType == 'person') { |
if (config.userType == 'person') { |
||||
return |
return |
||||
} |
|
||||
const complition = await fetchGet(config.userInfo.url + '/news/list?page=' + page.value.current + '&limit=' + page.value.size) |
|
||||
if (!complition.ok) { |
|
||||
return; |
|
||||
} |
|
||||
const data = await complition.json(); |
|
||||
if (data.success) { |
|
||||
page.value.total = data.data.total; |
|
||||
notifyList.value = data.data.list; |
|
||||
page.value.pages = Math.ceil(page.value.total / page.value.size) |
|
||||
checkNotify() |
|
||||
} |
|
||||
|
|
||||
} |
} |
||||
const checkNotify = ()=> { |
const complition = await fetchGet(config.userInfo.url + '/news/list?page=' + page.value.current + '&limit=' + page.value.size) |
||||
const list = notifyList.value.filter((item: any) => { |
if (!complition.ok) { |
||||
return readList.value.indexOf(item.id) < 0 |
return; |
||||
}) |
|
||||
if(list.length < 1)return; |
|
||||
const centerList = list.filter((item: any) => { |
|
||||
return item.position == 'center' |
|
||||
}) |
|
||||
const bottomList = list.filter((item: any) => { |
|
||||
return item.position == 'bottom' |
|
||||
}) |
|
||||
if(centerList.length > 0){ |
|
||||
upgradeStore.hasAd = true |
|
||||
upgradeStore.adList = [...centerList, ...upgradeStore.adList] |
|
||||
} |
|
||||
if(bottomList.length > 0){ |
|
||||
upgradeStore.hasNotice = true |
|
||||
upgradeStore.noticeList = [...bottomList, ...upgradeStore.noticeList] |
|
||||
} |
|
||||
|
|
||||
} |
} |
||||
const addRead = (id: number) => { |
const data = await complition.json(); |
||||
if (readList.value.indexOf(id) < 0) { |
if (data.success) { |
||||
readList.value.push(id) |
page.value.total = data.data.total; |
||||
} |
notifyList.value = data.data.list; |
||||
|
page.value.pages = Math.ceil(page.value.total / page.value.size) |
||||
|
checkNotify() |
||||
} |
} |
||||
const pageClick = async (pageNum: any) => { |
|
||||
//console.log(pageNum)
|
} |
||||
page.value.current = pageNum |
const checkNotify = () => { |
||||
await getList() |
const list = notifyList.value.filter((item: any) => { |
||||
|
return readList.value.indexOf(item.id) < 0 |
||||
|
}) |
||||
|
if (list.length < 1) return; |
||||
|
const centerList = list.filter((item: any) => { |
||||
|
return item.position == 'center' |
||||
|
}) |
||||
|
const bottomList = list.filter((item: any) => { |
||||
|
return item.position == 'bottom' |
||||
|
}) |
||||
|
if (centerList.length > 0) { |
||||
|
upgradeStore.hasAd = true |
||||
|
upgradeStore.adList = [...centerList, ...upgradeStore.adList] |
||||
} |
} |
||||
const viewContent = (item :any) =>{ |
if (bottomList.length > 0) { |
||||
const timestamp = item.add_time * 1000; // 将 10 位时间戳转换为 13 位
|
upgradeStore.hasNotice = true |
||||
const date = new Date(timestamp); |
upgradeStore.noticeList = [...bottomList, ...upgradeStore.noticeList] |
||||
item.showtime = date.toLocaleString(); |
|
||||
newsDetail.value = item |
|
||||
addRead(item.id) |
|
||||
showNews.value = true |
|
||||
} |
} |
||||
return { |
|
||||
notifyList, |
} |
||||
showNews, |
const addRead = (id: number) => { |
||||
newsDetail, |
if (readList.value.indexOf(id) < 0) { |
||||
getList, |
readList.value.push(id) |
||||
addRead, |
|
||||
page, |
|
||||
pageClick, |
|
||||
readList, |
|
||||
viewContent |
|
||||
} |
} |
||||
|
} |
||||
|
const pageClick = async (pageNum: any) => { |
||||
|
//console.log(pageNum)
|
||||
|
page.value.current = pageNum |
||||
|
await getList() |
||||
|
} |
||||
|
const viewContent = (item: any) => { |
||||
|
const timestamp = item.add_time * 1000; // 将 10 位时间戳转换为 13 位
|
||||
|
const date = new Date(timestamp); |
||||
|
item.showtime = date.toLocaleString(); |
||||
|
newsDetail.value = item |
||||
|
addRead(item.id) |
||||
|
showNews.value = true |
||||
|
} |
||||
|
return { |
||||
|
notifyList, |
||||
|
showNews, |
||||
|
newsDetail, |
||||
|
getList, |
||||
|
addRead, |
||||
|
page, |
||||
|
pageClick, |
||||
|
readList, |
||||
|
viewContent |
||||
|
} |
||||
}, { |
}, { |
||||
persist: { |
persist: { |
||||
enabled: true, |
enabled: true, |
||||
strategies: [ |
strategies: [ |
||||
{ |
{ |
||||
storage: localStorage, |
storage: localStorage, |
||||
paths: [ |
paths: [ |
||||
"readList", |
"readList", |
||||
] |
] |
||||
}, // name 字段用localstorage存储
|
}, // name 字段用localstorage存储
|
||||
], |
], |
||||
} |
} |
||||
}) |
}) |
Loading…
Reference in new issue