| | |
| | | import axios from 'axios' |
| | | import store from '@/store/' |
| | | import router from '@/router/' |
| | | import { serialize } from '@/utils/util' |
| | | import { logOutFun, serialize } from '@/utils/util' |
| | | import { getToken, removeToken, removeRefreshToken } from '@/utils/auth' |
| | | import { isURL, validatenull } from '@/utils/validate' |
| | | import { ElMessage } from 'element-plus' |
| | |
| | | //跨域请求,允许保存cookie |
| | | axios.defaults.withCredentials = true |
| | | |
| | | function logOutFun() { |
| | | store.dispatch('FedLogOut').then(() =>{ |
| | | const {VITE_APP_PARENT_SYSTEM,VITE_APP_ENV} = import.meta.env |
| | | const isDev = VITE_APP_ENV === 'development' |
| | | isDev |
| | | ? router.push({ path: '/login' }) |
| | | : window.location.replace(`${VITE_APP_PARENT_SYSTEM}/#/login`) |
| | | }) |
| | | } |
| | | |
| | | //http request拦截 |
| | | axios.interceptors.request.use( |
| | |
| | | const currentRouteName = router.currentRoute.value.name |
| | | // 如果当前路由不是登录页,则跳转到登录页 |
| | | if (currentRouteName !== '登录页') { |
| | | store.dispatch('FedLogOut').then(() => |
| | | router.push({ |
| | | path: '/login', |
| | | }) |
| | | ) |
| | | logOutFun() |
| | | } |
| | | return Promise.reject(new Error(message)) |
| | | } |
| | |
| | | </template> |
| | | |
| | | <script> |
| | | import { mapGetters } from 'vuex'; |
| | | import { validatenull } from 'utils/validate'; |
| | | import { registerGuest } from '@/api/user'; |
| | | import { getTopUrl } from 'utils/util'; |
| | | import { info } from '@/api/system/tenant'; |
| | | import { resetRouter } from '@/router/index'; |
| | | import { mapGetters } from 'vuex' |
| | | import { validatenull } from 'utils/validate' |
| | | import { registerGuest } from '@/api/user' |
| | | import { getTopUrl, logOutFun } from 'utils/util' |
| | | import { info } from '@/api/system/tenant' |
| | | import { resetRouter } from '@/router/index' |
| | | |
| | | export default { |
| | | name: 'thirdRegister', |
| | |
| | | loading: false, |
| | | tenantMode: true, |
| | | accountBox: false, |
| | | }; |
| | | } |
| | | }, |
| | | computed: { |
| | | ...mapGetters(['userInfo']), |
| | | }, |
| | | created() { |
| | | this.getTenant(); |
| | | this.getTenant() |
| | | }, |
| | | mounted() { |
| | | // 若未登录则弹出框进行绑定 |
| | | if (validatenull(this.userInfo.user_id) || this.userInfo.user_id < 0) { |
| | | this.form.name = this.userInfo.user_name; |
| | | this.form.account = this.userInfo.account; |
| | | this.accountBox = true; |
| | | this.form.name = this.userInfo.user_name |
| | | this.form.account = this.userInfo.account |
| | | this.accountBox = true |
| | | } |
| | | }, |
| | | methods: { |
| | | handleRegister() { |
| | | if (this.form.tenantId === '') { |
| | | this.$message.warning('请先输入租户编号'); |
| | | return; |
| | | this.$message.warning('请先输入租户编号') |
| | | return |
| | | } |
| | | if (this.form.account === '') { |
| | | this.$message.warning('请先输入账号名称'); |
| | | return; |
| | | this.$message.warning('请先输入账号名称') |
| | | return |
| | | } |
| | | if (this.form.password === '' || this.form.password2 === '') { |
| | | this.$message.warning('请先输入密码'); |
| | | return; |
| | | this.$message.warning('请先输入密码') |
| | | return |
| | | } |
| | | if (this.form.password !== this.form.password2) { |
| | | this.$message.warning('两次密码输入不一致'); |
| | | return; |
| | | this.$message.warning('两次密码输入不一致') |
| | | return |
| | | } |
| | | this.loading = true; |
| | | this.loading = true |
| | | registerGuest(this.form, this.userInfo.oauth_id).then( |
| | | res => { |
| | | this.loading = false; |
| | | const data = res.data; |
| | | this.loading = false |
| | | const data = res.data |
| | | if (data.success) { |
| | | this.accountBox = false; |
| | | this.accountBox = false |
| | | this.$alert('注册申请已提交,请耐心等待管理员通过!', '注册提示').then(() => { |
| | | this.$store.dispatch('LogOut').then(() => { |
| | | resetRouter(); |
| | | this.$router.push({ path: '/login' }); |
| | | }); |
| | | }); |
| | | resetRouter() |
| | | logOutFun() |
| | | }) |
| | | }) |
| | | } else { |
| | | this.$message.error(data.msg || '提交失败'); |
| | | this.$message.error(data.msg || '提交失败') |
| | | } |
| | | }, |
| | | error => { |
| | | window.console.log(error); |
| | | this.loading = false; |
| | | window.console.log(error) |
| | | this.loading = false |
| | | } |
| | | ); |
| | | ) |
| | | }, |
| | | getTenant() { |
| | | let domain = getTopUrl(); |
| | | let domain = getTopUrl() |
| | | // 临时指定域名,方便测试 |
| | | //domain = "https://bladex.cn"; |
| | | info(domain).then(res => { |
| | | const data = res.data; |
| | | const data = res.data |
| | | if (data.success && data.data.tenantId) { |
| | | this.form.tenantId = data.data.tenantId; |
| | | this.tenantMode = false; |
| | | this.form.tenantId = data.data.tenantId |
| | | this.tenantMode = false |
| | | } |
| | | }); |
| | | }) |
| | | }, |
| | | }, |
| | | }; |
| | | } |
| | | </script> |
| | |
| | | import index from '@/mixins/index' |
| | | import topLock from '@/page/index/top/top-lock.vue' |
| | | |
| | | |
| | | import { logOutFun } from '@/utils/util' |
| | | |
| | | export default { |
| | | mixins: [index], |
| | | components: { |
| | |
| | | logout () { |
| | | this.$store.commit('SET_THEME_NAME', '') |
| | | this.$store.dispatch('LogOut').then(() => { |
| | | this.$router.push({ path: '/login' }) |
| | | setTimeout(() => location.reload()) |
| | | logOutFun() |
| | | }) |
| | | }, |
| | | startTimer () { |
| | |
| | | <script> |
| | | import { mapGetters } from 'vuex'; |
| | | |
| | | |
| | | import { logOutFun } from '@/utils/util' |
| | | |
| | | export default { |
| | | data() { |
| | | return { |
| | |
| | | methods: { |
| | | handleLogout() { |
| | | this.$store.dispatch('LogOut').then(() => { |
| | | this.$router.push({ path: '/login' }); |
| | | logOutFun() |
| | | }); |
| | | }, |
| | | handleLogin() { |
| | |
| | | import topQna from './top-qna.vue' |
| | | import topSetting from '../setting.vue' |
| | | |
| | | |
| | | import { logOutFun } from '@/utils/util' |
| | | |
| | | export default { |
| | | components: { |
| | | topLock, |
| | |
| | | confirmButtonClass: 'command-message-box-confirm', |
| | | cancelButtonClass: 'command-message-box-cancel', |
| | | }).then(() => { |
| | | this.$store.dispatch('LogOut').then(() => { |
| | | const { VITE_APP_PARENT_SYSTEM, VITE_APP_ENV } = import.meta.env |
| | | const isDev = VITE_APP_ENV === 'development' |
| | | isDev |
| | | ? this.$router.push({ path: '/login' }) |
| | | : window.location.replace(`${VITE_APP_PARENT_SYSTEM}/#/login`) |
| | | }) |
| | | logOutFun() |
| | | }) |
| | | }, |
| | | jumpMH () { |
| | |
| | | import { useConnectWebSocket } from '@/utils/websocket/connect-websocket' |
| | | import { useStore } from 'vuex' |
| | | import dayjs from 'dayjs' |
| | | import { aLinkDownloadUtil } from '@/utils/util' |
| | | import { aLinkDownloadUtil, logOutFun } from '@/utils/util' |
| | | import EventBus from '@/utils/eventBus' |
| | | import { getStore, setStore } from '@/utils/store' |
| | | |
| | |
| | | |
| | | const logOut = () => { |
| | | store.commit('SET_THEME_NAME', '') |
| | | store.dispatch('LogOut').then(() => { |
| | | router.push({ path: '/login' }) |
| | | setTimeout(() => location.reload()) |
| | | }) |
| | | logOutFun() |
| | | } |
| | | function messageHandler(payload) { |
| | | switch (payload.biz_code) { |
| | |
| | | <div class="lock-form animate__animated animate__bounceInDown"> |
| | | <div class="animate__animated" :class="{ shake: passwdError, animate__bounceOut: pass }"> |
| | | <h3 style="color: #333">{{ userInfo.username }}</h3> |
| | | <el-input placeholder="请输入登录密码" type="password" class="input-with-select animated" v-model="passwd" |
| | | @keyup.enter="handleLogin"> |
| | | <el-input |
| | | placeholder="请输入登录密码" |
| | | type="password" |
| | | class="input-with-select animated" |
| | | v-model="passwd" |
| | | @keyup.enter="handleLogin" |
| | | > |
| | | <template #append> |
| | | <i class="icon-bofangqi-suoping" @click="handleLogin"></i> |
| | | |
| | |
| | | import { mapGetters } from 'vuex' |
| | | import { removeRefreshToken, removeToken } from '@/utils/auth' |
| | | import { ElMessage, ElMessageBox } from 'element-plus' |
| | | import { logOutFun } from '@/utils/util' |
| | | |
| | | export default { |
| | | name: 'lock', |
| | |
| | | confirmButtonClass: 'command-message-box-confirm', |
| | | cancelButtonClass: 'command-message-box-cancel', |
| | | }).then(() => { |
| | | this.$store.dispatch('LogOut').then(() => { |
| | | // 清除token信息 |
| | | removeToken() |
| | | removeRefreshToken() |
| | | this.$router.push({ path: '/login' }) |
| | | }) |
| | | logOutFun() |
| | | }) |
| | | }, |
| | | handleLogin () { |
| | |
| | | import { getToken } from '@/utils/auth' |
| | | import { getUrlParams } from './utils/validate' |
| | | import NProgress from 'nprogress' // progress bar |
| | | import 'nprogress/nprogress.css' // progress bar style |
| | | import 'nprogress/nprogress.css' |
| | | import { logOutFun } from '@/utils/util' |
| | | // progress bar style |
| | | NProgress.configure({ showSpinner: false }) |
| | | const lockPage = '/lock' //锁屏页 |
| | | const urlParams = getUrlParams(window.location.href) |
| | |
| | | } else { |
| | | const systemToken = store.getters.token || urlParams?.token |
| | | if (systemToken === 0) { |
| | | store.dispatch('FedLogOut').then(() =>{ |
| | | const {VITE_APP_PARENT_SYSTEM,VITE_APP_ENV} = import.meta.env |
| | | const isDev = VITE_APP_ENV === 'development' |
| | | isDev |
| | | ? router.push({ path: '/login' }) |
| | | : window.location.replace(`${VITE_APP_PARENT_SYSTEM}/#/login`) |
| | | }) |
| | | logOutFun() |
| | | } else { |
| | | const meta = to.meta || {} |
| | | const query = to.query || {} |
| | |
| | | next() |
| | | } else { |
| | | next('/login') |
| | | logOutFun() |
| | | } |
| | | } |
| | | }) |
| | |
| | | commit('CLEAR_LOCK') |
| | | removeToken() |
| | | removeRefreshToken() |
| | | removeToken() |
| | | resolve() |
| | | localStorage.clear() |
| | | }) |
| | | .catch(error => { |
| | | reject(error) |
| | | }) |
| | | }) |
| | | }, |
| | | //注销session |
| | | FedLogOut ({ commit }) { |
| | | return new Promise(resolve => { |
| | | commit('SET_TOKEN', '') |
| | | commit('SET_MENU_ALL_NULL', []) |
| | | commit('SET_MENU', []) |
| | | commit('SET_ROLES', []) |
| | | commit('DEL_ALL_TAG', []) |
| | | commit('CLEAR_LOCK') |
| | | removeToken() |
| | | removeRefreshToken() |
| | | removeToken() |
| | | resolve() |
| | | localStorage.clear() |
| | | }) |
| | | }, |
| | | GetTopMenu () { |
| | |
| | | /* |
| | | * @Author : yuan |
| | | * @Date : 2026-01-06 09:47:09 |
| | | * @LastEditors : yuan |
| | | * @LastEditTime : 2026-01-06 11:03:04 |
| | | * @FilePath : \applications\drone-command\src\utils\auth.js |
| | | * @Description : |
| | | * Copyright 2026 OBKoro1, All Rights Reserved. |
| | | * 2026-01-06 09:47:09 |
| | | */ |
| | | import Cookies from 'js-cookie'; |
| | | import Cookies from 'js-cookie' |
| | | |
| | | const TokenKey = 'command-access-token'; |
| | | const TokenKey = 'command-access-token' |
| | | const RefreshTokenKey = 'command-refresh-token'; |
| | | const SessionId = 'JSESSIONID'; |
| | | const UserId = 'b-user-id'; |
| | | |
| | | export function getToken() { |
| | | return Cookies.get(TokenKey, { |
| | | path: '/' |
| | |
| | | } |
| | | |
| | | export function removeRefreshToken() { |
| | | return Cookies.remove(RefreshTokenKey); |
| | | return Cookies.remove(RefreshTokenKey) |
| | | } |
| | | |
| | |
| | | a.click() |
| | | document.body.removeChild(a) |
| | | a = null |
| | | } |
| | | // 统一退出登录 |
| | | export function logOutFun() { |
| | | // 延迟导入 store 和 router,避免循环依赖: |
| | | // auth.js → router → store → user.js → auth.js |
| | | const store = require('@/store').default |
| | | const router = require('@/router').default |
| | | const { VITE_APP_PARENT_SYSTEM, VITE_APP_ENV } = import.meta.env |
| | | store.dispatch('LogOut').then(() => { |
| | | const isDev = VITE_APP_ENV === 'development' |
| | | if (isDev) { |
| | | router.push({ path: '/login' }) |
| | | setTimeout(() => location.reload()) |
| | | } else { |
| | | window.location.replace(`${VITE_APP_PARENT_SYSTEM}/#/login`) |
| | | } |
| | | }) |
| | | } |
| | |
| | | import axios from 'axios' |
| | | import store from '@/store/' |
| | | import router from '@/router/' |
| | | import { serialize } from '@/utils/util' |
| | | import { logOutFun, serialize } from '@/utils/util' |
| | | import { getToken, removeToken, removeRefreshToken } from '@/utils/auth' |
| | | import { isURL, validatenull } from '@/utils/validate' |
| | | import { ElMessage } from 'element-plus' |
| | |
| | | withCredentials: true, |
| | | }) |
| | | |
| | | function logOutFun() { |
| | | store.dispatch('FedLogOut').then(() =>{ |
| | | const {VITE_APP_PARENT_SYSTEM,VITE_APP_ENV} = import.meta.env |
| | | const isDev = VITE_APP_ENV === 'development' |
| | | isDev |
| | | ? router.push({ path: '/login' }) |
| | | : window.location.replace(`${VITE_APP_PARENT_SYSTEM}/#/login`) |
| | | }) |
| | | } |
| | | |
| | | |
| | | //http request拦截 |
| | |
| | | const currentRouteName = router.currentRoute.value.name |
| | | // 如果当前路由不是登录页,则跳转到登录页 |
| | | if (currentRouteName !== '登录页') { |
| | | store.dispatch('FedLogOut').then(() => |
| | | router.push({ |
| | | path: '/login', |
| | | }) |
| | | ) |
| | | logOutFun() |
| | | } |
| | | return Promise.reject(new Error(message)) |
| | | } |
| | |
| | | import { mapGetters } from 'vuex'; |
| | | import { validatenull } from 'utils/validate'; |
| | | import { registerGuest } from '@/api/user'; |
| | | import { getTopUrl } from 'utils/util'; |
| | | import { getTopUrl, logOutFun } from 'utils/util'; |
| | | import { info } from '@/api/system/tenant'; |
| | | import { resetRouter } from '@/router/index'; |
| | | |
| | |
| | | this.$alert('注册申请已提交,请耐心等待管理员通过!', '注册提示').then(() => { |
| | | this.$store.dispatch('LogOut').then(() => { |
| | | resetRouter(); |
| | | this.$router.push({ path: '/login' }); |
| | | logOutFun(); |
| | | }); |
| | | }); |
| | | } else { |
| | |
| | | }, |
| | | logout () { |
| | | this.$store.commit('SET_THEME_NAME', '') |
| | | this.$store.dispatch('LogOut').then(() => { |
| | | this.$router.push({ path: '/login' }) |
| | | setTimeout(() => location.reload()) |
| | | }) |
| | | logOutFun() |
| | | }, |
| | | startTimer () { |
| | | setInterval(() => { |
| | |
| | | </template> |
| | | <script> |
| | | import { mapGetters } from 'vuex'; |
| | | import { logOutFun } from '@/utils/util' |
| | | |
| | | export default { |
| | | data() { |
| | |
| | | }, |
| | | methods: { |
| | | handleLogout() { |
| | | this.$store.dispatch('LogOut').then(() => { |
| | | this.$router.push({ path: '/login' }); |
| | | }); |
| | | logOutFun() |
| | | }, |
| | | handleLogin() { |
| | | if (this.passwd != this.lockPasswd) { |
| | |
| | | import topFull from './top-full.vue' |
| | | import topQna from './top-qna.vue' |
| | | import topSetting from '../setting.vue' |
| | | import { logOutFun } from '@/utils/util' |
| | | |
| | | export default { |
| | | components: { |
| | |
| | | cancelButtonText: this.$t('cancelText'), |
| | | type: 'warning', |
| | | }).then(() => { |
| | | this.$store.dispatch('LogOut').then(() => { |
| | | const {VITE_APP_PARENT_SYSTEM,VITE_APP_ENV} = import.meta.env |
| | | const isDev = VITE_APP_ENV === 'development' |
| | | isDev |
| | | ? this.$router.push({ path: '/login' }) |
| | | : window.location.replace(`${VITE_APP_PARENT_SYSTEM}/#/login`) |
| | | }) |
| | | logOutFun() |
| | | }) |
| | | }, |
| | | jumpMH () { |
| | |
| | | import { useConnectWebSocket } from '@/utils/websocket/connect-websocket' |
| | | import { useStore } from 'vuex' |
| | | import dayjs from 'dayjs' |
| | | import { aLinkDownloadUtil } from '@/utils/util' |
| | | import { aLinkDownloadUtil, logOutFun } from '@/utils/util' |
| | | import EventBus from '@/utils/eventBus' |
| | | import { getStore, setStore } from '@/utils/store' |
| | | |
| | |
| | | |
| | | const logOut = () => { |
| | | store.commit('SET_THEME_NAME', '') |
| | | store.dispatch('LogOut').then(() => { |
| | | router.push({ path: '/login' }) |
| | | setTimeout(() => location.reload()) |
| | | }) |
| | | logOutFun() |
| | | } |
| | | function messageHandler(payload) { |
| | | switch (payload.biz_code) { |
| | |
| | | <script> |
| | | import { mapGetters } from 'vuex'; |
| | | import { removeRefreshToken, removeToken } from '@/utils/auth'; |
| | | import { logOutFun } from '@/utils/util' |
| | | |
| | | export default { |
| | | name: 'lock', |
| | |
| | | cancelButtonText: '取消', |
| | | type: 'warning', |
| | | }).then(() => { |
| | | this.$store.dispatch('LogOut').then(() => { |
| | | // 清除token信息 |
| | | removeToken(); |
| | | removeRefreshToken(); |
| | | this.$router.push({ path: '/login' }); |
| | | }); |
| | | logOutFun() |
| | | }); |
| | | }, |
| | | handleLogin() { |
| | |
| | | import { getToken } from '@/utils/auth' |
| | | import { getUrlParams } from './utils/validate' |
| | | import NProgress from 'nprogress' // progress bar |
| | | import 'nprogress/nprogress.css' // progress bar style |
| | | import 'nprogress/nprogress.css' |
| | | import { logOutFun } from '@/utils/util' // progress bar style |
| | | NProgress.configure({ showSpinner: false }) |
| | | const lockPage = '/lock' //锁屏页 |
| | | const urlParams = getUrlParams(window.location.href) |
| | |
| | | } else { |
| | | const systemToken = store.getters.token || urlParams?.token |
| | | if (systemToken === 0) { |
| | | store.dispatch('FedLogOut').then(() =>{ |
| | | const {VITE_APP_PARENT_SYSTEM,VITE_APP_ENV} = import.meta.env |
| | | const isDev = VITE_APP_ENV === 'development' |
| | | isDev |
| | | ? router.push({ path: '/login' }) |
| | | : window.location.replace(`${VITE_APP_PARENT_SYSTEM}/#/login`) |
| | | }) |
| | | logOutFun() |
| | | } else { |
| | | const meta = to.meta || {} |
| | | const query = to.query || {} |
| | |
| | | next() |
| | | } else { |
| | | next('/login') |
| | | logOutFun() |
| | | // env === 'development' ? next('/login') : window.location.replace(`${adminUrl}#/login`) |
| | | } |
| | | } |
| | |
| | | import { setToken, setRefreshToken, removeToken, removeRefreshToken, getRefreshToken } from '@/utils/auth' |
| | | import { setStore, getStore } from '@/utils/store' |
| | | import { validatenull } from '@/utils/validate' |
| | | import { deepClone } from '@/utils/util' |
| | | import { deepClone, logOutFun } from '@/utils/util' |
| | | import defaultAva from '@/assets/images/defaultava.png' |
| | | import { |
| | | loginByUsername, |
| | |
| | | }, |
| | | GetMenu({ commit, dispatch }, tenantId) { |
| | | const errLogOut = () => { |
| | | dispatch('LogOut').then(() => { |
| | | const env = import.meta.env.VITE_APP_ENV |
| | | const adminUrl = import.meta.env.VITE_APP_DASHBOARD_URL |
| | | (window.location.href = '/task-work-order/login') |
| | | // env === 'development' |
| | | // ? (window.location.href = '/task-work-order/login') |
| | | // : window.location.replace(`${adminUrl}#/login`) |
| | | }) |
| | | logOutFun() |
| | | } |
| | | return new Promise(resolve => { |
| | | getRoutes({ tenantId, sysType: 6 }) |
| | |
| | | document.body.removeChild(a) |
| | | a = null |
| | | } |
| | | |
| | | // 统一退出登录 |
| | | export function logOutFun() { |
| | | // 延迟导入 store 和 router,避免循环依赖: |
| | | // auth.js → router → store → user.js → auth.js |
| | | const store = require('@/store').default |
| | | const router = require('@/router').default |
| | | const { VITE_APP_PARENT_SYSTEM, VITE_APP_ENV } = import.meta.env |
| | | store.dispatch('LogOut').then(() => { |
| | | const isDev = VITE_APP_ENV === 'development' |
| | | if (isDev) { |
| | | router.push({ path: '/login' }) |
| | | setTimeout(() => location.reload()) |
| | | } else { |
| | | window.location.replace(`${VITE_APP_PARENT_SYSTEM}/#/login`) |
| | | } |
| | | }) |
| | | } |