2023-07-27 14:31:52 +09:00
|
|
|
<!--
|
|
|
|
SPDX-FileCopyrightText: syuilo and other misskey contributors
|
|
|
|
SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
-->
|
|
|
|
|
2020-11-25 21:31:34 +09:00
|
|
|
<template>
|
2023-01-06 13:40:17 +09:00
|
|
|
<div class="_gaps_m">
|
2023-01-07 15:09:46 +09:00
|
|
|
<MkTextarea v-model="installThemeCode">
|
2022-01-28 11:39:49 +09:00
|
|
|
<template #label>{{ i18n.ts._theme.code }}</template>
|
2023-01-07 15:09:46 +09:00
|
|
|
</MkTextarea>
|
2020-11-25 21:31:34 +09:00
|
|
|
|
2023-01-06 09:41:14 +09:00
|
|
|
<div class="_buttons">
|
2023-10-21 18:41:12 +09:00
|
|
|
<MkButton :disabled="installThemeCode == null" inline @click="() => previewTheme(installThemeCode)"><i class="ti ti-eye"></i> {{ i18n.ts.preview }}</MkButton>
|
2023-01-06 09:41:14 +09:00
|
|
|
<MkButton :disabled="installThemeCode == null" primary inline @click="() => install(installThemeCode)"><i class="ti ti-check"></i> {{ i18n.ts.install }}</MkButton>
|
2022-01-02 21:35:23 +09:00
|
|
|
</div>
|
|
|
|
</div>
|
2020-11-25 21:31:34 +09:00
|
|
|
</template>
|
|
|
|
|
2022-01-15 17:58:35 +09:00
|
|
|
<script lang="ts" setup>
|
|
|
|
import { } from 'vue';
|
2023-01-07 15:09:46 +09:00
|
|
|
import MkTextarea from '@/components/MkTextarea.vue';
|
2023-01-06 09:41:14 +09:00
|
|
|
import MkButton from '@/components/MkButton.vue';
|
2023-10-21 18:41:12 +09:00
|
|
|
import { parseThemeCode, previewTheme, installTheme } from '@/scripts/install-theme.js';
|
2023-09-19 16:37:43 +09:00
|
|
|
import * as os from '@/os.js';
|
|
|
|
import { i18n } from '@/i18n.js';
|
|
|
|
import { definePageMetadata } from '@/scripts/page-metadata.js';
|
2020-11-25 21:31:34 +09:00
|
|
|
|
2022-01-15 17:58:35 +09:00
|
|
|
let installThemeCode = $ref(null);
|
2020-11-25 21:31:34 +09:00
|
|
|
|
2023-10-21 18:41:12 +09:00
|
|
|
async function install(code: string): Promise<void> {
|
2022-01-15 17:58:35 +09:00
|
|
|
try {
|
2023-10-21 18:41:12 +09:00
|
|
|
const theme = parseThemeCode(code);
|
|
|
|
await installTheme(code);
|
2022-01-15 17:58:35 +09:00
|
|
|
os.alert({
|
2023-10-21 18:41:12 +09:00
|
|
|
type: 'success',
|
|
|
|
text: i18n.t('_theme.installed', { name: theme.name }),
|
2022-01-15 17:58:35 +09:00
|
|
|
});
|
2023-10-21 18:41:12 +09:00
|
|
|
} catch (err) {
|
|
|
|
switch (err.message.toLowerCase()) {
|
|
|
|
case 'this theme is already installed':
|
|
|
|
os.alert({
|
|
|
|
type: 'info',
|
|
|
|
text: i18n.ts._theme.alreadyInstalled,
|
|
|
|
});
|
|
|
|
break;
|
2020-11-25 21:31:34 +09:00
|
|
|
|
2023-10-21 18:41:12 +09:00
|
|
|
default:
|
|
|
|
os.alert({
|
|
|
|
type: 'error',
|
|
|
|
text: i18n.ts._theme.invalid,
|
|
|
|
});
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
console.error(err);
|
|
|
|
}
|
2022-01-15 17:58:35 +09:00
|
|
|
}
|
2020-11-25 21:31:34 +09:00
|
|
|
|
2022-06-20 17:38:49 +09:00
|
|
|
const headerActions = $computed(() => []);
|
|
|
|
|
|
|
|
const headerTabs = $computed(() => []);
|
|
|
|
|
|
|
|
definePageMetadata({
|
|
|
|
title: i18n.ts._theme.install,
|
2022-12-19 19:01:30 +09:00
|
|
|
icon: 'ti ti-download',
|
2020-11-25 21:31:34 +09:00
|
|
|
});
|
|
|
|
</script>
|