Skip to content

Commit

Permalink
feat: persist the sorting mode
Browse files Browse the repository at this point in the history
  • Loading branch information
WhiteMinds committed Mar 9, 2024
1 parent 47bf04f commit b6c015f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
1 change: 1 addition & 0 deletions packages/shared/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export interface Settings {
autoGenerateSRTOnRecordStop?: boolean
autoRemoveRecordWhenTinySize?: boolean
locale?: string
sortMode?: string
}

/** electron render 给 web 暴露的 API */
Expand Down
12 changes: 11 additions & 1 deletion packages/web/src/views/RecordersManage/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,15 @@
</template>

<script setup lang="ts">
import { computed, onMounted, ref, normalizeClass } from 'vue'
import { computed, onMounted, ref, normalizeClass, watch } from 'vue'
import type { ClientRecorder } from '@autorecord/http-server'
import { RecorderService } from '../../services/RecorderService'
import RecorderCard from './RecorderCard.vue'
import { RouteNames } from '../../router'
import { assert } from '../../utils'
import { useRoute } from 'vue-router'
import { useI18n } from 'vue-i18n'
import { LARServerService } from '../../services/LARServerService'
const { t, locale } = useI18n()
const route = useRoute()
Expand Down Expand Up @@ -113,6 +114,15 @@ const sortModes: {
const sortMode = ref(sortModes[0])
const filterText = ref<string>('')
// TODO: 不知道为啥直接 await 会白屏,先简单实现
LARServerService.getSettings({}).then((settings) => {
sortMode.value = sortModes.find((mode) => mode.id === settings.sortMode) ?? sortModes[0]
})
watch(sortMode, async ({ id }) => {
const settings = await LARServerService.getSettings({})
await LARServerService.setSettings({ ...settings, sortMode: id })
})
const displayingRecorders = computed(() => {
const fields: (keyof ClientRecorder)[] = ['remarks', 'channelId']
const result = recorders.value.filter((recorder) =>
Expand Down

0 comments on commit b6c015f

Please sign in to comment.