refactor pages/auth.form.vue to composition API

This commit is contained in:
Johann150 2022-07-25 21:57:19 +02:00 committed by ThatOneCalculator
parent d93a6752a0
commit 5972640a17

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: {
}).then(() => { name: string;
this.$emit('accepted'); 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> </script>