From 0e01c8de18bb9bb5a27b13df227ec7576e0a1fc3 Mon Sep 17 00:00:00 2001 From: lixg Date: Sat, 17 Dec 2022 15:26:48 +0800 Subject: [PATCH 1/2] =?UTF-8?q?feat:=E5=90=88=E5=B9=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/api.js | 2 +- src/api/request.js | 20 ++++----- src/components/img/UploadImg.vue | 74 +++++++++++++++++++------------- 3 files changed, 54 insertions(+), 42 deletions(-) diff --git a/src/api/api.js b/src/api/api.js index 657b967..167f637 100644 --- a/src/api/api.js +++ b/src/api/api.js @@ -2,7 +2,7 @@ * @Author: lixg lixg@dongwu-inc.com * @Date: 2022-12-11 16:57:58 * @LastEditors: lixg lixg@dongwu-inc.com - * @LastEditTime: 2022-12-15 10:56:54 + * @LastEditTime: 2022-12-17 14:59:41 * @FilePath: /fe-stu/src/api/api.js * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE */ diff --git a/src/api/request.js b/src/api/request.js index 97970b1..6c1d984 100644 --- a/src/api/request.js +++ b/src/api/request.js @@ -1,7 +1,7 @@ import router from "@/router"; -import {reactive, ref, toRefs, watch} from "vue"; +import { reactive, ref, toRefs, watch } from "vue"; import axios from 'axios'; -import {getCookie} from "@/api/utils"; +import { getCookie } from "@/api/utils"; export function usePage(_url, param) { @@ -11,11 +11,11 @@ export function usePage(_url, param) { total: 0, size: 10, current: 1, - params: {pageNo: 1, pageSize: 10, ...param} + params: { pageNo: 1, pageSize: 10, ...param } }) watch(param, () => { - state.params = {...state.params, ...param} + state.params = { ...state.params, ...param } fetchData() }) @@ -86,14 +86,14 @@ export async function request(_url, params) { method, headers: { 'token': getCookie('token'), - ...method !== 'get' ? {'Content-Type': 'application/json'} : {} + ...method !== 'get' ? { 'Content-Type': 'application/json' } : {} }, baseURL: import.meta.env.VITE_BASE_API, - ...method !== 'get' ? {data: JSON.stringify(body)} : {} + ...method !== 'get' ? { data: JSON.stringify(body) } : {} }).then(resp => resp.data).then(response => { if (response.code !== 200 && response.code !== 0) { if (response.code === 1000) { - import.meta.env.MODE === 'development' ? router.push({path: '/login'}) : window.open(import.meta.env.VITE_BASE_LOGIN_URL) + import.meta.env.MODE === 'development' ? router.push({ path: '/login' }) : window.open(import.meta.env.VITE_BASE_LOGIN_URL) } // if (import.meta.env.DEV && response.code === 1000) { // router.push({path: '/login'}) @@ -108,7 +108,7 @@ export async function request(_url, params) { } return response }).catch(e => { - console.log(e) + console.log('eeeee', e) // router.push({path: '/login'}) }) } @@ -135,10 +135,10 @@ export async function boeRequest(_url, params) { method, headers: { token: getCookie('token'), - ...method !== 'get' ? {'Content-Type': 'application/json'} : {} + ...method !== 'get' ? { 'Content-Type': 'application/json' } : {} }, baseURL: '', - ...method !== 'get' ? {data: JSON.stringify(body)} : {} + ...method !== 'get' ? { data: JSON.stringify(body) } : {} }).then(resp => resp.data).then(response => { return response }).catch(e => { diff --git a/src/components/img/UploadImg.vue b/src/components/img/UploadImg.vue index 0193096..570098d 100644 --- a/src/components/img/UploadImg.vue +++ b/src/components/img/UploadImg.vue @@ -1,11 +1,19 @@ +