This commit is contained in:
syuilo 2022-02-16 22:42:47 +09:00
parent 7492a158d2
commit df9facac5b
2 changed files with 198 additions and 234 deletions

View File

@ -19,7 +19,16 @@
<div class="main"> <div class="main">
<MkStickyContainer> <MkStickyContainer>
<template #header><MkHeader v-if="childInfo && !childInfo.hideHeader" :info="childInfo"/></template> <template #header><MkHeader v-if="childInfo && !childInfo.hideHeader" :info="childInfo"/></template>
<suspense>
<template #default>
<component :is="component" :ref="el => pageChanged(el)" :key="page" v-bind="pageProps"/> <component :is="component" :ref="el => pageChanged(el)" :key="page" v-bind="pageProps"/>
</template>
<template #fallback>
<div>
Loading...
</div>
</template>
</suspense>
</MkStickyContainer> </MkStickyContainer>
</div> </div>
</div> </div>

View File

@ -1,6 +1,5 @@
<template> <template>
<MkSpacer :content-max="700" :margin-min="16" :margin-max="32"> <MkSpacer :content-max="700" :margin-min="16" :margin-max="32">
<FormSuspense :p="init">
<div class="_formRoot"> <div class="_formRoot">
<FormInput v-model="name" class="_formBlock"> <FormInput v-model="name" class="_formBlock">
<template #label>{{ $ts.instanceName }}</template> <template #label>{{ $ts.instanceName }}</template>
@ -134,135 +133,91 @@
</FormSwitch> </FormSwitch>
</FormSection> </FormSection>
</div> </div>
</FormSuspense>
</MkSpacer> </MkSpacer>
</template> </template>
<script lang="ts"> <script lang="ts" setup>
import { defineComponent } from 'vue'; import { } from 'vue';
import FormSwitch from '@/components/form/switch.vue'; import FormSwitch from '@/components/form/switch.vue';
import FormInput from '@/components/form/input.vue'; import FormInput from '@/components/form/input.vue';
import FormTextarea from '@/components/form/textarea.vue'; import FormTextarea from '@/components/form/textarea.vue';
import FormInfo from '@/components/ui/info.vue'; import FormInfo from '@/components/ui/info.vue';
import FormSection from '@/components/form/section.vue'; import FormSection from '@/components/form/section.vue';
import FormSplit from '@/components/form/split.vue'; import FormSplit from '@/components/form/split.vue';
import FormSuspense from '@/components/form/suspense.vue';
import * as os from '@/os'; import * as os from '@/os';
import * as symbols from '@/symbols'; import * as symbols from '@/symbols';
import { fetchInstance } from '@/instance'; import { fetchInstance } from '@/instance';
import { i18n } from '@/i18n';
export default defineComponent({ defineExpose({
components: {
FormSwitch,
FormInput,
FormSuspense,
FormTextarea,
FormInfo,
FormSection,
FormSplit,
},
emits: ['info'],
data() {
return {
[symbols.PAGE_INFO]: { [symbols.PAGE_INFO]: {
title: this.$ts.general, title: i18n.ts.general,
icon: 'fas fa-cog', icon: 'fas fa-cog',
bg: 'var(--bg)', bg: 'var(--bg)',
actions: [{ actions: [{
asFullButton: true, asFullButton: true,
icon: 'fas fa-check', icon: 'fas fa-check',
text: this.$ts.save, text: i18n.ts.save,
handler: this.save, handler: save,
}], }],
}, },
name: null, });
description: null,
tosUrl: null as string | null,
maintainerName: null,
maintainerEmail: null,
iconUrl: null,
bannerUrl: null,
backgroundImageUrl: null,
themeColor: null,
maxNoteTextLength: 0,
enableLocalTimeline: false,
enableGlobalTimeline: false,
pinnedUsers: '',
cacheRemoteFiles: false,
proxyRemoteFiles: false,
localDriveCapacityMb: 0,
remoteDriveCapacityMb: 0,
enableRegistration: false,
emailRequiredForSignup: false,
enableServiceWorker: false,
swPublicKey: null,
swPrivateKey: null,
deeplAuthKey: '',
deeplIsPro: false,
}
},
methods: {
async init() {
const meta = await os.api('meta', { detail: true }); const meta = await os.api('meta', { detail: true });
this.name = meta.name;
this.description = meta.description;
this.tosUrl = meta.tosUrl;
this.iconUrl = meta.iconUrl;
this.bannerUrl = meta.bannerUrl;
this.backgroundImageUrl = meta.backgroundImageUrl;
this.themeColor = meta.themeColor;
this.maintainerName = meta.maintainerName;
this.maintainerEmail = meta.maintainerEmail;
this.maxNoteTextLength = meta.maxNoteTextLength;
this.enableLocalTimeline = !meta.disableLocalTimeline;
this.enableGlobalTimeline = !meta.disableGlobalTimeline;
this.pinnedUsers = meta.pinnedUsers.join('\n');
this.cacheRemoteFiles = meta.cacheRemoteFiles;
this.proxyRemoteFiles = meta.proxyRemoteFiles;
this.localDriveCapacityMb = meta.driveCapacityPerLocalUserMb;
this.remoteDriveCapacityMb = meta.driveCapacityPerRemoteUserMb;
this.enableRegistration = !meta.disableRegistration;
this.emailRequiredForSignup = meta.emailRequiredForSignup;
this.enableServiceWorker = meta.enableServiceWorker;
this.swPublicKey = meta.swPublickey;
this.swPrivateKey = meta.swPrivateKey;
this.deeplAuthKey = meta.deeplAuthKey;
this.deeplIsPro = meta.deeplIsPro;
},
save() { let name = $ref(meta.name);
os.apiWithDialog('admin/update-meta', { let description = $ref(meta.description);
name: this.name, let tosUrl = $ref(meta.tosUrl);
description: this.description, let iconUrl = $ref(meta.iconUrl);
tosUrl: this.tosUrl, let bannerUrl = $ref(meta.bannerUrl);
iconUrl: this.iconUrl, let backgroundImageUrl = $ref(meta.backgroundImageUrl);
bannerUrl: this.bannerUrl, let themeColor = $ref(meta.themeColor);
backgroundImageUrl: this.backgroundImageUrl, let maintainerName = $ref(meta.maintainerName);
themeColor: this.themeColor === '' ? null : this.themeColor, let maintainerEmail = $ref(meta.maintainerEmail);
maintainerName: this.maintainerName, let maxNoteTextLength = $ref(meta.maxNoteTextLength);
maintainerEmail: this.maintainerEmail, let enableLocalTimeline = $ref(!meta.disableLocalTimeline);
maxNoteTextLength: this.maxNoteTextLength, let enableGlobalTimeline = $ref(!meta.disableGlobalTimeline);
disableLocalTimeline: !this.enableLocalTimeline, let pinnedUsers = $ref(meta.pinnedUsers.join('\n'));
disableGlobalTimeline: !this.enableGlobalTimeline, let cacheRemoteFiles = $ref(meta.cacheRemoteFiles);
pinnedUsers: this.pinnedUsers.split('\n'), let proxyRemoteFiles = $ref(meta.proxyRemoteFiles);
cacheRemoteFiles: this.cacheRemoteFiles, let localDriveCapacityMb = $ref(meta.driveCapacityPerLocalUserMb);
proxyRemoteFiles: this.proxyRemoteFiles, let remoteDriveCapacityMb = $ref(meta.driveCapacityPerRemoteUserMb);
localDriveCapacityMb: parseInt(this.localDriveCapacityMb, 10), let enableRegistration = $ref(!meta.disableRegistration);
remoteDriveCapacityMb: parseInt(this.remoteDriveCapacityMb, 10), let emailRequiredForSignup = $ref(meta.emailRequiredForSignup);
disableRegistration: !this.enableRegistration, let enableServiceWorker = $ref(meta.enableServiceWorker);
emailRequiredForSignup: this.emailRequiredForSignup, let swPublicKey = $ref(meta.swPublickey);
enableServiceWorker: this.enableServiceWorker, let swPrivateKey = $ref(meta.swPrivateKey);
swPublicKey: this.swPublicKey, let deeplAuthKey = $ref(meta.deeplAuthKey);
swPrivateKey: this.swPrivateKey, let deeplIsPro = $ref(meta.deeplIsPro);
deeplAuthKey: this.deeplAuthKey,
deeplIsPro: this.deeplIsPro, async function save() {
}).then(() => { await os.apiWithDialog('admin/update-meta', {
name: name,
description: description,
tosUrl: tosUrl,
iconUrl: iconUrl,
bannerUrl: bannerUrl,
backgroundImageUrl: backgroundImageUrl,
themeColor: themeColor === '' ? null : themeColor,
maintainerName: maintainerName,
maintainerEmail: maintainerEmail,
maxNoteTextLength: maxNoteTextLength,
disableLocalTimeline: !enableLocalTimeline,
disableGlobalTimeline: !enableGlobalTimeline,
pinnedUsers: pinnedUsers.split('\n'),
cacheRemoteFiles: cacheRemoteFiles,
proxyRemoteFiles: proxyRemoteFiles,
localDriveCapacityMb: parseInt(localDriveCapacityMb, 10),
remoteDriveCapacityMb: parseInt(remoteDriveCapacityMb, 10),
disableRegistration: !enableRegistration,
emailRequiredForSignup: emailRequiredForSignup,
enableServiceWorker: enableServiceWorker,
swPublicKey: swPublicKey,
swPrivateKey: swPrivateKey,
deeplAuthKey: deeplAuthKey,
deeplIsPro: deeplIsPro,
});
fetchInstance(); fetchInstance();
});
} }
}
});
</script> </script>