refactor
This commit is contained in:
parent
9e5c8d94bf
commit
dbb6c71c5c
|
@ -92,7 +92,7 @@ const props = defineProps<{
|
||||||
}>();
|
}>();
|
||||||
|
|
||||||
const channel = ref<Misskey.entities.Channel | null>(null);
|
const channel = ref<Misskey.entities.Channel | null>(null);
|
||||||
const name = ref<string | null>(null);
|
const name = ref<string>('');
|
||||||
const description = ref<string | null>(null);
|
const description = ref<string | null>(null);
|
||||||
const bannerUrl = ref<string | null>(null);
|
const bannerUrl = ref<string | null>(null);
|
||||||
const bannerId = ref<string | null>(null);
|
const bannerId = ref<string | null>(null);
|
||||||
|
@ -114,20 +114,22 @@ watch(() => bannerId.value, async () => {
|
||||||
async function fetchChannel() {
|
async function fetchChannel() {
|
||||||
if (props.channelId == null) return;
|
if (props.channelId == null) return;
|
||||||
|
|
||||||
channel.value = await misskeyApi('channels/show', {
|
const result = await misskeyApi('channels/show', {
|
||||||
channelId: props.channelId,
|
channelId: props.channelId,
|
||||||
});
|
});
|
||||||
|
|
||||||
name.value = channel.value.name;
|
name.value = result.name;
|
||||||
description.value = channel.value.description;
|
description.value = result.description;
|
||||||
bannerId.value = channel.value.bannerId;
|
bannerId.value = result.bannerId;
|
||||||
bannerUrl.value = channel.value.bannerUrl;
|
bannerUrl.value = result.bannerUrl;
|
||||||
isSensitive.value = channel.value.isSensitive;
|
isSensitive.value = result.isSensitive;
|
||||||
pinnedNotes.value = channel.value.pinnedNoteIds.map(id => ({
|
pinnedNotes.value = result.pinnedNoteIds.map(id => ({
|
||||||
id,
|
id,
|
||||||
}));
|
}));
|
||||||
color.value = channel.value.color;
|
color.value = result.color;
|
||||||
allowRenoteToExternal.value = channel.value.allowRenoteToExternal;
|
allowRenoteToExternal.value = result.allowRenoteToExternal;
|
||||||
|
|
||||||
|
channel.value = result;
|
||||||
}
|
}
|
||||||
|
|
||||||
fetchChannel();
|
fetchChannel();
|
||||||
|
@ -154,15 +156,17 @@ function save() {
|
||||||
name: name.value,
|
name: name.value,
|
||||||
description: description.value,
|
description: description.value,
|
||||||
bannerId: bannerId.value,
|
bannerId: bannerId.value,
|
||||||
pinnedNoteIds: pinnedNotes.value.map(x => x.id),
|
|
||||||
color: color.value,
|
color: color.value,
|
||||||
isSensitive: isSensitive.value,
|
isSensitive: isSensitive.value,
|
||||||
allowRenoteToExternal: allowRenoteToExternal.value,
|
allowRenoteToExternal: allowRenoteToExternal.value,
|
||||||
};
|
} satisfies Misskey.entities.ChannelsCreateRequest;
|
||||||
|
|
||||||
if (props.channelId) {
|
if (props.channelId != null) {
|
||||||
params.channelId = props.channelId;
|
os.apiWithDialog('channels/update', {
|
||||||
os.apiWithDialog('channels/update', params);
|
...params,
|
||||||
|
channelId: props.channelId,
|
||||||
|
pinnedNoteIds: pinnedNotes.value.map(x => x.id),
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
os.apiWithDialog('channels/create', params).then(created => {
|
os.apiWithDialog('channels/create', params).then(created => {
|
||||||
router.push('/channels/:channelId', {
|
router.push('/channels/:channelId', {
|
||||||
|
@ -175,12 +179,13 @@ function save() {
|
||||||
}
|
}
|
||||||
|
|
||||||
async function archive() {
|
async function archive() {
|
||||||
|
if (props.channelId == null) return;
|
||||||
|
|
||||||
const { canceled } = await os.confirm({
|
const { canceled } = await os.confirm({
|
||||||
type: 'warning',
|
type: 'warning',
|
||||||
title: i18n.tsx.channelArchiveConfirmTitle({ name: name.value }),
|
title: i18n.tsx.channelArchiveConfirmTitle({ name: name.value }),
|
||||||
text: i18n.ts.channelArchiveConfirmDescription,
|
text: i18n.ts.channelArchiveConfirmDescription,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (canceled) return;
|
if (canceled) return;
|
||||||
|
|
||||||
misskeyApi('channels/update', {
|
misskeyApi('channels/update', {
|
||||||
|
|
|
@ -16,7 +16,7 @@ SPDX-License-Identifier: AGPL-3.0-only
|
||||||
</MkTextarea>
|
</MkTextarea>
|
||||||
|
|
||||||
<div class="_gaps_s">
|
<div class="_gaps_s">
|
||||||
<div v-for="file in files" :key="file.id" class="wqugxsfx" :style="{ backgroundImage: file ? `url(${ file.thumbnailUrl })` : null }">
|
<div v-for="file in files" :key="file.id" class="wqugxsfx" :style="{ backgroundImage: file ? `url(${ file.thumbnailUrl })` : '' }">
|
||||||
<div class="name">{{ file.name }}</div>
|
<div class="name">{{ file.name }}</div>
|
||||||
<button v-tooltip="i18n.ts.remove" class="remove _button" @click="remove(file)"><i class="ti ti-x"></i></button>
|
<button v-tooltip="i18n.ts.remove" class="remove _button" @click="remove(file)"><i class="ti ti-x"></i></button>
|
||||||
</div>
|
</div>
|
||||||
|
@ -88,7 +88,7 @@ async function save() {
|
||||||
router.push('/gallery/:postId', {
|
router.push('/gallery/:postId', {
|
||||||
params: {
|
params: {
|
||||||
postId: props.postId,
|
postId: props.postId,
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
const created = await os.apiWithDialog('gallery/posts/create', {
|
const created = await os.apiWithDialog('gallery/posts/create', {
|
||||||
|
@ -100,7 +100,7 @@ async function save() {
|
||||||
router.push('/gallery/:postId', {
|
router.push('/gallery/:postId', {
|
||||||
params: {
|
params: {
|
||||||
postId: created.id,
|
postId: created.id,
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,7 @@ SPDX-License-Identifier: AGPL-3.0-only
|
||||||
<MkButton primary @click="createKey">{{ i18n.ts._registry.createKey }}</MkButton>
|
<MkButton primary @click="createKey">{{ i18n.ts._registry.createKey }}</MkButton>
|
||||||
|
|
||||||
<div v-if="scopesWithDomain" class="_gaps_m">
|
<div v-if="scopesWithDomain" class="_gaps_m">
|
||||||
<FormSection v-for="domain in scopesWithDomain" :key="domain.domain">
|
<FormSection v-for="domain in scopesWithDomain" :key="domain.domain ?? 'system'">
|
||||||
<template #label>{{ domain.domain ? domain.domain.toUpperCase() : i18n.ts.system }}</template>
|
<template #label>{{ domain.domain ? domain.domain.toUpperCase() : i18n.ts.system }}</template>
|
||||||
<div class="_gaps_s">
|
<div class="_gaps_s">
|
||||||
<FormLink v-for="scope in domain.scopes" :to="`/registry/keys/${domain.domain ?? '@'}/${scope.join('/')}`" class="_monospace">{{ scope.length === 0 ? '(root)' : scope.join('/') }}</FormLink>
|
<FormLink v-for="scope in domain.scopes" :to="`/registry/keys/${domain.domain ?? '@'}/${scope.join('/')}`" class="_monospace">{{ scope.length === 0 ? '(root)' : scope.join('/') }}</FormLink>
|
||||||
|
|
|
@ -160,10 +160,18 @@ SPDX-License-Identifier: AGPL-3.0-only
|
||||||
<template #label><SearchLabel>{{ i18n.ts._accountSettings.makeNotesHiddenBefore }}</SearchLabel></template>
|
<template #label><SearchLabel>{{ i18n.ts._accountSettings.makeNotesHiddenBefore }}</SearchLabel></template>
|
||||||
|
|
||||||
<div class="_gaps_s">
|
<div class="_gaps_s">
|
||||||
<MkSelect :modelValue="makeNotesHiddenBefore_type" @update:modelValue="makeNotesHiddenBefore = $event === 'relative' ? -604800 : $event === 'absolute' ? Math.floor(Date.now() / 1000) : null">
|
<MkSelect
|
||||||
<option :value="null">{{ i18n.ts.none }}</option>
|
:items="[{
|
||||||
<option value="relative">{{ i18n.ts._accountSettings.notesHavePassedSpecifiedPeriod }}</option>
|
value: null,
|
||||||
<option value="absolute">{{ i18n.ts._accountSettings.notesOlderThanSpecifiedDateAndTime }}</option>
|
label: i18n.ts.none
|
||||||
|
}, {
|
||||||
|
value: 'relative',
|
||||||
|
label: i18n.ts._accountSettings.notesHavePassedSpecifiedPeriod
|
||||||
|
}, {
|
||||||
|
value: 'absolute',
|
||||||
|
label: i18n.ts._accountSettings.notesOlderThanSpecifiedDateAndTime
|
||||||
|
}] as const" :modelValue="makeNotesHiddenBefore_type" @update:modelValue="makeNotesHiddenBefore = $event === 'relative' ? -604800 : $event === 'absolute' ? Math.floor(Date.now() / 1000) : null"
|
||||||
|
>
|
||||||
</MkSelect>
|
</MkSelect>
|
||||||
|
|
||||||
<MkSelect v-if="makeNotesHiddenBefore_type === 'relative'" v-model="makeNotesHiddenBefore_selection">
|
<MkSelect v-if="makeNotesHiddenBefore_type === 'relative'" v-model="makeNotesHiddenBefore_selection">
|
||||||
|
@ -262,7 +270,7 @@ const makeNotesFollowersOnlyBefore_presets = [
|
||||||
const makeNotesFollowersOnlyBefore_isCustomMode = ref(
|
const makeNotesFollowersOnlyBefore_isCustomMode = ref(
|
||||||
makeNotesFollowersOnlyBefore.value != null &&
|
makeNotesFollowersOnlyBefore.value != null &&
|
||||||
makeNotesFollowersOnlyBefore.value < 0 &&
|
makeNotesFollowersOnlyBefore.value < 0 &&
|
||||||
!makeNotesFollowersOnlyBefore_presets.some((preset) => preset.value === makeNotesFollowersOnlyBefore.value)
|
!makeNotesFollowersOnlyBefore_presets.some((preset) => preset.value === makeNotesFollowersOnlyBefore.value),
|
||||||
);
|
);
|
||||||
|
|
||||||
const makeNotesFollowersOnlyBefore_selection = computed({
|
const makeNotesFollowersOnlyBefore_selection = computed({
|
||||||
|
@ -270,14 +278,14 @@ const makeNotesFollowersOnlyBefore_selection = computed({
|
||||||
set(value) {
|
set(value) {
|
||||||
makeNotesFollowersOnlyBefore_isCustomMode.value = value === 'custom';
|
makeNotesFollowersOnlyBefore_isCustomMode.value = value === 'custom';
|
||||||
if (value !== 'custom') makeNotesFollowersOnlyBefore.value = value;
|
if (value !== 'custom') makeNotesFollowersOnlyBefore.value = value;
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const makeNotesFollowersOnlyBefore_customMonths = computed({
|
const makeNotesFollowersOnlyBefore_customMonths = computed({
|
||||||
get: () => makeNotesFollowersOnlyBefore.value ? Math.abs(makeNotesFollowersOnlyBefore.value) / (30 * 24 * 60 * 60) : null,
|
get: () => makeNotesFollowersOnlyBefore.value ? Math.abs(makeNotesFollowersOnlyBefore.value) / (30 * 24 * 60 * 60) : null,
|
||||||
set(value) {
|
set(value) {
|
||||||
if (value != null && value > 0) makeNotesFollowersOnlyBefore.value = -Math.abs(Math.floor(Number(value))) * 30 * 24 * 60 * 60;
|
if (value != null && value > 0) makeNotesFollowersOnlyBefore.value = -Math.abs(Math.floor(Number(value))) * 30 * 24 * 60 * 60;
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const makeNotesHiddenBefore_type = computed(() => {
|
const makeNotesHiddenBefore_type = computed(() => {
|
||||||
|
@ -303,7 +311,7 @@ const makeNotesHiddenBefore_presets = [
|
||||||
const makeNotesHiddenBefore_isCustomMode = ref(
|
const makeNotesHiddenBefore_isCustomMode = ref(
|
||||||
makeNotesHiddenBefore.value != null &&
|
makeNotesHiddenBefore.value != null &&
|
||||||
makeNotesHiddenBefore.value < 0 &&
|
makeNotesHiddenBefore.value < 0 &&
|
||||||
!makeNotesHiddenBefore_presets.some((preset) => preset.value === makeNotesHiddenBefore.value)
|
!makeNotesHiddenBefore_presets.some((preset) => preset.value === makeNotesHiddenBefore.value),
|
||||||
);
|
);
|
||||||
|
|
||||||
const makeNotesHiddenBefore_selection = computed({
|
const makeNotesHiddenBefore_selection = computed({
|
||||||
|
@ -311,14 +319,14 @@ const makeNotesHiddenBefore_selection = computed({
|
||||||
set(value) {
|
set(value) {
|
||||||
makeNotesHiddenBefore_isCustomMode.value = value === 'custom';
|
makeNotesHiddenBefore_isCustomMode.value = value === 'custom';
|
||||||
if (value !== 'custom') makeNotesHiddenBefore.value = value;
|
if (value !== 'custom') makeNotesHiddenBefore.value = value;
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const makeNotesHiddenBefore_customMonths = computed({
|
const makeNotesHiddenBefore_customMonths = computed({
|
||||||
get: () => makeNotesHiddenBefore.value ? Math.abs(makeNotesHiddenBefore.value) / (30 * 24 * 60 * 60) : null,
|
get: () => makeNotesHiddenBefore.value ? Math.abs(makeNotesHiddenBefore.value) / (30 * 24 * 60 * 60) : null,
|
||||||
set(value) {
|
set(value) {
|
||||||
if (value != null && value > 0) makeNotesHiddenBefore.value = -Math.abs(Math.floor(Number(value))) * 30 * 24 * 60 * 60;
|
if (value != null && value > 0) makeNotesHiddenBefore.value = -Math.abs(Math.floor(Number(value))) * 30 * 24 * 60 * 60;
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
watch([makeNotesFollowersOnlyBefore, makeNotesHiddenBefore], () => {
|
watch([makeNotesFollowersOnlyBefore, makeNotesHiddenBefore], () => {
|
||||||
|
|
|
@ -52,7 +52,7 @@ async function post() {
|
||||||
|
|
||||||
const headerActions = computed(() => [{
|
const headerActions = computed(() => [{
|
||||||
icon: 'ti ti-dots',
|
icon: 'ti ti-dots',
|
||||||
label: i18n.ts.more,
|
text: i18n.ts.more,
|
||||||
handler: (ev: MouseEvent) => {
|
handler: (ev: MouseEvent) => {
|
||||||
os.popupMenu([{
|
os.popupMenu([{
|
||||||
text: i18n.ts.embed,
|
text: i18n.ts.embed,
|
||||||
|
|
|
@ -8,9 +8,10 @@ import type { Plugin } from 'chart.js';
|
||||||
export const chartVLine = (vLineColor: string) => ({
|
export const chartVLine = (vLineColor: string) => ({
|
||||||
id: 'vLine',
|
id: 'vLine',
|
||||||
beforeDraw(chart, args, options) {
|
beforeDraw(chart, args, options) {
|
||||||
if (chart.tooltip?._active?.length) {
|
const tooltip = chart.tooltip as any;
|
||||||
|
if (tooltip?._active?.length) {
|
||||||
const ctx = chart.ctx;
|
const ctx = chart.ctx;
|
||||||
const xs = chart.tooltip._active.map(a => a.element.x);
|
const xs = tooltip._active.map(a => a.element.x);
|
||||||
const x = xs.reduce((a, b) => a + b, 0) / xs.length;
|
const x = xs.reduce((a, b) => a + b, 0) / xs.length;
|
||||||
const topY = chart.scales.y.top;
|
const topY = chart.scales.y.top;
|
||||||
const bottomY = chart.scales.y.bottom;
|
const bottomY = chart.scales.y.bottom;
|
||||||
|
|
|
@ -20,8 +20,8 @@ export function popout(path: string, w?: HTMLElement) {
|
||||||
} else {
|
} else {
|
||||||
const width = 400;
|
const width = 400;
|
||||||
const height = 500;
|
const height = 500;
|
||||||
const x = window.top.outerHeight / 2 + window.top.screenY - (height / 2);
|
const x = window.top == null ? 0 : window.top.outerHeight / 2 + window.top.screenY - (height / 2);
|
||||||
const y = window.top.outerWidth / 2 + window.top.screenX - (width / 2);
|
const y = window.top == null ? 0 : window.top.outerWidth / 2 + window.top.screenX - (width / 2);
|
||||||
window.open(url, url,
|
window.open(url, url,
|
||||||
`width=${width}, height=${height}, top=${x}, left=${y}`);
|
`width=${width}, height=${height}, top=${x}, left=${y}`);
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
* SPDX-License-Identifier: AGPL-3.0-only
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
export class StickySidebar {
|
export class StickySidebar {
|
||||||
private lastScrollTop = 0;
|
private lastScrollTop = 0;
|
||||||
private container: HTMLElement;
|
private container: HTMLElement;
|
||||||
|
@ -53,3 +54,4 @@ export class StickySidebar {
|
||||||
this.lastScrollTop = scrollTop <= 0 ? 0 : scrollTop;
|
this.lastScrollTop = scrollTop <= 0 ? 0 : scrollTop;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
Loading…
Reference in New Issue