2020-03-27 19:24:37 -07:00
|
|
|
<template>
|
2020-12-18 17:55:52 -08:00
|
|
|
<div v-if="$i">
|
2021-11-19 02:36:12 -08:00
|
|
|
<div v-if="state == 'waiting'" class="waiting _section">
|
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>
|
2021-11-19 02:36:12 -08:00
|
|
|
<div v-if="state == 'denied'" class="denied _section">
|
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>
|
2021-11-19 02:36:12 -08:00
|
|
|
<div v-else-if="state == 'accepted'" class="accepted _section">
|
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>
|
2021-11-19 02:36:12 -08:00
|
|
|
<div v-else class="_section">
|
|
|
|
<div v-if="name" class="_title">{{ $t('_auth.shareAccess', { name: name }) }}</div>
|
|
|
|
<div v-else class="_title">{{ $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">
|
2021-11-19 02:36:12 -08:00
|
|
|
<MkButton inline @click="deny">{{ $ts.cancel }}</MkButton>
|
|
|
|
<MkButton inline primary @click="accept">{{ $ts.accept }}</MkButton>
|
2020-03-27 19:24:37 -07:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
2021-11-19 02:36:12 -08:00
|
|
|
<div v-else class="signin">
|
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-11-11 09:02:25 -08:00
|
|
|
import MkSignin from '@/components/signin.vue';
|
|
|
|
import MkButton from '@/components/ui/button.vue';
|
|
|
|
import * as os from '@/os';
|
|
|
|
import { login } from '@/account';
|
2022-06-03 05:22:03 -07:00
|
|
|
import { appendQuery, query } from '@/scripts/url';
|
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) {
|
2022-06-03 05:22:03 -07:00
|
|
|
location.href = appendQuery(this.callback, query({
|
|
|
|
session: this.session
|
|
|
|
}));
|
2020-03-27 19:24:37 -07:00
|
|
|
}
|
|
|
|
},
|
|
|
|
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>
|