mirror of
https://github.com/Molunerfinn/PicGo.git
synced 2024-04-21 10:31:33 +00:00
📦 Chore: change version files' upload dest & dist files' upload dest
This commit is contained in:
@@ -7,10 +7,11 @@ import {
|
||||
selectUploaderConfig,
|
||||
updateUploaderConfig
|
||||
} from '~/main/utils/handleUploaderConfig'
|
||||
import { getLatestVersion } from '~/main/utils/getLatestVersion'
|
||||
|
||||
class RPCServer {
|
||||
start () {
|
||||
ipcMain.on(RPC_ACTIONS, (event: IpcMainEvent, action: IRPCActionType, args: any[], callbackId: string) => {
|
||||
ipcMain.on(RPC_ACTIONS, async (event: IpcMainEvent, action: IRPCActionType, args: any[], callbackId: string) => {
|
||||
try {
|
||||
switch (action) {
|
||||
case IRPCActionType.GET_PICBED_CONFIG_LIST: {
|
||||
@@ -33,6 +34,11 @@ class RPCServer {
|
||||
this.sendBack(event, action, true, callbackId)
|
||||
break
|
||||
}
|
||||
case IRPCActionType.GET_LATEST_VERSION: {
|
||||
const res = await this.getLastestVersion(args as IGetLatestVersionArgs)
|
||||
this.sendBack(event, action, res, callbackId)
|
||||
break
|
||||
}
|
||||
default: {
|
||||
this.sendBack(event, action, null, callbackId)
|
||||
break
|
||||
@@ -74,6 +80,12 @@ class RPCServer {
|
||||
const res = updateUploaderConfig(type, id, config)
|
||||
return res
|
||||
}
|
||||
|
||||
private async getLastestVersion (args: IGetLatestVersionArgs) {
|
||||
const [isCheckBetaUpdate] = args
|
||||
const version = await getLatestVersion(isCheckBetaUpdate)
|
||||
return version
|
||||
}
|
||||
}
|
||||
|
||||
const rpcServer = new RPCServer()
|
||||
|
||||
@@ -1,11 +1,16 @@
|
||||
// for referer policy, we can't use it in renderer
|
||||
import axios from 'axios'
|
||||
import { RELEASE_URL, RELEASE_URL_BACKUP } from './static'
|
||||
import { RELEASE_URL, RELEASE_URL_BACKUP } from '../../universal/utils/static'
|
||||
import yaml from 'js-yaml'
|
||||
|
||||
export const getLatestVersion = async (isCheckBetaUpdate: boolean = false) => {
|
||||
let res: string = ''
|
||||
try {
|
||||
res = await axios.get(RELEASE_URL).then(r => {
|
||||
res = await axios.get(RELEASE_URL, {
|
||||
headers: {
|
||||
Referer: 'https://github.com'
|
||||
}
|
||||
}).then(r => {
|
||||
const list = r.data as IStringKeyMap[]
|
||||
if (isCheckBetaUpdate) {
|
||||
const betaList = list.filter(item => item.name.includes('beta'))
|
||||
@@ -14,7 +19,11 @@ export const getLatestVersion = async (isCheckBetaUpdate: boolean = false) => {
|
||||
const normalList = list.filter(item => !item.name.includes('beta'))
|
||||
return normalList[0].name
|
||||
}).catch(async () => {
|
||||
const result = await axios.get(isCheckBetaUpdate ? `${RELEASE_URL_BACKUP}/latest.beta.yml` : `${RELEASE_URL_BACKUP}/latest.yml`)
|
||||
const result = await axios.get(isCheckBetaUpdate ? `${RELEASE_URL_BACKUP}/latest.beta.yml` : `${RELEASE_URL_BACKUP}/latest.yml`, {
|
||||
headers: {
|
||||
Referer: 'https://github.com'
|
||||
}
|
||||
})
|
||||
const r = yaml.load(result.data) as IStringKeyMap
|
||||
return r.version
|
||||
})
|
||||
@@ -3,7 +3,7 @@ import db from '~/main/apis/core/datastore'
|
||||
import pkg from 'root/package.json'
|
||||
import { lt } from 'semver'
|
||||
import { T } from '~/main/i18n'
|
||||
import { getLatestVersion } from '#/utils/getLatestVersion'
|
||||
import { getLatestVersion } from '~/main/utils/getLatestVersion'
|
||||
const version = pkg.version
|
||||
// const releaseUrl = 'https://api.github.com/repos/Molunerfinn/PicGo/releases'
|
||||
// const releaseUrlBackup = 'https://picgo-1251750343.cos.ap-chengdu.myqcloud.com'
|
||||
|
||||
@@ -527,13 +527,13 @@ import {
|
||||
} from 'electron'
|
||||
import { i18nManager, T as $T } from '@/i18n/index'
|
||||
import { enforceNumber } from '~/universal/utils/common'
|
||||
import { getLatestVersion } from '#/utils/getLatestVersion'
|
||||
import { compare } from 'compare-versions'
|
||||
import { STABLE_RELEASE_URL, BETA_RELEASE_URL } from '#/utils/static'
|
||||
import { computed, onBeforeMount, onBeforeUnmount, reactive, ref } from 'vue'
|
||||
import { getConfig, saveConfig, sendToMain } from '@/utils/dataSender'
|
||||
import { getConfig, saveConfig, sendToMain, triggerRPC } from '@/utils/dataSender'
|
||||
import { useRouter } from 'vue-router'
|
||||
import { SHORTKEY_PAGE } from '@/router/config'
|
||||
import { IRPCActionType } from '~/universal/types/enum'
|
||||
|
||||
const $customLink = ref<InstanceType<typeof ElForm> | null>(null)
|
||||
|
||||
@@ -774,7 +774,7 @@ function compareVersion2Update (current: string, latest: string): boolean {
|
||||
|
||||
async function checkUpdate () {
|
||||
checkUpdateVisible.value = true
|
||||
const version = await getLatestVersion(form.checkBetaUpdate)
|
||||
const version = await triggerRPC<string>(IRPCActionType.GET_LATEST_VERSION, form.checkBetaUpdate)
|
||||
if (version) {
|
||||
latestVersion.value = version
|
||||
} else {
|
||||
|
||||
@@ -56,4 +56,5 @@ export enum IRPCActionType {
|
||||
CHANGE_CURRENT_UPLOADER = 'CHANGE_CURRENT_UPLOADER',
|
||||
SELECT_UPLOADER = 'SELECT_UPLOADER',
|
||||
UPDATE_UPLOADER_CONFIG = 'UPDATE_UPLOADER_CONFIG',
|
||||
GET_LATEST_VERSION = 'GET_LATEST_VERSION',
|
||||
}
|
||||
|
||||
Vendored
+1
@@ -2,3 +2,4 @@ type IGetUploaderConfigListArgs = [type: string]
|
||||
type IDeleteUploaderConfigArgs = [type: string, id: string]
|
||||
type ISelectUploaderConfigArgs = [type: string, id: string]
|
||||
type IUpdateUploaderConfigArgs = [type: string, id: string, config: IStringKeyMap]
|
||||
type IGetLatestVersionArgs = [isCheckBetaVersion: boolean]
|
||||
|
||||
Reference in New Issue
Block a user