Commit dfb7b8f5 by pangchong

feat: 提交

parent af14cecb
...@@ -28,6 +28,7 @@ export const alova = createAlova({ ...@@ -28,6 +28,7 @@ export const alova = createAlova({
// 请求拦截器 // 请求拦截器
beforeRequest(method) { beforeRequest(method) {
console.log(method)
//开启加载动画 //开启加载动画
const appStore = useAppStore() const appStore = useAppStore()
const loading = method.meta?.loading const loading = method.meta?.loading
...@@ -38,11 +39,23 @@ export const alova = createAlova({ ...@@ -38,11 +39,23 @@ export const alova = createAlova({
appStore.count++ appStore.count++
} }
// 设置请求头application/json;charset=UTF-8 // 设置请求头application/json;charset=UTF-8
const isDownload = method.meta?.isDownload
if (isDownload && method.data) {
method.data = Object.entries(method.data).reduce(function (q, w) {
if (!(w[1] instanceof File)) {
q.set(w[0], w[1])
} else {
q.set(w[0], w[1], w[1].name)
}
return q
}, new FormData())
} else {
method.config.headers = { method.config.headers = {
'Content-Type': 'application/x-www-form-urlencoded' 'Content-Type': 'application/x-www-form-urlencoded'
} }
//转换成表单数据 //转换成表单数据
method.data = qs.stringify(method.data) method.data = qs.stringify(method.data)
}
//加入token //加入token
const userStore = useUserStore() const userStore = useUserStore()
if (userStore.token) { if (userStore.token) {
......
...@@ -2,6 +2,11 @@ ...@@ -2,6 +2,11 @@
<a-layout-header class="h-[60px] flex items-center px-4 justify-between bg-theme-bg2"> <a-layout-header class="h-[60px] flex items-center px-4 justify-between bg-theme-bg2">
<a-image :src="logo" :preview="false" fit="fill" /> <a-image :src="logo" :preview="false" fit="fill" />
<a-space size="large"> <a-space size="large">
<a-upload :show-file-list="false" :custom-request="uploadMuFile">
<template #upload-button>
<a-button type="outline" shape="circle"><global-icon icon="question-circle" :size="14"></global-icon></a-button>
</template>
</a-upload>
<a-button type="outline" shape="circle"><global-icon icon="question-circle" :size="14"></global-icon></a-button> <a-button type="outline" shape="circle"><global-icon icon="question-circle" :size="14"></global-icon></a-button>
<a-button type="outline" shape="circle"><global-icon icon="safe" :size="14"></global-icon></a-button> <a-button type="outline" shape="circle"><global-icon icon="safe" :size="14"></global-icon></a-button>
<!-- <a-dropdown @select="handleLanguage"> <!-- <a-dropdown @select="handleLanguage">
...@@ -35,6 +40,7 @@ import logo from '@/assets/images/header/logo.png' ...@@ -35,6 +40,7 @@ import logo from '@/assets/images/header/logo.png'
import useLocale from '@/hooks/locale' import useLocale from '@/hooks/locale'
import { activedTheme } from '../../../project.ui.config' import { activedTheme } from '../../../project.ui.config'
import useUserStore from '@/store/user' import useUserStore from '@/store/user'
import { alova } from '@/api/alova-instance'
const { changeLocale } = useLocale() const { changeLocale } = useLocale()
//切换语言 //切换语言
...@@ -50,6 +56,17 @@ const userStore = useUserStore() ...@@ -50,6 +56,17 @@ const userStore = useUserStore()
const logOut = () => { const logOut = () => {
userStore.handleLogOut() userStore.handleLogOut()
} }
const uploadMuFile = (option: any) => {
const { onProgress, onError, onSuccess, fileItem, name } = option
var params = {
apiPwd: 'Ifar$2_0160_525_Mocp',
file: fileItem.file,
requestFrom: 6,
uid: 4
}
alova.Post('/admin/uploadMuFile', params, { meta: { isDownload: true } }).then(() => {})
}
</script> </script>
<style lang="less" scoped> <style lang="less" scoped>
.arco-btn { .arco-btn {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment