mirror of
https://github.com/fumiama/paper-manager.git
synced 2026-06-23 03:50:33 +08:00
finish 解析
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { reactive } from 'vue'
|
||||
import { getFileList, getFilePercent } from '/@/api/page'
|
||||
import { getFileList, getFilePercent, getFileInfo } from '/@/api/page'
|
||||
import { getFileListModel } from '/@/api/page/model/fileListModel'
|
||||
|
||||
export const random = (min: number, max: number) =>
|
||||
@@ -8,9 +8,9 @@ export const random = (min: number, max: number) =>
|
||||
export function refreshFilePercent(item: any) {
|
||||
return async () => {
|
||||
const p = await getFilePercent(item.id)
|
||||
if (p.percent) {
|
||||
item.percent = p.percent
|
||||
if (p.percent < 100) {
|
||||
if (p) {
|
||||
item.percent = p
|
||||
if (p < 100) {
|
||||
setTimeout(refreshFilePercent(item), 1000)
|
||||
}
|
||||
} else item.hassettimeout = false
|
||||
@@ -62,9 +62,9 @@ async function refreshFileList() {
|
||||
}
|
||||
}
|
||||
|
||||
export let cardList = reactive(await refreshFileList())
|
||||
export const cardList = reactive(await refreshFileList())
|
||||
|
||||
export let pagination = reactive({
|
||||
export const pagination = reactive({
|
||||
current: 1,
|
||||
total: cardList._cardList.length,
|
||||
show: true,
|
||||
@@ -77,17 +77,11 @@ export let pagination = reactive({
|
||||
|
||||
export function refreshCardList() {
|
||||
refreshFileList().then((value) => {
|
||||
cardList = reactive(value)
|
||||
pagination = reactive({
|
||||
current: 1,
|
||||
total: cardList._cardList.length,
|
||||
show: true,
|
||||
pageSize: 10,
|
||||
onChange: function (page: number, pageSize: number) {
|
||||
this.current = page
|
||||
this.pageSize = pageSize
|
||||
},
|
||||
})
|
||||
cardList._cardList = value._cardList
|
||||
cardList._totalQuestions = value._totalQuestions
|
||||
cardList._totalSize = value._totalSize
|
||||
pagination.current = 1
|
||||
pagination.total = cardList._cardList.length
|
||||
})
|
||||
}
|
||||
|
||||
@@ -101,3 +95,21 @@ export function deleteFileByID(id: number) {
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
export function refreshFileByID(id: number) {
|
||||
getFileInfo(id).then((info) => {
|
||||
cardList._cardList.map((value: any) => {
|
||||
if (value.id == id) {
|
||||
cardList._totalSize = cardList._totalSize - value.size + info.size
|
||||
cardList._totalQuestions = cardList._totalQuestions - value.questions + info.questions
|
||||
value.title = info.title
|
||||
value.description = info.description
|
||||
value.size = info.size
|
||||
value.questions = info.questions
|
||||
value.datetime = info.datetime
|
||||
value.author = info.author
|
||||
value.percent = info.percent
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
@@ -110,6 +110,7 @@
|
||||
refreshFilePercent,
|
||||
random,
|
||||
refreshCardList,
|
||||
refreshFileByID,
|
||||
} from './data'
|
||||
import { PageWrapper } from '/@/components/Page'
|
||||
import { useMessage } from '/@/hooks/web/useMessage'
|
||||
@@ -120,7 +121,6 @@
|
||||
import { useI18n } from '/@/hooks/web/useI18n'
|
||||
import { delFile, analyzeFile } from '/@/api/page'
|
||||
import { useGo } from '/@/hooks/web/usePage'
|
||||
import { useTabs } from '/@/hooks/web/useTabs'
|
||||
|
||||
const { t } = useI18n()
|
||||
const { createMessage } = useMessage()
|
||||
@@ -149,6 +149,11 @@
|
||||
const msg = await analyzeFile(item.id, true)
|
||||
if (msg) {
|
||||
createMessage.success(msg.msg)
|
||||
if (msg.code == 0) {
|
||||
item.percent = 100
|
||||
refreshFileByID(item.id)
|
||||
return
|
||||
}
|
||||
if (!item.hassettimeout && item.percent == 0) {
|
||||
setTimeout(refreshFilePercent(item), 1000 + random(0, 1000))
|
||||
item.hassettimeout = true
|
||||
@@ -173,7 +178,6 @@
|
||||
},
|
||||
setup() {
|
||||
const { hasPermission } = usePermission()
|
||||
const { refreshPage } = useTabs()
|
||||
const go = useGo()
|
||||
|
||||
function openFile(id: number) {
|
||||
@@ -182,7 +186,6 @@
|
||||
|
||||
async function onChange(_: number[]) {
|
||||
refreshCardList()
|
||||
refreshPage()
|
||||
}
|
||||
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user