Skip to content

Commit 7e8cd8a

Browse files
committed
* fix vuejs/language-tools#4798 @ <PostBadge(Time|Common)>
@ fe
1 parent 8e88757 commit 7e8cd8a

File tree

3 files changed

+25
-16
lines changed

3 files changed

+25
-16
lines changed

fe/src/components/post/badge/Common.vue

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ import { faClock } from '@fortawesome/free-regular-svg-icons';
4141
import { faArrowUpRightFromSquare, faHashtag, faLink } from '@fortawesome/free-solid-svg-icons';
4242
import { DateTime } from 'luxon';
4343
44-
const props = defineProps<{
44+
const { post, postIDKey, postTypeText } = defineProps<{
4545
post: TPost,
4646
postIDKey: TPostIDKey,
4747
postTypeText: PostTypeTextOf<TPost>
@@ -64,7 +64,7 @@ const formatTime = (time: UnixTimestamp) => {
6464
};
6565
6666
const tippyContent = () => `
67-
首次收录时间:${formatTime(props.post.createdAt)}<br>
68-
最后更新时间:${formatTime(props.post.updatedAt ?? props.post.createdAt)}<br>
69-
最后发现时间:${formatTime(props.post.lastSeenAt ?? props.post.updatedAt ?? props.post.createdAt)}`;
67+
首次收录时间:${formatTime(post.createdAt)}<br>
68+
最后更新时间:${formatTime(post.updatedAt ?? post.createdAt)}<br>
69+
最后发现时间:${formatTime(post.lastSeenAt ?? post.updatedAt ?? post.createdAt)}`;
7070
</script>

fe/src/components/post/badge/Time.vue

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@
77
@mouseleave="highlightPostStore.unset()"
88
:current="currentDateTime" :relativeTo="previousDateTime"
99
:relativeToText="`相对于上一${postType}${timestampType}`"
10-
:postType="props.postType" :timestampType="timestampType" v-bind="$attrs">
11-
<!-- https://github.com/vuejs/language-tools/issues/4798 -->
10+
:postType="postType" :timestampType="timestampType" v-bind="$attrs">
1211
<FontAwesome :icon="faChevronUp" class="me-1 align-bottom" />
1312
</PostBadgeTimeView>
1413
<PostBadgeTimeView
@@ -18,7 +17,7 @@
1817
@mouseleave="highlightPostStore.unset()"
1918
:current="currentDateTime" :relativeTo="nextDateTime"
2019
:relativeToText="`相对于下一${postType}${timestampType}`"
21-
:postType="props.postType" :timestampType="timestampType" v-bind="$attrs">
20+
:postType="postType" :timestampType="timestampType" v-bind="$attrs">
2221
<FontAwesome :icon="faChevronDown" class="me-1 align-bottom" />
2322
</PostBadgeTimeView>
2423
<PostBadgeTimeView
@@ -29,12 +28,12 @@
2928
@mouseleave="highlightPostStore.unset()"
3029
:current="currentDateTime" :relativeTo="parentDateTime"
3130
:relativeToText="`相对于所属${postTypeText[postTypeText.indexOf(postType) - 1]}${timestampType}`"
32-
:postType="props.postType" :timestampType="timestampType" v-bind="$attrs">
31+
:postType="postType" :timestampType="timestampType" v-bind="$attrs">
3332
<FontAwesome :icon="faAnglesUp" class="me-1 align-bottom" />
3433
</PostBadgeTimeView>
3534
</ClientOnly>
3635
<PostBadgeTimeView
37-
:current="currentDateTime" :postType="props.postType"
36+
:current="currentDateTime" :postType="postType"
3837
:timestampType="timestampType" class="text-end"
3938
:class="{ 'post-badge-time-current-full': hydrationStore.isHydratingOrSSR }" v-bind="$attrs" />
4039
</template>
@@ -54,7 +53,17 @@ import { faAnglesUp, faChevronDown, faChevronUp } from '@fortawesome/free-solid-
5453
import { DateTime } from 'luxon';
5554
5655
defineOptions({ inheritAttrs: false });
57-
const props = defineProps<{
56+
const {
57+
previousPost,
58+
nextPost,
59+
currentPost,
60+
currentPostIDKey,
61+
parentPost,
62+
parentPostIDKey,
63+
postType,
64+
postTimeKey,
65+
timestampType
66+
} = defineProps<{
5867
previousPost?: TPost,
5968
nextPost?: TPost,
6069
currentPost: TPost,
@@ -78,12 +87,12 @@ useNoScript(`<style>
7887
// https://github.com/typescript-eslint/typescript-eslint/issues/9723
7988
// eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents, @typescript-eslint/no-unnecessary-type-parameters
8089
const getPostTime = <T extends TPost | TParentPost>(post?: T) =>
81-
post?.[props.postTimeKey as keyof T] as TPostTimeValue | undefined;
82-
const previousTime = computed(() => getPostTime(props.previousPost));
83-
const nextTime = computed(() => getPostTime(props.nextPost));
84-
const parentTime = computed(() => getPostTime(props.parentPost));
90+
post?.[postTimeKey as keyof T] as TPostTimeValue | undefined;
91+
const previousTime = computed(() => getPostTime(previousPost));
92+
const nextTime = computed(() => getPostTime(nextPost));
93+
const parentTime = computed(() => getPostTime(parentPost));
8594
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
86-
const currentTime = computed(() => getPostTime(props.currentPost)!);
95+
const currentTime = computed(() => getPostTime(currentPost)!);
8796
8897
const previousDateTime = computed(() =>
8998
undefinedOr(previousTime.value, i => DateTime.fromSeconds(i)));

fe/src/components/post/queryForm/QueryForm.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ const { queryFormDeps } = defineProps<{
203203
isLoading: boolean,
204204
queryFormDeps: QueryFormDeps
205205
}>();
206-
const {
206+
const { // https://github.com/orgs/vuejs/discussions/6147
207207
isOrderByInvalid,
208208
isFidInvalid,
209209
currentQueryType,

0 commit comments

Comments
 (0)