Skip to content

Commit

Permalink
🎈 perf: 类型注释等细节优化
Browse files Browse the repository at this point in the history
  • Loading branch information
andywang425 committed Sep 13, 2023
1 parent 742235c commit 1eb2d98
Show file tree
Hide file tree
Showing 9 changed files with 20 additions and 11 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

- 修复部分模块在特殊直播间不运行的Bug
- 修复领取大会员权益模块在领取前一天会多次运行的Bug
- 修复体验优化和移除元素板块不显示标题的Bug

## 调整

Expand Down
5 changes: 3 additions & 2 deletions src/components/PanelMain.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,18 @@ import LiveTasks from './LiveTasks.vue'
import OtherTasks from './OtherTasks.vue'
import EnhanceExperience from './EnhanceExperience.vue'
import RemoveElement from './RemoveElement.vue'
import { defineComponent } from 'vue'
// 注册对当前组件实例可用的组件
export default {
export default defineComponent({
components: {
MainSiteTasks,
LiveTasks,
OtherTasks,
EnhanceExperience,
RemoveElement
}
}
})
</script>

<script setup lang="ts">
Expand Down
1 change: 1 addition & 0 deletions src/library/mitt/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import mitt, { Emitter, EventHandlerMap, EventType, Handler } from 'mitt'

export interface EmitterOnce<Events extends Record<EventType, unknown>> extends Emitter<Events> {
/**
* 新增的 once 方法
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion src/library/storage/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { GM_getValue, GM_setValue } from '$'
import defaultValues from './defaultValue'
import defaultValues from './defaultValues'
import { IuiConfig, ImoduleConfig, Icache } from '../../types'
import _ from 'lodash'

Expand Down
7 changes: 3 additions & 4 deletions src/stores/useBiliStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,9 @@ export const useBiliStore = defineStore('bili', () => {
// 粉丝勋章列表
const fansMedals = ref<LiveData.FansMedalPanel.List[] | null>(null)
// 过滤了不存在直播间的粉丝勋章
const filteredFansMedals = computed<LiveData.FansMedalPanel.List[] | null>(() => {
if (!fansMedals.value) return null
return fansMedals.value.filter((m) => m.room_info.room_id !== 0)
})
const filteredFansMedals = computed<LiveData.FansMedalPanel.List[] | null>(
() => fansMedals.value?.filter((m) => m.room_info.room_id !== 0) ?? null
)

return {
BilibiliLive,
Expand Down
2 changes: 1 addition & 1 deletion src/stores/useModuleStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ export const useModuleStore = defineStore('module', () => {
* - `unknown`: 不知道(至少要等到`document-body`后才能确定)
* - `yes`: 是的
*/
function loadModules(isOnTargetFrame: isOnTargetFrameTypes) {
function loadModules(isOnTargetFrame: isOnTargetFrameTypes): void {
const cacheStore = useCacheStore()
const logger = new Logger('ModuleStore_LoadModules')
if (isOnTargetFrame === 'unknown') {
Expand Down
6 changes: 4 additions & 2 deletions src/types/cookies.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
type cookieValue = string | null

interface IbiliCookies {
bili_jct: string | null
LIVE_BUVID: string | null
bili_jct: cookieValue
LIVE_BUVID: cookieValue
}

export { IbiliCookies }
7 changes: 6 additions & 1 deletion src/types/storage.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,12 @@ interface ImoduleConfig {
}
}

type menuIndex = 'MainSiteTasks' | 'LiveTasks' | 'OtherTasks' | 'EnhanceExperience' | 'RemoveElement'
type menuIndex =
| 'MainSiteTasks'
| 'LiveTasks'
| 'OtherTasks'
| 'EnhanceExperience'
| 'RemoveElement'

interface IuiConfig {
isCollapse: boolean
Expand Down

0 comments on commit 1eb2d98

Please sign in to comment.