Browse Source

feat: [登录] 返回第一个url

lkf
memorylkf 2 months ago
parent
commit
e07a28ee68
4 changed files with 17 additions and 9 deletions
  1. +4
    -4
      src/layout/components/Sidebar/Logo.vue
  2. +3
    -1
      src/store/getters.js
  3. +8
    -2
      src/store/modules/user.js
  4. +2
    -2
      src/views/login.vue

+ 4
- 4
src/layout/components/Sidebar/Logo.vue View File

@ -2,16 +2,16 @@
<div class="sidebar-logo-container" :class="{ 'collapse': collapse }"
:style="{ backgroundColor: sideTheme === 'theme-dark' ? variables.menuBackground : variables.menuLightBackground }">
<transition name="sidebarLogoFade">
<router-link v-if="collapse" key="collapse" class="sidebar-logo-link" to="/">
<a v-if="collapse" key="collapse" class="sidebar-logo-link">
<img v-if="logo2" :src="logo2" class="sidebar-logo" />
<h1 v-else class="sidebar-title"
:style="{ color: sideTheme === 'theme-dark' ? variables.logoTitleColor : variables.logoLightTitleColor }">{{
$t('system.title') }} </h1>
</router-link>
<router-link v-else key="expand" class="sidebar-logo-link" to="/">
</a>
<a v-else key="expand" class="sidebar-logo-link">
<img v-if="logo" :src="logo" class="sidebar-expand-logo" />
<!-- <h1 class="sidebar-title" :style="{ color: sideTheme === 'theme-dark' ? variables.logoTitleColor : variables.logoLightTitleColor }">{{ $t('system.title') }} </h1> -->
</router-link>
</a>
</transition>
</div>
</template>

+ 3
- 1
src/store/getters.js View File

@ -17,6 +17,8 @@ const getters = {
topbarRouters: (state) => state.permission.topbarRouters,
defaultRoutes: (state) => state.permission.defaultRoutes,
sidebarRouters: (state) => state.permission.sidebarRouters,
language: (state) => state.app.language
language: (state) => state.app.language,
defaultUrl: (state) => state.user.defaultUrl
}
export default getters

+ 8
- 2
src/store/modules/user.js View File

@ -13,7 +13,9 @@ const user = {
nickName: '',
avatar: '',
roles: [],
permissions: []
permissions: [],
defaultUrl: '/user/work'
},
mutations: {
@ -40,6 +42,9 @@ const user = {
},
SET_PERMISSIONS: (state, permissions) => {
state.permissions = permissions
},
SET_DEFAULTURL: (state, defaultUrl) => {
state.defaultUrl = defaultUrl
}
},
@ -59,7 +64,8 @@ const user = {
commit('SET_TOKEN', data.access_token)
setExpiresIn(data.expires_in)
commit('SET_EXPIRES_IN', data.expires_in)
resolve()
commit('SET_DEFAULTURL', data.defaultUrl)
resolve(data.defaultUrl)
})
.catch((error) => {
reject(error)

+ 2
- 2
src/views/login.vue View File

@ -156,8 +156,8 @@ export default {
Cookies.remove("password");
Cookies.remove('rememberMe');
}
this.$store.dispatch("Login", this.loginForm).then(() => {
this.$router.push({ path: this.redirect || "/" }).catch(()=>{});
this.$store.dispatch("Login", this.loginForm).then((url) => {
this.$router.push({ path: url }).catch(()=>{});
}).catch(err => {
if(err && err.message==='exists'){
this.$confirm(this.$t('system.crowdOut'), this.$t('system.tip'), {

Loading…
Cancel
Save