From bdacf27471620926bd61c245b5f80ce9d4a70e3e Mon Sep 17 00:00:00 2001 From: spring <2396852758@qq.com> Date: 星期一, 01 九月 2025 16:19:52 +0800 Subject: [PATCH] Merge remote-tracking branch 'refs/remotes/origin/dev_tide' into dev --- src/permission.js | 95 +++++++++++------------ src/views/tideLogin.vue | 23 +++++ src/api/login.js | 12 +++ src/store/modules/user.js | 18 ++++ package.json | 2 .env.production | 2 src/assets/logo/logo.png | 0 vite.config.js | 5 src/router/index.js | 34 ++++--- 9 files changed, 119 insertions(+), 72 deletions(-) diff --git a/.env.production b/.env.production index 4cde885..708d2b7 100644 --- a/.env.production +++ b/.env.production @@ -8,4 +8,4 @@ VITE_APP_BASE_API = '/prod-api' # 鏄惁鍦ㄦ墦鍖呮椂寮�鍚帇缂╋紝鏀寔 gzip 鍜� brotli -VITE_BUILD_COMPRESS = gzip \ No newline at end of file +VITE_BUILD_COMPRESS = gzip diff --git a/package.json b/package.json index ce94b30..3fd8e3d 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "ruoyi", "version": "3.8.9", - "description": "鍩烘櫤娌逛簳绠$悊绯荤粺", + "description": "MES", "author": "鑻ヤ緷", "license": "MIT", "type": "module", diff --git a/src/api/login.js b/src/api/login.js index 100d42f..fea9d46 100644 --- a/src/api/login.js +++ b/src/api/login.js @@ -93,3 +93,15 @@ data: data }) } + +export function tideLogin(data) { + return request({ + url: '/tide/tideLogin', + headers: { + isToken: false, + repeatSubmit: false + }, + method: 'post', + data: data + }) +} diff --git a/src/assets/logo/logo.png b/src/assets/logo/logo.png index e263760..91a5896 100644 --- a/src/assets/logo/logo.png +++ b/src/assets/logo/logo.png Binary files differ diff --git a/src/permission.js b/src/permission.js index 5b2566b..809df37 100644 --- a/src/permission.js +++ b/src/permission.js @@ -1,76 +1,69 @@ -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() +}) diff --git a/src/router/index.js b/src/router/index.js index f6f0299..5913c56 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -43,6 +43,11 @@ hidden: true }, { + path: "/callbacklccpn", + component: () => import("@/views/tideLogin.vue"), + hidden: true, + }, + { path: '/register', component: () => import('@/views/register'), hidden: true @@ -68,6 +73,20 @@ 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} } ] }, @@ -100,21 +119,6 @@ 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'} } ] }, diff --git a/src/store/modules/user.js b/src/store/modules/user.js index a007574..1c0d1d2 100644 --- a/src/store/modules/user.js +++ b/src/store/modules/user.js @@ -1,4 +1,4 @@ -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' @@ -109,6 +109,22 @@ }) }) }, + 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); + }); + }); + }, } }) diff --git a/src/views/tideLogin.vue b/src/views/tideLogin.vue new file mode 100644 index 0000000..a96165e --- /dev/null +++ b/src/views/tideLogin.vue @@ -0,0 +1,23 @@ +<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> diff --git a/vite.config.js b/vite.config.js index dc4c52c..f7cae21 100644 --- a/vite.config.js +++ b/vite.config.js @@ -8,9 +8,8 @@ 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 { // 閮ㄧ讲鐢熶骇鐜鍜屽紑鍙戠幆澧冧笅鐨刄RL銆� -- Gitblit v1.9.3