refactor pages/auth.form.vue to composition API

This commit is contained in:
Johann150 2022-07-25 21:57:19 +02:00
parent 4bc9610d8b
commit 0ece67b04c
Signed by untrusted user: Johann150
GPG key ID: 9EE6577A2A06F8F1

View file

@ -19,42 +19,43 @@
</section> </section>
</template> </template>
<script lang="ts"> <script lang="ts" setup>
import { defineComponent } from 'vue'; import { defineComponent } from 'vue';
import MkButton from '@/components/ui/button.vue'; import MkButton from '@/components/ui/button.vue';
import * as os from '@/os'; import * as os from '@/os';
export default defineComponent({ const emit = defineEmits<{
components: { (ev: 'denied'): void;
MkButton (ev: 'accepted'): void;
}, }>();
props: ['session'],
computed: {
name(): string {
const el = document.createElement('div');
el.textContent = this.app.name;
return el.innerHTML;
},
app(): any {
return this.session.app;
}
},
methods: {
cancel() {
os.api('auth/deny', {
token: this.session.token
}).then(() => {
this.$emit('denied');
});
},
accept() { const props = defineProps<{
os.api('auth/accept', { session: {
token: this.session.token app: {
name: string;
id: string;
description: string;
permission: string[];
};
token: string;
};
}>();
const app = props.session.app;
function cancel() {
os.api('auth/deny', {
token: props.session.token,
}).then(() => { }).then(() => {
this.$emit('accepted'); emit('denied');
}); });
} }
}
}); function accept() {
os.api('auth/accept', {
token: props.session.token,
}).then(() => {
emit('accepted');
});
}
</script> </script>