Merge remote-tracking branch 'origin/dev' into dev
This commit is contained in:
commit
bdd1257572
4 changed files with 69 additions and 32 deletions
|
@ -88,10 +88,8 @@ try {
|
|||
}
|
||||
} catch (e) {
|
||||
console.error(e)
|
||||
require('electron').
|
||||
dialog.
|
||||
showErrorBox('创建配置目录失败 Failed to create config directory',
|
||||
'思源需要在用户家目录下创建配置文件夹(~/.config/siyuan),请确保该路径具有写入权限。\n\nSiYuan needs to create a configuration folder (~/.config/siyuan) in the user\'s home directory. Please make sure that the path has write permissions.')
|
||||
require('electron').dialog.showErrorBox('创建配置目录失败 Failed to create config directory',
|
||||
'思源需要在用户家目录下创建配置文件夹(~/.config/siyuan),请确保该路径具有写入权限。\n\nSiYuan needs to create a configuration folder (~/.config/siyuan) in the user\'s home directory. Please make sure that the path has write permissions.')
|
||||
app.exit()
|
||||
}
|
||||
|
||||
|
@ -192,8 +190,37 @@ const boot = () => {
|
|||
})
|
||||
|
||||
require('@electron/remote/main').enable(mainWindow.webContents)
|
||||
mainWindow.webContents.userAgent = 'SiYuan/' + appVer +
|
||||
' https://b3log.org/siyuan Electron'
|
||||
mainWindow.webContents.userAgent = 'SiYuan/' + appVer + ' https://b3log.org/siyuan Electron'
|
||||
|
||||
// 发起互联网服务请求时绕过安全策略 https://github.com/siyuan-note/siyuan/issues/5516
|
||||
mainWindow.webContents.session.webRequest.onBeforeSendHeaders(
|
||||
(details, cb) => {
|
||||
if (-1 < details.url.indexOf('bili')) {
|
||||
// B 站不移除 Referer https://github.com/siyuan-note/siyuan/issues/94
|
||||
cb({requestHeaders: details.requestHeaders})
|
||||
return
|
||||
}
|
||||
|
||||
for (let key in details.requestHeaders) {
|
||||
if ('referer' === key.toLowerCase()) {
|
||||
delete details.requestHeaders[key]
|
||||
}
|
||||
}
|
||||
cb({requestHeaders: details.requestHeaders})
|
||||
})
|
||||
mainWindow.webContents.session.webRequest.onHeadersReceived((details, cb) => {
|
||||
for (let key in details.responseHeaders) {
|
||||
if ('x-frame-options' === key.toLowerCase()) {
|
||||
delete details.responseHeaders[key]
|
||||
} else if ('content-security-policy' === key.toLowerCase()) {
|
||||
delete details.responseHeaders[key]
|
||||
} else if ('access-control-allow-origin' === key.toLowerCase()) {
|
||||
delete details.responseHeaders[key]
|
||||
}
|
||||
}
|
||||
cb({responseHeaders: details.responseHeaders})
|
||||
})
|
||||
|
||||
mainWindow.webContents.on('did-finish-load', () => {
|
||||
if ('win32' === process.platform || 'linux' === process.platform) {
|
||||
siyuanOpenURL = process.argv.find((arg) => arg.startsWith('siyuan://'))
|
||||
|
|
|
@ -39,7 +39,7 @@ require (
|
|||
github.com/panjf2000/ants/v2 v2.5.0
|
||||
github.com/patrickmn/go-cache v2.1.0+incompatible
|
||||
github.com/radovskyb/watcher v1.0.7
|
||||
github.com/siyuan-note/dejavu v0.0.0-20220723034802-a08cc67e6238
|
||||
github.com/siyuan-note/dejavu v0.0.0-20220725150423-1e913ff48241
|
||||
github.com/siyuan-note/encryption v0.0.0-20220713091850-5ecd92177b75
|
||||
github.com/siyuan-note/eventbus v0.0.0-20220624162334-ca7c06dc771f
|
||||
github.com/siyuan-note/filelock v0.0.0-20220720144616-011221f7e128
|
||||
|
@ -89,7 +89,7 @@ require (
|
|||
github.com/juju/errors v1.0.0 // indirect
|
||||
github.com/klauspost/compress v1.15.9 // indirect
|
||||
github.com/leodido/go-urn v1.2.1 // indirect
|
||||
github.com/lucas-clemente/quic-go v0.28.0 // indirect
|
||||
github.com/lucas-clemente/quic-go v0.28.1 // indirect
|
||||
github.com/marten-seemann/qpack v0.2.1 // indirect
|
||||
github.com/marten-seemann/qtls-go1-16 v0.1.5 // indirect
|
||||
github.com/marten-seemann/qtls-go1-17 v0.1.2 // indirect
|
||||
|
|
|
@ -372,8 +372,9 @@ github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
|
|||
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
|
||||
github.com/leodido/go-urn v1.2.1 h1:BqpAaACuzVSgi/VLzGZIobT2z4v53pjosyNd9Yv6n/w=
|
||||
github.com/leodido/go-urn v1.2.1/go.mod h1:zt4jvISO2HfUBqxjfIshjdMTYS56ZS/qv49ictyFfxY=
|
||||
github.com/lucas-clemente/quic-go v0.28.0 h1:9eXVRgIkMQQyiyorz/dAaOYIx3TFzXsIFkNFz4cxuJM=
|
||||
github.com/lucas-clemente/quic-go v0.28.0/go.mod h1:oGz5DKK41cJt5+773+BSO9BXDsREY4HLf7+0odGAPO0=
|
||||
github.com/lucas-clemente/quic-go v0.28.1 h1:Uo0lvVxWg5la9gflIF9lwa39ONq85Xq2D91YNEIslzU=
|
||||
github.com/lucas-clemente/quic-go v0.28.1/go.mod h1:oGz5DKK41cJt5+773+BSO9BXDsREY4HLf7+0odGAPO0=
|
||||
github.com/lunixbochs/vtclean v1.0.0/go.mod h1:pHhQNgMf3btfWnGBVipUOjRYhoOsdGqdm/+2c2E2WMI=
|
||||
github.com/magiconair/properties v1.8.5/go.mod h1:y3VJvCyxH9uVvJTWEGAELF3aiYNyPKd5NZ3oSwXrF60=
|
||||
github.com/mailru/easyjson v0.0.0-20190312143242-1de009706dbe/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc=
|
||||
|
@ -515,8 +516,8 @@ github.com/shurcooL/users v0.0.0-20180125191416-49c67e49c537/go.mod h1:QJTqeLYED
|
|||
github.com/shurcooL/vfsgen v0.0.0-20200824052919-0d455de96546/go.mod h1:TrYk7fJVaAttu97ZZKrO9UbRa8izdowaMIZcxYMbVaw=
|
||||
github.com/shurcooL/webdavfs v0.0.0-20170829043945-18c3829fa133/go.mod h1:hKmq5kWdCj2z2KEozexVbfEZIWiTjhE0+UjmZgPqehw=
|
||||
github.com/sirupsen/logrus v1.8.1/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0=
|
||||
github.com/siyuan-note/dejavu v0.0.0-20220723034802-a08cc67e6238 h1:WMjKoFKKxI2lr+eBOb5p/NDNpEjkmSXBZRD0MTScfuQ=
|
||||
github.com/siyuan-note/dejavu v0.0.0-20220723034802-a08cc67e6238/go.mod h1:o+UdjzTM4t7gPFpbNUTPgCEVhEcFAHvonVZm6SeyJJs=
|
||||
github.com/siyuan-note/dejavu v0.0.0-20220725150423-1e913ff48241 h1:Nz0hAQ9yF783Hbqd0msKO5bxkgg6Y3sSCRKg9A8fVmU=
|
||||
github.com/siyuan-note/dejavu v0.0.0-20220725150423-1e913ff48241/go.mod h1:o+UdjzTM4t7gPFpbNUTPgCEVhEcFAHvonVZm6SeyJJs=
|
||||
github.com/siyuan-note/encryption v0.0.0-20220713091850-5ecd92177b75 h1:Bi7/7f29LW+Fm0cHc0J1NO1cZqyJwljSWVmfOqVZgaE=
|
||||
github.com/siyuan-note/encryption v0.0.0-20220713091850-5ecd92177b75/go.mod h1:H8fyqqAbp9XreANjeSbc72zEdFfKTXYN34tc1TjZwtw=
|
||||
github.com/siyuan-note/eventbus v0.0.0-20220624162334-ca7c06dc771f h1:JMobMNZ7AqaKKyEK+WeWFhix/2TDQXgPZDajU00IybU=
|
||||
|
|
|
@ -635,40 +635,42 @@ func subscribeEvents() {
|
|||
contextPushMsg(context, msg)
|
||||
})
|
||||
|
||||
count := 0
|
||||
indexWalkDataCount := 0
|
||||
eventbus.Subscribe(dejavu.EvtIndexWalkData, func(context map[string]interface{}, path string) {
|
||||
msg := fmt.Sprintf(Conf.Language(158), path)
|
||||
count++
|
||||
if 0 == count%128 {
|
||||
if 0 == indexWalkDataCount%512 {
|
||||
util.SetBootDetails(msg)
|
||||
contextPushMsg(context, msg)
|
||||
}
|
||||
indexWalkDataCount++
|
||||
})
|
||||
eventbus.Subscribe(dejavu.EvtIndexBeforeGetLatestFiles, func(context map[string]interface{}, files []string) {
|
||||
msg := fmt.Sprintf(Conf.Language(159), len(files))
|
||||
util.SetBootDetails(msg)
|
||||
contextPushMsg(context, msg)
|
||||
})
|
||||
getLatestFileCount := 0
|
||||
eventbus.Subscribe(dejavu.EvtIndexGetLatestFile, func(context map[string]interface{}, path string) {
|
||||
msg := fmt.Sprintf(Conf.Language(159), path)
|
||||
count++
|
||||
if 0 == count%128 {
|
||||
if 0 == getLatestFileCount%512 {
|
||||
util.SetBootDetails(msg)
|
||||
contextPushMsg(context, msg)
|
||||
}
|
||||
getLatestFileCount++
|
||||
})
|
||||
eventbus.Subscribe(dejavu.EvtIndexUpsertFiles, func(context map[string]interface{}, files []*entity.File) {
|
||||
msg := fmt.Sprintf(Conf.Language(160), len(files))
|
||||
util.SetBootDetails(msg)
|
||||
contextPushMsg(context, msg)
|
||||
})
|
||||
indexUpsertFileCount := 0
|
||||
eventbus.Subscribe(dejavu.EvtIndexUpsertFile, func(context map[string]interface{}, path string) {
|
||||
msg := fmt.Sprintf(Conf.Language(160), path)
|
||||
count++
|
||||
if 0 == count%64 {
|
||||
if 0 == indexUpsertFileCount%128 {
|
||||
util.SetBootDetails(msg)
|
||||
contextPushMsg(context, msg)
|
||||
}
|
||||
indexUpsertFileCount++
|
||||
})
|
||||
|
||||
eventbus.Subscribe(dejavu.EvtCheckoutBeforeWalkData, func(context map[string]interface{}, path string) {
|
||||
|
@ -676,13 +678,14 @@ func subscribeEvents() {
|
|||
util.SetBootDetails(msg)
|
||||
contextPushMsg(context, msg)
|
||||
})
|
||||
coWalkDataCount := 0
|
||||
eventbus.Subscribe(dejavu.EvtCheckoutWalkData, func(context map[string]interface{}, path string) {
|
||||
msg := fmt.Sprintf(Conf.Language(161), path)
|
||||
count++
|
||||
if 0 == count%128 {
|
||||
if 0 == coWalkDataCount%512 {
|
||||
util.SetBootDetails(msg)
|
||||
contextPushMsg(context, msg)
|
||||
}
|
||||
coWalkDataCount++
|
||||
})
|
||||
var bootProgressPart float64
|
||||
eventbus.Subscribe(dejavu.EvtCheckoutUpsertFiles, func(context map[string]interface{}, files []*entity.File) {
|
||||
|
@ -691,13 +694,14 @@ func subscribeEvents() {
|
|||
bootProgressPart = 10 / float64(len(files))
|
||||
contextPushMsg(context, msg)
|
||||
})
|
||||
coUpsertFileCount := 0
|
||||
eventbus.Subscribe(dejavu.EvtCheckoutUpsertFile, func(context map[string]interface{}, path string) {
|
||||
msg := fmt.Sprintf(Conf.Language(162), path)
|
||||
util.IncBootProgress(bootProgressPart, msg)
|
||||
count++
|
||||
if 0 == count%64 {
|
||||
if 0 == coUpsertFileCount%128 {
|
||||
contextPushMsg(context, msg)
|
||||
}
|
||||
coUpsertFileCount++
|
||||
})
|
||||
eventbus.Subscribe(dejavu.EvtCheckoutRemoveFiles, func(context map[string]interface{}, files []*entity.File) {
|
||||
msg := fmt.Sprintf(Conf.Language(163), files)
|
||||
|
@ -705,13 +709,14 @@ func subscribeEvents() {
|
|||
bootProgressPart = 10 / float64(len(files))
|
||||
contextPushMsg(context, msg)
|
||||
})
|
||||
coRemoveFileCount := 0
|
||||
eventbus.Subscribe(dejavu.EvtCheckoutRemoveFile, func(context map[string]interface{}, path string) {
|
||||
msg := fmt.Sprintf(Conf.Language(163), path)
|
||||
util.IncBootProgress(bootProgressPart, msg)
|
||||
count++
|
||||
if 0 == count%64 {
|
||||
if 0 == coRemoveFileCount%512 {
|
||||
contextPushMsg(context, msg)
|
||||
}
|
||||
coRemoveFileCount++
|
||||
})
|
||||
|
||||
eventbus.Subscribe(dejavu.EvtCloudBeforeDownloadIndex, func(context map[string]interface{}, id string) {
|
||||
|
@ -726,13 +731,14 @@ func subscribeEvents() {
|
|||
bootProgressPart = 10 / float64(len(ids))
|
||||
contextPushMsg(context, msg)
|
||||
})
|
||||
downloadFileCount := 0
|
||||
eventbus.Subscribe(dejavu.EvtCloudBeforeDownloadFile, func(context map[string]interface{}, id string) {
|
||||
msg := fmt.Sprintf(Conf.Language(165), id[:7])
|
||||
util.IncBootProgress(bootProgressPart, msg)
|
||||
count++
|
||||
if 0 == count%8 {
|
||||
if 0 == downloadFileCount%8 {
|
||||
contextPushMsg(context, msg)
|
||||
}
|
||||
downloadFileCount++
|
||||
})
|
||||
eventbus.Subscribe(dejavu.EvtCloudBeforeDownloadChunks, func(context map[string]interface{}, ids []string) {
|
||||
msg := fmt.Sprintf(Conf.Language(166), len(ids))
|
||||
|
@ -740,13 +746,14 @@ func subscribeEvents() {
|
|||
bootProgressPart = 10 / float64(len(ids))
|
||||
contextPushMsg(context, msg)
|
||||
})
|
||||
downloadChunkCount := 0
|
||||
eventbus.Subscribe(dejavu.EvtCloudBeforeDownloadChunk, func(context map[string]interface{}, id string) {
|
||||
msg := fmt.Sprintf(Conf.Language(166), id[:7])
|
||||
util.IncBootProgress(bootProgressPart, msg)
|
||||
count++
|
||||
if 0 == count%8 {
|
||||
if 0 == downloadChunkCount%8 {
|
||||
contextPushMsg(context, msg)
|
||||
}
|
||||
downloadChunkCount++
|
||||
})
|
||||
eventbus.Subscribe(dejavu.EvtCloudBeforeDownloadRef, func(context map[string]interface{}, ref string) {
|
||||
msg := fmt.Sprintf(Conf.Language(167), ref)
|
||||
|
@ -763,26 +770,28 @@ func subscribeEvents() {
|
|||
util.SetBootDetails(msg)
|
||||
contextPushMsg(context, msg)
|
||||
})
|
||||
uploadFileCount := 0
|
||||
eventbus.Subscribe(dejavu.EvtCloudBeforeUploadFile, func(context map[string]interface{}, id string) {
|
||||
msg := fmt.Sprintf(Conf.Language(169), id[:7])
|
||||
count++
|
||||
if 0 == count%8 {
|
||||
if 0 == uploadFileCount%8 {
|
||||
util.SetBootDetails(msg)
|
||||
contextPushMsg(context, msg)
|
||||
}
|
||||
uploadFileCount++
|
||||
})
|
||||
eventbus.Subscribe(dejavu.EvtCloudBeforeUploadChunks, func(context map[string]interface{}, ids []string) {
|
||||
msg := fmt.Sprintf(Conf.Language(170), len(ids))
|
||||
util.SetBootDetails(msg)
|
||||
contextPushMsg(context, msg)
|
||||
})
|
||||
uploadChunkCount := 0
|
||||
eventbus.Subscribe(dejavu.EvtCloudBeforeUploadChunk, func(context map[string]interface{}, id string) {
|
||||
msg := fmt.Sprintf(Conf.Language(170), id[:7])
|
||||
count++
|
||||
if 0 == count%8 {
|
||||
if 0 == uploadChunkCount%8 {
|
||||
util.SetBootDetails(msg)
|
||||
contextPushMsg(context, msg)
|
||||
}
|
||||
uploadChunkCount++
|
||||
})
|
||||
eventbus.Subscribe(dejavu.EvtCloudBeforeUploadRef, func(context map[string]interface{}, ref string) {
|
||||
msg := fmt.Sprintf(Conf.Language(171), ref)
|
||||
|
|
Loading…
Add table
Reference in a new issue