2020-03-27 19:24:37 -07:00
|
|
|
<template>
|
2020-12-18 17:55:52 -08:00
|
|
|
<div v-if="$i">
|
2020-10-17 04:12:00 -07:00
|
|
|
<div class="waiting _section" v-if="state == 'waiting'">
|
2020-03-27 19:24:37 -07:00
|
|
|
<div class="_content">
|
2020-10-17 04:12:00 -07:00
|
|
|
<MkLoading/>
|
2020-03-27 19:24:37 -07:00
|
|
|
</div>
|
|
|
|
</div>
|
2020-10-17 04:12:00 -07:00
|
|
|
<div class="denied _section" v-if="state == 'denied'">
|
2020-03-27 19:24:37 -07:00
|
|
|
<div class="_content">
|
2020-12-25 17:47:36 -08:00
|
|
|
<p>{{ $ts._auth.denied }}</p>
|
2020-03-27 19:24:37 -07:00
|
|
|
</div>
|
|
|
|
</div>
|
2020-10-17 04:12:00 -07:00
|
|
|
<div class="accepted _section" v-else-if="state == 'accepted'">
|
2020-03-27 19:24:37 -07:00
|
|
|
<div class="_content">
|
2020-12-25 17:47:36 -08:00
|
|
|
<p v-if="callback">{{ $ts._auth.callback }}<MkEllipsis/></p>
|
|
|
|
<p v-else>{{ $ts._auth.pleaseGoBack }}</p>
|
2020-03-27 19:24:37 -07:00
|
|
|
</div>
|
|
|
|
</div>
|
2020-10-17 04:12:00 -07:00
|
|
|
<div class="_section" v-else>
|
2020-03-27 19:24:37 -07:00
|
|
|
<div class="_title" v-if="name">{{ $t('_auth.shareAccess', { name: name }) }}</div>
|
2020-12-25 17:47:36 -08:00
|
|
|
<div class="_title" v-else>{{ $ts._auth.shareAccessAsk }}</div>
|
2020-03-27 19:24:37 -07:00
|
|
|
<div class="_content">
|
2020-12-25 17:47:36 -08:00
|
|
|
<p>{{ $ts._auth.permissionAsk }}</p>
|
2020-03-27 19:24:37 -07:00
|
|
|
<ul>
|
2020-10-17 04:12:00 -07:00
|
|
|
<li v-for="p in permission" :key="p">{{ $t(`_permissions.${p}`) }}</li>
|
2020-03-27 19:24:37 -07:00
|
|
|
</ul>
|
|
|
|
</div>
|
|
|
|
<div class="_footer">
|
2020-12-25 17:47:36 -08:00
|
|
|
<MkButton @click="deny" inline>{{ $ts.cancel }}</MkButton>
|
|
|
|
<MkButton @click="accept" inline primary>{{ $ts.accept }}</MkButton>
|
2020-03-27 19:24:37 -07:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="signin" v-else>
|
2020-10-17 04:12:00 -07:00
|
|
|
<MkSignin @login="onLogin"/>
|
2020-03-27 19:24:37 -07:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
2020-10-17 04:12:00 -07:00
|
|
|
import { defineComponent } from 'vue';
|
2021-03-23 01:30:14 -07:00
|
|
|
import MkSignin from '@client/components/signin.vue';
|
|
|
|
import MkButton from '@client/components/ui/button.vue';
|
|
|
|
import * as os from '@client/os';
|
|
|
|
import { login } from '@client/account';
|
2020-03-27 19:24:37 -07:00
|
|
|
|
2020-10-17 04:12:00 -07:00
|
|
|
export default defineComponent({
|
2020-03-27 19:24:37 -07:00
|
|
|
components: {
|
|
|
|
MkSignin,
|
|
|
|
MkButton,
|
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
state: null
|
|
|
|
};
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
session(): string {
|
|
|
|
return this.$route.params.session;
|
|
|
|
},
|
|
|
|
callback(): string {
|
|
|
|
return this.$route.query.callback;
|
|
|
|
},
|
|
|
|
name(): string {
|
|
|
|
return this.$route.query.name;
|
|
|
|
},
|
2020-03-28 02:33:24 -07:00
|
|
|
icon(): string {
|
|
|
|
return this.$route.query.icon;
|
|
|
|
},
|
2020-03-29 01:04:22 -07:00
|
|
|
permission(): string[] {
|
|
|
|
return this.$route.query.permission ? this.$route.query.permission.split(',') : [];
|
2020-03-27 19:24:37 -07:00
|
|
|
},
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
async accept() {
|
|
|
|
this.state = 'waiting';
|
2020-10-17 04:12:00 -07:00
|
|
|
await os.api('miauth/gen-token', {
|
2020-03-27 19:24:37 -07:00
|
|
|
session: this.session,
|
|
|
|
name: this.name,
|
2020-03-28 02:33:24 -07:00
|
|
|
iconUrl: this.icon,
|
2020-03-29 01:04:22 -07:00
|
|
|
permission: this.permission,
|
2020-03-27 19:24:37 -07:00
|
|
|
});
|
|
|
|
|
|
|
|
this.state = 'accepted';
|
|
|
|
if (this.callback) {
|
|
|
|
location.href = `${this.callback}?session=${this.session}`;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
deny() {
|
|
|
|
this.state = 'denied';
|
|
|
|
},
|
|
|
|
onLogin(res) {
|
2020-12-18 17:55:52 -08:00
|
|
|
login(res.i);
|
2020-03-27 19:24:37 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
|
|
|
|
</style>
|