Skip to content

Commit 6b7ca4a

Browse files
committed
* fix violation of roslyn analyzer rule RSPEC-2325 @ c#/shared
* fix vueuse/vueuse#4216 @ utils/echarts.ts * fix typescript-eslint/typescript-eslint#9706 @ api/index.ts * fix violation of eslitn rule `@stylistic/indent` @ pages/posts.vue $ git checkout 982e84b^1 src/components/post/badge/{Common,Time}.vue # to fix vuejs/language-tools#4820 @ fe
1 parent 694976f commit 6b7ca4a

File tree

6 files changed

+31
-35
lines changed

6 files changed

+31
-35
lines changed

c#/shared/src/Db/TbmDbContext.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,9 @@ public class TbmDbContext<TModelCacheKeyFactory>(ILogger<TbmDbContext<TModelCach
144144
public DbSet<ImageInReply> ImageInReplies => Set<ImageInReply>();
145145
public DbSet<ReplyContentImage> ReplyContentImages => Set<ReplyContentImage>();
146146

147+
protected static void OnModelCreatingWithFid(ModelBuilder b, uint fid) =>
148+
b.Entity<ReplyContentImage>().ToTable($"tbmc_f{fid}_reply_content_image");
149+
147150
[SuppressMessage("Naming", "CA1725:Parameter names should match base declaration")]
148151
[SuppressMessage("Critical Code Smell", "S927:Parameter names should match base declaration and other partial definitions")]
149152
[SuppressMessage("Style", "IDE0058:Expression value is never used")]
@@ -176,9 +179,6 @@ protected override void OnModelCreating(ModelBuilder b)
176179
b.Entity<ReplyContentImage>().HasOne(e => e.ImageInReply).WithMany();
177180
}
178181

179-
protected void OnModelCreatingWithFid(ModelBuilder b, uint fid) =>
180-
b.Entity<ReplyContentImage>().ToTable($"tbmc_f{fid}_reply_content_image");
181-
182182
protected virtual void OnConfiguringNpgsql(NpgsqlDbContextOptionsBuilder builder) { }
183183
protected virtual void OnBuildingNpgsqlDataSource(NpgsqlDataSourceBuilder builder) { }
184184

fe/src/api/index.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,6 @@ const queryFunctionWithReCAPTCHA = async <TResponse>
8888
export type ApiErrorClass = ApiResponseError | FetchError;
8989
type QueryFunctions = typeof queryFunction | typeof queryFunctionWithReCAPTCHA;
9090
const useApi = <
91-
92-
// https://github.com/typescript-eslint/typescript-eslint/issues/9706
93-
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-parameters
9491
TApi extends Api<TResponse, TQueryParam>,
9592
TResponse = TApi['response'],
9693
TQueryParam extends ObjUnknown = TApi['queryParam']>
@@ -128,9 +125,6 @@ const useApi = <
128125
return ret;
129126
};
130127
const useApiWithCursor = <
131-
132-
// https://github.com/typescript-eslint/typescript-eslint/issues/9706
133-
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-parameters
134128
TApi extends Api<TResponse, TQueryParam>,
135129
TResponse extends CursorPagination = TApi['response'],
136130
TQueryParam extends ObjUnknown = TApi['queryParam']>

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ 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+
// https://github.com/vuejs/language-tools/issues/3267
45+
const { post } = defineProps<{
4546
post: TPost,
4647
postIDKey: TPostIDKey,
4748
postTypeText: PostTypeTextOf<TPost>
@@ -64,7 +65,7 @@ const formatTime = (time: UnixTimestamp) => {
6465
};
6566
6667
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)}`;
68+
首次收录时间:${formatTime(post.createdAt)}<br>
69+
最后更新时间:${formatTime(post.updatedAt ?? post.createdAt)}<br>
70+
最后发现时间:${formatTime(post.lastSeenAt ?? post.updatedAt ?? post.createdAt)}`;
7071
</script>

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

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,39 +2,39 @@
22
<ClientOnly>
33
<PostBadgeTimeView
44
v-if="previousTime !== undefined && previousTime < currentTime"
5-
@mouseenter="previousPost !== undefined
5+
@mouseenter="() => previousPost !== undefined
66
&& highlightPostStore.set(previousPost, currentPostIDKey)"
7-
@mouseleave="highlightPostStore.unset()"
7+
@mouseleave="() => highlightPostStore.unset()"
88
:current="currentDateTime" :relativeTo="previousDateTime"
99
:relativeToText="`相对于上一${postType}${timestampType}`"
10-
:postType="props.postType" :timestampType="timestampType" v-bind="$attrs">
10+
:postType="postType" :timestampType="timestampType" v-bind="$attrs">
1111
<!-- https://github.com/vuejs/language-tools/issues/4798 -->
1212
<FontAwesome :icon="faChevronUp" class="me-1 align-bottom" />
1313
</PostBadgeTimeView>
1414
<PostBadgeTimeView
1515
v-else-if="nextTime !== undefined && nextTime < currentTime"
16-
@mouseenter="nextPost !== undefined
16+
@mouseenter="() => nextPost !== undefined
1717
&& highlightPostStore.set(nextPost, currentPostIDKey)"
18-
@mouseleave="highlightPostStore.unset()"
18+
@mouseleave="() => highlightPostStore.unset()"
1919
:current="currentDateTime" :relativeTo="nextDateTime"
2020
:relativeToText="`相对于下一${postType}${timestampType}`"
21-
:postType="props.postType" :timestampType="timestampType" v-bind="$attrs">
21+
:postType="postType" :timestampType="timestampType" v-bind="$attrs">
2222
<FontAwesome :icon="faChevronDown" class="me-1 align-bottom" />
2323
</PostBadgeTimeView>
2424
<PostBadgeTimeView
2525
v-else-if="parentTime !== undefined && parentTime !== currentTime"
26-
@mouseenter="parentPost !== undefined
26+
@mouseenter="() => parentPost !== undefined
2727
&& parentPostIDKey !== undefined
2828
&& highlightPostStore.set(parentPost, parentPostIDKey)"
29-
@mouseleave="highlightPostStore.unset()"
29+
@mouseleave="() => highlightPostStore.unset()"
3030
:current="currentDateTime" :relativeTo="parentDateTime"
3131
:relativeToText="`相对于所属${postTypeText[postTypeText.indexOf(postType) - 1]}${timestampType}`"
32-
:postType="props.postType" :timestampType="timestampType" v-bind="$attrs">
32+
:postType="postType" :timestampType="timestampType" v-bind="$attrs">
3333
<FontAwesome :icon="faAnglesUp" class="me-1 align-bottom" />
3434
</PostBadgeTimeView>
3535
</ClientOnly>
3636
<PostBadgeTimeView
37-
:current="currentDateTime" :postType="props.postType"
37+
:current="currentDateTime" :postType="postType"
3838
:timestampType="timestampType" class="text-end"
3939
:class="{ 'post-badge-time-current-full': hydrationStore.isHydratingOrSSR }" v-bind="$attrs" />
4040
</template>
@@ -54,7 +54,7 @@ import { faAnglesUp, faChevronDown, faChevronUp } from '@fortawesome/free-solid-
5454
import { DateTime } from 'luxon';
5555
5656
defineOptions({ inheritAttrs: false });
57-
const props = defineProps<{
57+
const { previousPost, nextPost, currentPost, parentPost, postTimeKey } = defineProps<{
5858
previousPost?: TPost,
5959
nextPost?: TPost,
6060
currentPost: TPost,
@@ -69,21 +69,22 @@ const props = defineProps<{
6969
const highlightPostStore = useHighlightPostStore();
7070
const hydrationStore = useHydrationStore();
7171
72-
useNoScript(`<style>
72+
const noScriptStyle = `<style>
7373
.post-badge-time-current-full {
7474
width: auto !important;
7575
}
76-
</style>`);
76+
</style>`; // https://github.com/nuxt/nuxt/issues/13848
77+
useHead({ noscript: [{ innerHTML: noScriptStyle }] });
7778
7879
// https://github.com/typescript-eslint/typescript-eslint/issues/9723
7980
// eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents, @typescript-eslint/no-unnecessary-type-parameters
8081
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));
82+
post?.[postTimeKey as keyof T] as TPostTimeValue | undefined;
83+
const previousTime = computed(() => getPostTime(previousPost));
84+
const nextTime = computed(() => getPostTime(nextPost));
85+
const parentTime = computed(() => getPostTime(parentPost));
8586
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
86-
const currentTime = computed(() => getPostTime(props.currentPost)!);
87+
const currentTime = computed(() => getPostTime(currentPost)!);
8788
8889
const previousDateTime = computed(() =>
8990
undefinedOr(previousTime.value, i => DateTime.fromSeconds(i)));

fe/src/pages/posts.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,8 @@ watch([dataUpdatedAt, errorUpdatedAt], async (updatedAt: UnixTimestamp[]) => {
7676
const postCount = _.sum(Object.values(fetchedPage?.pages.matchQueryPostCount ?? {}));
7777
notyShow('success', `已加载${postCount}条记录
7878
${isQueryCached
79-
? '使用前端本地缓存'
80-
: `
79+
? '使用前端本地缓存'
80+
: `
8181
前端耗时${_.round(renderDuration / 1000, 2)}s
8282
${isQueriedBySSR ? '使用服务端渲染预请求' : ''}
8383
后端+网络耗时${_.round(networkDuration / 1000, 2)}s`}`);

fe/src/utils/echarts.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ import * as echarts from 'echarts/core';
55
import type { ColorPaletteOptionMixin } from 'echarts/types/src/util/types.d.ts';
66

77
export const useResizeableEcharts = (el: Parameters<typeof useResizeObserver>[0]) =>
8-
useResizeObserver(el, _.debounce((entries: Parameters<Parameters<typeof useResizeObserver>[1]>[0]) => { // https://github.com/vueuse/vueuse/issues/4216
9-
entries.forEach(entry => {
8+
useResizeObserver(el, _.debounce((entries: ResizeObserverEntry) => {
9+
entries.forEach(entry => {
1010
echarts.getInstanceByDom(entry.target as HTMLElement)?.resize();
1111
});
1212
}, 1000));

0 commit comments

Comments
 (0)