Skip to content

Commit

Permalink
feat: other login
Browse files Browse the repository at this point in the history
  • Loading branch information
dawnwinterLiu committed Nov 3, 2023
1 parent a3311b8 commit 006a560
Show file tree
Hide file tree
Showing 7 changed files with 87 additions and 29 deletions.
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@dgiot/dgiot-dashboard",
"version": "4.8.5",
"version": "4.8.6",
"author": "xxb",
"license": "MPL-2.0",
"private": false,
Expand Down Expand Up @@ -65,8 +65,10 @@
"@material/icon-button": "13.0.0",
"amis": "1.9.1-beta.11",
"amis-editor": "4.1.0-beta.24",
"cache-loader": "^4.1.0",
"driver.js": "^0.9.8",
"pnpm": "^7.3.0",
"rc-input-number": "7.3.11",
"register-service-worker": "1.7.2",
"resize-detector": "0.3.0",
"vditor": "^3.8.15",
Expand Down
8 changes: 8 additions & 0 deletions src/api/User/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,14 @@ export function Sitepro(pro) {
})
}

export function checkoutToken(tempToken) {
return request({
url: '/checkoutToken?tempToken=' + tempToken,
method: 'get',
data: {},
})
}

// export function login(username, password) {
// return request({
// url: 'auth/login',
Expand Down
46 changes: 30 additions & 16 deletions src/dgiot/plugins/permissions.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ import DgiotProgress from 'nprogress'
// import 'nprogress/nprogress.css'
import getPageTitle from '@/utils/vue/pageTitle'
import { toLoginRoute } from '@/utils/router/routes'
import { checkoutToken, login } from '@/api/User'

import {
authentication,
loginInterception,
Expand All @@ -28,6 +30,7 @@ DgiotProgress.configure({
trickleSpeed: 200,
showSpinner: false,
})

router.beforeEach(async (to, from, next) => {
window.errRoute = null
store.dispatch('routes/setRoutesOpenTime', {
Expand All @@ -36,19 +39,39 @@ router.beforeEach(async (to, from, next) => {
})
if (to.name == '404') {
window.errRoute = to
console.log('dgiot router log---')
console.log(to)

return false
}
if (to.query.tempToken) {
let checkoutflag = false
await checkoutToken(to.query.tempToken).then((res) => {
if (res.code == 200) {
checkoutflag = true
}
})
if (checkoutflag) {
Vue.prototype.$baseMessage(
Vue.prototype.$translateTitle(`token有效,登录跳转中`),
'success'
)
await store.dispatch('user/login', {
username: 'dgiot',
password: 'w9943535dsgfgdsgdsertet',
})
} else {
Vue.prototype.$baseMessage(
Vue.prototype.$translateTitle(`token已失效。`),
'error'
)
}
}
const { showProgressBar } = store.getters['settings/theme']
if (showProgressBar) DgiotProgress.start()
let hasToken = store.getters['user/token']

// let hasToken = store.getters['user/token']
let hasToken = localStorage.getItem('sessionToken')
if (!loginInterception) hasToken = true
if (hasToken) {
if (store.getters['routes/routes'].length) {
// 这里判断下存储的路由表 并且过滤掉白名单
// dgiotlog.log(store.getters['routes/routes'])
// 禁止已登录用户返回登录页
if (to.path === '/login') {
next({
Expand Down Expand Up @@ -83,16 +106,7 @@ router.beforeEach(async (to, from, next) => {
}
} else {
if (routesWhiteList.includes(to.path)) {
// 设置游客路由(不需要可以删除)
if (supportVisit && !store.getters['routes/routes'].length) {
await store.dispatch('routes/setRoutes', 'visit')
next({
...to,
replace: true,
})
} else {
next()
}
next()
} else {
next(toLoginRoute(to))
}
Expand Down
1 change: 1 addition & 0 deletions src/store/modules/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -427,6 +427,7 @@ const actions = {
localStorage.setItem('homeScreen', homeScreen)
localStorage.setItem('background', background)
localStorage.setItem('rolename', roles[0].name)
localStorage.setItem('sessionToken', sessionToken)
// console.log('不是pc端', isPC())
if (!isPC()) {
window.jstoken?.setJsToken(
Expand Down
33 changes: 33 additions & 0 deletions src/views/CloudFunction/topo/components/TopoTabs.vue
Original file line number Diff line number Diff line change
Expand Up @@ -873,6 +873,39 @@
"
/>
<el-divider />
<div style="text-align: left; margin: 10px; font-weight: 600">
低代码视图组件
</div>
<img
draggable="true"
size="mini"
:src="$FileServe + '/dgiot_file/topo/png/amiscomponent.png'"
style="
width: 70px;
height: 40px;
display: inline-block;
margin-left: 20px;
"
type="primary"
@click="
createBasicThing({
productid: $route.query.productid,
type: 'amiscomponent',
data: {
id: `a8d787d0ec`, //amis_${new Date().getTime()}
width: 500,
height: 350,
fill: 'rgba(23, 37, 76, 0.7)',
text: '低代码视图组件',
source: 'api',
src: '/dgiot_file/topo/png/amiscomponent.png',
},
chart: 'amisview',
hidden: false,
})
"
/>
<el-divider />
</a-collapse-panel>
<a-collapse-panel key="99" :header="'低代码组件'">
<img
Expand Down
21 changes: 10 additions & 11 deletions src/views/DeviceCloud/manage/home_index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@
slot="prepend"
>
<el-option label="设备名称" value="name" />
<el-option label="资产编号" value="detail.assetNum" />
<el-option label="设备编号" value="detail.assetNum" />
<el-option label="设备地址" value="devaddr" />
</el-select>
</el-input>
Expand Down Expand Up @@ -547,14 +547,14 @@
sortable
width="120"
/>
<!-- <el-table-column-->
<!-- align="center"-->
<!-- label="资产编号"-->
<!-- prop="detail.assetNum"-->
<!-- show-overflow-tooltip-->
<!-- sortable-->
<!-- width="120"-->
<!-- />-->
<el-table-column
align="center"
label="设备编号"
prop="detail.assetNum"
show-overflow-tooltip
sortable
width="120"
/>
<el-table-column
align="center"
:label="$translateTitle('Maintenance.maintenance_personnel')"
Expand Down Expand Up @@ -915,8 +915,7 @@
selectRows: '',
queryForm: {
type: 'name',
excludeKeys:
'channel,children,config,thing,decoder,data,basedata,content',
excludeKeys: 'channel,children,config,thing,decoder,data,content',
include: 'product',
product: this.$route.query.product ? this.$route.query.product : '',
title: '',
Expand Down
3 changes: 2 additions & 1 deletion src/views/MultiTenant/user/login/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@
import { isPassword } from '@/utils/data/validate'
import { SiteDefault } from '@/api/License'
import { Roletree } from '@/api/Menu'
import { checkoutToken, getUser } from '@/api/User'
export default {
name: 'Login',
Expand Down Expand Up @@ -240,7 +241,7 @@
await this.init()
})
},
created() {
async created() {
this.$removeToken()
this.isShow = window.name == 'dgiot_iframe' ? false : true
window.addEventListener('message', this.iframeLogin)
Expand Down

0 comments on commit 006a560

Please sign in to comment.