Merge remote-tracking branch 'upstream/master' into avoiding-anomalies

pull/407/head
王良 2024-12-02 15:51:01 +08:00
commit e76231bb25
9 changed files with 158 additions and 48 deletions

View File

@ -419,4 +419,15 @@ module.exports = {
},
proxy: {},
plugin: {},
help: {
data: [
{
title: '查看DevSidecar的说明文档Wiki',
url: 'https://github.com/docmirror/dev-sidecar/wiki',
},
{
title: '为了展示更多帮助信息,请启用 “远程配置” 功能!!!',
},
],
},
}

View File

@ -171,20 +171,28 @@ function updateHandle (app, api, win, beforeQuit, quit, log) {
return
}
// log.info('github api返回的release数据', JSON.stringify(data, null, '\t'))
log.debug('github api返回的release数据', JSON.stringify(data, null, '\t'))
// 检查更新
for (let i = 0; i < data.length; i++) {
const versionData = data[i]
// log.debug('版本数据:', versionData)
if (!versionData.assets || versionData.assets.length === 0) {
log.info('跳过空版本,即未上传过安装包:', versionData.name)
continue // 跳过空版本,即未上传过安装包
}
if (!isPreRelease && DevSidecar.api.config.get().app.skipPreRelease && versionData.name.includes('-')) {
if (!versionData.name.match(/^v?\d+(\.\d+)*(-.+)?$/g)) {
log.info('跳过即 “不是正式,又不是预发布” 的版本:', versionData.name)
continue // 跳过即 “不是正式,又不是预发布” 的版本
}
if (!isPreRelease && DevSidecar.api.config.get().app.skipPreRelease && (versionData.name.includes('-') || versionData.prerelease)) {
log.info('跳过预发布版本:', versionData.name)
continue // 跳过预发布版本
}
// log.info('最近正式版本数据:', versionData)
log.info('最近正式版本:', versionData.name)
// 获取版本号
let version = versionData.name

View File

@ -42,11 +42,11 @@ export default {
handleClick (e) {
console.log('click', e)
},
titleClick (e) {
console.log('titleClick', e)
titleClick (item) {
console.log('title click:', item)
},
menuClick (item) {
console.log('menu click', item)
console.log('menu click:', item)
this.$router.replace(item.path)
},
},

View File

@ -0,0 +1,25 @@
<script>
export default {
name: 'TreeNode',
props: {
treeData: Array,
},
methods: {
async openExternal (url) {
await this.$api.ipc.openExternal(url)
},
},
}
</script>
<template>
<ul>
<li v-for="node in treeData" :key="node.title">
<span v-if="node.url && (node.url.startsWith('http://') || node.url.startsWith('https://'))" :title="node.tip || node.title">
<a @click="openExternal(node.url)">{{ node.title }}</a>
</span>
<span v-else :title="node.tip || node.title">{{ node.title }}</span>
<tree-node v-if="node.children && node.children.length > 0" :tree-data="node.children" class="child-node" />
</li>
</ul>
</template>

View File

@ -0,0 +1,37 @@
<script>
import Plugin from '../mixins/plugin'
import TreeNode from '../components/tree-node'
export default {
name: 'Help',
components: {
TreeNode,
},
mixins: [Plugin],
data () {
return {
key: 'help',
}
},
methods: {
async openExternal (url) {
await this.$api.ipc.openExternal(url)
},
},
}
</script>
<template>
<ds-container>
<template slot="header">
帮助中心
<span>
<a-button @click="openExternal('https://github.com/docmirror/dev-sidecar/issues/new/choose')"></a-button>
</span>
</template>
<div v-if="config" class="help-list">
<TreeNode :tree-data="config.help.dataList" />
</div>
</ds-container>
</template>

View File

@ -6,6 +6,7 @@ import Pip from '../pages/plugin/pip'
import Proxy from '../pages/proxy'
import Server from '../pages/server'
import Setting from '../pages/setting'
import Help from '../pages/help'
const routes = [
{ path: '/', redirect: '/index' },
@ -17,6 +18,7 @@ const routes = [
{ path: '/plugin/git', component: Git },
{ path: '/plugin/pip', component: Pip },
{ path: '/plugin/overwall', component: Overwall },
{ path: '/help', component: Help },
]
export default routes

View File

@ -15,6 +15,7 @@ export default function createMenus (app) {
icon: 'api',
children: plugins,
},
{ title: '帮助中心', path: '/help', icon: 'star' },
]
if (app.$global && app.$global.setting && app.$global.setting.overwall) {
plugins.push({ title: '功能增强', path: '/plugin/overwall', icon: 'global' })

View File

@ -138,3 +138,29 @@ hr {
margin: 0 5px 5px 5px;
}
}
.help-list {
ul {
padding-left: 10px;
li {
list-style: none;
line-height: 30px;
span {
display: block;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
a:hover {
text-decoration: underline;
}
}
//
ul {
padding-left: 20px;
}
}
}

View File

@ -7,48 +7,6 @@ const { fireError, fireStatus } = require('./utils/util.process')
let servers = []
function registerProcessListener () {
process.on('message', (msg) => {
log.info('child get msg:', JSON.stringify(msg))
if (msg.type === 'action') {
api[msg.event.key](msg.event.params)
} else if (msg.type === 'speed') {
speedTest.action(msg.event)
}
})
process.on('SIGINT', () => {
log.info('on sigint : closed ')
process.exit(0)
})
// 避免异常崩溃
process.on('uncaughtException', (err) => {
if (err.code === 'ECONNABORTED') {
// log.error(err.errno)
return
}
log.error('Process uncaughtException:', err)
})
process.on('unhandledRejection', (err, p) => {
log.info('Process unhandledRejection at: Promise', p, 'err:', err)
// application specific logging, throwing an error, or other logic here
})
process.on('uncaughtExceptionMonitor', (err, origin) => {
log.info('Process uncaughtExceptionMonitor:', err, origin)
})
process.on('exit', (code, signal) => {
log.info('代理服务进程被关闭:', code, signal)
})
process.on('beforeExit', (code, signal) => {
console.log('Process beforeExit event with code: ', code, signal)
})
process.on('SIGPIPE', (code, signal) => {
log.warn('sub Process SIGPIPE', code, signal)
})
}
const api = {
async start (config) {
const proxyOptions = ProxyOptions(config)
@ -119,6 +77,48 @@ const api = {
},
}
function registerProcessListener () {
process.on('message', (msg) => {
log.info('child get msg:', JSON.stringify(msg))
if (msg.type === 'action') {
api[msg.event.key](msg.event.params)
} else if (msg.type === 'speed') {
speedTest.action(msg.event)
}
})
process.on('SIGINT', () => {
log.info('on sigint : closed ')
process.exit(0)
})
// 避免异常崩溃
process.on('uncaughtException', (err) => {
if (err.code === 'ECONNABORTED') {
// log.error(err.errno)
return
}
log.error('Process uncaughtException:', err)
})
process.on('unhandledRejection', (err, p) => {
log.info('Process unhandledRejection at: Promise', p, 'err:', err)
// application specific logging, throwing an error, or other logic here
})
process.on('uncaughtExceptionMonitor', (err, origin) => {
log.info('Process uncaughtExceptionMonitor:', err, origin)
})
process.on('exit', (code, signal) => {
log.info('代理服务进程被关闭:', code, signal)
})
process.on('beforeExit', (code, signal) => {
console.log('Process beforeExit event with code: ', code, signal)
})
process.on('SIGPIPE', (code, signal) => {
log.warn('sub Process SIGPIPE', code, signal)
})
}
module.exports = {
...api,
config: proxyConfig,