refactor(frontend): 非推奨となったReactivity Transformを使わないように (#12539)

* refactor(frontend): 非推奨となったReactivity Transformを使わないように

* refactor: 不要な括弧を除去

* fix: 不要なアノテーションを除去

* fix: Refの配列をrefしている部分の対応

* refactor: 不要な括弧を除去

* fix: lint

* refactor: Ref、ShallowRef、ComputedRefの変数の宣言をletからconstに置換

* fix: type error

* chore: drop reactivity transform from eslint configuration

* refactor: remove unnecessary import

* fix: 対応漏れ
This commit is contained in:
zyoshoka
2023-12-07 14:42:09 +09:00
committed by GitHub
parent e42c91dee7
commit 406b4bdbe7
277 changed files with 3353 additions and 3441 deletions

View File

@@ -38,7 +38,7 @@ SPDX-License-Identifier: AGPL-3.0-only
</template>
<script lang="ts" setup>
import { computed, watch } from 'vue';
import { computed, watch, ref } from 'vue';
import MkButton from '@/components/MkButton.vue';
import MkInput from '@/components/MkInput.vue';
import MkTextarea from '@/components/MkTextarea.vue';
@@ -56,38 +56,38 @@ const props = defineProps<{
postId?: string;
}>();
let init = $ref(null);
let files = $ref([]);
let description = $ref(null);
let title = $ref(null);
let isSensitive = $ref(false);
const init = ref(null);
const files = ref([]);
const description = ref(null);
const title = ref(null);
const isSensitive = ref(false);
function selectFile(evt) {
selectFiles(evt.currentTarget ?? evt.target, null).then(selected => {
files = files.concat(selected);
files.value = files.value.concat(selected);
});
}
function remove(file) {
files = files.filter(f => f.id !== file.id);
files.value = files.value.filter(f => f.id !== file.id);
}
async function save() {
if (props.postId) {
await os.apiWithDialog('gallery/posts/update', {
postId: props.postId,
title: title,
description: description,
fileIds: files.map(file => file.id),
isSensitive: isSensitive,
title: title.value,
description: description.value,
fileIds: files.value.map(file => file.id),
isSensitive: isSensitive.value,
});
router.push(`/gallery/${props.postId}`);
} else {
const created = await os.apiWithDialog('gallery/posts/create', {
title: title,
description: description,
fileIds: files.map(file => file.id),
isSensitive: isSensitive,
title: title.value,
description: description.value,
fileIds: files.value.map(file => file.id),
isSensitive: isSensitive.value,
});
router.push(`/gallery/${created.id}`);
}
@@ -106,19 +106,19 @@ async function del() {
}
watch(() => props.postId, () => {
init = () => props.postId ? os.api('gallery/posts/show', {
init.value = () => props.postId ? os.api('gallery/posts/show', {
postId: props.postId,
}).then(post => {
files = post.files;
title = post.title;
description = post.description;
isSensitive = post.isSensitive;
files.value = post.files;
title.value = post.title;
description.value = post.description;
isSensitive.value = post.isSensitive;
}) : Promise.resolve(null);
}, { immediate: true });
const headerActions = $computed(() => []);
const headerActions = computed(() => []);
const headerTabs = $computed(() => []);
const headerTabs = computed(() => []);
definePageMetadata(computed(() => props.postId ? {
title: i18n.ts.edit,