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 { ref } from "vue"; |
|||
import { getSystemConfig, fetchGet } from "@/system/config"; |
|||
import { useUpgradeStore } from "./upgrade"; |
|||
export const useNotifyStore = defineStore('notifyStore', () => { |
|||
const config = getSystemConfig(); |
|||
const upgradeStore = useUpgradeStore() |
|||
const notifyList: any = ref([]); |
|||
const readList: any = ref([]) |
|||
const showNews = ref(false) |
|||
const newsDetail = ref({}) |
|||
const page = ref({ |
|||
current: 1, |
|||
size: 10, |
|||
total: 0, |
|||
pages: 0, |
|||
}) |
|||
async function getList() { |
|||
if (config.userType == 'person') { |
|||
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 config = getSystemConfig(); |
|||
const upgradeStore = useUpgradeStore() |
|||
const notifyList: any = ref([]); |
|||
const readList: any = ref([]) |
|||
const showNews = ref(false) |
|||
const newsDetail = ref({}) |
|||
const page = ref({ |
|||
current: 1, |
|||
size: 10, |
|||
total: 0, |
|||
pages: 0, |
|||
}) |
|||
async function getList() { |
|||
if (config.userType == 'person') { |
|||
return |
|||
} |
|||
const checkNotify = ()=> { |
|||
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] |
|||
} |
|||
if(bottomList.length > 0){ |
|||
upgradeStore.hasNotice = true |
|||
upgradeStore.noticeList = [...bottomList, ...upgradeStore.noticeList] |
|||
} |
|||
|
|||
const complition = await fetchGet(config.userInfo.url + '/news/list?page=' + page.value.current + '&limit=' + page.value.size) |
|||
if (!complition.ok) { |
|||
return; |
|||
} |
|||
const addRead = (id: number) => { |
|||
if (readList.value.indexOf(id) < 0) { |
|||
readList.value.push(id) |
|||
} |
|||
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 pageClick = async (pageNum: any) => { |
|||
//console.log(pageNum)
|
|||
page.value.current = pageNum |
|||
await getList() |
|||
|
|||
} |
|||
const checkNotify = () => { |
|||
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) =>{ |
|||
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 |
|||
if (bottomList.length > 0) { |
|||
upgradeStore.hasNotice = true |
|||
upgradeStore.noticeList = [...bottomList, ...upgradeStore.noticeList] |
|||
} |
|||
return { |
|||
notifyList, |
|||
showNews, |
|||
newsDetail, |
|||
getList, |
|||
addRead, |
|||
page, |
|||
pageClick, |
|||
readList, |
|||
viewContent |
|||
|
|||
} |
|||
const addRead = (id: number) => { |
|||
if (readList.value.indexOf(id) < 0) { |
|||
readList.value.push(id) |
|||
} |
|||
} |
|||
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: { |
|||
enabled: true, |
|||
strategies: [ |
|||
{ |
|||
storage: localStorage, |
|||
paths: [ |
|||
"readList", |
|||
] |
|||
}, // name 字段用localstorage存储
|
|||
], |
|||
} |
|||
persist: { |
|||
enabled: true, |
|||
strategies: [ |
|||
{ |
|||
storage: localStorage, |
|||
paths: [ |
|||
"readList", |
|||
] |
|||
}, // name 字段用localstorage存储
|
|||
], |
|||
} |
|||
}) |
Loading…
Reference in new issue