feat: 新增 upload hook

This commit is contained in:
JaguarJack 2024-04-23 13:12:36 +08:00
parent bc59731083
commit 51be5c648b
5 changed files with 42 additions and 4 deletions

View File

@ -1,7 +1,7 @@
import { ref } from 'vue' import { ref } from 'vue'
import { getFileExt, getFilename } from '@/form/support/helper' import { getFileExt, getFilename } from '/admin/support/helper'
import { Code } from '@/form/enum/app' import { Code } from '/admin/enum/app'
import Message from '@/form/support/message' import Message from '/admin/support/message'
import { genFileId } from 'element-plus' import { genFileId } from 'element-plus'
import type { UploadInstance, UploadProps, UploadRawFile } from 'element-plus' import type { UploadInstance, UploadProps, UploadRawFile } from 'element-plus'

View File

@ -14,6 +14,8 @@ const en = {
finish: 'Finish', finish: 'Finish',
back: 'Back', back: 'Back',
update: 'Update', update: 'Update',
search: 'Search',
reset: 'Reset'
}, },
login: { login: {

View File

@ -15,6 +15,8 @@ const zh = {
finish: '完成', finish: '完成',
back: '返回', back: '返回',
update: '更新', update: '更新',
search: '搜索',
reset: '重置'
}, },
login: { login: {

View File

@ -12,6 +12,8 @@ import { bootstrapI18n } from '/admin/i18n'
import guard from '/admin/router/guard' import guard from '/admin/router/guard'
import { bootstrapDirectives } from '/admin/directives' import { bootstrapDirectives } from '/admin/directives'
import { Language } from 'element-plus/es/locale' import { Language } from 'element-plus/es/locale'
import { bootstrapCatchForm } from '/admin/components/catchForm'
import http from '/admin/support/http'
/** /**
* catchadmin * catchadmin
@ -35,7 +37,7 @@ export default class CatchAdmin {
* admin boot * admin boot
*/ */
bootstrap(): void { bootstrap(): void {
this.useElementPlus().usePinia().useI18n().installDirectives().useRouter().mount() this.useElementPlus().usePinia().useI18n().installDirectives().bootstrapCatchForm().useRouter().mount()
} }
/** /**
@ -103,6 +105,12 @@ export default class CatchAdmin {
protected installDirectives(): CatchAdmin { protected installDirectives(): CatchAdmin {
bootstrapDirectives(this.app) bootstrapDirectives(this.app)
return this
}
protected bootstrapCatchForm(): CatchAdmin {
bootstrapCatchForm(this.app, {http: http})
return this return this
} }
} }

View File

@ -100,3 +100,29 @@ export function _window(key: string) {
export function getBaseUrl() { export function getBaseUrl() {
return _window('BASE_URL') ? _window('BASE_URL') : env('VITE_BASE_URL') return _window('BASE_URL') ? _window('BASE_URL') : env('VITE_BASE_URL')
} }
/**
* is boolean
* @param value
* @returns
*/
export function isBoolean(value: any): boolean {
return typeof value === 'boolean'
}
/**
*
* @param value
* @returns
*/
export function isNumber(value: any): boolean {
return typeof value === 'number'
}
export const getFileExt = (filename: string): string => {
return filename.substring(filename.lastIndexOf('.')).toLowerCase()
}
// 获取文件名
export const getFilename = (filename: string): string => {
return filename.substring(filename.lastIndexOf('/') + 1)
}