style: move post schedule button inside "more!" menu

This commit is contained in:
Lhcfl 2024-05-22 10:45:07 +08:00
parent 0cdf8dbcda
commit 9f23c8aee6
4 changed files with 103 additions and 30 deletions

View file

@ -2255,6 +2255,8 @@ noteEditHistory: "Post edit history"
slashQuote: "Chain quote"
foldNotification: "Group similar notifications"
scheduledPost: "Schedule this post"
scheduledPostAt: "The post will be sent at {time}"
cancelScheduledPost: "Cancel schedule"
scheduledDate: "Scheduled date"
mergeThreadInTimeline: "Merge multiple posts in the same thread in timelines"
mergeRenotesInTimeline: "Group multiple boosts of the same post"

View file

@ -2082,6 +2082,8 @@ media: 媒体
slashQuote: "斜杠引用"
foldNotification: "将通知按同类型分组"
scheduledPost: "定时发送"
cancelScheduledPost: "取消定时发送"
scheduledPostAt: "帖子将于 {time} 发送"
scheduledDate: "发送日期"
mergeThreadInTimeline: "将时间线内的连续回复合并成一串"
mergeRenotesInTimeline: "合并同一个帖子的转发"

View file

@ -54,7 +54,7 @@
><i :class="icon('ph-eye-slash')"></i
></span>
</button>
<button
<!-- <button
v-if="editId == null"
v-tooltip="i18n.ts.scheduledPost"
class="_button schedule"
@ -62,7 +62,7 @@
@click="setScheduledAt"
>
<i :class="icon('ph-clock')"></i>
</button>
</button> -->
<button
ref="languageButton"
v-tooltip="i18n.ts.language"
@ -105,15 +105,7 @@
/>
<i
v-else
:class="
icon(
reply
? 'ph-arrow-u-up-left'
: renote
? 'ph-quotes'
: 'ph-paper-plane-tilt',
)
"
:class="submitIcon"
></i>
</button>
</div>
@ -153,12 +145,26 @@
<MkInfo
v-if="hasNotSpecifiedMentions"
warn
class="hasNotSpecifiedMentions"
>{{ i18n.ts.notSpecifiedMentionWarning }} -
class="form-info"
>
{{ i18n.ts.notSpecifiedMentionWarning }} -
<button class="_textButton" @click="addMissingMention()">
{{ i18n.ts.add }}
</button></MkInfo
</button>
</MkInfo>
<MkInfo
v-if="scheduledAt"
class="form-info"
>
<I18n
:src="i18n.ts.scheduledPostAt"
tag="span"
>
<template #time>
<MkTime :time="scheduledAt"></MkTime>
</template>
</I18n>
</MkInfo>
<input
v-show="useCw"
ref="cwInputEl"
@ -235,13 +241,13 @@
>
<i :class="icon('ph-eye-slash')"></i>
</button>
<button
<!-- <button
v-tooltip="i18n.ts.mention"
class="_button"
@click="insertMention"
>
<i :class="icon('ph-at')"></i>
</button>
</button> -->
<button
v-tooltip="i18n.ts.hashtags"
class="_button"
@ -257,21 +263,28 @@
>
<i :class="icon('ph-smiley')"></i>
</button>
<button
<!-- <button
v-if="postFormActions.length > 0"
v-tooltip="i18n.ts.plugin"
class="_button"
@click="showActions"
>
<i :class="icon('ph-plug')"></i>
</button>
</button> -->
<!-- v-if="showMfmCheatsheet" -->
<button
<!-- <button
v-tooltip="i18n.ts._mfm.cheatSheet"
class="_button right"
@click="openCheatSheet"
>
<i :class="icon('ph-question')"></i>
</button> -->
<button
v-tooltip="i18n.ts.other"
class="_button right"
@click="openMoreActionsMenu"
>
<i :class="icon('ph-dots-three-circle')"></i>
</button>
<div v-if="showBigPostButton">
<button
@ -283,13 +296,7 @@
>
{{ submitText
}}<i
:class="
reply
? 'ph-arrow-u-up-left ph-bold ph-lg'
: renote
? 'ph-quotes ph-bold ph-lg'
: 'ph-paper-plane-tilt ph-bold ph-lg'
"
:class="submitIcon"
></i>
</button>
</div>
@ -496,6 +503,19 @@ const submitText = computed((): string => {
? i18n.ts.toReply
: i18n.ts.toPost;
});
const submitIcon = computed(() =>
icon(
props.editId
? "ph-pencil"
: scheduledAt.value
? "ph-clock"
: props.reply
? "ph-arrow-u-up-left"
: props.renote
? "ph-quotes"
: "ph-paper-plane-tilt",
),
);
const textLength = computed((): number => {
return length((preprocess(text.value) + imeText.value).trim());
@ -809,11 +829,13 @@ async function setScheduledAt() {
scheduledAt.value = Number(
new Date(`${result.result.at_date}T${result.result.at_time}`),
);
} else {
scheduledAt.value = null;
}
}
function removeScheduledAt() {
scheduledAt.value = null;
}
const language = ref<string | null>(
props.initialLanguage ??
defaultStore.state.recentlyUsedPostLanguages[0] ??
@ -1345,6 +1367,53 @@ function showActions(ev: MouseEvent) {
);
}
function openMoreActionsMenu(ev: MouseEvent) {
const pluginMenu: MenuItem[] = postFormActions.map((action) => ({
text: action.title,
icon: icon("ph-plug"),
action: () => {
action.handler(
{
text: text.value,
},
(key: string, value: string) => {
if (key === "text") {
text.value = value;
}
},
);
},
}));
const menu: MenuItem[] = [
{
text: i18n.ts.scheduledPost,
icon: icon("ph-clock"),
action: setScheduledAt,
},
scheduledAt.value != null
? {
text: i18n.ts.cancelScheduledPost,
icon: icon("ph-clock-countdown"),
danger: true,
action: removeScheduledAt,
}
: undefined,
null, // divider
{
text: i18n.ts.mention,
icon: icon("ph-at"),
action: insertMention,
},
{
text: i18n.ts._mfm.cheatSheet,
icon: icon("ph-question"),
action: openCheatSheet,
},
...(pluginMenu.length > 0 ? [null, ...pluginMenu] : []),
];
os.popupMenu(menu, (ev.currentTarget ?? ev.target) as HTMLElement);
}
const postAccount = ref<entities.UserDetailed | null>(null);
function openAccountMenu(ev: MouseEvent) {
@ -1621,7 +1690,7 @@ onMounted(() => {
}
}
> .hasNotSpecifiedMentions {
> .form-info {
margin: 0 20px 16px 20px;
}

View file

@ -13,7 +13,7 @@
<i
v-else-if="note.visibility === 'specified' && note.scheduledAt"
ref="specified"
v-tooltip="`scheduled at ${note.scheduledAt}`"
v-tooltip="i18n.t('scheduledPostAt', { time: note.scheduledAt })"
:class="icon('ph-clock')"
></i>
<i