mizzkey/packages/frontend/src/pages/settings/plugin.install.vue

61 lines
1.4 KiB
Vue
Raw Normal View History

<!--
SPDX-FileCopyrightText: syuilo and other misskey contributors
SPDX-License-Identifier: AGPL-3.0-only
-->
2021-02-06 13:05:00 +01:00
<template>
2023-01-06 05:40:17 +01:00
<div class="_gaps_m">
2023-01-05 13:04:56 +01:00
<FormInfo warn>{{ i18n.ts._plugin.installWarn }}</FormInfo>
2021-02-06 13:05:00 +01:00
2023-01-07 07:09:46 +01:00
<MkTextarea v-model="code" tall>
<template #label>{{ i18n.ts.code }}</template>
2023-01-07 07:09:46 +01:00
</MkTextarea>
2021-02-06 13:05:00 +01:00
2023-01-05 13:04:56 +01:00
<div>
2023-01-06 01:41:14 +01:00
<MkButton :disabled="code == null" primary inline @click="install"><i class="ti ti-check"></i> {{ i18n.ts.install }}</MkButton>
2022-01-04 09:52:44 +01:00
</div>
</div>
2021-02-06 13:05:00 +01:00
</template>
<script lang="ts" setup>
import { nextTick, ref } from 'vue';
2023-01-07 07:09:46 +01:00
import MkTextarea from '@/components/MkTextarea.vue';
2023-01-06 01:41:14 +01:00
import MkButton from '@/components/MkButton.vue';
import FormInfo from '@/components/MkInfo.vue';
2023-09-19 09:37:43 +02:00
import * as os from '@/os.js';
import { installPlugin } from '@/scripts/install-plugin.js';
2023-09-19 09:37:43 +02:00
import { unisonReload } from '@/scripts/unison-reload.js';
import { i18n } from '@/i18n.js';
import { definePageMetadata } from '@/scripts/page-metadata.js';
2021-02-06 13:05:00 +01:00
const code = ref<string | null>(null);
async function install() {
if (!code.value) return;
2023-01-03 07:51:49 +01:00
try {
await installPlugin(code.value);
os.success();
nextTick(() => {
unisonReload();
});
} catch (err) {
os.alert({
type: 'error',
title: 'Install failed',
text: err.toString() ?? null,
});
}
}
const headerActions = $computed(() => []);
const headerTabs = $computed(() => []);
definePageMetadata({
title: i18n.ts._plugin.install,
icon: 'ti ti-download',
2021-02-06 13:05:00 +01:00
});
</script>