Skip to content

Commit

Permalink
* fix getUser() & renderUsername() is not reactivity like d65bec2
Browse files Browse the repository at this point in the history
…@ `<RendererTable>`

* omit explicit reference to `props` in `<template>` @ `<PostPage>` & `<SelectParam>`
* inline immediately assign to `ref.value` to the initial value param of `ref()` @ `<Time(Range|Granularity)>`
* using https://github.com/tc39/proposal-import-attributes when importing JSON files as ESM @ api/bilibiliVote/index.ts
* enable some `*.inlayHints.*` and `typescript.preferences.preferTypeOnlyAutoImports` @ .vscode/settings.json
@ fe
  • Loading branch information
n0099 committed Mar 12, 2024
1 parent 1e5835e commit 68ce9df
Show file tree
Hide file tree
Showing 8 changed files with 41 additions and 26 deletions.
20 changes: 18 additions & 2 deletions fe/.vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,24 @@
"typescript.enablePromptUseWorkspaceTsdk": true,
"typescript.tsdk": ".yarn/sdks/typescript/lib",
"eslint.nodePath": ".yarn/sdks",
"vue.complete.casing.props": "autoCamel",
"[vue]": {
"editor.defaultFormatter": "Vue.volar"
}
},
// below are optional settings
"vue.complete.casing.props": "autoCamel",
"javascript.inlayHints.enumMemberValues.enabled": true,
"javascript.inlayHints.functionLikeReturnTypes.enabled": true,
"javascript.inlayHints.parameterNames.enabled": "literals",
"javascript.inlayHints.parameterTypes.enabled": true,
"javascript.inlayHints.propertyDeclarationTypes.enabled": true,
"typescript.inlayHints.enumMemberValues.enabled": true,
"typescript.inlayHints.propertyDeclarationTypes.enabled": true,
"typescript.inlayHints.parameterTypes.enabled": true,
"typescript.inlayHints.parameterNames.enabled": "literals",
"typescript.inlayHints.functionLikeReturnTypes.enabled": true,
"vue.inlayHints.missingProps": true,
"vue.inlayHints.inlineHandlerLeading": true,
"vue.inlayHints.optionsWrapper": true,
"vue.inlayHints.vBindShorthand": true,
"typescript.preferences.preferTypeOnlyAutoImports": true
}
18 changes: 9 additions & 9 deletions fe/src/api/bilibiliVote/index.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import allCandidatesVoteCount from './allCandidatesVoteCount.json';
import allVoteCountGroupByHour from './allVoteCountGroupByHour.json';
import allVoteCountGroupByMinute from './allVoteCountGroupByMinute.json';
import candidateNames from './candidateNames.json';
import top10CandidatesTimeline from './top10CandidatesTimeline.json';
import top50CandidatesOfficialValidVoteCount from './top50CandidatesOfficialValidVoteCount.json';
import top50CandidatesVoteCount from './top50CandidatesVoteCount.json';
import top5CandidatesVoteCountGroupByHour from './top5CandidatesVoteCountGroupByHour.json';
import top5CandidatesVoteCountGroupByMinute from './top5CandidatesVoteCountGroupByMinute.json';
import allCandidatesVoteCount from './allCandidatesVoteCount.json' with { type: 'json' };
import allVoteCountGroupByHour from './allVoteCountGroupByHour.json' with { type: 'json' };
import allVoteCountGroupByMinute from './allVoteCountGroupByMinute.json' with { type: 'json' };
import candidateNames from './candidateNames.json' with { type: 'json' };
import top10CandidatesTimeline from './top10CandidatesTimeline.json' with { type: 'json' };
import top50CandidatesOfficialValidVoteCount from './top50CandidatesOfficialValidVoteCount.json' with { type: 'json' };
import top50CandidatesVoteCount from './top50CandidatesVoteCount.json' with { type: 'json' };
import top5CandidatesVoteCountGroupByHour from './top5CandidatesVoteCountGroupByHour.json' with { type: 'json' };
import top5CandidatesVoteCountGroupByMinute from './top5CandidatesVoteCountGroupByMinute.json' with { type: 'json' };
import type { BoolInt, Float, SqlDateTimeUtcPlus8, UInt, UnixTimestamp } from '@/shared';

export const json = {
Expand Down
4 changes: 2 additions & 2 deletions fe/src/components/Post/PostPage.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<PageCurrentButton :currentCursor="props.posts.pages.currentCursor" />
<PageCurrentButton :currentCursor="posts.pages.currentCursor" />
<RendererList v-if="renderType === 'list'" :initialPosts="posts" />
<RendererTable v-else-if="renderType === 'table'" :posts="posts" />
<PageNextButton v-if="isLastPageInPages && !isFetching && hasNextPage"
Expand All @@ -14,7 +14,7 @@ import PageNextButton from '../paginations/PageNextButton.vue';
import type { PostRenderer } from '@/views/Post.vue';
import type { ApiPosts } from '@/api/index.d';
const props = defineProps<{
defineProps<{
posts: ApiPosts['response'],
renderType: PostRenderer,
isFetching: boolean,
Expand Down
4 changes: 2 additions & 2 deletions fe/src/components/Post/badges/BadgeUser.vue
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,6 @@ const knownModeratorTypes: { [P in ForumModeratorType]: [string, BootstrapColor]
publication_editor: ['吧刊小编', 'secondary'],
publication: ['吧刊小编', 'secondary']
};
const moderators = computed(() =>
_.pick(knownModeratorTypes, props.user.currentForumModerator?.moderatorTypes.split(',') ?? []));
const moderators = computed(() => _.pick(knownModeratorTypes,
props.user.currentForumModerator?.moderatorTypes.split(',') ?? []));
</script>
4 changes: 2 additions & 2 deletions fe/src/components/Post/queryForm/widgets/SelectParam.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<template>
<select @change="e => emit('paramChange', (e.target as HTMLSelectElement).value)"
:value="props.currentParam" class="form-select form-control flex-grow-0" id="newParam">
:value="currentParam" class="form-select form-control flex-grow-0" id="newParam">
<option value="add" disabled>New...</option>
<optgroup v-for="(group, groupName) in paramsGroup" :key="groupName" :label="groupName">
<option v-for="(paramDescription, paramName) in group"
Expand Down Expand Up @@ -49,7 +49,7 @@ const paramsGroup = {
<script setup lang="ts">
import * as _ from 'lodash-es';
const props = defineProps<{ currentParam: string }>();
defineProps<{ currentParam: string }>();
// eslint-disable-next-line vue/define-emits-declaration
const emit = defineEmits({ paramChange: p => _.includes(_.flatMap(paramsGroup, Object.keys), p) });
</script>
Expand Down
6 changes: 3 additions & 3 deletions fe/src/components/Post/renderers/RendererTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ import type { Reply, SubReply, Thread } from '@/api/post';
import type { Pid, Tid } from '@/shared';
import { toUserPortraitImageUrl, toUserProfileUrl } from '@/shared';
import { onMounted, ref } from 'vue';
import { computed, onMounted, ref } from 'vue';
import { RouterLink } from 'vue-router';
import { Table } from 'ant-design-vue';
import type { ColumnType } from 'ant-design-vue/es/table/interface';
Expand Down Expand Up @@ -145,8 +145,8 @@ const subReplyColumns = ref<ColumnType[]>([
{ title: '最后更新时间', dataIndex: 'updatedAt' }
]);
const getUser = baseGetUser(props.posts.users);
const renderUsername = baseRenderUsername(getUser);
const getUser = computed(() => baseGetUser(props.posts.users));
const renderUsername = computed(() => baseRenderUsername(getUser.value));
onMounted(() => {
threads.value = props.posts.threads;
Expand Down
5 changes: 2 additions & 3 deletions fe/src/components/widgets/TimeGranularity.vue
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ const granularitiesDefaultOption: TimeGranularityStringMap = {
month: '',
year: ''
};
const options = ref<TimeGranularityStringMap>({});
options.value = _.pick(granularitiesDefaultOption,
_.intersection(props.granularities, Object.keys(granularitiesDefaultOption)));
const options = ref<TimeGranularityStringMap>(_.pick(granularitiesDefaultOption,
_.intersection(props.granularities, Object.keys(granularitiesDefaultOption))));
</script>
6 changes: 3 additions & 3 deletions fe/src/components/widgets/TimeRange.vue
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@ const emit = defineEmits({
'update:startTime': i => _.isNumber(i),
'update:endTime': i => _.isNumber(i)
});
const timeRange = ref<[Dayjs, Dayjs]>([dayjs(), dayjs()]);
timeRange.value = [
const timeRange = ref<[Dayjs, Dayjs]>([
dayjs(DateTime.now().minus(props.startBefore).startOf('minute').toISO()),
dayjs(DateTime.now().startOf('minute').toISO())
];
]);
watchEffect(() => {
timeRange.value = [unix(props.startTime), unix(props.endTime)];
});
Expand Down

0 comments on commit 68ce9df

Please sign in to comment.