forked from FoundKeyGang/FoundKey
refactor(client): refactor settings/security to use Composition API (#8592)
This commit is contained in:
parent
1f222e6cd1
commit
f8c66be130
1 changed files with 61 additions and 75 deletions
|
@ -1,17 +1,17 @@
|
||||||
<template>
|
<template>
|
||||||
<div class="_formRoot">
|
<div class="_formRoot">
|
||||||
<FormSection>
|
<FormSection>
|
||||||
<template #label>{{ $ts.password }}</template>
|
<template #label>{{ i18n.ts.password }}</template>
|
||||||
<FormButton primary @click="change()">{{ $ts.changePassword }}</FormButton>
|
<FormButton primary @click="change()">{{ i18n.ts.changePassword }}</FormButton>
|
||||||
</FormSection>
|
</FormSection>
|
||||||
|
|
||||||
<FormSection>
|
<FormSection>
|
||||||
<template #label>{{ $ts.twoStepAuthentication }}</template>
|
<template #label>{{ i18n.ts.twoStepAuthentication }}</template>
|
||||||
<X2fa/>
|
<X2fa/>
|
||||||
</FormSection>
|
</FormSection>
|
||||||
|
|
||||||
<FormSection>
|
<FormSection>
|
||||||
<template #label>{{ $ts.signinHistory }}</template>
|
<template #label>{{ i18n.ts.signinHistory }}</template>
|
||||||
<MkPagination :pagination="pagination">
|
<MkPagination :pagination="pagination">
|
||||||
<template v-slot="{items}">
|
<template v-slot="{items}">
|
||||||
<div>
|
<div>
|
||||||
|
@ -30,15 +30,15 @@
|
||||||
|
|
||||||
<FormSection>
|
<FormSection>
|
||||||
<FormSlot>
|
<FormSlot>
|
||||||
<FormButton danger @click="regenerateToken"><i class="fas fa-sync-alt"></i> {{ $ts.regenerateLoginToken }}</FormButton>
|
<FormButton danger @click="regenerateToken"><i class="fas fa-sync-alt"></i> {{ i18n.ts.regenerateLoginToken }}</FormButton>
|
||||||
<template #caption>{{ $ts.regenerateLoginTokenDescription }}</template>
|
<template #caption>{{ i18n.ts.regenerateLoginTokenDescription }}</template>
|
||||||
</FormSlot>
|
</FormSlot>
|
||||||
</FormSection>
|
</FormSection>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts" setup>
|
||||||
import { defineComponent } from 'vue';
|
import { defineExpose } from 'vue';
|
||||||
import FormSection from '@/components/form/section.vue';
|
import FormSection from '@/components/form/section.vue';
|
||||||
import FormSlot from '@/components/form/slot.vue';
|
import FormSlot from '@/components/form/slot.vue';
|
||||||
import FormButton from '@/components/ui/button.vue';
|
import FormButton from '@/components/ui/button.vue';
|
||||||
|
@ -46,48 +46,28 @@ import MkPagination from '@/components/ui/pagination.vue';
|
||||||
import X2fa from './2fa.vue';
|
import X2fa from './2fa.vue';
|
||||||
import * as os from '@/os';
|
import * as os from '@/os';
|
||||||
import * as symbols from '@/symbols';
|
import * as symbols from '@/symbols';
|
||||||
|
import { i18n } from '@/i18n';
|
||||||
|
|
||||||
export default defineComponent({
|
const pagination = {
|
||||||
components: {
|
|
||||||
FormSection,
|
|
||||||
FormButton,
|
|
||||||
MkPagination,
|
|
||||||
FormSlot,
|
|
||||||
X2fa,
|
|
||||||
},
|
|
||||||
|
|
||||||
emits: ['info'],
|
|
||||||
|
|
||||||
data() {
|
|
||||||
return {
|
|
||||||
[symbols.PAGE_INFO]: {
|
|
||||||
title: this.$ts.security,
|
|
||||||
icon: 'fas fa-lock',
|
|
||||||
bg: 'var(--bg)',
|
|
||||||
},
|
|
||||||
pagination: {
|
|
||||||
endpoint: 'i/signin-history' as const,
|
endpoint: 'i/signin-history' as const,
|
||||||
limit: 5,
|
limit: 5,
|
||||||
},
|
};
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
methods: {
|
async function change() {
|
||||||
async change() {
|
|
||||||
const { canceled: canceled1, result: currentPassword } = await os.inputText({
|
const { canceled: canceled1, result: currentPassword } = await os.inputText({
|
||||||
title: this.$ts.currentPassword,
|
title: i18n.ts.currentPassword,
|
||||||
type: 'password'
|
type: 'password'
|
||||||
});
|
});
|
||||||
if (canceled1) return;
|
if (canceled1) return;
|
||||||
|
|
||||||
const { canceled: canceled2, result: newPassword } = await os.inputText({
|
const { canceled: canceled2, result: newPassword } = await os.inputText({
|
||||||
title: this.$ts.newPassword,
|
title: i18n.ts.newPassword,
|
||||||
type: 'password'
|
type: 'password'
|
||||||
});
|
});
|
||||||
if (canceled2) return;
|
if (canceled2) return;
|
||||||
|
|
||||||
const { canceled: canceled3, result: newPassword2 } = await os.inputText({
|
const { canceled: canceled3, result: newPassword2 } = await os.inputText({
|
||||||
title: this.$ts.newPasswordRetype,
|
title: i18n.ts.newPasswordRetype,
|
||||||
type: 'password'
|
type: 'password'
|
||||||
});
|
});
|
||||||
if (canceled3) return;
|
if (canceled3) return;
|
||||||
|
@ -95,7 +75,7 @@ export default defineComponent({
|
||||||
if (newPassword !== newPassword2) {
|
if (newPassword !== newPassword2) {
|
||||||
os.alert({
|
os.alert({
|
||||||
type: 'error',
|
type: 'error',
|
||||||
text: this.$ts.retypedNotMatch
|
text: i18n.ts.retypedNotMatch
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -104,11 +84,11 @@ export default defineComponent({
|
||||||
currentPassword,
|
currentPassword,
|
||||||
newPassword
|
newPassword
|
||||||
});
|
});
|
||||||
},
|
}
|
||||||
|
|
||||||
regenerateToken() {
|
function regenerateToken() {
|
||||||
os.inputText({
|
os.inputText({
|
||||||
title: this.$ts.password,
|
title: i18n.ts.password,
|
||||||
type: 'password'
|
type: 'password'
|
||||||
}).then(({ canceled, result: password }) => {
|
}).then(({ canceled, result: password }) => {
|
||||||
if (canceled) return;
|
if (canceled) return;
|
||||||
|
@ -116,7 +96,13 @@ export default defineComponent({
|
||||||
password: password
|
password: password
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
},
|
}
|
||||||
|
|
||||||
|
defineExpose({
|
||||||
|
[symbols.PAGE_INFO]: {
|
||||||
|
title: i18n.ts.security,
|
||||||
|
icon: 'fas fa-lock',
|
||||||
|
bg: 'var(--bg)',
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
Loading…
Reference in a new issue