From 8b1f1ca494b4ede4a2ecc7bee026b3cfb789287b Mon Sep 17 00:00:00 2001 From: n0099 Date: Thu, 19 Sep 2024 11:45:04 +0000 Subject: [PATCH] * fix violation of roslyn analyzer rule `RSPEC-2325` @ c#/shared * fix https://github.com/vueuse/vueuse/issues/4216 @ utils/echarts.ts * fix https://github.com/typescript-eslint/typescript-eslint/issues/9706 @ api/index.ts * fix violation of eslitn rule `@stylistic/indent` @ pages/posts.vue $ git checkout 982e84b17956b0c4b264332b88799952a6949885^1 src/components/post/badge/{Common,Time}.vue # to fix https://github.com/vuejs/language-tools/issues/4820 @ fe $ git ls-files -z | xargs -0 sed -i 's/\t/ /g' --- .gitmodules | 4 +- .../Tieba/Crawl/Saver/SaverWithRevision.cs | 8 +-- c#/shared/src/Db/TbmDbContext.cs | 6 +- c#/tbm.sln | 70 +++++++++---------- c#/tbm.sln.DotSettings | 4 +- fe/src/api/index.ts | 6 -- fe/src/components/post/badge/Common.vue | 9 +-- fe/src/components/post/badge/Time.vue | 25 +++---- fe/src/pages/posts.vue | 4 +- fe/src/utils/echarts.ts | 2 +- 10 files changed, 67 insertions(+), 71 deletions(-) diff --git a/.gitmodules b/.gitmodules index 6b477c90..5c94e873 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,3 @@ [submodule "tbclient.protobuf"] - path = tbclient.protobuf - url = git@github.com:n0099/tbclient.protobuf.git + path = tbclient.protobuf + url = git@github.com:n0099/tbclient.protobuf.git diff --git a/c#/crawler/src/Tieba/Crawl/Saver/SaverWithRevision.cs b/c#/crawler/src/Tieba/Crawl/Saver/SaverWithRevision.cs index 1b7409b7..53614a6a 100644 --- a/c#/crawler/src/Tieba/Crawl/Saver/SaverWithRevision.cs +++ b/c#/crawler/src/Tieba/Crawl/Saver/SaverWithRevision.cs @@ -62,9 +62,7 @@ public partial class SaverWithRevision } public partial class SaverWithRevision { - protected abstract NullFieldsBitMask GetRevisionNullFieldBitMask(string fieldName); - - protected IEnumerable> SaveNewEntities( + protected static IEnumerable> SaveNewEntities( CrawlerDbContext db, IReadOnlyCollection> maybeEntities) where TEntity : RowVersionedEntity @@ -76,7 +74,7 @@ protected IEnumerable> SaveNewEntities( .Select(entity => new ExistingAndNewEntity(entity.Existing!, entity.New)); } - protected void SaveExistingEntities( + protected static void SaveExistingEntities( CrawlerDbContext db, IEnumerable> existingAndNewEntities) where TEntity : RowVersionedEntity => @@ -103,6 +101,8 @@ on newNavigation.Metadata.Name equals existingNavigation.Metadata.Name .ForEach(prop => prop.IsModified = false); }); + protected abstract NullFieldsBitMask GetRevisionNullFieldBitMask(string fieldName); + protected void SaveExistingEntityRevisions( CrawlerDbContext db, Func revisionFactory, diff --git a/c#/shared/src/Db/TbmDbContext.cs b/c#/shared/src/Db/TbmDbContext.cs index 01a5396d..0f4ab596 100644 --- a/c#/shared/src/Db/TbmDbContext.cs +++ b/c#/shared/src/Db/TbmDbContext.cs @@ -144,6 +144,9 @@ public class TbmDbContext(ILogger ImageInReplies => Set(); public DbSet ReplyContentImages => Set(); + protected static void OnModelCreatingWithFid(ModelBuilder b, uint fid) => + b.Entity().ToTable($"tbmc_f{fid}_reply_content_image"); + [SuppressMessage("Naming", "CA1725:Parameter names should match base declaration")] [SuppressMessage("Critical Code Smell", "S927:Parameter names should match base declaration and other partial definitions")] [SuppressMessage("Style", "IDE0058:Expression value is never used")] @@ -176,9 +179,6 @@ protected override void OnModelCreating(ModelBuilder b) b.Entity().HasOne(e => e.ImageInReply).WithMany(); } - protected void OnModelCreatingWithFid(ModelBuilder b, uint fid) => - b.Entity().ToTable($"tbmc_f{fid}_reply_content_image"); - protected virtual void OnConfiguringNpgsql(NpgsqlDbContextOptionsBuilder builder) { } protected virtual void OnBuildingNpgsqlDataSource(NpgsqlDataSourceBuilder builder) { } diff --git a/c#/tbm.sln b/c#/tbm.sln index ca51ba54..9b4b2269 100644 --- a/c#/tbm.sln +++ b/c#/tbm.sln @@ -3,13 +3,13 @@ Microsoft Visual Studio Solution File, Format Version 12.00 VisualStudioVersion = 17.4.33213.308 MinimumVisualStudioVersion = 10.0.40219.1 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{B0F531C7-9D14-4F81-B809-D6429D4103FC}" - ProjectSection(SolutionItems) = preProject - .editorconfig = .editorconfig - .gitignore = .gitignore - stylecop.json = stylecop.json - GlobalSuppressions.cs = GlobalSuppressions.cs - Directory.Build.props = Directory.Build.props - EndProjectSection + ProjectSection(SolutionItems) = preProject + .editorconfig = .editorconfig + .gitignore = .gitignore + stylecop.json = stylecop.json + GlobalSuppressions.cs = GlobalSuppressions.cs + Directory.Build.props = Directory.Build.props + EndProjectSection EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TbClient", "tbClient\TbClient.csproj", "{4D782E36-9769-4B10-8D5F-F1F3648F8D74}" EndProject @@ -20,32 +20,32 @@ EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "tbm.ImagePipeline", "imagePipeline\tbm.ImagePipeline.csproj", "{3DC9F1EC-5F76-4F78-9F00-99908CED450B}" EndProject Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {D7F086F7-6DBF-4C26-AB68-0093063FF755}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {D7F086F7-6DBF-4C26-AB68-0093063FF755}.Debug|Any CPU.Build.0 = Debug|Any CPU - {D7F086F7-6DBF-4C26-AB68-0093063FF755}.Release|Any CPU.ActiveCfg = Release|Any CPU - {D7F086F7-6DBF-4C26-AB68-0093063FF755}.Release|Any CPU.Build.0 = Release|Any CPU - {3DAC21AE-4493-4CF2-B887-203A781C12AA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {3DAC21AE-4493-4CF2-B887-203A781C12AA}.Debug|Any CPU.Build.0 = Debug|Any CPU - {3DAC21AE-4493-4CF2-B887-203A781C12AA}.Release|Any CPU.ActiveCfg = Release|Any CPU - {3DAC21AE-4493-4CF2-B887-203A781C12AA}.Release|Any CPU.Build.0 = Release|Any CPU - {3DC9F1EC-5F76-4F78-9F00-99908CED450B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {3DC9F1EC-5F76-4F78-9F00-99908CED450B}.Debug|Any CPU.Build.0 = Debug|Any CPU - {3DC9F1EC-5F76-4F78-9F00-99908CED450B}.Release|Any CPU.ActiveCfg = Release|Any CPU - {3DC9F1EC-5F76-4F78-9F00-99908CED450B}.Release|Any CPU.Build.0 = Release|Any CPU - {4D782E36-9769-4B10-8D5F-F1F3648F8D74}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {4D782E36-9769-4B10-8D5F-F1F3648F8D74}.Debug|Any CPU.Build.0 = Debug|Any CPU - {4D782E36-9769-4B10-8D5F-F1F3648F8D74}.Release|Any CPU.ActiveCfg = Release|Any CPU - {4D782E36-9769-4B10-8D5F-F1F3648F8D74}.Release|Any CPU.Build.0 = Release|Any CPU - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {A136C5D5-62D8-4451-B139-33124D2A44E5} - EndGlobalSection + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {D7F086F7-6DBF-4C26-AB68-0093063FF755}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {D7F086F7-6DBF-4C26-AB68-0093063FF755}.Debug|Any CPU.Build.0 = Debug|Any CPU + {D7F086F7-6DBF-4C26-AB68-0093063FF755}.Release|Any CPU.ActiveCfg = Release|Any CPU + {D7F086F7-6DBF-4C26-AB68-0093063FF755}.Release|Any CPU.Build.0 = Release|Any CPU + {3DAC21AE-4493-4CF2-B887-203A781C12AA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {3DAC21AE-4493-4CF2-B887-203A781C12AA}.Debug|Any CPU.Build.0 = Debug|Any CPU + {3DAC21AE-4493-4CF2-B887-203A781C12AA}.Release|Any CPU.ActiveCfg = Release|Any CPU + {3DAC21AE-4493-4CF2-B887-203A781C12AA}.Release|Any CPU.Build.0 = Release|Any CPU + {3DC9F1EC-5F76-4F78-9F00-99908CED450B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {3DC9F1EC-5F76-4F78-9F00-99908CED450B}.Debug|Any CPU.Build.0 = Debug|Any CPU + {3DC9F1EC-5F76-4F78-9F00-99908CED450B}.Release|Any CPU.ActiveCfg = Release|Any CPU + {3DC9F1EC-5F76-4F78-9F00-99908CED450B}.Release|Any CPU.Build.0 = Release|Any CPU + {4D782E36-9769-4B10-8D5F-F1F3648F8D74}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {4D782E36-9769-4B10-8D5F-F1F3648F8D74}.Debug|Any CPU.Build.0 = Debug|Any CPU + {4D782E36-9769-4B10-8D5F-F1F3648F8D74}.Release|Any CPU.ActiveCfg = Release|Any CPU + {4D782E36-9769-4B10-8D5F-F1F3648F8D74}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {A136C5D5-62D8-4451-B139-33124D2A44E5} + EndGlobalSection EndGlobal diff --git a/c#/tbm.sln.DotSettings b/c#/tbm.sln.DotSettings index 89139de3..3179b1d6 100644 --- a/c#/tbm.sln.DotSettings +++ b/c#/tbm.sln.DotSettings @@ -1,6 +1,6 @@ - False - True + False + True True True True diff --git a/fe/src/api/index.ts b/fe/src/api/index.ts index 488e8705..9d7d77d9 100644 --- a/fe/src/api/index.ts +++ b/fe/src/api/index.ts @@ -88,9 +88,6 @@ const queryFunctionWithReCAPTCHA = async export type ApiErrorClass = ApiResponseError | FetchError; type QueryFunctions = typeof queryFunction | typeof queryFunctionWithReCAPTCHA; const useApi = < - - // https://github.com/typescript-eslint/typescript-eslint/issues/9706 - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-parameters TApi extends Api, TResponse = TApi['response'], TQueryParam extends ObjUnknown = TApi['queryParam']> @@ -128,9 +125,6 @@ const useApi = < return ret; }; const useApiWithCursor = < - - // https://github.com/typescript-eslint/typescript-eslint/issues/9706 - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-parameters TApi extends Api, TResponse extends CursorPagination = TApi['response'], TQueryParam extends ObjUnknown = TApi['queryParam']> diff --git a/fe/src/components/post/badge/Common.vue b/fe/src/components/post/badge/Common.vue index 774cc103..85434bd9 100644 --- a/fe/src/components/post/badge/Common.vue +++ b/fe/src/components/post/badge/Common.vue @@ -41,7 +41,8 @@ import { faClock } from '@fortawesome/free-regular-svg-icons'; import { faArrowUpRightFromSquare, faHashtag, faLink } from '@fortawesome/free-solid-svg-icons'; import { DateTime } from 'luxon'; -const props = defineProps<{ +// https://github.com/vuejs/language-tools/issues/3267 +const { post } = defineProps<{ post: TPost, postIDKey: TPostIDKey, postTypeText: PostTypeTextOf @@ -64,7 +65,7 @@ const formatTime = (time: UnixTimestamp) => { }; const tippyContent = () => ` -首次收录时间:${formatTime(props.post.createdAt)}
-最后更新时间:${formatTime(props.post.updatedAt ?? props.post.createdAt)}
-最后发现时间:${formatTime(props.post.lastSeenAt ?? props.post.updatedAt ?? props.post.createdAt)}`; +首次收录时间:${formatTime(post.createdAt)}
+最后更新时间:${formatTime(post.updatedAt ?? post.createdAt)}
+最后发现时间:${formatTime(post.lastSeenAt ?? post.updatedAt ?? post.createdAt)}`; diff --git a/fe/src/components/post/badge/Time.vue b/fe/src/components/post/badge/Time.vue index 31237e28..3e7b606f 100644 --- a/fe/src/components/post/badge/Time.vue +++ b/fe/src/components/post/badge/Time.vue @@ -7,7 +7,7 @@ @mouseleave="highlightPostStore.unset()" :current="currentDateTime" :relativeTo="previousDateTime" :relativeToText="`相对于上一${postType}${timestampType}`" - :postType="props.postType" :timestampType="timestampType" v-bind="$attrs"> + :postType="postType" :timestampType="timestampType" v-bind="$attrs"> @@ -18,7 +18,7 @@ @mouseleave="highlightPostStore.unset()" :current="currentDateTime" :relativeTo="nextDateTime" :relativeToText="`相对于下一${postType}${timestampType}`" - :postType="props.postType" :timestampType="timestampType" v-bind="$attrs"> + :postType="postType" :timestampType="timestampType" v-bind="$attrs"> + :postType="postType" :timestampType="timestampType" v-bind="$attrs"> @@ -54,7 +54,7 @@ import { faAnglesUp, faChevronDown, faChevronUp } from '@fortawesome/free-solid- import { DateTime } from 'luxon'; defineOptions({ inheritAttrs: false }); -const props = defineProps<{ +const { previousPost, nextPost, currentPost, parentPost, postTimeKey } = defineProps<{ previousPost?: TPost, nextPost?: TPost, currentPost: TPost, @@ -69,21 +69,22 @@ const props = defineProps<{ const highlightPostStore = useHighlightPostStore(); const hydrationStore = useHydrationStore(); -useNoScript(``); +`; // https://github.com/nuxt/nuxt/issues/13848 +useHead({ noscript: [{ innerHTML: noScriptStyle }] }); // https://github.com/typescript-eslint/typescript-eslint/issues/9723 // eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents, @typescript-eslint/no-unnecessary-type-parameters const getPostTime = (post?: T) => - post?.[props.postTimeKey as keyof T] as TPostTimeValue | undefined; -const previousTime = computed(() => getPostTime(props.previousPost)); -const nextTime = computed(() => getPostTime(props.nextPost)); -const parentTime = computed(() => getPostTime(props.parentPost)); + post?.[postTimeKey as keyof T] as TPostTimeValue | undefined; +const previousTime = computed(() => getPostTime(previousPost)); +const nextTime = computed(() => getPostTime(nextPost)); +const parentTime = computed(() => getPostTime(parentPost)); // eslint-disable-next-line @typescript-eslint/no-non-null-assertion -const currentTime = computed(() => getPostTime(props.currentPost)!); +const currentTime = computed(() => getPostTime(currentPost)!); const previousDateTime = computed(() => undefinedOr(previousTime.value, i => DateTime.fromSeconds(i))); diff --git a/fe/src/pages/posts.vue b/fe/src/pages/posts.vue index 146d86fe..1351f9be 100644 --- a/fe/src/pages/posts.vue +++ b/fe/src/pages/posts.vue @@ -76,8 +76,8 @@ watch([dataUpdatedAt, errorUpdatedAt], async (updatedAt: UnixTimestamp[]) => { const postCount = _.sum(Object.values(fetchedPage?.pages.matchQueryPostCount ?? {})); notyShow('success', `已加载${postCount}条记录 ${isQueryCached - ? '使用前端本地缓存' - : ` + ? '使用前端本地缓存' + : ` 前端耗时${_.round(renderDuration / 1000, 2)}s ${isQueriedBySSR ? '使用服务端渲染预请求' : ''} 后端+网络耗时${_.round(networkDuration / 1000, 2)}s`}`); diff --git a/fe/src/utils/echarts.ts b/fe/src/utils/echarts.ts index 5ac3a7d2..91f9c22e 100644 --- a/fe/src/utils/echarts.ts +++ b/fe/src/utils/echarts.ts @@ -5,7 +5,7 @@ import * as echarts from 'echarts/core'; import type { ColorPaletteOptionMixin } from 'echarts/types/src/util/types.d.ts'; export const useResizeableEcharts = (el: Parameters[0]) => - useResizeObserver(el, _.debounce((entries: Parameters[1]>[0]) => { // https://github.com/vueuse/vueuse/issues/4216 + useResizeObserver(el, _.debounce((entries: readonly ResizeObserverEntry[]) => { entries.forEach(entry => { echarts.getInstanceByDom(entry.target as HTMLElement)?.resize(); });