Merge remote-tracking branch 'refs/remotes/origin/dev_tide' into dev
# Conflicts:
# package.json
# src/permission.js
# src/router/index.js
# vite.config.js
| | |
| | | VITE_APP_BASE_API = '/prod-api'
|
| | |
|
| | | # æ¯å¦å¨æå
æ¶å¼å¯åç¼©ï¼æ¯æ gzip å brotli
|
| | | VITE_BUILD_COMPRESS = gzip |
| | | VITE_BUILD_COMPRESS = gzip
|
| | |
| | | { |
| | | "name": "ruoyi", |
| | | "version": "3.8.9", |
| | | "description": "åºæºæ²¹äºç®¡çç³»ç»", |
| | | "description": "MES", |
| | | "author": "è¥ä¾", |
| | | "license": "MIT", |
| | | "type": "module", |
| | |
| | | data: data
|
| | | })
|
| | | }
|
| | |
|
| | | export function tideLogin(data) {
|
| | | return request({
|
| | | url: '/tide/tideLogin',
|
| | | headers: {
|
| | | isToken: false,
|
| | | repeatSubmit: false
|
| | | },
|
| | | method: 'post',
|
| | | data: data
|
| | | })
|
| | | }
|
| | |
| | | import router from "./router";
|
| | | import { ElMessage } from "element-plus";
|
| | | import NProgress from "nprogress";
|
| | | import "nprogress/nprogress.css";
|
| | | import { getToken } from "@/utils/auth";
|
| | | import { isHttp, isPathMatch } from "@/utils/validate";
|
| | | import { isRelogin } from "@/utils/request";
|
| | | import useUserStore from "@/store/modules/user";
|
| | | import useSettingsStore from "@/store/modules/settings";
|
| | | import usePermissionStore from "@/store/modules/permission";
|
| | | import router from './router'
|
| | | import { ElMessage } from 'element-plus'
|
| | | import NProgress from 'nprogress'
|
| | | import 'nprogress/nprogress.css'
|
| | | import { getToken } from '@/utils/auth'
|
| | | import { isHttp, isPathMatch } from '@/utils/validate'
|
| | | import { isRelogin } from '@/utils/request'
|
| | | import useUserStore from '@/store/modules/user'
|
| | | import useSettingsStore from '@/store/modules/settings'
|
| | | import usePermissionStore from '@/store/modules/permission'
|
| | |
|
| | | NProgress.configure({ showSpinner: false });
|
| | | NProgress.configure({ showSpinner: false })
|
| | |
|
| | | const whiteList = ["/login", "/register", "/device-info"];
|
| | | const whiteList = ['/login', '/register', '/callbacklccpn']
|
| | |
|
| | | const isWhiteList = (path) => {
|
| | | return whiteList.some((pattern) => isPathMatch(pattern, path));
|
| | | };
|
| | | return whiteList.some(pattern => isPathMatch(pattern, path))
|
| | | }
|
| | |
|
| | | router.beforeEach((to, from, next) => {
|
| | | NProgress.start();
|
| | | NProgress.start()
|
| | | if (getToken()) {
|
| | | to.meta.title && useSettingsStore().setTitle(to.meta.title);
|
| | | to.meta.title && useSettingsStore().setTitle(to.meta.title)
|
| | | /* has token*/
|
| | | if (to.path === "/login") {
|
| | | next({ path: "/" });
|
| | | NProgress.done();
|
| | | if (to.path === '/login') {
|
| | | next({ path: '/' })
|
| | | NProgress.done()
|
| | | } else if (isWhiteList(to.path)) {
|
| | | next();
|
| | | next()
|
| | | } else {
|
| | | if (useUserStore().roles.length === 0) {
|
| | | isRelogin.show = true;
|
| | | isRelogin.show = true
|
| | | // 夿å½åç¨æ·æ¯å¦å·²æåå®user_infoä¿¡æ¯
|
| | | useUserStore()
|
| | | .getInfo()
|
| | | .then(() => {
|
| | | isRelogin.show = false;
|
| | | usePermissionStore()
|
| | | .generateRoutes()
|
| | | .then((accessRoutes) => {
|
| | | // æ ¹æ®rolesæéçæå¯è®¿é®çè·¯ç±è¡¨
|
| | | accessRoutes.forEach((route) => {
|
| | | if (!isHttp(route.path)) {
|
| | | router.addRoute(route); // å¨ææ·»å å¯è®¿é®è·¯ç±è¡¨
|
| | | }
|
| | | });
|
| | | next({ ...to, replace: true }); // hackæ¹æ³ ç¡®ä¿addRoutes已宿
|
| | | });
|
| | | useUserStore().getInfo().then(() => {
|
| | | isRelogin.show = false
|
| | | usePermissionStore().generateRoutes().then(accessRoutes => {
|
| | | // æ ¹æ®rolesæéçæå¯è®¿é®çè·¯ç±è¡¨
|
| | | accessRoutes.forEach(route => {
|
| | | if (!isHttp(route.path)) {
|
| | | router.addRoute(route) // å¨ææ·»å å¯è®¿é®è·¯ç±è¡¨
|
| | | }
|
| | | })
|
| | | next({ ...to, replace: true }) // hackæ¹æ³ ç¡®ä¿addRoutes已宿
|
| | | })
|
| | | .catch((err) => {
|
| | | useUserStore()
|
| | | .logOut()
|
| | | .then(() => {
|
| | | ElMessage.error(err);
|
| | | next({ path: "/" });
|
| | | });
|
| | | });
|
| | | }).catch(err => {
|
| | | useUserStore().logOut().then(() => {
|
| | | ElMessage.error(err)
|
| | | next({ path: '/' })
|
| | | })
|
| | | })
|
| | | } else {
|
| | | next();
|
| | | next()
|
| | | }
|
| | | }
|
| | | } else {
|
| | | // 没ætoken
|
| | | if (isWhiteList(to.path)) {
|
| | | // å¨å
ç»å½ç½ååï¼ç´æ¥è¿å
¥
|
| | | next();
|
| | | next()
|
| | | } else {
|
| | | next(`/login?redirect=${to.fullPath}`); // å¦åå
¨é¨éå®åå°ç»å½é¡µ
|
| | | NProgress.done();
|
| | | next(`/login?redirect=${to.fullPath}`) // å¦åå
¨é¨éå®åå°ç»å½é¡µ
|
| | | NProgress.done()
|
| | | }
|
| | | }
|
| | | });
|
| | | })
|
| | |
|
| | | router.afterEach(() => {
|
| | | NProgress.done();
|
| | | });
|
| | | NProgress.done()
|
| | | })
|
| | |
| | | hidden: true |
| | | }, |
| | | { |
| | | path: "/callbacklccpn", |
| | | component: () => import("@/views/tideLogin.vue"), |
| | | hidden: true, |
| | | }, |
| | | { |
| | | path: '/register', |
| | | component: () => import('@/views/register'), |
| | | hidden: true |
| | |
| | | component: () => import('@/views/index'), |
| | | name: 'Index', |
| | | meta: { title: 'é¦é¡µ', icon: 'dashboard', affix: true } |
| | | } |
| | | ] |
| | | }, |
| | | { |
| | | path: '/main/MobileChat', |
| | | component: Layout, |
| | | redirect: '', |
| | | hidden: true, |
| | | children: [ |
| | | { |
| | | path: '', |
| | | component: () => import('@/views/chatHome/chatHomeIndex/MobileChat'), |
| | | name: 'MobileChat', |
| | | meta: { title: 'AI对è¯', icon: 'dashboard', affix: true} |
| | | } |
| | | ] |
| | | }, |
| | |
| | | component: () => import('@/views/system/user/authRole'), |
| | | name: 'AuthRole', |
| | | meta: { title: 'åé
è§è²', activeMenu: '/system/user' } |
| | | } |
| | | ] |
| | | }, |
| | | { |
| | | path: '/main/MobileChat', |
| | | component: Layout, |
| | | redirect: '', |
| | | hidden: true, |
| | | permissions: ['MobileChat:edit'], |
| | | children: [ |
| | | { |
| | | path: '', |
| | | component: () => import('@/views/chatHome/chatHomeIndex/MobileChat'), |
| | | name: 'MobileChat', |
| | | meta: { title: 'AI对è¯', activeMenu: '/chatHome/chatHomeIndex'} |
| | | } |
| | | ] |
| | | }, |
| | |
| | | import {login, logout, getInfo, loginCheck, loginCheckFactory} from '@/api/login'
|
| | | import {login, logout, getInfo, loginCheck, loginCheckFactory,tideLogin} from '@/api/login'
|
| | | import { getToken, setToken, removeToken } from '@/utils/auth'
|
| | | import { isHttp, isEmpty } from "@/utils/validate"
|
| | | import defAva from '@/assets/images/profile.jpg'
|
| | |
| | | })
|
| | | })
|
| | | },
|
| | | TideLogin({ commit }, code) {
|
| | | return new Promise((resolve, reject) => {
|
| | | tideLogin(code)
|
| | | .then((res) => {
|
| | | setToken(res.token);
|
| | | commit("SET_TOKEN", res.token);
|
| | | Vue.prototype.uploadHeader = {
|
| | | Authorization: "Bearer " + res.token,
|
| | | };
|
| | | resolve();
|
| | | })
|
| | | .catch((error) => {
|
| | | reject(error);
|
| | | });
|
| | | });
|
| | | },
|
| | | }
|
| | | })
|
| | |
|
¶Ô±ÈÐÂÎļþ |
| | |
| | | <template> |
| | | <div></div> |
| | | </template> |
| | | <script> |
| | | import store from "@/store"; |
| | | export default { |
| | | data() { |
| | | return {} |
| | | }, |
| | | created() { |
| | | this.goLogin() |
| | | }, |
| | | computed: {}, |
| | | methods: { |
| | | goLogin() { |
| | | store.dispatch('TideLogin', {code : this.$route.query.code}).then(() => { |
| | | this.$router.push({ path: this.redirect || "/" }).catch(() => { }); |
| | | }) |
| | | } |
| | | } |
| | | } |
| | | </script> |
| | | <style scoped></style> |
| | |
| | | const { VITE_APP_ENV } = env;
|
| | | const baseUrl =
|
| | | VITE_APP_ENV == "development"
|
| | | ? "http://114.132.189.42:8089" // å¼åç¯å¢å端æ¥å£
|
| | | // : "http://114.132.189.42:8068"; // é¦å¾·å®ä¸ç产ç¯å¢å端æ¥å£
|
| | | : "http://114.132.189.42:8078"; // åºæºæ²¹äºç产ç¯å¢å端æ¥å£
|
| | | ? "http://192.168.1.147:7003" // å¼åç¯å¢å端æ¥å£
|
| | | : "http://10.136.12.71:7003"; // ç产ç¯å¢å端æ¥å£
|
| | |
|
| | | return {
|
| | | // é¨ç½²ç产ç¯å¢åå¼åç¯å¢ä¸çURLã
|