-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
崔庆才丨静觅
authored
Jan 2, 2024
1 parent
c5d5b47
commit c82f04e
Showing
11 changed files
with
95 additions
and
20 deletions.
There are no files selected for viewing
7 changes: 7 additions & 0 deletions
7
change/@zhishuyun-hub-8ef393bb-8bf8-4e7c-b165-250df21c65ac.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"type": "minor", | ||
"comment": "add auth modal", | ||
"packageName": "@zhishuyun/hub", | ||
"email": "[email protected]", | ||
"dependentChangeType": "patch" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
<template> | ||
<el-dialog | ||
:model-value="!authenticated" | ||
modal-class="dialog" | ||
width="400px" | ||
:show-close="false" | ||
:close-on-press-escape="false" | ||
:close-on-click-modal="false" | ||
> | ||
<iframe width="360" height="560" :src="iframeUrl" frameborder="0" /> | ||
</el-dialog> | ||
</template> | ||
|
||
<script lang="ts"> | ||
import { defineComponent } from 'vue'; | ||
import { ElDialog } from 'element-plus'; | ||
import { getBaseUrlAuth } from '@/utils'; | ||
export default defineComponent({ | ||
name: 'AuthPanel', | ||
components: { | ||
ElDialog | ||
}, | ||
data() { | ||
return { | ||
iframeUrl: `${getBaseUrlAuth()}/auth/login` | ||
}; | ||
}, | ||
computed: { | ||
authenticated() { | ||
return !!this.$store.state.token.access; | ||
} | ||
}, | ||
mounted() { | ||
window.addEventListener('message', async (event: MessageEvent) => { | ||
if (event.origin !== getBaseUrlAuth()) { | ||
return; | ||
} | ||
if (event.data.name === 'login') { | ||
const data = event.data.data; | ||
const token = { | ||
access: data.access_token, | ||
refresh: data.refresh_token, | ||
expiration: data.expires_in | ||
}; | ||
await this.$store.dispatch('setToken', token); | ||
await this.$store.dispatch('getUser'); | ||
window.location.reload(); | ||
} | ||
}); | ||
} | ||
}); | ||
</script> | ||
|
||
<style lang="scss" scoped> | ||
.dialog { | ||
width: 400px; | ||
height: 600px; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters