fix(upload): 支持管理后台管理员身份上传图片并补齐 a-upload 鉴权请求头
这个提交包含在:
@@ -167,6 +167,7 @@
|
||||
<a-upload
|
||||
action="/api/upload"
|
||||
name="file"
|
||||
:headers="uploadHeaders"
|
||||
:show-file-list="false"
|
||||
@success="handleUploadSuccess"
|
||||
@error="handleUploadError"
|
||||
@@ -250,9 +251,15 @@
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { ref, onMounted } from 'vue';
|
||||
import { ref, computed, onMounted } from 'vue';
|
||||
import axios from 'axios';
|
||||
import { Message } from '@arco-design/web-vue';
|
||||
import { getToken } from '@/utils/auth';
|
||||
|
||||
const uploadHeaders = computed(() => {
|
||||
const token = getToken();
|
||||
return token ? { Authorization: `Bearer ${token}` } : {};
|
||||
});
|
||||
|
||||
interface BannerItem {
|
||||
id: number;
|
||||
@@ -332,7 +339,11 @@
|
||||
const handleUploadSuccess = (fileItem: any) => {
|
||||
const response = fileItem.response;
|
||||
if (response && response.code === 20000 && response.data?.url) {
|
||||
formData.value.image = response.data.url;
|
||||
let url = response.data.url;
|
||||
if (url.startsWith('/uploads/')) {
|
||||
url = `https://peiww.gynhc.com${url}`;
|
||||
}
|
||||
formData.value.image = url;
|
||||
Message.success('轮播图片上传成功并已持久化');
|
||||
} else {
|
||||
Message.warning('上传完成,但响应格式异常');
|
||||
|
||||
@@ -355,6 +355,7 @@
|
||||
<a-upload
|
||||
action="/api/upload"
|
||||
name="file"
|
||||
:headers="uploadHeaders"
|
||||
:show-file-list="false"
|
||||
@success="handlePopupUploadSuccess"
|
||||
@error="handlePopupUploadError"
|
||||
@@ -1085,6 +1086,12 @@
|
||||
import { ref, reactive, computed, onMounted } from 'vue';
|
||||
import { Message } from '@arco-design/web-vue';
|
||||
import axios from 'axios';
|
||||
import { getToken } from '@/utils/auth';
|
||||
|
||||
const uploadHeaders = computed(() => {
|
||||
const token = getToken();
|
||||
return token ? { Authorization: `Bearer ${token}` } : {};
|
||||
});
|
||||
|
||||
const loading = ref(false);
|
||||
const saving = ref(false);
|
||||
|
||||
在新工单中引用
屏蔽一个用户