2022-07-25 18:37:14 +02:00
|
|
|
<template>
|
|
|
|
<div>
|
|
|
|
<n-form-item label="Username">
|
|
|
|
<n-input v-model:value="username" placeholder="Your username..." clearable />
|
|
|
|
</n-form-item>
|
|
|
|
<n-form-item label="Password">
|
|
|
|
<n-input
|
|
|
|
v-model:value="password"
|
|
|
|
placeholder="Your password..."
|
|
|
|
type="password"
|
|
|
|
show-password-on="click"
|
|
|
|
clearable
|
|
|
|
/>
|
|
|
|
</n-form-item>
|
|
|
|
|
|
|
|
<n-card>
|
|
|
|
<n-statistic label="Authorization header:" class="header">
|
|
|
|
<n-scrollbar x-scrollable style="max-width: 550px; margin-bottom: -10px; padding-bottom: 10px" trigger="none">
|
|
|
|
{{ header }}
|
|
|
|
</n-scrollbar>
|
|
|
|
</n-statistic>
|
|
|
|
</n-card>
|
2023-04-19 22:44:22 +02:00
|
|
|
<n-space justify="center" mt-5>
|
2023-04-19 21:38:59 +02:00
|
|
|
<c-button @click="copy">Copy header</c-button>
|
2022-07-25 18:37:14 +02:00
|
|
|
</n-space>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script setup lang="ts">
|
|
|
|
import { useCopy } from '@/composable/copy';
|
2022-08-04 12:09:32 +02:00
|
|
|
import { textToBase64 } from '@/utils/base64';
|
2022-07-25 18:37:14 +02:00
|
|
|
import { computed, ref } from 'vue';
|
|
|
|
|
|
|
|
const username = ref('');
|
|
|
|
const password = ref('');
|
2022-08-04 12:09:32 +02:00
|
|
|
const header = computed(() => `Authorization: Basic ${textToBase64(`${username.value}:${password.value}`)}`);
|
2022-07-25 18:37:14 +02:00
|
|
|
|
|
|
|
const { copy } = useCopy({ source: header, text: 'Header copied to the clipboard' });
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="less" scoped>
|
|
|
|
::v-deep(.n-statistic-value__content) {
|
|
|
|
font-family: monospace;
|
|
|
|
font-size: 17px !important;
|
|
|
|
white-space: nowrap;
|
|
|
|
}
|
|
|
|
</style>
|