mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/vue/fe-student.git
synced 2025-12-09 02:46:48 +08:00
init
This commit is contained in:
4
src/api/ThirdApi.js
Normal file
4
src/api/ThirdApi.js
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
export const BASE = 'https://u-pre.boe.com'
|
||||||
|
export const GET_USER_LIST = `/userbasic/user/list post`
|
||||||
|
|
||||||
|
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
import router from "@/router";
|
import router from "@/router";
|
||||||
import {reactive, ref, toRefs, watch} from "vue";
|
import {reactive, ref, toRefs, watch} from "vue";
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
|
import {getCookie} from "@/api/utils";
|
||||||
|
|
||||||
export function usePage(_url, param) {
|
export function usePage(_url, param) {
|
||||||
|
|
||||||
@@ -109,4 +110,39 @@ export async function request(_url, params) {
|
|||||||
console.log(e)
|
console.log(e)
|
||||||
// router.push({path: '/login'})
|
// 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'})
|
||||||
|
})
|
||||||
}
|
}
|
||||||
@@ -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) {
|
export function useImage(src) {
|
||||||
return new URL(`../assets/image/${src}`, import.meta.url).href
|
return new URL(`../assets/image/${src}`, import.meta.url).href
|
||||||
}
|
}
|
||||||
@@ -10,4 +14,14 @@ export function setCookie(name, value, perpetual) {
|
|||||||
|
|
||||||
export function getCookie(name) {
|
export function getCookie(name) {
|
||||||
return document.cookie?.split(";").find(e => e.includes(name)).replace(`${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
|
||||||
}
|
}
|
||||||
@@ -182,7 +182,7 @@
|
|||||||
class="teacheritem"
|
class="teacheritem"
|
||||||
:style="{'border-bottom': '1px solid rgba(56, 125, 247, 0.2)'}"
|
:style="{'border-bottom': '1px solid rgba(56, 125, 247, 0.2)'}"
|
||||||
>
|
>
|
||||||
<img class="peopleimg" :src="data.userInfoBo?.peopleimg"/>
|
<img class="peopleimg" :src="userAvatar"/>
|
||||||
<div style="margin-left: 17px">
|
<div style="margin-left: 17px">
|
||||||
<div class="teacherName">
|
<div class="teacherName">
|
||||||
<div style="margin-right: 5px">{{ data.userInfoBo?.userName }}</div>
|
<div style="margin-right: 5px">{{ data.userInfoBo?.userName }}</div>
|
||||||
@@ -213,7 +213,7 @@
|
|||||||
<div class="progress">
|
<div class="progress">
|
||||||
<div style="width: 291px">
|
<div style="width: 291px">
|
||||||
<el-progress
|
<el-progress
|
||||||
:percentage="data.totalChapterCnt"
|
:percentage="parseInt(data.currentChapterCnt/data.totalChapterCnt * 100)"
|
||||||
:show-text="false"
|
:show-text="false"
|
||||||
:stroke-width="8"
|
:stroke-width="8"
|
||||||
:color="
|
:color="
|
||||||
@@ -224,7 +224,7 @@
|
|||||||
3:'rgba(59, 94, 251, 1)',
|
3:'rgba(59, 94, 251, 1)',
|
||||||
4:'rgba(57, 219, 183, 1)',
|
4:'rgba(57, 219, 183, 1)',
|
||||||
5:'rgba(57, 219, 183, 1)'
|
5:'rgba(57, 219, 183, 1)'
|
||||||
}[parseInt(data.totalChapterCnt/20)]
|
}[parseInt(data.currentChapterCnt/data.totalChapterCnt)]
|
||||||
"
|
"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
@@ -242,10 +242,10 @@
|
|||||||
3:'rgba(59, 94, 251, 1)',
|
3:'rgba(59, 94, 251, 1)',
|
||||||
4:'rgba(57, 219, 183, 1)',
|
4:'rgba(57, 219, 183, 1)',
|
||||||
5:'rgba(57, 219, 183, 1)'
|
5:'rgba(57, 219, 183, 1)'
|
||||||
}[parseInt(data.totalChapterCnt/20)]
|
}[parseInt(data.currentChapterCnt/data.totalChapterCnt)]
|
||||||
}"
|
}"
|
||||||
>
|
>
|
||||||
{{ data.totalChapterCnt }}%
|
{{ parseInt(data.currentChapterCnt / data.totalChapterCnt * 100) }}%
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -256,7 +256,7 @@
|
|||||||
<div class="progress">
|
<div class="progress">
|
||||||
<div style="width: 291px">
|
<div style="width: 291px">
|
||||||
<el-progress
|
<el-progress
|
||||||
:percentage="data.currentChapterCnt"
|
:percentage="parseInt(data.currentReqCnt/data.totalReqCnt * 100)"
|
||||||
:show-text="false"
|
:show-text="false"
|
||||||
:stroke-width="8"
|
:stroke-width="8"
|
||||||
:color="
|
:color="
|
||||||
@@ -267,7 +267,7 @@
|
|||||||
3:'rgba(59, 94, 251, 1)',
|
3:'rgba(59, 94, 251, 1)',
|
||||||
4:'rgba(57, 219, 183, 1)',
|
4:'rgba(57, 219, 183, 1)',
|
||||||
5:'rgba(57, 219, 183, 1)'
|
5:'rgba(57, 219, 183, 1)'
|
||||||
}[parseInt(data.currentChapterCnt/20)]
|
}[parseInt(data.currentReqCnt/data.totalReqCnt)]
|
||||||
"
|
"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
@@ -287,10 +287,10 @@
|
|||||||
3:'rgba(59, 94, 251, 1)',
|
3:'rgba(59, 94, 251, 1)',
|
||||||
4:'rgba(57, 219, 183, 1)',
|
4:'rgba(57, 219, 183, 1)',
|
||||||
5:'rgba(57, 219, 183, 1)'
|
5:'rgba(57, 219, 183, 1)'
|
||||||
}[parseInt(data.currentChapterCnt/20)]
|
}[parseInt(data.currentReqCnt/data.totalReqCnt)]
|
||||||
}"
|
}"
|
||||||
>
|
>
|
||||||
{{ data.currentChapterCnt }}%
|
{{ parseInt(data.currentReqCnt / data.totalReqCnt * 100) }}%
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -305,7 +305,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import {reactive, ref} from "vue";
|
import {computed, reactive, ref, watch} from "vue";
|
||||||
import word from '@/assets/image/file/word.png'
|
import word from '@/assets/image/file/word.png'
|
||||||
import ppt from '@/assets/image/file/ppt.png'
|
import ppt from '@/assets/image/file/ppt.png'
|
||||||
import pdf from '@/assets/image/file/pdf.png'
|
import pdf from '@/assets/image/file/pdf.png'
|
||||||
@@ -315,14 +315,17 @@ import medal1 from '@/assets/image/medal/medal1.png'
|
|||||||
import medal2 from '@/assets/image/medal/medal2.png'
|
import medal2 from '@/assets/image/medal/medal2.png'
|
||||||
import medal3 from '@/assets/image/medal/medal3.png'
|
import medal3 from '@/assets/image/medal/medal3.png'
|
||||||
import img from '@/assets/image/uploadimg.png'
|
import img from '@/assets/image/uploadimg.png'
|
||||||
import {useRequest} from "@/api/request";
|
import {boeRequest, useRequest} from "@/api/request";
|
||||||
import {ROUTER_PROCESS} from "@/api/api";
|
import {ROUTER_PROCESS} from "@/api/api";
|
||||||
import {useRoute, useRouter} from "vue-router";
|
import {useRoute, useRouter} from "vue-router";
|
||||||
import { ElMessage } from 'element-plus'
|
import {ElMessage} from 'element-plus'
|
||||||
|
import {useUserInfoAvatar} from "@/api/utils";
|
||||||
|
|
||||||
const {query: {routerId}} = useRoute()
|
const {query: {routerId}} = useRoute()
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
const {data} = useRequest(ROUTER_PROCESS, {routerId})
|
const {data} = useRequest(ROUTER_PROCESS, {routerId})
|
||||||
|
const userAvatar = useUserInfoAvatar(computed(() => data.value?.userInfoBo?.userId))
|
||||||
|
|
||||||
const state = reactive({
|
const state = reactive({
|
||||||
course: [
|
course: [
|
||||||
{
|
{
|
||||||
|
|||||||
161
vite.config.js
161
vite.config.js
@@ -6,89 +6,92 @@
|
|||||||
* @FilePath: /fe-stu/vite.config.js
|
* @FilePath: /fe-stu/vite.config.js
|
||||||
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
|
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
|
||||||
*/
|
*/
|
||||||
import { defineConfig } from 'vite'
|
import {defineConfig} from 'vite'
|
||||||
import vue from '@vitejs/plugin-vue'
|
import vue from '@vitejs/plugin-vue'
|
||||||
import legacy from '@vitejs/plugin-legacy'
|
import legacy from '@vitejs/plugin-legacy'
|
||||||
import { viteMockServe } from 'vite-plugin-mock'
|
import {viteMockServe} from 'vite-plugin-mock'
|
||||||
import topLevelAwait from "vite-plugin-top-level-await";
|
import topLevelAwait from "vite-plugin-top-level-await";
|
||||||
|
|
||||||
const path = require('path')
|
const path = require('path')
|
||||||
const url = 'http://localhost:30001'
|
const url = 'http://localhost:30001'
|
||||||
export default defineConfig(({ command }) =>
|
export default defineConfig(({command}) =>
|
||||||
({
|
({
|
||||||
base: '/fe-student',
|
base: '/fe-student',
|
||||||
plugins: [
|
plugins: [
|
||||||
vue(),
|
vue(),
|
||||||
// legacy({
|
// legacy({
|
||||||
// targets: ['chrome 64', 'defaults', 'not IE 11']
|
// targets: ['chrome 64', 'defaults', 'not IE 11']
|
||||||
// }),
|
// }),
|
||||||
topLevelAwait({
|
topLevelAwait({
|
||||||
promiseExportName: '__tla',
|
promiseExportName: '__tla',
|
||||||
promiseImportName: i => `__tla_${i}`
|
promiseImportName: i => `__tla_${i}`
|
||||||
}),
|
}),
|
||||||
// viteMockServe({
|
// viteMockServe({
|
||||||
// mockPath: './src/mock/mocks',
|
// mockPath: './src/mock/mocks',
|
||||||
// })
|
// })
|
||||||
],
|
],
|
||||||
resolve: {
|
resolve: {
|
||||||
alias: [
|
alias: [
|
||||||
{ find: '@', replacement: path.resolve(__dirname, 'src') }
|
{find: '@', replacement: path.resolve(__dirname, 'src')}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
// server: {
|
server: {
|
||||||
// proxy: {
|
proxy: {
|
||||||
// '/file/upload': {
|
'/file/upload': {
|
||||||
// target: 'http://111.231.196.214:30001',
|
target: 'http://111.231.196.214:30001',
|
||||||
// changeOrigin: true,
|
changeOrigin: true,
|
||||||
// },
|
},
|
||||||
// '/stu': {
|
'/stu': {
|
||||||
// target: url,
|
target: url,
|
||||||
// changeOrigin: true,
|
changeOrigin: true,
|
||||||
// },
|
},
|
||||||
// '/queryVoteSubmitDetailById': {
|
'/queryVoteSubmitDetailById': {
|
||||||
// target: url,
|
target: url,
|
||||||
// changeOrigin: true,
|
changeOrigin: true,
|
||||||
// },
|
},
|
||||||
// '/work': {
|
'/work': {
|
||||||
// target: url,
|
target: url,
|
||||||
// changeOrigin: true,
|
changeOrigin: true,
|
||||||
// },
|
},
|
||||||
// '/discuss': {
|
'/discuss': {
|
||||||
// target: url,
|
target: url,
|
||||||
// changeOrigin: true,
|
changeOrigin: true,
|
||||||
// },
|
},
|
||||||
// '/discussSubmit': {
|
'/discussSubmit': {
|
||||||
// target: url,
|
target: url,
|
||||||
// changeOrigin: true,
|
changeOrigin: true,
|
||||||
// },
|
},
|
||||||
// '/comment': {
|
'/comment': {
|
||||||
// target: url,
|
target: url,
|
||||||
// changeOrigin: true,
|
changeOrigin: true,
|
||||||
// },
|
},
|
||||||
// '/vote': {
|
'/vote': {
|
||||||
// target: url,
|
target: url,
|
||||||
// changeOrigin: true,
|
changeOrigin: true,
|
||||||
// },
|
},
|
||||||
// '/admin': {
|
'/admin': {
|
||||||
// target: url,
|
target: url,
|
||||||
// changeOrigin: true,
|
changeOrigin: true,
|
||||||
// }, '/activity': {
|
}, '/activity': {
|
||||||
// target: url,
|
target: url,
|
||||||
// changeOrigin: true,
|
changeOrigin: true,
|
||||||
// }, '/liveBroadcast': {
|
}, '/liveBroadcast': {
|
||||||
// target: url,
|
target: url,
|
||||||
// changeOrigin: true,
|
changeOrigin: true,
|
||||||
// }, '/examination': {
|
}, '/examination': {
|
||||||
// target: url,
|
target: url,
|
||||||
// changeOrigin: true,
|
changeOrigin: true,
|
||||||
// }, '/assessment': {
|
}, '/assessment': {
|
||||||
// target: url,
|
target: url,
|
||||||
// changeOrigin: true,
|
changeOrigin: true,
|
||||||
// },'/workSubmit': {
|
}, '/workSubmit': {
|
||||||
// target: url,
|
target: url,
|
||||||
// changeOrigin: true,
|
changeOrigin: true,
|
||||||
// },
|
}, '/userbasic': {
|
||||||
// }
|
target: 'https://u-pre.boe.com',
|
||||||
// }
|
changeOrigin: true,
|
||||||
})
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user