mirror of
https://activitypub.software/TransFem-org/Sharkey.git
synced 2024-12-15 00:55:48 +01:00
refactor(client): refactor settings/api to use Composition API (#8569)
This commit is contained in:
parent
6226e8d902
commit
c72f5e2773
1 changed files with 28 additions and 39 deletions
|
@ -1,56 +1,45 @@
|
||||||
<template>
|
<template>
|
||||||
<div class="_formRoot">
|
<div class="_formRoot">
|
||||||
<FormButton primary class="_formBlock" @click="generateToken">{{ $ts.generateAccessToken }}</FormButton>
|
<FormButton primary class="_formBlock" @click="generateToken">{{ i18n.ts.generateAccessToken }}</FormButton>
|
||||||
<FormLink to="/settings/apps" class="_formBlock">{{ $ts.manageAccessTokens }}</FormLink>
|
<FormLink to="/settings/apps" class="_formBlock">{{ i18n.ts.manageAccessTokens }}</FormLink>
|
||||||
<FormLink to="/api-console" :behavior="isDesktop ? 'window' : null" class="_formBlock">API console</FormLink>
|
<FormLink to="/api-console" :behavior="isDesktop ? 'window' : null" class="_formBlock">API console</FormLink>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts" setup>
|
||||||
import { defineAsyncComponent, defineComponent } from 'vue';
|
import { defineAsyncComponent, defineExpose, ref } from 'vue';
|
||||||
import FormLink from '@/components/form/link.vue';
|
import FormLink from '@/components/form/link.vue';
|
||||||
import FormButton from '@/components/ui/button.vue';
|
import FormButton from '@/components/ui/button.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 isDesktop = ref(window.innerWidth >= 1100);
|
||||||
components: {
|
|
||||||
FormButton,
|
|
||||||
FormLink,
|
|
||||||
},
|
|
||||||
|
|
||||||
emits: ['info'],
|
function generateToken() {
|
||||||
|
os.popup(defineAsyncComponent(() => import('@/components/token-generate-window.vue')), {}, {
|
||||||
|
done: async result => {
|
||||||
|
const { name, permissions } = result;
|
||||||
|
const { token } = await os.api('miauth/gen-token', {
|
||||||
|
session: null,
|
||||||
|
name: name,
|
||||||
|
permission: permissions,
|
||||||
|
});
|
||||||
|
|
||||||
data() {
|
os.alert({
|
||||||
return {
|
type: 'success',
|
||||||
[symbols.PAGE_INFO]: {
|
title: i18n.ts.token,
|
||||||
title: 'API',
|
text: token
|
||||||
icon: 'fas fa-key',
|
});
|
||||||
bg: 'var(--bg)',
|
|
||||||
},
|
|
||||||
isDesktop: window.innerWidth >= 1100,
|
|
||||||
};
|
|
||||||
},
|
|
||||||
|
|
||||||
methods: {
|
|
||||||
generateToken() {
|
|
||||||
os.popup(defineAsyncComponent(() => import('@/components/token-generate-window.vue')), {}, {
|
|
||||||
done: async result => {
|
|
||||||
const { name, permissions } = result;
|
|
||||||
const { token } = await os.api('miauth/gen-token', {
|
|
||||||
session: null,
|
|
||||||
name: name,
|
|
||||||
permission: permissions,
|
|
||||||
});
|
|
||||||
|
|
||||||
os.alert({
|
|
||||||
type: 'success',
|
|
||||||
title: this.$ts.token,
|
|
||||||
text: token
|
|
||||||
});
|
|
||||||
},
|
|
||||||
}, 'closed');
|
|
||||||
},
|
},
|
||||||
|
}, 'closed');
|
||||||
|
}
|
||||||
|
|
||||||
|
defineExpose({
|
||||||
|
[symbols.PAGE_INFO]: {
|
||||||
|
title: 'API',
|
||||||
|
icon: 'fas fa-key',
|
||||||
|
bg: 'var(--bg)',
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
Loading…
Reference in a new issue