From edde5f8a88d5eec166aed93305d7a4c5b818bd5c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E6=B7=B3?= Date: Thu, 13 Oct 2022 11:05:43 +0800 Subject: [PATCH] =?UTF-8?q?=E5=89=8D=E7=AB=AF=E7=99=BB=E5=BD=95=E9=80=BB?= =?UTF-8?q?=E8=BE=91=E5=AF=B9=E6=8E=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Properties/launchSettings.json | 3 +- .../yi-sqlsugar-dev.db | Bin 221184 -> 229376 bytes Yi.Vue3.x.Vant/src/main.ts | 2 + Yi.Vue3.x.Vant/src/permission.ts | 47 +-- Yi.Vue3.x.Vant/src/router/index.ts | 3 +- Yi.Vue3.x.Vant/src/store/modules/user.ts | 8 +- Yi.Vue3.x.Vant/src/utils/myaxios.ts | 125 +++--- Yi.Vue3.x.Vant/src/view/login.vue | 205 +++++----- Yi.Vue3.x.Vant/src/view/main/recommend.vue | 4 +- Yi.Vue3.x.Vant/src/view/main/square.vue | 124 +----- Yi.Vue3.x.Vant/src/view/my.vue | 370 ++++++++++-------- 11 files changed, 421 insertions(+), 470 deletions(-) diff --git a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Properties/launchSettings.json b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Properties/launchSettings.json index 07a01e59..d49e5e26 100644 --- a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Properties/launchSettings.json +++ b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Properties/launchSettings.json @@ -2,7 +2,8 @@ "profiles": { "Yi.Framework.ApiMicroservice": { "commandName": "Project", - "launchBrowser": true, + //开发环境根据情况是否自动启动浏览器,个人感觉开开关关比较麻烦 + "launchBrowser": false, "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development" }, diff --git a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/yi-sqlsugar-dev.db b/Yi.Framework.Net6/Yi.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^1i$ji{xapdP#}Br~e2pIN z7CAYGdJ5wN+6Z&yJdM7gG@EnO+d~gV+##;#P&rrQS#(wJAw)3G!E%ny)2{bm;``VU zvQFcv@1Nf0(W`*4SlD=6mpUw2I9us+#@x|S8#8M}(`{HZJ-`an3R7qggvwd@E5Q{i z<9u;H-~qHnm^cjHzMQG?+~1KK9h`BDFs6Lnwhr3wri(vut5c5Jkl`}N@8;7z7 zP`wxy-VFpCbeFnvy2f)c);T1{Lm+jypmLf<4)?y?kf4un#5snjsGO?Nr=I17L<0hA z2*QL%Uk-m0Azs4by`Xn3FaeD4gP+Uca7^b^FdgOy0uG(k$nvvkNerZ&nnT M$g=&s2(zI#0O6V-b^rhX diff --git a/Yi.Vue3.x.Vant/src/main.ts b/Yi.Vue3.x.Vant/src/main.ts index 4582cc72..324a16a3 100644 --- a/Yi.Vue3.x.Vant/src/main.ts +++ b/Yi.Vue3.x.Vant/src/main.ts @@ -1,6 +1,8 @@ import { createApp } from 'vue' import './style.css' import 'vant/es/image-preview/style'; +import 'vant/es/toast/style'; +import 'vant/es/dialog/style'; import router from './router' import store from './store' import './permission' diff --git a/Yi.Vue3.x.Vant/src/permission.ts b/Yi.Vue3.x.Vant/src/permission.ts index 596daa6c..00dae628 100644 --- a/Yi.Vue3.x.Vant/src/permission.ts +++ b/Yi.Vue3.x.Vant/src/permission.ts @@ -4,59 +4,44 @@ import router from './router' // import 'nprogress/nprogress.css' import { getToken } from '@/utils/auth' // import { isHttp } from '@/utils/validate' -// import { isRelogin } from '@/utils/request' import useUserStore from '@/store/modules/user' +import { isRelogin } from '@/utils/myaxios' // import useSettingsStore from '@/store/modules/settings' // import usePermissionStore from '@/store/modules/permission' // NProgress.configure({ showSpinner: false }); -const whiteList = ['/square', '/auth-redirect', '/bind', '/register']; +const whiteList = ['/login', '/auth-redirect', '/bind', '/register']; router.beforeEach((to, from, next) => { // NProgress.start() if (getToken()) { // to.meta.title && useSettingsStore().setTitle(to.meta.title) /* has token*/ - if (to.path === '/square') { + if (to.path === '/login') { next({ path: '/' }) // NProgress.done() } else { - useUserStore().getInfo(); - next() - // if (useUserStore().roles.length === 0) - // { - // // isRelogin.show = true - // // 鍒ゆ柇褰撳墠鐢ㄦ埛鏄惁宸叉媺鍙栧畬user_info淇℃伅 - // useUserStore().getInfo().then(() => { - // // isRelogin.show = false - // next({ ...to, replace: true }) // hack鏂规硶 纭繚addRoutes宸插畬鎴 - // // usePermissionStore().generateRoutes().then(accessRoutes => { - // // // 鏍规嵁roles鏉冮檺鐢熸垚鍙闂殑璺敱琛 - // // accessRoutes.forEach(route => { - // // if (!isHttp(route.path)) { - // // router.addRoute(route) // 鍔ㄦ佹坊鍔犲彲璁块棶璺敱琛 - // // } - // // }) - - // // }) - // }).catch(err => { - // useUserStore().logOut().then(() => { - // // ElMessage.error(err) - // next({ path: '/' }) - // }) - // }) - // } else { - // next() - // } + if (useUserStore().roles.length === 0) { + isRelogin.show = true + useUserStore().getInfo().then((response: any) => { + next() + }); + + } + else + { + next() + } } } else { + // 娌℃湁token if (whiteList.indexOf(to.path) !== -1) { // 鍦ㄥ厤鐧诲綍鐧藉悕鍗曪紝鐩存帴杩涘叆 next() } else { - next(`/square?redirect=${to.fullPath}`) // 鍚﹀垯鍏ㄩ儴閲嶅畾鍚戝埌鐧诲綍椤 + next(`/login?redirect=${to.fullPath}`) // 鍚﹀垯鍏ㄩ儴閲嶅畾鍚戝埌鐧诲綍椤 // NProgress.done() } } diff --git a/Yi.Vue3.x.Vant/src/router/index.ts b/Yi.Vue3.x.Vant/src/router/index.ts index 8fb7fea6..4337c530 100644 --- a/Yi.Vue3.x.Vant/src/router/index.ts +++ b/Yi.Vue3.x.Vant/src/router/index.ts @@ -2,6 +2,7 @@ import { createWebHistory, createRouter } from 'vue-router'; import Layout from '@/layout/index.vue'; export const constantRoutes = [ + { name:'Layout', path: '/', @@ -45,7 +46,7 @@ export const constantRoutes = [ }, { path: '/login', - component: () => import('@/view/Login.vue'), + component: () => import('@/view/login.vue'), name: 'Login', }, ]; diff --git a/Yi.Vue3.x.Vant/src/store/modules/user.ts b/Yi.Vue3.x.Vant/src/store/modules/user.ts index fc5f83a6..2d43fc5e 100644 --- a/Yi.Vue3.x.Vant/src/store/modules/user.ts +++ b/Yi.Vue3.x.Vant/src/store/modules/user.ts @@ -24,7 +24,7 @@ const useUserStore = defineStore( login(username, password, code, uuid).then(res => { setToken(res.data.token); this.token = res.data.token; - resolve(); + resolve(res); }).catch(error => { reject(error) }) @@ -37,7 +37,7 @@ const useUserStore = defineStore( const res=response.data; const user = res.user // const avatar = (user.avatar == "" || user.avatar == null) ? defAva : import.meta.env.VITE_APP_BASE_API + user.avatar; - + const avatar="" if (res.roleCodes && res.roleCodes.length > 0) { // 楠岃瘉杩斿洖鐨剅oles鏄惁鏄竴涓潪绌烘暟缁 this.roles = res.roleCodes this.permissions = res.permissionCodes @@ -63,12 +63,12 @@ const useUserStore = defineStore( // 閫鍑虹郴缁 logOut() { return new Promise((resolve, reject) => { - logout(this.token).then(() => { + logout(this.token).then((response) => { this.token = '' this.roles = [] this.permissions = [] removeToken() - resolve() + resolve(response) }).catch(error => { reject(error) }) diff --git a/Yi.Vue3.x.Vant/src/utils/myaxios.ts b/Yi.Vue3.x.Vant/src/utils/myaxios.ts index 2da5e11c..b6ad7d08 100644 --- a/Yi.Vue3.x.Vant/src/utils/myaxios.ts +++ b/Yi.Vue3.x.Vant/src/utils/myaxios.ts @@ -3,7 +3,10 @@ import axios from 'axios' // import vm from '../main' import JsonBig from 'json-bigint' import { getToken } from '@/utils/auth' +import { useRouter } from "vue-router"; +import useUserStore from '@/store/modules/user' // import VuetifyDialogPlugin from 'vuetify-dialog/nuxt/index'; +export let isRelogin = { show: false }; const myaxios = axios.create({ // baseURL:'/'// baseURL: import.meta.env.VITE_APP_BASE_API, // /dev-apis @@ -35,64 +38,88 @@ myaxios.interceptors.request.use(function(config) { // 鍝嶅簲鎷︽埅鍣 myaxios.interceptors.response.use(async function(response) { +//鎴愬姛 const resp = response.data - if (resp.code == undefined && resp.message == undefined) { - // vm.$dialog.notify.error("閿欒浠g爜锛氭棤锛屽師鍥狅細涓庢湇鍔″櫒澶卞幓杩炴帴", { - // position: "top-right", - // timeout: 5000, - // }); - } else if (resp.code == 401) { - // const res = await vm.$dialog.error({ - // text: `閿欒浠g爜锛${resp.code}锛屽師鍥狅細${resp.message}
鏄惁閲嶆柊杩涜鐧诲綍锛焋, - // title: '閿欒', - // actions: { - // 'false': '鍙栨秷', - // 'true': '璺宠浆' - // } - // }); - // if (res) { - // vm.$router.push({ path: "/login" }); - // } + // if (resp.code == undefined && resp.message == undefined) { + // alert("鐩存帴鐖嗙偢") + // // vm.$dialog.notify.error("閿欒浠g爜锛氭棤锛屽師鍥狅細涓庢湇鍔″櫒澶卞幓杩炴帴", { + // // position: "top-right", + // // timeout: 5000, + // // }); + // } else if (resp.code == 401) { + // alert("鐧诲綍杩囨湡锛侀噸鏂扮櫥褰"); - } else if (resp.code !== 200) { - // vm.$dialog.notify.error(`閿欒浠g爜锛${resp.code}锛屽師鍥狅細${resp.message}`, { - // position: "top-right", - // timeout: 5000, - // }); - } + // const router = useRouter(); + // router.push({ path:"/login" }); + + // // const res = await vm.$dialog.error({ + // // text: `閿欒浠g爜锛${resp.code}锛屽師鍥狅細${resp.message}
鏄惁閲嶆柊杩涜鐧诲綍锛焋, + // // title: '閿欒', + // // actions: { + // // 'false': '鍙栨秷', + // // 'true': '璺宠浆' + // // } + // // }); + // // if (res) { + // // vm.$router.push({ path: "/login" }); + // // } + + // } else if (resp.code !== 200) { + // // vm.$dialog.notify.error(`閿欒浠g爜锛${resp.code}锛屽師鍥狅細${resp.message}`, { + // // position: "top-right", + // // timeout: 5000, + // // }); + // } // store.dispatch("closeLoad"); return resp; }, async function(error) { - // const resp = error.response.data - // if (resp.code == undefined && resp.message == undefined) { - // vm.$dialog.notify.error("閿欒浠g爜锛氭棤锛屽師鍥狅細涓庢湇鍔″櫒澶卞幓杩炴帴", { - // position: "top-right", - // timeout: 5000, - // }); - // } else if (resp.code == 401) { - // const res = await vm.$dialog.error({ - // text: `閿欒浠g爜锛${resp.code}锛屽師鍥狅細${resp.message}
鏄惁閲嶆柊杩涜鐧诲綍锛焋, - // title: '閿欒', - // actions: { - // 'false': '鍙栨秷', - // 'true': '璺宠浆' - // } - // }); - // if (res) { - // vm.$store.dispatch("Logout").then((resp) => { - // vm.$router.push({ path: "/login" }); - // }); - // } +//鏈巿鏉冦佸け璐 +const resp = error.response.data - // } else if (resp.code !== 200) { - // vm.$dialog.notify.error(`閿欒浠g爜锛${resp.code}锛屽師鍥狅細${resp.message}`, { - // position: "top-right", - // timeout: 5000, - // }); + +if (resp.code == undefined && resp.message == undefined) { + alert("鐩存帴鐖嗙偢") + // vm.$dialog.notify.error("閿欒浠g爜锛氭棤锛屽師鍥狅細涓庢湇鍔″櫒澶卞幓杩炴帴", { + // position: "top-right", + // timeout: 5000, + // }); +} else if (resp.code == 401) { + if (!isRelogin.show) { + + + + alert("鐧诲綍杩囨湡锛侀噸鏂扮櫥褰"); + //鐧诲嚭 + useUserStore().logOut().then(() => { + location.href = '/'; + }) + + isRelogin.show = false; + } + // const router = useRouter(); + // router.push({ path:"/login" }); + + // const res = await vm.$dialog.error({ + // text: `閿欒浠g爜锛${resp.code}锛屽師鍥狅細${resp.message}
鏄惁閲嶆柊杩涜鐧诲綍锛焋, + // title: '閿欒', + // actions: { + // 'false': '鍙栨秷', + // 'true': '璺宠浆' + // } + // }); + // if (res) { + // vm.$router.push({ path: "/login" }); // } - // store.dispatch("closeLoad"); +} else if (resp.code !== 200) { + alert("鏈嶅姟鍣ㄥ唴閮ㄩ敊璇") + // vm.$dialog.notify.error(`閿欒浠g爜锛${resp.code}锛屽師鍥狅細${resp.message}`, { + // position: "top-right", + // timeout: 5000, + // }); +} + return Promise.reject(error); }); export default myaxios \ No newline at end of file diff --git a/Yi.Vue3.x.Vant/src/view/login.vue b/Yi.Vue3.x.Vant/src/view/login.vue index 7376c6de..6c7f50ff 100644 --- a/Yi.Vue3.x.Vant/src/view/login.vue +++ b/Yi.Vue3.x.Vant/src/view/login.vue @@ -1,100 +1,129 @@ - - \ No newline at end of file +} +.title { + position: absolute; + top: 15%; + transform: translateX(-50%); + font-size: 1.8rem; + font-weight: bolder; +} +.subtitle { + transform: translateX(-50%); + position: absolute; + top: 30%; + font-weight: lighter; +} +.van-field-username { + margin-top: 2rem; +} +.van-field-password { + margin-top: 1rem; +} +h5 { + text-align: left; + font-size: 1.2rem; + font-weight: bolder; +} +.div-bottom .van-button { + margin-top: 1rem; + width: 100%; + border-radius: 0.4rem; +} +.div-bottom p { + text-align: center; +} +.row-bottom { +} + \ No newline at end of file diff --git a/Yi.Vue3.x.Vant/src/view/main/recommend.vue b/Yi.Vue3.x.Vant/src/view/main/recommend.vue index cd11abd6..3b364a25 100644 --- a/Yi.Vue3.x.Vant/src/view/main/recommend.vue +++ b/Yi.Vue3.x.Vant/src/view/main/recommend.vue @@ -30,7 +30,7 @@ {{ item.content }} - - + --> diff --git a/Yi.Vue3.x.Vant/src/view/main/square.vue b/Yi.Vue3.x.Vant/src/view/main/square.vue index f5acd48a..2515880a 100644 --- a/Yi.Vue3.x.Vant/src/view/main/square.vue +++ b/Yi.Vue3.x.Vant/src/view/main/square.vue @@ -1,123 +1 @@ - - - \ No newline at end of file + \ No newline at end of file diff --git a/Yi.Vue3.x.Vant/src/view/my.vue b/Yi.Vue3.x.Vant/src/view/my.vue index 78969a13..fe7006e0 100644 --- a/Yi.Vue3.x.Vant/src/view/my.vue +++ b/Yi.Vue3.x.Vant/src/view/my.vue @@ -1,211 +1,239 @@ \ No newline at end of file