登录接口正常
This commit is contained in:
parent
2e4af49963
commit
bd0290dcf8
|
|
@ -7,23 +7,12 @@ export {}
|
|||
|
||||
declare module 'vue' {
|
||||
export interface GlobalComponents {
|
||||
ElButton: typeof import('element-plus/es')['ElButton']
|
||||
ElCarousel: typeof import('element-plus/es')['ElCarousel']
|
||||
ElCarouselItem: typeof import('element-plus/es')['ElCarouselItem']
|
||||
<<<<<<< HEAD
|
||||
ElIcon: typeof import('element-plus/es')['ElIcon']
|
||||
ElPagination: typeof import('element-plus/es')['ElPagination']
|
||||
ElTag: typeof import('element-plus/es')['ElTag']
|
||||
=======
|
||||
ElDialog: typeof import('element-plus/es')['ElDialog']
|
||||
ElForm: typeof import('element-plus/es')['ElForm']
|
||||
ElFormItem: typeof import('element-plus/es')['ElFormItem']
|
||||
ElInput: typeof import('element-plus/es')['ElInput']
|
||||
ElMenu: typeof import('element-plus/es')['ElMenu']
|
||||
ElMenuItem: typeof import('element-plus/es')['ElMenuItem']
|
||||
ElPagination: typeof import('element-plus/es')['ElPagination']
|
||||
ElTable: typeof import('element-plus/es')['ElTable']
|
||||
ElTableColumn: typeof import('element-plus/es')['ElTableColumn']
|
||||
>>>>>>> dev-songyang
|
||||
RouterLink: typeof import('vue-router')['RouterLink']
|
||||
RouterView: typeof import('vue-router')['RouterView']
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,12 +1,11 @@
|
|||
VITE_ENV = 'development'
|
||||
|
||||
VITE_BUILD_MODE = 'dev'
|
||||
# 开发环境接口地址
|
||||
<<<<<<< HEAD
|
||||
VITE_API_URL = '/proxyApi'
|
||||
# 开发环境接口地址
|
||||
VITE_proxyTarget = 'http://10.40.92.66:9206'
|
||||
=======
|
||||
|
||||
VITE_API_URL = '/proxyApi'
|
||||
|
||||
>>>>>>> dev-songyang
|
||||
# 开发环境接口地址
|
||||
# VITE_proxyTarget = 'http://10.40.92.66:9206' #盛旭
|
||||
|
||||
VITE_proxyTarget = 'http://10.40.92.185:9200'
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import { get, post } from '../../index'
|
||||
|
||||
// 登录接口
|
||||
export const loginApi = (data) => {
|
||||
export const loginApi = (data: any) => {
|
||||
return post('/login', data)
|
||||
}
|
||||
|
|
@ -63,9 +63,9 @@ export function post(url: string, params: any) {
|
|||
NProgress.done()
|
||||
console.log('---------------------------', res)
|
||||
if (res.code == '200') {
|
||||
resolve(res.data)
|
||||
resolve(res)
|
||||
} else {
|
||||
reject(res.data)
|
||||
reject(res)
|
||||
}
|
||||
})
|
||||
.catch((err) => {
|
||||
|
|
@ -90,9 +90,9 @@ export function upload(url: string, params: any) {
|
|||
.then((res: any) => {
|
||||
NProgress.done()
|
||||
if (res.code == '200') {
|
||||
resolve(res.data)
|
||||
resolve(res)
|
||||
} else {
|
||||
reject(res.data)
|
||||
reject(res)
|
||||
}
|
||||
})
|
||||
.catch((err) => {
|
||||
|
|
|
|||
18
src/main.ts
18
src/main.ts
|
|
@ -2,9 +2,10 @@ import './assets/main.css'
|
|||
import * as ElementPlusIconsVue from '@element-plus/icons-vue'
|
||||
|
||||
import { createApp } from 'vue'
|
||||
import { createPinia } from 'pinia'
|
||||
// import { createPinia } from 'pinia'
|
||||
|
||||
import App from './App.vue'
|
||||
import pinia from "./store"
|
||||
import router from './router'
|
||||
import 'element-plus/dist/index.css'
|
||||
import './style/css/reset.css'
|
||||
|
|
@ -13,21 +14,8 @@ const app = createApp(App)
|
|||
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
|
||||
app.component(key, component)
|
||||
}
|
||||
import pinia from "./store"
|
||||
|
||||
|
||||
|
||||
|
||||
// 使页面跳转后滚动条恢复至顶部
|
||||
router.beforeEach((to, from, next) => {
|
||||
// chrome
|
||||
document.body.scrollTop = 0;
|
||||
// firefox 兼容火狐
|
||||
document.documentElement.scrollTop = 0;
|
||||
next();
|
||||
})
|
||||
|
||||
app.use(createPinia())
|
||||
app.use(router)
|
||||
app.use(pinia)
|
||||
app.use(router)
|
||||
app.mount('#app')
|
||||
|
|
|
|||
|
|
@ -1,6 +1,11 @@
|
|||
import { createRouter, createWebHashHistory, RouteRecordRaw } from 'vue-router'
|
||||
import test from './module/test'
|
||||
import myInfo from './module/myInfo'
|
||||
|
||||
import { useStore } from 'store/main'
|
||||
|
||||
|
||||
|
||||
const routes: Array<RouteRecordRaw> = [
|
||||
{
|
||||
path: '/index',
|
||||
|
|
@ -192,10 +197,26 @@ const routes: Array<RouteRecordRaw> = [
|
|||
|
||||
]
|
||||
|
||||
|
||||
const router = createRouter({
|
||||
// 路由模式
|
||||
history: createWebHashHistory(),
|
||||
routes
|
||||
})
|
||||
|
||||
// 使页面跳转后滚动条恢复至顶部
|
||||
router.beforeEach((to, from, next) => {
|
||||
const store = useStore()
|
||||
|
||||
if (store.token) {
|
||||
next()
|
||||
} else {
|
||||
next({ path: '/login' })
|
||||
}
|
||||
|
||||
// chrome
|
||||
document.body.scrollTop = 0;
|
||||
// firefox 兼容火狐
|
||||
document.documentElement.scrollTop = 0;
|
||||
})
|
||||
export default router
|
||||
|
|
|
|||
|
|
@ -41,9 +41,9 @@
|
|||
<ul class="header-wapper">
|
||||
<li>
|
||||
<span>
|
||||
<a href="">登录</a>
|
||||
<a @click="$router.push('/login')">登录</a>
|
||||
/
|
||||
<a href="" style="color: #6d6d6d">注册</a>
|
||||
<a style="color: #6d6d6d">注册</a>
|
||||
</span>
|
||||
</li>
|
||||
<li>
|
||||
|
|
|
|||
|
|
@ -1,29 +1,28 @@
|
|||
<script setup lang="ts">
|
||||
import { loginApi } from '../../src/http/api/login/index.ts'
|
||||
// import { ElMessage } from 'element-plus'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import { useRouter } from 'vue-router'
|
||||
import { useStore } from 'store/main.ts'
|
||||
const userStore = useStore()
|
||||
const router = useRouter()
|
||||
|
||||
const loginForm = ref({
|
||||
username: '',
|
||||
password: ''
|
||||
})
|
||||
|
||||
const handlerLogin = async () => {
|
||||
const res = await loginApi(loginForm.value)
|
||||
|
||||
console.log('登录成功**', res)
|
||||
|
||||
// const res: any = await loginApi(loginForm.value)
|
||||
// console.log(res, '登录成功**')
|
||||
// if (res.code === 200) {
|
||||
// // ElMessage({
|
||||
// // showClose: true,
|
||||
// // message: '登录成功',
|
||||
// // type: 'success'
|
||||
// // })
|
||||
// // 登录首页
|
||||
// // router.push('/')
|
||||
|
||||
// ElMessage({
|
||||
// showClose: true,
|
||||
// message: '登录成功',
|
||||
// type: 'success'
|
||||
// })
|
||||
// }
|
||||
// userStore.setToken(res.data.access_token)
|
||||
// 跳转登录页面
|
||||
router.push('/')
|
||||
}
|
||||
</script>
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,11 @@
|
|||
<script setup lang="ts">
|
||||
import EquipCard from '@/compontents/equipCard.vue'
|
||||
import Navmenu from '@/compontents/Navmenu/index.vue'
|
||||
import { useStore } from 'store/main.ts'
|
||||
const userStore = useStore()
|
||||
onMounted(() => {
|
||||
console.log(userStore.token, '****')
|
||||
})
|
||||
|
||||
const leftNavList = [
|
||||
{
|
||||
|
|
|
|||
|
|
@ -68,8 +68,8 @@ export default ({ mode }: any) => {
|
|||
preprocessorOptions: {
|
||||
scss: {
|
||||
// 两种方式都可以
|
||||
additionalData:''
|
||||
// "@import '@/style/scss/index.scss';"
|
||||
additionalData: ''
|
||||
// "@import '@/style/scss/index.scss';"
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -80,11 +80,7 @@ export default ({ mode }: any) => {
|
|||
// open: envInfo.VITE_OPEN,
|
||||
proxy: {
|
||||
'/proxyApi': {
|
||||
<<<<<<< HEAD
|
||||
target: envInfo.VITE_proxyTarget,
|
||||
=======
|
||||
target: 'http://10.40.92.185:9200',
|
||||
>>>>>>> dev-songyang
|
||||
secure: false,
|
||||
changeOrigin: true,
|
||||
rewrite: (path) => path.replace(/^\/proxyApi/, ''),
|
||||
|
|
@ -130,7 +126,7 @@ export default ({ mode }: any) => {
|
|||
},
|
||||
envDir: 'env',
|
||||
build: {
|
||||
outDir: 'dist/' + pjson.name +'-'+envInfo.VITE_BUILD_MODE,
|
||||
outDir: 'dist/' + pjson.name + '-' + envInfo.VITE_BUILD_MODE,
|
||||
emptyOutDir: true,
|
||||
terserOptions: {
|
||||
compress: {
|
||||
|
|
|
|||
Loading…
Reference in New Issue