Merge branch 'dev-wangyiming'

# Conflicts:
#	src/views/AppMain.vue
#	src/views/equip/detail.vue
#	src/views/equip/list.vue
This commit is contained in:
wlikett 2023-12-05 09:47:17 +08:00
commit 7a847933cf
5 changed files with 49 additions and 18 deletions

View File

@ -1,5 +1,10 @@
import { post,get } from '../index' import { post,get } from '../index'
export const getList = () => { // 获取装备列表
return get('/dev/list',{}) export const getList = (params = {}) => {
return post('/dev/list',params)
}
export const getDetail = (id = '') => {
return get(`/dev/${id}`)
} }

View File

@ -3,11 +3,14 @@
import axios from 'axios' import axios from 'axios'
import NProgress from 'nprogress' import NProgress from 'nprogress'
import { useStore } from 'store/main' import { useStore } from 'store/main'
import {ElMessage} from "element-plus";
import router from "@/router"
const store = useStore() const store = useStore()
// const CancelToken = axios.CancelToken // const CancelToken = axios.CancelToken
// const source = CancelToken.source() // const source = CancelToken.source()
const baseUrl = import.meta.env.VITE_API_URL const baseUrl = import.meta.env.VITE_API_URL
// const mode = import.meta.env.VITE_BUILD_MODE // const mode = import.meta.env.VITE_BUILD_MODE
const service = axios.create({ const service = axios.create({
baseURL: baseUrl, baseURL: baseUrl,
timeout: 60000 timeout: 60000
@ -15,7 +18,7 @@ const service = axios.create({
service.interceptors.request.use( service.interceptors.request.use(
(config) => { (config) => {
config.headers['Authorization'] = "eyJhbGciOiJIUzUxMiJ9.eyJ1c2VyX2lkIjoxLCJ1c2VyX2tleSI6Ijc5MjRkNDc1LTRjMmUtNGViYy05ZDU0LTA2NzNmNWU0MDhiMyIsInVzZXJuYW1lIjoiYWRtaW4ifQ.M3H9jHnfFAKJ3szdiDb79hIHfiS8AWvaI51mP65l01Q2G0jcLSTvjlub8FykYV3A27If7V6GBRo83u8spRDquw" config.headers['Authorization'] = store.token
return config return config
}, },
(error) => { (error) => {
@ -25,7 +28,15 @@ service.interceptors.request.use(
// 响应拦截 // 响应拦截
service.interceptors.response.use( service.interceptors.response.use(
(res) => { (res) => {
return res.data const { data } = res
if(data.code == '200'){
return data
}else if(data.code == '403'){
ElMessage.error('请重新登录')
router.push('/login')
}else{
return data
}
}, },
(error) => { (error) => {

View File

@ -208,12 +208,11 @@ const router = createRouter({
router.beforeEach((to, from, next) => { router.beforeEach((to, from, next) => {
const store = useStore() const store = useStore()
if (store.token) { if (store.token || to.path == '/login') {
next() next()
} else { } else {
next({ path: '/login' }) next('/login')
} }
// chrome // chrome
document.body.scrollTop = 0; document.body.scrollTop = 0;
// firefox 兼容火狐 // firefox 兼容火狐

View File

@ -2,7 +2,7 @@ export const useStore = defineStore('main', {
state: () => { state: () => {
return { return {
loadingFlag: false, //loading控制, loadingFlag: false, //loading控制,
token: '' token: 'eyJhbGciOiJIUzUxMiJ9.eyJ1c2VyX2lkIjoxLCJ1c2VyX2tleSI6Ijc5MjRkNDc1LTRjMmUtNGViYy05ZDU0LTA2NzNmNWU0MDhiMyIsInVzZXJuYW1lIjoiYWRtaW4ifQ.M3H9jHnfFAKJ3szdiDb79hIHfiS8AWvaI51mP65l01Q2G0jcLSTvjlub8FykYV3A27If7V6GBRo83u8spRDquw'
} }
}, },
getters: {}, getters: {},

View File

@ -1,18 +1,20 @@
<template> <template>
<div class="equipShowImg"> <div class="equipShowImg">
<div class="show"> <div class="show">
<img :src="activeUrl"> <img :src="urlList[activeUrl]">
</div> </div>
<div class="loop"> <div class="loop">
<div class="prev btn"> <div class="prev btn" @click="changeActive(-1)">
<el-icon><ArrowLeftBold /></el-icon> <el-icon><ArrowLeftBold /></el-icon>
</div> </div>
<div class="list"> <div class="list">
<div class="item" @mouseenter="mouseenter($event,v)" :class="v == activeUrl && 'activeUrl'" v-for="(v,i) in urlList" :key="i"> <div class="line" :style="`transform: translateX(calc((-100% - 10px) / 3 * ${activeUrl - 3}))`">
<img :src="v"> <div class="item" @mouseenter="mouseenter($event,i)" :class="i == activeUrl && 'activeUrl'" v-for="(v,i) in urlList" :key="i">
<img :src="v">
</div>
</div> </div>
</div> </div>
<div class="next btn"> <div class="next btn" @click="changeActive(1)">
<el-icon><ArrowRightBold /></el-icon> <el-icon><ArrowRightBold /></el-icon>
</div> </div>
</div> </div>
@ -33,10 +35,11 @@
} }
}) })
const activeUrl = ref('') //
const activeUrl = ref(0)
const init = () => { const init = () => {
activeUrl.value = props.urlList ? props.urlList[0] : ''
} }
init() init()
@ -44,6 +47,15 @@
activeUrl.value = val activeUrl.value = val
} }
const changeActive = (val) => {
activeUrl.value = activeUrl.value + val
if(activeUrl.value < 0){
activeUrl.value = 0
}else if(activeUrl.value == props.urlList?.length){
activeUrl.value = props.urlList.length - 1
}
}
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.equipShowImg{ .equipShowImg{
@ -83,9 +95,13 @@
flex: 1; flex: 1;
overflow: hidden; overflow: hidden;
display: flex;
align-items: center;
height: 100%; height: 100%;
.line{
height: 100%;
display: flex;
align-items: center;
}
.item{ .item{
height: 100%; height: 100%;
margin-right: 5px; margin-right: 5px;