2023-07-27 07:31:52 +02:00
|
|
|
<!--
|
2024-02-13 16:59:27 +01:00
|
|
|
SPDX-FileCopyrightText: syuilo and misskey-project
|
2023-07-27 07:31:52 +02:00
|
|
|
SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
-->
|
|
|
|
|
2023-04-19 14:24:31 +02:00
|
|
|
<template>
|
|
|
|
<div>
|
|
|
|
<MkStickyContainer>
|
|
|
|
<template #header><XHeader :tabs="headerTabs"/></template>
|
2023-05-19 13:52:15 +02:00
|
|
|
<MkSpacer :contentMax="700" :marginMin="16" :marginMax="32">
|
2023-04-19 14:24:31 +02:00
|
|
|
<div class="_gaps_m">
|
|
|
|
<div>{{ i18n.ts._serverRules.description }}</div>
|
|
|
|
<Sortable
|
|
|
|
v-model="serverRules"
|
|
|
|
class="_gaps_m"
|
2023-05-19 13:52:15 +02:00
|
|
|
:itemKey="(_, i) => i"
|
2023-04-19 14:24:31 +02:00
|
|
|
:animation="150"
|
|
|
|
:handle="'.' + $style.itemHandle"
|
|
|
|
@start="e => e.item.classList.add('active')"
|
|
|
|
@end="e => e.item.classList.remove('active')"
|
|
|
|
>
|
|
|
|
<template #item="{element,index}">
|
|
|
|
<div :class="$style.item">
|
|
|
|
<div :class="$style.itemHeader">
|
|
|
|
<div :class="$style.itemNumber" v-text="String(index + 1)"/>
|
|
|
|
<span :class="$style.itemHandle"><i class="ti ti-menu"/></span>
|
|
|
|
<button class="_button" :class="$style.itemRemove" @click="remove(index)"><i class="ti ti-x"></i></button>
|
|
|
|
</div>
|
|
|
|
<MkInput v-model="serverRules[index]"/>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
</Sortable>
|
|
|
|
<div :class="$style.commands">
|
|
|
|
<MkButton rounded @click="serverRules.push('')"><i class="ti ti-plus"></i> {{ i18n.ts.add }}</MkButton>
|
2023-06-01 10:19:46 +02:00
|
|
|
<MkButton primary rounded @click="save"><i class="ti ti-check"></i> {{ i18n.ts.save }}</MkButton>
|
2023-04-19 14:24:31 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</MkSpacer>
|
|
|
|
</MkStickyContainer>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts" setup>
|
2023-12-07 06:42:09 +01:00
|
|
|
import { defineAsyncComponent, ref, computed } from 'vue';
|
2023-04-19 14:24:31 +02:00
|
|
|
import XHeader from './_header_.vue';
|
2023-09-19 09:37:43 +02:00
|
|
|
import * as os from '@/os.js';
|
|
|
|
import { fetchInstance, instance } from '@/instance.js';
|
|
|
|
import { i18n } from '@/i18n.js';
|
|
|
|
import { definePageMetadata } from '@/scripts/page-metadata.js';
|
2023-04-19 14:24:31 +02:00
|
|
|
import MkButton from '@/components/MkButton.vue';
|
|
|
|
import MkInput from '@/components/MkInput.vue';
|
|
|
|
|
|
|
|
const Sortable = defineAsyncComponent(() => import('vuedraggable').then(x => x.default));
|
|
|
|
|
2023-12-07 06:42:09 +01:00
|
|
|
const serverRules = ref<string[]>(instance.serverRules);
|
2023-04-19 14:24:31 +02:00
|
|
|
|
|
|
|
const save = async () => {
|
|
|
|
await os.apiWithDialog('admin/update-meta', {
|
2023-12-07 06:42:09 +01:00
|
|
|
serverRules: serverRules.value,
|
2023-04-19 14:24:31 +02:00
|
|
|
});
|
|
|
|
fetchInstance();
|
|
|
|
};
|
|
|
|
|
|
|
|
const remove = (index: number): void => {
|
2023-12-07 06:42:09 +01:00
|
|
|
serverRules.value.splice(index, 1);
|
2023-04-19 14:24:31 +02:00
|
|
|
};
|
|
|
|
|
2023-12-07 06:42:09 +01:00
|
|
|
const headerTabs = computed(() => []);
|
2023-04-19 14:24:31 +02:00
|
|
|
|
2024-02-16 08:17:09 +01:00
|
|
|
definePageMetadata(() => ({
|
2023-04-19 14:24:31 +02:00
|
|
|
title: i18n.ts.serverRules,
|
|
|
|
icon: 'ti ti-checkbox',
|
2024-02-16 08:17:09 +01:00
|
|
|
}));
|
2023-04-19 14:24:31 +02:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss" module>
|
|
|
|
.item {
|
|
|
|
display: block;
|
|
|
|
color: var(--navFg);
|
|
|
|
}
|
|
|
|
|
|
|
|
.itemHeader {
|
|
|
|
display: flex;
|
|
|
|
margin-bottom: 8px;
|
|
|
|
align-items: center;
|
|
|
|
}
|
|
|
|
|
|
|
|
.itemHandle {
|
|
|
|
display: flex;
|
|
|
|
width: 40px;
|
|
|
|
height: 40px;
|
|
|
|
align-items: center;
|
|
|
|
justify-content: center;
|
|
|
|
cursor: move;
|
|
|
|
}
|
|
|
|
|
|
|
|
.itemNumber {
|
|
|
|
display: flex;
|
|
|
|
background-color: var(--accentedBg);
|
|
|
|
color: var(--accent);
|
|
|
|
font-size: 14px;
|
|
|
|
font-weight: bold;
|
|
|
|
width: 28px;
|
|
|
|
height: 28px;
|
|
|
|
align-items: center;
|
|
|
|
justify-content: center;
|
|
|
|
border-radius: 999px;
|
|
|
|
margin-right: 8px;
|
|
|
|
}
|
|
|
|
|
|
|
|
.itemEdit {
|
|
|
|
width: 100%;
|
|
|
|
max-width: 100%;
|
|
|
|
min-width: 100%;
|
|
|
|
}
|
|
|
|
|
|
|
|
.itemRemove {
|
|
|
|
width: 40px;
|
|
|
|
height: 40px;
|
|
|
|
color: var(--error);
|
|
|
|
margin-left: auto;
|
|
|
|
border-radius: 6px;
|
|
|
|
|
|
|
|
&:hover {
|
|
|
|
background: var(--X5);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
.commands {
|
|
|
|
display: flex;
|
|
|
|
gap: 16px;
|
|
|
|
}
|
|
|
|
</style>
|