mirror of
https://github.com/misskey-dev/misskey.git
synced 2024-12-24 00:39:32 +09:00
refactor(client): refactor settings/api to use Composition API (#8569)
This commit is contained in:
parent
6226e8d902
commit
c72f5e2773
@ -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 New Issue
Block a user