Skip to content

Commit

Permalink
feat: add version display
Browse files Browse the repository at this point in the history
  • Loading branch information
WhiteMinds committed Jan 8, 2024
1 parent 98777ba commit f7d6cfc
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 2 deletions.
7 changes: 6 additions & 1 deletion packages/electron/src/preload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,12 @@
*/
import { ClientAPI } from '@autorecord/shared'
import { contextBridge } from 'electron'
import packageJSON from '../package.json'

const clientAPI: ClientAPI = {}
const clientAPI: ClientAPI = {
getVersion() {
return packageJSON.version
},
}

contextBridge.exposeInMainWorld('clientAPI', clientAPI)
4 changes: 3 additions & 1 deletion packages/shared/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,6 @@ export interface Settings {
}

/** electron render 给 web 暴露的 API */
export interface ClientAPI {}
export interface ClientAPI {
getVersion(): string
}
12 changes: 12 additions & 0 deletions packages/web/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,15 @@
<router-view />
</div>
</template>

<script setup lang="ts">
import { onMounted } from 'vue'
import { ClientService } from './services/ClientService'
onMounted(() => {
const clientAPI = ClientService.getClientAPI()
if (clientAPI) {
document.title = `LAR 直播自动录制 v${clientAPI.getVersion()}`
}
})
</script>
5 changes: 5 additions & 0 deletions packages/web/src/views/RecordersManage/Settings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,10 @@
<v-card-item>
<v-table>
<tbody>
<tr>
<td>版本</td>
<td>v{{ version }}</td>
</tr>
<tr>
<td>开源地址</td>
<td>
Expand Down Expand Up @@ -160,6 +164,7 @@ import { useEffectInLifecycle } from '../../hooks'
import { InteractionService } from '../../services/InteractionService'
const isClient = ClientService.isClientMode()
const version = ClientService.getClientAPI()?.getVersion()
const router = useRouter()
const manager = ref<API.getManager.Resp>()
const settings = ref<API.getSettings.Resp>()
Expand Down

0 comments on commit f7d6cfc

Please sign in to comment.