mirror of
https://github.com/Kuingsmile/PicList.git
synced 2025-01-23 06:38:13 -05:00
✨ Feature: add beta-version update support
This commit is contained in:
parent
2aeca509a8
commit
ad6acd8c4f
1
.gitignore
vendored
1
.gitignore
vendored
@ -16,3 +16,4 @@ docs/dist/
|
|||||||
.env.local
|
.env.local
|
||||||
.env.*.local
|
.env.*.local
|
||||||
dist_electron/
|
dist_electron/
|
||||||
|
test.js
|
||||||
|
@ -2,6 +2,7 @@ import { dialog, shell } from 'electron'
|
|||||||
import db from '#/datastore'
|
import db from '#/datastore'
|
||||||
import axios from 'axios'
|
import axios from 'axios'
|
||||||
import pkg from 'root/package.json'
|
import pkg from 'root/package.json'
|
||||||
|
import { lt } from 'semver'
|
||||||
const version = pkg.version
|
const version = pkg.version
|
||||||
const releaseUrl = 'https://api.github.com/repos/Molunerfinn/PicGo/releases/latest'
|
const releaseUrl = 'https://api.github.com/repos/Molunerfinn/PicGo/releases/latest'
|
||||||
const releaseUrlBackup = 'https://cdn.jsdelivr.net/gh/Molunerfinn/PicGo@latest/package.json'
|
const releaseUrlBackup = 'https://cdn.jsdelivr.net/gh/Molunerfinn/PicGo@latest/package.json'
|
||||||
@ -51,18 +52,17 @@ const checkVersion = async () => {
|
|||||||
|
|
||||||
// if true -> update else return false
|
// if true -> update else return false
|
||||||
const compareVersion2Update = (current: string, latest: string) => {
|
const compareVersion2Update = (current: string, latest: string) => {
|
||||||
const currentVersion = current.split('.').map(item => parseInt(item))
|
try {
|
||||||
const latestVersion = latest.split('.').map(item => parseInt(item))
|
if (latest.includes('Beta')) {
|
||||||
|
const isCheckBetaUpdate = db.get('settings.checkBetaUpdate') !== false
|
||||||
for (let i = 0; i < 3; i++) {
|
if (!isCheckBetaUpdate) {
|
||||||
if (currentVersion[i] < latestVersion[i]) {
|
return false
|
||||||
return true
|
}
|
||||||
}
|
|
||||||
if (currentVersion[i] > latestVersion[i]) {
|
|
||||||
return false
|
|
||||||
}
|
}
|
||||||
|
return lt(current, latest)
|
||||||
|
} catch (e) {
|
||||||
|
return false
|
||||||
}
|
}
|
||||||
return false
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export default checkVersion
|
export default checkVersion
|
||||||
|
@ -56,6 +56,17 @@
|
|||||||
@change="updateHelperChange"
|
@change="updateHelperChange"
|
||||||
></el-switch>
|
></el-switch>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
<el-form-item
|
||||||
|
v-show="form.updateHelper"
|
||||||
|
label="接受Beta版本更新"
|
||||||
|
>
|
||||||
|
<el-switch
|
||||||
|
v-model="form.checkBetaUpdate"
|
||||||
|
active-text="开"
|
||||||
|
inactive-text="关"
|
||||||
|
@change="checkBetaUpdateChange"
|
||||||
|
></el-switch>
|
||||||
|
</el-form-item>
|
||||||
<el-form-item
|
<el-form-item
|
||||||
label="开机自启"
|
label="开机自启"
|
||||||
>
|
>
|
||||||
@ -347,7 +358,8 @@ export default class extends Vue {
|
|||||||
uploadNotification: db.get('settings.uploadNotification') || false,
|
uploadNotification: db.get('settings.uploadNotification') || false,
|
||||||
miniWindowOntop: db.get('settings.miniWindowOntop') || false,
|
miniWindowOntop: db.get('settings.miniWindowOntop') || false,
|
||||||
logLevel,
|
logLevel,
|
||||||
autoCopyUrl: db.get('settings.autoCopy') === undefined ? true : db.get('settings.autoCopy')
|
autoCopyUrl: db.get('settings.autoCopy') === undefined ? true : db.get('settings.autoCopy'),
|
||||||
|
checkBetaUpdate: db.get('settings.checkBetaUpdate') === undefined ? true : db.get('settings.checkBetaUpdate')
|
||||||
}
|
}
|
||||||
picBed: IPicBedType[] = []
|
picBed: IPicBedType[] = []
|
||||||
logFileVisible = false
|
logFileVisible = false
|
||||||
@ -452,6 +464,9 @@ export default class extends Vue {
|
|||||||
updateHelperChange (val: boolean) {
|
updateHelperChange (val: boolean) {
|
||||||
db.set('settings.showUpdateTip', val)
|
db.set('settings.showUpdateTip', val)
|
||||||
}
|
}
|
||||||
|
checkBetaUpdateChange (val: boolean) {
|
||||||
|
db.set('settings.checkBetaUpdate', val)
|
||||||
|
}
|
||||||
handleShowPicBedListChange (val: string[]) {
|
handleShowPicBedListChange (val: string[]) {
|
||||||
const list = this.picBed.map(item => {
|
const list = this.picBed.map(item => {
|
||||||
if (!val.includes(item.name)) {
|
if (!val.includes(item.name)) {
|
||||||
|
1
src/universal/types/view.d.ts
vendored
1
src/universal/types/view.d.ts
vendored
@ -8,6 +8,7 @@ interface ISettingForm {
|
|||||||
miniWindowOntop: boolean
|
miniWindowOntop: boolean
|
||||||
logLevel: string[]
|
logLevel: string[]
|
||||||
autoCopyUrl: boolean
|
autoCopyUrl: boolean
|
||||||
|
checkBetaUpdate: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
interface IShortKeyMap {
|
interface IShortKeyMap {
|
||||||
|
Loading…
Reference in New Issue
Block a user