diff --git a/src/App.vue b/src/App.vue index fd811d8..2193592 100644 --- a/src/App.vue +++ b/src/App.vue @@ -11,14 +11,14 @@ export default { // console.log('已执行聊天机器人') // 在这里插入你的聊天机器人配置代码 window.difyChatbotConfig = { - token: 'pEaqgEzss5GXwtBk', - baseUrl: 'http://9552chyh1609.vicp.fun' + token: 'FwKMmP8HLst0WSG0', + baseUrl: 'https://dell.ezangao.cn' }; // 动态创建脚本元素并插入到文档中 const script = document.createElement('script'); - script.src = 'http://9552chyh1609.vicp.fun/embed.min.js'; - script.id = 'pEaqgEzss5GXwtBk'; + script.src = 'https://dell.ezangao.cn/embed.min.js'; + script.id = 'FwKMmP8HLst0WSG0'; script.defer = true; document.head.appendChild(script); }, diff --git a/src/permission.js b/src/permission.js index 5a2259b..dcf5bb1 100644 --- a/src/permission.js +++ b/src/permission.js @@ -5,12 +5,13 @@ import NProgress from 'nprogress' // progress bar import 'nprogress/nprogress.css' // progress bar style import { getToken } from '@/utils/auth' // get token from cookie import getPageTitle from '@/utils/get-page-title' +import { MessageBox } from 'element-ui' NProgress.configure({ showSpinner: false }) // NProgress Configuration const whiteList = ['/login', '/callback'] // no redirect whitelist -router.beforeEach(async(to, from, next) => { +router.beforeEach(async (to, from, next) => { // start progress bar NProgress.start() @@ -28,12 +29,47 @@ router.beforeEach(async(to, from, next) => { // 开发环境不启用ONEID if (isDevelopment) { console.log('开发环境,启用某些代码') - // 启用某些代码 + // 启用某些代码 } else if (isProduction) { console.log('生产环境,禁用某些代码') - // 禁用某些代码 + // 禁用某些代码 } + // 提示用户新网址并进行重定向 + // 添加一个开关变量 + const showMigrationAlert = false; // 设置为 false 可以禁用通知 + + const newUrl = 'https://cs-vsc.siemens.com.cn:444' + if (showMigrationAlert && to.path !== '/new-site') { + MessageBox.alert( + `
+

重要通知

+

本站点已迁移至新网址:

+ ${newUrl} +

本站点预计一月份底失效,请及时收藏新网址!

+
`, + '站点迁移通知', + { + dangerouslyUseHTMLString: true, + confirmButtonText: '收藏新网址', + showClose: false, + callback: action => { + if (action === 'confirm') { + const bookmark = document.createElement('a') + bookmark.href = newUrl + bookmark.title = '新网址' + bookmark.rel = 'sidebar' + bookmark.click() + } + window.location.href = newUrl + } + } + ) + return + } + + + if (hasToken) { if (to.path === '/login' || to.path === '/callback') { // if is logged in, redirect to the home page @@ -70,11 +106,14 @@ router.beforeEach(async(to, from, next) => { } else { // other pages that do not have permission to access are redirected to the login page. if (isDevelopment) { + // window.location.href = 'https://api.oneid.siemens.com.cn/api/bff/v1.2/developer/ciam/oauth/authorize?client_id=1b867769c8cb221fb7fdb0f8beba6138TwXkI4mX8um&response_type=code&redirect_uri=http://csdc.siemens.com.cn:8001/callback&scope=openid%20phone' + // window.location.href = 'https://api.oneid.siemens.com.cn/api/bff/v1.2/developer/ciam/oauth/authorize?client_id=1b867769c8cb221fb7fdb0f8beba6138TwXkI4mX8um&response_type=code&redirect_uri=https://cs-vsc.siemens.com.cn:444/callback&scope=openid%20phone' next(`/login?redirect=${to.path}`) } else { - window.location.href = 'https://api.oneid.siemens.com.cn/api/bff/v1.2/developer/ciam/oauth/authorize?client_id=1b867769c8cb221fb7fdb0f8beba6138TwXkI4mX8um&response_type=code&redirect_uri=http://csdc.siemens.com.cn:8001/callback&scope=openid%20phone' + // window.location.href = 'https://api.oneid.siemens.com.cn/api/bff/v1.2/developer/ciam/oauth/authorize?client_id=1b867769c8cb221fb7fdb0f8beba6138TwXkI4mX8um&response_type=code&redirect_uri=http://csdc.siemens.com.cn:8001/callback&scope=openid%20phone' // window.location.href = 'https://api.oneid.siemens.com.cn/api/bff/v1.2/developer/ciam/oauth/authorize?client_id=1b867769c8cb221fb7fdb0f8beba6138TwXkI4mX8um&response_type=code&redirect_uri=http://localhost:9528/callback&scope=openid%20phone' // window.location.href = 'https://api.oneid.siemens.com.cn/api/bff/v1.2/developer/ciam/oauth/authorize?client_id=1b867769c8cb221fb7fdb0f8beba6138TwXkI4mX8um&response_type=code&redirect_uri=https://cs-vsc.siemens.com.cn:444/callback&scope=openid%20phone' + next(`/login?redirect=${to.path}`) } NProgress.done() } diff --git a/src/views/callback/index.vue b/src/views/callback/index.vue index e32ce07..3bf1c1c 100644 --- a/src/views/callback/index.vue +++ b/src/views/callback/index.vue @@ -14,10 +14,6 @@ export default { }, async mounted() { // 获取 URL 参数中的 code - // const urlParams = new URLSearchParams(window.location.hash.substring(1)) - // const code = urlParams.get('code') - // alert('callback page') - // this.$router.push({ path: '/nav' }) const urlParams = new URLSearchParams(window.location.search) const code = urlParams.get('code') // 在这里可以将 code 发送到后端进行处理 @@ -27,8 +23,8 @@ export default { const response = await getOneIdToken(code) if (response) { console.log('🐱one自动登录接口状态:', response.code) + console.log('response.Token:' + response.data.token) if (response.code === 200) { - console.log('response.Token:' + response.data.token) // 存token this.$store.dispatch('user/commitToken', response.data.token) // 重新加载路由 这里不对 @@ -40,14 +36,16 @@ export default { } } else { console.log('No token found with code') - window.location.href = 'https://api.oneid.siemens.com.cn/api/bff/v1.2/developer/ciam/oauth/authorize?client_id=1b867769c8cb221fb7fdb0f8beba6138TwXkI4mX8um&response_type=code&redirect_uri=http://csdc.siemens.com.cn:8001/callback&scope=openid%20phone' + // window.location.href = 'https://api.oneid.siemens.com.cn/api/bff/v1.2/developer/ciam/oauth/authorize?client_id=1b867769c8cb221fb7fdb0f8beba6138TwXkI4mX8um&response_type=code&redirect_uri=http://csdc.siemens.com.cn:8001/callback&scope=openid%20phone' // window.location.href = 'https://api.oneid.siemens.com.cn/api/bff/v1.2/developer/ciam/oauth/authorize?client_id=1b867769c8cb221fb7fdb0f8beba6138TwXkI4mX8um&response_type=code&redirect_uri=http://localhost:9528/callback&scope=openid%20phone' + window.location.href = 'https://api.oneid.siemens.com.cn/api/bff/v1.2/developer/ciam/oauth/authorize?client_id=1b867769c8cb221fb7fdb0f8beba6138TwXkI4mX8um&response_type=code&redirect_uri=https://cs-vsc.siemens.com.cn:444/callback&scope=openid%20phone' } } else { // 如果没有 code,则处理错误, 跳转回登录页面 console.error('No code found in URL parameters.') - window.location.href = 'https://api.oneid.siemens.com.cn/api/bff/v1.2/developer/ciam/oauth/authorize?client_id=1b867769c8cb221fb7fdb0f8beba6138TwXkI4mX8um&response_type=code&redirect_uri=http://csdc.siemens.com.cn:8001/callback&scope=openid%20phone' + // window.location.href = 'https://api.oneid.siemens.com.cn/api/bff/v1.2/developer/ciam/oauth/authorize?client_id=1b867769c8cb221fb7fdb0f8beba6138TwXkI4mX8um&response_type=code&redirect_uri=http://csdc.siemens.com.cn:8001/callback&scope=openid%20phone' // window.location.href = 'https://api.oneid.siemens.com.cn/api/bff/v1.2/developer/ciam/oauth/authorize?client_id=1b867769c8cb221fb7fdb0f8beba6138TwXkI4mX8um&response_type=code&redirect_uri=http://localhost:9528/callback&scope=openid%20phone' + window.location.href = 'https://api.oneid.siemens.com.cn/api/bff/v1.2/developer/ciam/oauth/authorize?client_id=1b867769c8cb221fb7fdb0f8beba6138TwXkI4mX8um&response_type=code&redirect_uri=https://cs-vsc.siemens.com.cn:444/callback&scope=openid%20phone' // window.location.href = 'https://oneid.siemens.com.cn/frontend/login?idaasAppId=siemens_ciam2' } } diff --git a/vue.config.js b/vue.config.js index 4519719..c5486db 100644 --- a/vue.config.js +++ b/vue.config.js @@ -38,7 +38,7 @@ module.exports = { }, proxy: { [process.env.VUE_APP_BASE_API]: { - target: 'http://139.219.4.195:8003', + target: 'http://cs-vsc.siemens.com.cn:8003',//'http://139.219.4.195:8003', // 测试地址 // target: 'http://192.168.237.154:8003', pathRewrite: {