From 19bfce36fe33ed8676803fcf970e46c7c38066c1 Mon Sep 17 00:00:00 2001
From: yuping <82253452@qq.com>
Date: Tue, 13 Dec 2022 17:02:07 +0800
Subject: [PATCH] init
---
src/api/ThirdApi.js | 4 +
src/api/request.js | 36 +++++++
src/api/utils.js | 14 +++
src/views/roadmap/PathDetails.vue | 27 ++---
vite.config.js | 161 +++++++++++++++---------------
5 files changed, 151 insertions(+), 91 deletions(-)
create mode 100644 src/api/ThirdApi.js
diff --git a/src/api/ThirdApi.js b/src/api/ThirdApi.js
new file mode 100644
index 0000000..7988a32
--- /dev/null
+++ b/src/api/ThirdApi.js
@@ -0,0 +1,4 @@
+export const BASE = 'https://u-pre.boe.com'
+export const GET_USER_LIST = `/userbasic/user/list post`
+
+
diff --git a/src/api/request.js b/src/api/request.js
index 8a71ade..f33c90a 100644
--- a/src/api/request.js
+++ b/src/api/request.js
@@ -1,6 +1,7 @@
import router from "@/router";
import {reactive, ref, toRefs, watch} from "vue";
import axios from 'axios';
+import {getCookie} from "@/api/utils";
export function usePage(_url, param) {
@@ -109,4 +110,39 @@ export async function request(_url, params) {
console.log(e)
// router.push({path: '/login'})
})
+}
+
+export async function boeRequest(_url, params) {
+ const s = _url.split(' ')
+ let url = s[0]
+ const method = s[1]?.toLowerCase() || 'get'
+ if (method === 'get') {
+ let paramsArray = [];
+ //拼接参数
+ if (params) {
+ Object.keys(params).forEach(key => paramsArray.push(key + '=' + params[key]))
+ if (url.search(/\?/) === -1) {
+ url += '?' + paramsArray.join('&')
+ } else {
+ url += '&' + paramsArray.join('&')
+ }
+ }
+ }
+ const body = method !== 'get' ? params || {} : {}
+ return axios({
+ url,
+ method,
+ headers: {
+ token: getCookie('token'),
+ ...method !== 'get' ? {'Content-Type': 'application/json'} : {}
+ },
+ baseURL: '',
+ ...method !== 'get' ? {data: JSON.stringify(body)} : {}
+ }).then(resp => resp.data).then(response => {
+ return response
+ }).catch(e => {
+ console.log(2222)
+ console.log(e)
+ // router.push({path: '/login'})
+ })
}
\ No newline at end of file
diff --git a/src/api/utils.js b/src/api/utils.js
index bf71f6e..33fd183 100644
--- a/src/api/utils.js
+++ b/src/api/utils.js
@@ -1,3 +1,7 @@
+import {watch, ref} from "vue";
+import {boeRequest} from "@/api/request";
+import {BASE, GET_USER_LIST} from "@/api/ThirdApi";
+
export function useImage(src) {
return new URL(`../assets/image/${src}`, import.meta.url).href
}
@@ -10,4 +14,14 @@ export function setCookie(name, value, perpetual) {
export function getCookie(name) {
return document.cookie?.split(";").find(e => e.includes(name)).replace(`${name}=`, '') || ''
+}
+
+export function useUserInfoAvatar(id) {
+ const avatar = ref(import.meta.env.DEV ? `${BASE}/upload` : '')
+ watch(id, () => {
+ id.value && boeRequest(GET_USER_LIST, {id: id.value}).then(res => {
+ avatar.value = avatar.value + res.result.userInfoList[0].avatar
+ })
+ })
+ return avatar
}
\ No newline at end of file
diff --git a/src/views/roadmap/PathDetails.vue b/src/views/roadmap/PathDetails.vue
index b2a8020..cef50d8 100644
--- a/src/views/roadmap/PathDetails.vue
+++ b/src/views/roadmap/PathDetails.vue
@@ -182,7 +182,7 @@
class="teacheritem"
:style="{'border-bottom': '1px solid rgba(56, 125, 247, 0.2)'}"
>
-
+