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,39 +1,22 @@
|
||||||
<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() {
|
||||||
|
|
||||||
data() {
|
|
||||||
return {
|
|
||||||
[symbols.PAGE_INFO]: {
|
|
||||||
title: 'API',
|
|
||||||
icon: 'fas fa-key',
|
|
||||||
bg: 'var(--bg)',
|
|
||||||
},
|
|
||||||
isDesktop: window.innerWidth >= 1100,
|
|
||||||
};
|
|
||||||
},
|
|
||||||
|
|
||||||
methods: {
|
|
||||||
generateToken() {
|
|
||||||
os.popup(defineAsyncComponent(() => import('@/components/token-generate-window.vue')), {}, {
|
os.popup(defineAsyncComponent(() => import('@/components/token-generate-window.vue')), {}, {
|
||||||
done: async result => {
|
done: async result => {
|
||||||
const { name, permissions } = result;
|
const { name, permissions } = result;
|
||||||
|
@ -45,12 +28,18 @@ export default defineComponent({
|
||||||
|
|
||||||
os.alert({
|
os.alert({
|
||||||
type: 'success',
|
type: 'success',
|
||||||
title: this.$ts.token,
|
title: i18n.ts.token,
|
||||||
text: 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