mirror of
https://github.com/geekgeekrun/geekgeekrun.git
synced 2026-09-05 23:47:54 +08:00
add pinia; call check update in ui
This commit is contained in:
@@ -40,6 +40,7 @@
|
||||
"electron-updater": "^6.1.7",
|
||||
"minimist": "^1.2.8",
|
||||
"node-machine-id": "^1.1.12",
|
||||
"pinia": "^3.0.2",
|
||||
"puppeteer": "20.1.0",
|
||||
"puppeteer-extra-plugin-stealth": "2.11.2",
|
||||
"uuid": "^11.1.0"
|
||||
|
||||
@@ -5,7 +5,6 @@ import './app-menu'
|
||||
import initIpc from './ipc'
|
||||
import gtag from '../../utils/gtag'
|
||||
import initPublicIpc from '../../utils/initPublicIpc'
|
||||
import { checkUpdateForUi } from '../../features/updater'
|
||||
export function openSettingWindow() {
|
||||
// TODO: singleton lock; how can we check if there is another process should run as singleton with arguments?
|
||||
if (!app.requestSingleInstanceLock()) {
|
||||
@@ -66,6 +65,4 @@ export function openSettingWindow() {
|
||||
globalShortcut.unregister('Command+Option+Shift+/')
|
||||
})
|
||||
})
|
||||
|
||||
checkUpdateForUi()
|
||||
}
|
||||
|
||||
@@ -50,6 +50,7 @@ import {
|
||||
readNoReplyReminderLlmMockWindow
|
||||
} from '../../../window/readNoReplyReminderLlmMockWindow'
|
||||
import { RequestSceneEnum } from '../../../features/llm-request-log'
|
||||
import { checkUpdateForUi } from '../../../features/updater'
|
||||
|
||||
export default function initIpc() {
|
||||
ipcMain.handle('fetch-config-file-content', async () => {
|
||||
@@ -579,6 +580,10 @@ export default function initIpc() {
|
||||
ipcMain.on('close-read-no-reply-reminder-llm-mock-window', () =>
|
||||
readNoReplyReminderLlmMockWindow?.close()
|
||||
)
|
||||
ipcMain.handle('check-update', async () => {
|
||||
const newRelease = await checkUpdateForUi()
|
||||
return newRelease
|
||||
})
|
||||
|
||||
ipcMain.handle('exit-app-immediately', () => {
|
||||
app.exit(0)
|
||||
|
||||
@@ -2,13 +2,15 @@ import { createApp } from 'vue'
|
||||
import ElementPlus, { ElMessage } from 'element-plus'
|
||||
import App from './App.vue'
|
||||
import router from './router'
|
||||
import { createPinia } from 'pinia'
|
||||
import 'normalize.css'
|
||||
import './style/public.scss'
|
||||
import 'element-plus/dist/index.css'
|
||||
import 'virtual:uno.css'
|
||||
import 'animate.css'
|
||||
|
||||
createApp(App).use(router).use(ElementPlus).mount('#app')
|
||||
const pinia = createPinia()
|
||||
createApp(App).use(pinia).use(router).use(ElementPlus).mount('#app')
|
||||
electron.ipcRenderer.on('toast-message', (_, payload) => {
|
||||
ElMessage(payload)
|
||||
})
|
||||
|
||||
@@ -96,13 +96,43 @@
|
||||
<RouterLink to="./CompanyLibrary">公司库</RouterLink>
|
||||
</div>
|
||||
<div class="pt-16px pb-16px flex-0 font-size-12px">
|
||||
<div>当前版本: {{ buildInfo.version }}({{ buildInfo.buildVersion }})</div>
|
||||
<div class="feedback-area flex flex-items-center mt-8px">
|
||||
<el-button type="text" size="small" @click="handleGotoProjectPageClick"
|
||||
>项目首页</el-button
|
||||
<div v-if="updateStore.availableNewRelease" mb16px>
|
||||
<div
|
||||
:style="{
|
||||
display: 'flex',
|
||||
alignItems: 'center'
|
||||
}"
|
||||
>
|
||||
|
|
||||
<el-button type="text" size="small" @click="handleFeedbackClick">反馈问题</el-button>
|
||||
最新版本: {{ updateStore.availableNewRelease.releaseVersion }}
|
||||
<img
|
||||
h12px
|
||||
ml10px
|
||||
:style="{
|
||||
filter: `saturate(1.5) brightness(1.5)`,
|
||||
transform: `translateY(-10px)`
|
||||
}"
|
||||
src="./resources/new.gif"
|
||||
/>
|
||||
</div>
|
||||
<div class="update-button-area flex flex-items-center mt-8px">
|
||||
<el-button type="text" size="small" @click="handleDownloadNewReleaseClick"
|
||||
>从GitHub下载</el-button
|
||||
>
|
||||
|
|
||||
<el-button type="text" size="small" @click="handleViewNewReleaseClick"
|
||||
>了解更新内容</el-button
|
||||
>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<div>当前版本: {{ buildInfo.version }}({{ buildInfo.buildVersion }})</div>
|
||||
<div class="feedback-button-area flex flex-items-center mt-8px">
|
||||
<el-button type="text" size="small" @click="handleGotoProjectPageClick"
|
||||
>项目首页</el-button
|
||||
>
|
||||
|
|
||||
<el-button type="text" size="small" @click="handleFeedbackClick">反馈问题</el-button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -121,6 +151,8 @@ import { TopRight, QuestionFilled } from '@element-plus/icons-vue'
|
||||
import useBuildInfo from '@renderer/hooks/useBuildInfo'
|
||||
import { debounce } from 'lodash-es'
|
||||
import { gtagRenderer } from '@renderer/utils/gtag'
|
||||
import { useUpdateStore } from '../../store/index'
|
||||
|
||||
const router = useRouter()
|
||||
const unmountedCbs: Array<InstanceType<typeof Function>> = []
|
||||
onUnmounted(() => {
|
||||
@@ -175,6 +207,16 @@ const handleLaunchBossSite = debounce(
|
||||
1000,
|
||||
{ leading: true, trailing: false }
|
||||
)
|
||||
|
||||
const updateStore = useUpdateStore()
|
||||
function handleDownloadNewReleaseClick() {
|
||||
gtagRenderer('click_download_release_form_nav')
|
||||
electron.ipcRenderer.send('open-external-link', updateStore.availableNewRelease!.assetUrl)
|
||||
}
|
||||
function handleViewNewReleaseClick() {
|
||||
gtagRenderer('click_view_release_form_nav')
|
||||
electron.ipcRenderer.send('open-external-link', updateStore.availableNewRelease!.releasePageUrl)
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
@@ -204,7 +246,8 @@ const handleLaunchBossSite = debounce(
|
||||
margin-right: 0;
|
||||
}
|
||||
}
|
||||
.feedback-area {
|
||||
.feedback-button-area,
|
||||
.update-button-area {
|
||||
:deep(.el-button) {
|
||||
height: fit-content;
|
||||
padding: 0;
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 6.1 KiB |
@@ -0,0 +1,20 @@
|
||||
import { defineStore } from 'pinia'
|
||||
import { NewReleaseInfo } from '../../../common/types/update'
|
||||
import { ref } from 'vue'
|
||||
|
||||
export const useUpdateStore = defineStore('update', () => {
|
||||
const availableNewRelease = ref<NewReleaseInfo | null>(null)
|
||||
|
||||
async function checkUpdate() {
|
||||
let result: NewReleaseInfo | null = null
|
||||
try {
|
||||
result = (await electron.ipcRenderer.invoke('check-update')) as NewReleaseInfo | null
|
||||
} catch {
|
||||
//
|
||||
}
|
||||
availableNewRelease.value = result
|
||||
}
|
||||
checkUpdate()
|
||||
setInterval(checkUpdate, 30 * 30 * 1000)
|
||||
return { availableNewRelease }
|
||||
})
|
||||
Reference in New Issue
Block a user