mirror of
https://github.com/Kuingsmile/PicList.git
synced 2026-05-20 15:50:04 +08:00
⬆️ Upgrade(custom): upgrade deps and fix lint error
This commit is contained in:
@@ -1252,7 +1252,7 @@ async function initData() {
|
||||
globalAutoRename.value = allConfig.settings?.autoRename ?? false
|
||||
globalManualRename.value = allConfig.settings?.rename ?? false
|
||||
if (compressInFile) {
|
||||
let cleanedObj = {}
|
||||
let cleanedObj: Record<string, any>
|
||||
try {
|
||||
if (typeof compressInFile.formatConvertObj === 'object') {
|
||||
cleanedObj = cleanFormatConvertObj(compressInFile.formatConvertObj)
|
||||
@@ -1343,7 +1343,7 @@ async function initData() {
|
||||
mergedWatermark[key as keyof IBuildInWaterMarkOptions] = mergedWatermark[mapFieldName][currentPicbedName]
|
||||
}
|
||||
})
|
||||
let cleanedFormatConvertObj = {}
|
||||
let cleanedFormatConvertObj: Record<string, any>
|
||||
try {
|
||||
const parsedObj = JSON.parse(singleConfigInFile.compress?.formatConvertObj as any)
|
||||
cleanedFormatConvertObj = cleanFormatConvertObj(parsedObj)
|
||||
@@ -1388,9 +1388,8 @@ function safeSetMapValue(form: any, fieldName: string, picbedType: string, value
|
||||
const mapFieldName = `${fieldName}Map`
|
||||
if (fieldName === 'formatConvertObj') {
|
||||
value = value || '{}'
|
||||
let parsedObj = {}
|
||||
try {
|
||||
parsedObj = JSON.parse(value)
|
||||
const parsedObj = JSON.parse(value)
|
||||
const cleanedObj = cleanFormatConvertObj(parsedObj)
|
||||
if (JSON.stringify(cleanedObj) !== JSON.stringify(parsedObj)) {
|
||||
value = JSON.stringify(cleanedObj)
|
||||
@@ -1692,9 +1691,8 @@ watch(activeTab, () => {
|
||||
})
|
||||
|
||||
watch(singleFormatConvertObj, () => {
|
||||
let parsedObj = {}
|
||||
try {
|
||||
parsedObj = JSON.parse(singleFormatConvertObj.value)
|
||||
const parsedObj = JSON.parse(singleFormatConvertObj.value)
|
||||
const cleanedObj = cleanFormatConvertObj(parsedObj)
|
||||
singleConfigSettings.value.compress!.formatConvertObj = cleanedObj
|
||||
if (JSON.stringify(cleanedObj) !== JSON.stringify(parsedObj)) {
|
||||
@@ -1706,9 +1704,8 @@ watch(singleFormatConvertObj, () => {
|
||||
})
|
||||
|
||||
watch(formatConvertObjStr, () => {
|
||||
let parsedObj = {}
|
||||
try {
|
||||
parsedObj = JSON.parse(formatConvertObjStr.value)
|
||||
const parsedObj = JSON.parse(formatConvertObjStr.value)
|
||||
const cleanedObj = cleanFormatConvertObj(parsedObj)
|
||||
compressForm.value.formatConvertObj = cleanedObj
|
||||
if (JSON.stringify(cleanedObj) !== JSON.stringify(parsedObj)) {
|
||||
|
||||
@@ -47,7 +47,7 @@ const imageSource = computed(() => {
|
||||
const iconPath = computed(() => `./assets/icons/${getFileIconPath(props.item.fileName ?? '')}`)
|
||||
|
||||
async function getWebdavHeader(key: string) {
|
||||
let headers = {} as any
|
||||
let headers: Record<string, any>
|
||||
if (props.config.authType === 'digest') {
|
||||
const authHeader = await getAuthHeader(
|
||||
'GET',
|
||||
|
||||
@@ -2007,16 +2007,16 @@ async function saveEditorContent() {
|
||||
}
|
||||
|
||||
async function saveFile(file: string, content: string) {
|
||||
let dataToSave = content
|
||||
let formattedContent: string
|
||||
try {
|
||||
dataToSave = JSON.stringify(JSON.parse(content), null, 2)
|
||||
formattedContent = JSON.stringify(JSON.parse(content), null, 2)
|
||||
} catch (error) {
|
||||
console.error('Invalid JSON content:', error)
|
||||
message.error(t('pages.settings.advanced.invalidJson'))
|
||||
return
|
||||
}
|
||||
try {
|
||||
window.electron.sendRPC(IRPCActionType.WRITE_FILE_CONTENT, file, dataToSave)
|
||||
window.electron.sendRPC(IRPCActionType.WRITE_FILE_CONTENT, file, formattedContent)
|
||||
message.success(t('pages.settings.advanced.saveFileSuccess'))
|
||||
setTimeout(() => {
|
||||
window.electron.sendRPC(IRPCActionType.RELOAD_WINDOW)
|
||||
|
||||
@@ -1,26 +1,37 @@
|
||||
import { RELEASE_URL, RELEASE_URL_BACKUP } from '@/utils/static'
|
||||
|
||||
async function fetchData(url: string, options?: RequestInit) {
|
||||
const response = await fetch(url, options)
|
||||
if (!response.ok) {
|
||||
throw new Error(`HTTP error! status: ${response.status}`, {
|
||||
cause: { url, status: response.status },
|
||||
})
|
||||
}
|
||||
return response
|
||||
}
|
||||
|
||||
export const getLatestVersion = async (): Promise<string> => {
|
||||
let primaryError: unknown
|
||||
|
||||
try {
|
||||
const response = await fetch(RELEASE_URL)
|
||||
if (!response.ok) {
|
||||
throw new Error(`HTTP error! status: ${response.status}`)
|
||||
}
|
||||
const response = await fetchData(RELEASE_URL)
|
||||
const normalList = await response.json()
|
||||
return normalList[0].name
|
||||
return normalList[0]?.name ?? ''
|
||||
} catch (err) {
|
||||
console.error('Error fetching latest version: ', err)
|
||||
try {
|
||||
const response = await fetch(`${RELEASE_URL_BACKUP}/latest.yml`)
|
||||
if (!response.ok) {
|
||||
throw new Error(`HTTP error! status: ${response.status}`)
|
||||
}
|
||||
const data = await response.text()
|
||||
const r = window.node.yaml.parse(data).toJSON() as IStringKeyMap
|
||||
return r.version
|
||||
} catch (err) {
|
||||
console.error('Error fetching backup latest version: ', err)
|
||||
return ''
|
||||
}
|
||||
primaryError = err
|
||||
console.warn('Primary version fetch failed, trying backup...', err)
|
||||
}
|
||||
|
||||
try {
|
||||
const response = await fetchData(`${RELEASE_URL_BACKUP}/latest.yml`)
|
||||
const data = await response.text()
|
||||
const r = window.node.yaml.parse(data).toJSON() as IStringKeyMap
|
||||
return r.version || ''
|
||||
} catch (backupErr) {
|
||||
const finalError = new Error('Both primary and backup version fetch failed', {
|
||||
cause: { primaryError, backupErr },
|
||||
})
|
||||
console.error(finalError)
|
||||
return ''
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user