Skip to content

Commit

Permalink
Merge pull request #47 from besscroft/dev
Browse files Browse the repository at this point in the history
v0.4.3
  • Loading branch information
besscroft authored Apr 10, 2024
2 parents 1bf9f2c + 876a3d1 commit 07aa513
Show file tree
Hide file tree
Showing 27 changed files with 1,303 additions and 1,768 deletions.
20 changes: 12 additions & 8 deletions middleware/auth.global.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,19 @@ export default defineNuxtRouteMiddleware(async (to, from) => {
if (loginPageWhiteList.includes(to.path) && !user.token) {
return navigateTo('/login')
}
try {
const { data } = await $fetch('/api/verify', {
method: 'get',
headers: {
Authorization: `${user.tokenName} ${user.token}`,
},
})
} catch (e) {

const res = await $fetch('/api/verify', {
method: 'get',
headers: {
Authorization: `${user.tokenName} ${user.token}`,
},
})
if (res?.code === 401) {
return navigateTo('/login')
}
if (res?.code === 200) {
return
}
return
}
})
24 changes: 13 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,32 +13,34 @@
"typecheck": "vue-tsc --noEmit"
},
"devDependencies": {
"@antfu/eslint-config": "^2.11.0",
"@antfu/eslint-config": "^2.13.2",
"@element-plus/nuxt": "^1.0.8",
"@iconify-json/carbon": "^1.1.31",
"@nuxt/eslint": "^0.3.0-beta.2",
"@nuxt/eslint": "^0.3.4",
"@nuxtjs/color-mode": "^3.3.3",
"@nuxtjs/device": "^3.1.1",
"@pinia-plugin-persistedstate/nuxt": "^1.2.0",
"@pinia/nuxt": "^0.5.1",
"@unocss/eslint-config": "^0.58.7",
"@unocss/nuxt": "^0.58.7",
"@types/crypto-js": "^4.2.2",
"@types/jsonwebtoken": "^9.0.6",
"@unocss/eslint-config": "^0.59.0",
"@unocss/nuxt": "^0.59.0",
"@vueuse/nuxt": "^10.9.0",
"consola": "^3.2.3",
"element-plus": "^2.6.2",
"element-plus": "^2.6.3",
"eslint": "^8.57.0",
"eslint-plugin-format": "^0.1.0",
"nuxt": "^3.11.1",
"nuxt": "^3.11.2",
"pinia": "^2.1.7",
"typescript": "^5.4.3",
"vue-tsc": "^2.0.7"
"typescript": "^5.4.4",
"vue-tsc": "^2.0.11"
},
"dependencies": {
"@formkit/auto-animate": "^0.8.1",
"@nuxt/ui": "^2.15.0",
"aws-sdk": "^2.1586.0",
"@nuxt/ui": "^2.15.1",
"aws-sdk": "^2.1596.0",
"crypto-js": "^4.2.0",
"exifreader": "^4.21.1",
"exifreader": "^4.22.1",
"jsonwebtoken": "^9.0.2",
"postgres": "^3.4.4",
"vue-waterfall-plugin-next": "^2.4.3"
Expand Down
26 changes: 14 additions & 12 deletions pages/[...slug].vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,25 +17,27 @@ const pageInfo = reactive({
const dataHandle = async () => {
loading.value = true
try {
const { total, totalPage, pageNum, pageSize, data } = await $fetch('/api/getImageList', {
const res = await $fetch('/api/getImageList', {
method: 'post',
headers: {
Authorization: `${user.tokenName} ${user.token}`,
},
body: { pageNum: pageInfo.pageNum, pageSize: pageInfo.pageSize, type: route.path.replace('/', '') },
})
if (pageInfo.pageNum <= totalPage) {
if (pageInfo.pageNum === totalPage) {
handleButton.value = false
if (res?.code === 200) {
if (pageInfo.pageNum <= res?.data.totalPage) {
if (pageInfo.pageNum === res?.data.totalPage) {
handleButton.value = false
}
pageInfo.pageNum++
if (dataList.value.length === 0) {
dataList.value = res?.data.data
} else {
dataList.value = dataList.value.concat(res?.data.data)
}
pageInfo.total = res?.data.total
pageInfo.totalPage = res?.data.totalPage
}
pageInfo.pageNum++
if (dataList.value.length === 0) {
dataList.value = data
} else {
dataList.value = dataList.value.concat(data)
}
pageInfo.total = total
pageInfo.totalPage = totalPage
}
} catch (e) {
toast.add({ title: '加载失败!', timeout: 2000, color: 'red' })
Expand Down
7 changes: 5 additions & 2 deletions pages/admin/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,17 @@ const dataInfo = ref({})
const dataHandle = async () => {
loading.value = true
try {
const { data } = await $fetch('/api/console', {
const res = await $fetch('/api/console', {
timeout: 60000,
method: 'get',
headers: {
Authorization: `${user.tokenName} ${user.token}`,
},
})
dataInfo.value = data
if (res?.code !== 200) {
toast.add({ title: '请求失败!', timeout: 2000, color: 'red' })
}
dataInfo.value = res?.data
} catch (e) {
console.log(e)
toast.add({ title: '数据获取失败!', timeout: 2000, color: 'red' })
Expand Down
22 changes: 12 additions & 10 deletions pages/admin/list.vue
Original file line number Diff line number Diff line change
Expand Up @@ -74,17 +74,19 @@ const uClick = async () => {
const dataHandle = async () => {
loading.value = true
try {
const { total, totalPage, pageNum, pageSize, data } = await $fetch('/api/getFileList', {
const res = await $fetch('/api/getFileList', {
timeout: 60000,
method: 'post',
headers: {
Authorization: `${user.tokenName} ${user.token}`,
},
body: { pageNum: pageInfo.pageNum, pageSize: pageInfo.pageSize, type: type.value },
})
dataList.value = data
pageInfo.total = total
pageInfo.totalPage = totalPage
if (res?.code === 200) {
dataList.value = res?.data.data
pageInfo.total = res?.data.total
pageInfo.totalPage = res?.data.totalPage
}
} catch (e) {
console.log(e)
toast.add({ title: '加载失败!', timeout: 2000, color: 'red' })
Expand All @@ -95,15 +97,15 @@ const dataHandle = async () => {
const updateHandle = async () => {
try {
const { data } = await $fetch('/api/updateImgInfo', {
const res = await $fetch('/api/updateImgInfo', {
timeout: 60000,
method: 'put',
headers: {
Authorization: `${user.tokenName} ${user.token}`,
},
body: { id: objInfo.id, type: objInfo.type, rating: objInfo.rating, detail: objInfo.detail, url: objInfo.url, sort: objInfo.sort },
})
if (data === 0) {
if (res?.code === 200) {
toast.add({ title: '更新成功!', timeout: 2000 })
await uClick()
await dataHandle()
Expand All @@ -118,15 +120,15 @@ const updateHandle = async () => {
const deleteHandle = async (id: number) => {
try {
const { data } = await $fetch('/api/deleteImg', {
const res = await $fetch('/api/deleteImg', {
timeout: 60000,
method: 'delete',
headers: {
Authorization: `${user.tokenName} ${user.token}`,
},
body: { id: id },
})
if (data === 0) {
if (res?.code === 200) {
toast.add({ title: '删除成功!', timeout: 2000 })
await dataHandle()
} else {
Expand All @@ -141,15 +143,15 @@ const deleteHandle = async (id: number) => {
const updateShowHandle = async (val: number, id: number) => {
showBtnLoading.value = true
try {
const { data } = await $fetch('/api/updateShow', {
const res = await $fetch('/api/updateShow', {
timeout: 60000,
method: 'put',
headers: {
Authorization: `${user.tokenName} ${user.token}`,
},
body: { id: id, show: val },
})
if (data === 0) {
if (res?.code === 200) {
toast.add({ title: '更新成功!', timeout: 2000 })
showBtnLoading.value = false
await dataHandle()
Expand Down
20 changes: 11 additions & 9 deletions pages/admin/system.vue
Original file line number Diff line number Diff line change
Expand Up @@ -58,17 +58,17 @@ const userState = reactive({
const onSubmitUser = async (event: FormSubmitEvent<any>) => {
userLoading.value = true
try {
const { data } = await $fetch('/api/updatePwd', {
const res = await $fetch('/api/updatePwd', {
method: 'post',
headers: {
Authorization: `${user.tokenName} ${user.token}`,
},
body: userState,
})
if (data === 0) {
if (res?.code === 200) {
toast.add({ title: '更新成功!', timeout: 2000 })
} else {
toast.add({ title: '更新失败!', timeout: 2000, color: 'red' })
toast.add({ title: res?.message, timeout: 2000, color: 'red' })
}
} catch (e) {
toast.add({ title: '更新失败!', timeout: 2000, color: 'red' })
Expand All @@ -80,13 +80,15 @@ const onSubmitUser = async (event: FormSubmitEvent<any>) => {
const getStorageInfo = async () => {
storageLoading.value = true
try {
const { data } = await $fetch('/api/getStorageInfo', {
const res = await $fetch('/api/getStorageInfo', {
method: 'get',
headers: {
Authorization: `${user.tokenName} ${user.token}`,
},
})
storageInfo.value = data
if (res?.code === 200) {
storageInfo.value = res?.data
}
} catch (e) {
console.log(e)
} finally {
Expand Down Expand Up @@ -127,14 +129,14 @@ const xClick = async () => {
const updateS3 = async () => {
try {
const { data } = await $fetch('/api/updateS3Info', {
const res= await $fetch('/api/updateS3Info', {
method: 'put',
headers: {
Authorization: `${user.tokenName} ${user.token}`,
},
body: s3State,
})
if (data === 0) {
if (res?.code === 200) {
toast.add({ title: '更新成功!', timeout: 2000 })
await xClick()
await getStorageInfo()
Expand All @@ -149,14 +151,14 @@ const updateS3 = async () => {
const updateAlist = async () => {
try {
const { data } = await $fetch('/api/updateAListInfo', {
const res = await $fetch('/api/updateAListInfo', {
method: 'put',
headers: {
Authorization: `${user.tokenName} ${user.token}`,
},
body: alistState,
})
if (data === 0) {
if (res?.code === 200) {
toast.add({ title: '更新成功!', timeout: 2000 })
await xClick()
await getStorageInfo()
Expand Down
23 changes: 12 additions & 11 deletions pages/admin/upload.vue
Original file line number Diff line number Diff line change
Expand Up @@ -63,16 +63,17 @@ async function onRequestUpload(option: any) {
formData.append('storage', storage.value || '')
formData.append('type', imgData.type || '')
formData.append('mountPath', imgData.mountPath || '')
const { data, url } = await $fetch('/api/uploadFile', {
const res: any = await $fetch('/api/uploadFile', {
timeout: 60000,
method: 'post',
headers: {
Authorization: `${user.tokenName} ${user.token}`,
},
body: formData,
})
if (data === 0) {
fileUrl.value = url
if (res?.code === 200) {
fileUrl.value = res.data?.url
imgData.url = res.data?.url
const tags = await ExifReader.load(file)
exif.make = tags?.Make?.description
exif.model = tags?.Model?.description
Expand All @@ -90,15 +91,15 @@ async function onRequestUpload(option: any) {
exif.color_space = tags?.ColorSpace?.description
exif.white_balance = tags?.WhiteBalance?.description
imgData.exif = exif
imgData.url = url
}
} catch (e) {
console.log(e)
if (e?.status === 413) {
toast.add({ title: '上传文件大小超出限制!', timeout: 2000, color: 'red' })
option.file.abort()
} else {
toast.add({ title: '图片上传/解析失败!', timeout: 2000, color: 'red' })
toast.add({ title: e?.message, timeout: 2000, color: 'red' })
}
option.file.abort()
}
}
Expand All @@ -121,15 +122,15 @@ async function submit() {
return
}
try {
const { data } = await $fetch('/api/addImg', {
const res = await $fetch('/api/addImg', {
timeout: 60000,
method: 'post',
headers: {
Authorization: `${user.tokenName} ${user.token}`,
},
body: imgData,
})
if (data === 0) {
if (res?.code === 200) {
toast.add({ title: '保存成功!', timeout: 2000 })
} else {
toast.add({ title: '保存失败!', timeout: 2000, color: 'red' })
Expand Down Expand Up @@ -194,16 +195,16 @@ watch(storage, async (val) => {
if (mountOptions.value.length === 0) {
try {
toast.add({ title: '正在获取 AList 挂载目录!', timeout: 2000 })
const { data } = await $fetch('/api/getStorageList', {
const res = await $fetch('/api/getStorageList', {
timeout: 60000,
method: 'get',
headers: {
Authorization: `${user.tokenName} ${user.token}`,
},
})
if (data) {
if (res?.code === 200) {
// 遍历数组,给 mountOptions 赋值
data.forEach((item: any) => {
res?.data.forEach((item: any) => {
if (item.status === 'work') {
mountOptions.value.push({
label: item.mount_path,
Expand Down
Loading

1 comment on commit 07aa513

@vercel
Copy link

@vercel vercel bot commented on 07aa513 Apr 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.