diff --git a/components.d.ts b/components.d.ts index 5f0af13..eeb3a5a 100644 --- a/components.d.ts +++ b/components.d.ts @@ -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'] } diff --git a/env/.env.dev b/env/.env.dev index 6d9d286..c042eae 100644 --- a/env/.env.dev +++ b/env/.env.dev @@ -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' + diff --git a/src/http/api/login/index.ts b/src/http/api/login/index.ts index 967e727..5da0441 100644 --- a/src/http/api/login/index.ts +++ b/src/http/api/login/index.ts @@ -1,6 +1,6 @@ import { get, post } from '../../index' // 登录接口 -export const loginApi = (data) => { +export const loginApi = (data: any) => { return post('/login', data) } \ No newline at end of file diff --git a/src/http/index.ts b/src/http/index.ts index 9908f53..4b9db14 100644 --- a/src/http/index.ts +++ b/src/http/index.ts @@ -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) => { diff --git a/src/main.ts b/src/main.ts index dc8c9b4..8058897 100644 --- a/src/main.ts +++ b/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') diff --git a/src/router/index.ts b/src/router/index.ts index 5d1da52..a25cfee 100644 --- a/src/router/index.ts +++ b/src/router/index.ts @@ -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 = [ { path: '/index', @@ -192,10 +197,26 @@ const routes: Array = [ ] + 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 diff --git a/src/views/AppMain.vue b/src/views/AppMain.vue index 8035a60..6900f07 100644 --- a/src/views/AppMain.vue +++ b/src/views/AppMain.vue @@ -41,9 +41,9 @@