fix: cannot read properties of undefined (reading 'content') (#419)
All checks were successful
Build and Deploy / build-and-deploy (push) Has been skipped

This commit is contained in:
brzhang 2024-09-19 07:10:24 +08:00 committed by GitHub
parent e8b2c18c6d
commit 30f0792baa
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 7 additions and 7 deletions

2
package-lock.json generated
View File

@ -885,7 +885,7 @@
},
"node_modules/@clack/prompts/node_modules/is-unicode-supported": {
"version": "1.3.0",
"dev": true,
"extraneous": true,
"inBundle": true,
"license": "MIT",
"engines": {

View File

@ -1,7 +1,3 @@
import { giteeConfig, githubConfig } from '@/config'
import fetch from '@/utils/fetch'
import { base64encode, safe64, utf16to8 } from '@/utils/tokenTools'
import * as tokenTools from '@/utils/tokenTools'
import Buffer from 'buffer-from'
import COS from 'cos-js-sdk-v5'
import CryptoJS from 'crypto-js'
@ -10,6 +6,10 @@ import * as Minio from 'minio'
import * as qiniu from 'qiniu-js'
import OSS from 'tiny-oss'
import { v4 as uuidv4 } from 'uuid'
import * as tokenTools from '@/utils/tokenTools'
import { base64encode, safe64, utf16to8 } from '@/utils/tokenTools'
import fetch from '@/utils/fetch'
import { giteeConfig, githubConfig } from '@/config'
function getConfig(useDefault: boolean, platform: string) {
if (useDefault) {
@ -87,7 +87,7 @@ async function ghFileUpload(content: string, filename: string) {
content: {
download_url: string
}
data: {
data?: {
content: {
download_url: string
}
@ -106,7 +106,7 @@ async function ghFileUpload(content: string, filename: string) {
})
const githubResourceUrl = `raw.githubusercontent.com/${username}/${repo}/${branch}/`
const cdnResourceUrl = `fastly.jsdelivr.net/gh/${username}/${repo}@${branch}/`
res.content = res.data.content || res.content
res.content = res.data?.content || res.content
return useDefault
? res.content.download_url.replace(githubResourceUrl, cdnResourceUrl)
: res.content.download_url