add verification support

This commit is contained in:
AceDataCloud committed 2022-04-05 19:38:04 +08:00
1 parent 91a5420a76
commit cc43fb39e8
10 files changed
+98 -29

No files matched your search

+47 -15
View File
@@ -3,25 +3,57 @@
<script lang="ts">
import { defineComponent } from 'vue';
import { ElMessageBox } from 'element-plus';
import AuthService from '@/services/auth/service';
import { ITokenResponse } from '@/services/auth/types';
export default defineComponent({
name: 'VerificationAlert',
mounted() {
ElMessageBox.alert(this.$t('auth.message.needVerification'), this.$t('common.message.info'), {
confirmButtonText: this.$t('common.button.verify'),
// cancelButtonText: this.$t('common.button.cancel'),
type: 'warning',
center: true,
showClose: false,
'show-cancel-button': false,
'close-on-click-modal': false,
'close-on-press-escape': false,
'close-on-hash-change': false
})
.then(() => {
window.open('https://auth.test.zhishuyun.com/user/verify');
computed: {
verified() {
return this.$store.getters.user.isVerified;
},
refresh() {
return this.$route.query.refresh;
}
},
methods: {
checkAndShowVerificationAlert() {
if (this.verified) {
return;
}
ElMessageBox.alert(this.$t('auth.message.needVerification'), this.$t('common.message.info'), {
confirmButtonText: this.$t('common.button.verify'),
// cancelButtonText: this.$t('common.button.cancel'),
type: 'warning',
center: true,
showClose: false,
showCancelButton: false,
closeOnClickModal: false,
closeOnPressEscape: false,
closeOnHashChange: false
})
.catch(() => {});
.then(() => {
window.open('https://auth.test.zhishuyun.com/user/verify?redirect=' + window.location.href + '?refresh=1');
})
.catch(() => {});
}
},
async mounted() {
if (this.refresh) {
AuthService.refreshToken({
refresh: this.$store.getters.refreshToken
}).then(async ({ data: data }: { data: ITokenResponse }) => {
await this.$store.dispatch('setAccessToken', data.access);
await this.$store.dispatch('getMe');
this.$router.push({
...this.$route,
query: {}
});
this.checkAndShowVerificationAlert();
});
} else {
this.checkAndShowVerificationAlert();
}
}
});
</script>
+18 -4
View File
@@ -9,9 +9,13 @@ import { defineComponent } from 'vue';
import VuePlyr from 'vue-plyr';
import 'vue-plyr/dist/vue-plyr.css';
import Hls from 'hls.js';
import Plyr from 'plyr';
interface IData {
options: {};
player?: typeof VuePlyr;
mounted: boolean;
hls?: any;
}
export default defineComponent({
@@ -29,14 +33,24 @@ export default defineComponent({
},
data(): IData {
return {
options: {}
player: undefined,
options: {},
mounted: false,
hls: undefined
};
},
async unmounted() {
console.log('un');
this.player?.stop();
this.hls?.stopLoad();
},
mounted() {
this.mounted = true;
const video = this.$refs.video as HTMLMediaElement;
const hls = new Hls();
hls.loadSource(this.resource);
hls.attachMedia(video);
this.player = (this.$refs.plyr as typeof VuePlyr).player as Plyr;
this.hls = new Hls() as Hls;
this.hls?.loadSource(this.resource);
this.hls?.attachMedia(video);
}
});
</script>