Sharkey/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 14:05:00 +02:00
<template>
2023-01-06 06:40:17 +02:00
<div class="_gaps_m">
2023-01-05 14:04:56 +02:00
<FormInfo warn>{{ i18n.ts._plugin.installWarn }}</FormInfo>
2021-02-06 14:05:00 +02:00
2023-01-07 08:09:46 +02:00
<MkTextarea v-model="code" tall>
<template #label>{{ i18n.ts.code }}</template>
2023-01-07 08:09:46 +02:00
</MkTextarea>
2021-02-06 14:05:00 +02:00
2023-01-05 14:04:56 +02:00
<div>
2023-01-06 02:41:14 +02:00
<MkButton :disabled="code == null" primary inline @click="install"><i class="ti ti-check"></i> {{ i18n.ts.install }}</MkButton>
2022-01-04 10:52:44 +02:00
</div>
</div>
2021-02-06 14:05:00 +02:00
</template>
<script lang="ts" setup>
import { nextTick, ref } from 'vue';
2023-01-07 08:09:46 +02:00
import MkTextarea from '@/components/MkTextarea.vue';
2023-01-06 02:41:14 +02:00
import MkButton from '@/components/MkButton.vue';
import FormInfo from '@/components/MkInfo.vue';
2023-09-19 10:37:43 +03:00
import * as os from '@/os.js';
import { installPlugin } from '@/scripts/install-plugin.js';
2023-09-19 10:37:43 +03:00
import { unisonReload } from '@/scripts/unison-reload.js';
import { i18n } from '@/i18n.js';
import { definePageMetadata } from '@/scripts/page-metadata.js';
2021-02-06 14:05:00 +02:00
const code = ref<string | null>(null);
async function install() {
if (!code.value) return;
2023-01-03 08:51:49 +02: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 14:05:00 +02:00
});
</script>