|
|
@@ -55,6 +55,7 @@
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
+import { logoutOnlineStatus } from "@/api/heartbeat";
|
|
|
import { mapGetters } from 'vuex'
|
|
|
import Breadcrumb from '@/components/Breadcrumb'
|
|
|
import TopNav from '@/components/TopNav'
|
|
|
@@ -191,18 +192,42 @@ export default {
|
|
|
toggleSideBar() {
|
|
|
this.$store.dispatch('app/toggleSideBar')
|
|
|
},
|
|
|
+ // async logout() {
|
|
|
+ // this.$confirm('确定注销并退出系统吗?', '提示', {
|
|
|
+ // confirmButtonText: '确定',
|
|
|
+ // cancelButtonText: '取消',
|
|
|
+ // type: 'warning'
|
|
|
+ // }).then(() => {
|
|
|
+ // //记录退出登录状态
|
|
|
+ // logoutOnlineStatus();
|
|
|
+ // this.$store.dispatch('LogOut').then(() => {
|
|
|
+ // this.$store.dispatch('imlogout')
|
|
|
+ // location.href = '/index';
|
|
|
+ //
|
|
|
+ // })
|
|
|
+ // }).catch(() => { });
|
|
|
+ // }
|
|
|
async logout() {
|
|
|
- this.$confirm('确定注销并退出系统吗?', '提示', {
|
|
|
- confirmButtonText: '确定',
|
|
|
- cancelButtonText: '取消',
|
|
|
- type: 'warning'
|
|
|
- }).then(() => {
|
|
|
- this.$store.dispatch('LogOut').then(() => {
|
|
|
- this.$store.dispatch('imlogout')
|
|
|
- location.href = '/index';
|
|
|
-
|
|
|
- })
|
|
|
- }).catch(() => { });
|
|
|
+ try {
|
|
|
+ await this.$confirm('确定注销并退出系统吗?', '提示', {
|
|
|
+ confirmButtonText: '确定',
|
|
|
+ cancelButtonText: '取消',
|
|
|
+ type: 'warning'
|
|
|
+ });
|
|
|
+ //先调用登出在线状态接口(此时 token 还有效!)
|
|
|
+ await logoutOnlineStatus();
|
|
|
+ // 清除本地登录状态
|
|
|
+ await this.$store.dispatch('LogOut');
|
|
|
+ // IM 登出
|
|
|
+ this.$store.dispatch('imlogout');
|
|
|
+ // 跳转登录页
|
|
|
+ this.$router.push({ path: '/login' });
|
|
|
+
|
|
|
+ } catch (error) {
|
|
|
+ if (error !== 'cancel') {
|
|
|
+ console.error('退出过程中发生错误:', error);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|