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