fix(type): 修复类型检查错误

This commit is contained in:
PKC278
2025-12-30 01:47:45 +08:00
parent b98512789f
commit c5d1c5a468
7 changed files with 16 additions and 14 deletions

1
shims.d.ts vendored
View File

@@ -12,3 +12,4 @@ declare module 'vue-prism-component' {
export default component export default component
} }
declare module 'vue-shepherd'; declare module 'vue-shepherd';
declare module 'colorthief';

View File

@@ -1,4 +1,4 @@
import type { ValidationRule } from 'vuetify/types/services/validation' type ValidationRule = (value: any) => string | boolean
// 必输校验 // 必输校验
export const requiredValidator: ValidationRule = (value: any) => { export const requiredValidator: ValidationRule = (value: any) => {

View File

@@ -4,6 +4,7 @@ import FileToolbar from './filebrowser/FileToolbar.vue'
import FileNavigator from './filebrowser/FileNavigator.vue' import FileNavigator from './filebrowser/FileNavigator.vue'
import type { EndPoints, FileItem, StorageConf } from '@/api/types' import type { EndPoints, FileItem, StorageConf } from '@/api/types'
import { storageIconDict } from '@/api/constants' import { storageIconDict } from '@/api/constants'
import type { AxiosInstance } from 'axios'
// LocalStorage keys // LocalStorage keys
const SORT_KEY = 'fileBrowser.sort' const SORT_KEY = 'fileBrowser.sort'
@@ -16,7 +17,7 @@ const props = defineProps({
tree: Boolean, tree: Boolean,
endpoints: Object as PropType<EndPoints>, endpoints: Object as PropType<EndPoints>,
axios: { axios: {
type: Function, type: Object as PropType<AxiosInstance>,
required: true, required: true,
}, },
axiosconfig: Object, axiosconfig: Object,

View File

@@ -1,5 +1,5 @@
<script lang="ts" setup> <script lang="ts" setup>
import type { AxiosRequestConfig } from 'axios' import type { AxiosRequestConfig, AxiosInstance } from 'axios'
import type { PropType } from 'vue' import type { PropType } from 'vue'
import { useConfirm } from '@/composables/useConfirm' import { useConfirm } from '@/composables/useConfirm'
import { useToast } from 'vue-toastification' import { useToast } from 'vue-toastification'
@@ -28,7 +28,7 @@ const inProps = defineProps({
icons: Object, icons: Object,
endpoints: Object as PropType<EndPoints>, endpoints: Object as PropType<EndPoints>,
axios: { axios: {
type: Function, type: Object as PropType<AxiosInstance>,
required: true, required: true,
}, },
refreshpending: Boolean, refreshpending: Boolean,
@@ -196,7 +196,7 @@ async function list_files() {
} }
// 加载数据 // 加载数据
const data = (await inProps.axios.request(config)) ?? [] const data = ((await inProps.axios.request(config)) as any) ?? []
// 如果当前路径已经变化,则放弃此次加载结果 // 如果当前路径已经变化,则放弃此次加载结果
if (prevURI !== takeURISnapshot()) { if (prevURI !== takeURISnapshot()) {
return; return;
@@ -300,7 +300,7 @@ async function download(item: FileItem) {
responseType: 'blob', responseType: 'blob',
} }
// 加载数据 // 加载数据
const result: Blob = await inProps.axios.request(config) const result: Blob = (await inProps.axios.request(config)) as any
if (result) { if (result) {
const downloadUrl = URL.createObjectURL(result) const downloadUrl = URL.createObjectURL(result)
window.open(downloadUrl, '_blank') window.open(downloadUrl, '_blank')
@@ -318,7 +318,7 @@ async function getImgLink(item: FileItem) {
responseType: 'blob', responseType: 'blob',
} }
// 加载二进制数据 // 加载二进制数据
const result: Blob = await inProps.axios.request(config) const result: Blob = (await inProps.axios.request(config)) as any
if (result) { if (result) {
// 创建图片地址 // 创建图片地址
currentImgLink.value = URL.createObjectURL(result) currentImgLink.value = URL.createObjectURL(result)
@@ -395,7 +395,7 @@ async function rename() {
method: inProps.endpoints?.rename.method || 'post', method: inProps.endpoints?.rename.method || 'post',
data: currentItem.value, data: currentItem.value,
} }
const result: { [key: string]: any } = await inProps.axios?.request(config) const result: { [key: string]: any } = (await inProps.axios?.request(config)) as any
if (!result.success) { if (!result.success) {
$toast.error(result.message) $toast.error(result.message)
} }

View File

@@ -2,7 +2,7 @@
import type { PropType } from 'vue' import type { PropType } from 'vue'
import type { FileItem } from '@/api/types' import type { FileItem } from '@/api/types'
import { useDisplay } from 'vuetify' import { useDisplay } from 'vuetify'
import type { AxiosRequestConfig } from 'axios' import type { AxiosRequestConfig, AxiosInstance } from 'axios'
import { useI18n } from 'vue-i18n' import { useI18n } from 'vue-i18n'
import { usePWA } from '@/composables/usePWA' import { usePWA } from '@/composables/usePWA'
@@ -54,7 +54,7 @@ const props = defineProps({
}, },
endpoints: Object, endpoints: Object,
axios: { axios: {
type: Function, type: Object as PropType<AxiosInstance>,
required: true, required: true,
}, },
}) })
@@ -131,7 +131,7 @@ async function loadSubdirectories(path: string) {
data: fakeItem, data: fakeItem,
} }
const result = await props.axios?.request(config) const result = (await props.axios?.request(config)) as any
if (result && Array.isArray(result)) { if (result && Array.isArray(result)) {
// 过滤出目录项 // 过滤出目录项
const dirs = result.filter(item => item.type === 'dir') const dirs = result.filter(item => item.type === 'dir')

View File

@@ -1,5 +1,5 @@
<script lang="ts" setup> <script lang="ts" setup>
import type { AxiosRequestConfig } from 'axios' import type { AxiosRequestConfig, AxiosInstance } from 'axios'
import type { EndPoints, FileItem } from '@/api/types' import type { EndPoints, FileItem } from '@/api/types'
import { useDisplay } from 'vuetify' import { useDisplay } from 'vuetify'
import { useI18n } from 'vue-i18n' import { useI18n } from 'vue-i18n'
@@ -23,7 +23,7 @@ const inProps = defineProps({
}, },
endpoints: Object as PropType<EndPoints>, endpoints: Object as PropType<EndPoints>,
axios: { axios: {
type: Function, type: Object as PropType<AxiosInstance>,
required: true, required: true,
}, },
sort: { sort: {

View File

@@ -1,5 +1,5 @@
import { Icon } from '@iconify/vue' import { Icon } from '@iconify/vue'
import { aliases } from 'vuetify/lib/iconsets/mdi' import { aliases } from 'vuetify/iconsets/mdi'
const alertTypeIcon = { const alertTypeIcon = {
success: 'mdi-check-circle-outline', success: 'mdi-check-circle-outline',