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>
</template>
<script lang="ts">
<script lang="ts" setup>
import { defineComponent } from 'vue';
import MkButton from '@/components/ui/button.vue';
import * as os from '@/os';
export default defineComponent({
components: {
MkButton
},
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');
});
},
const emit = defineEmits<{
(ev: 'denied'): void;
(ev: 'accepted'): void;
}>();
accept() {
os.api('auth/accept', {
token: this.session.token
}).then(() => {
this.$emit('accepted');
});
}
}
});
const props = defineProps<{
session: {
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(() => {
emit('denied');
});
}
function accept() {
os.api('auth/accept', {
token: props.session.token,
}).then(() => {
emit('accepted');
});
}
</script>