[优化] 同步上游更新 (@821938089)

This commit is contained in:
HapeLee
2025-12-20 03:33:17 +08:00
parent 9e8ab55e02
commit 060ec9ce1a
44 changed files with 373 additions and 205 deletions
@@ -206,7 +206,7 @@ object RhinoScriptEngine : AbstractScriptEngine(), Invocable, Compilable {
thiz1 = Context.toObject(thiz1, topLevel)
}
val engineScope = getRuntimeScope(context)
val localScope = if (thiz1 != null) thiz1 as Scriptable else engineScope
val localScope = thiz1 ?: engineScope
val obj = ScriptableObject.getProperty(localScope, name) as? Function
?: throw NoSuchMethodException("no such method: $name")
var scope = obj.parentScope
@@ -229,7 +229,7 @@ object RhinoScriptEngine : AbstractScriptEngine(), Invocable, Compilable {
override fun <T> getInterface(clazz: Class<T>): T? {
return try {
implementor.getInterface(null, clazz)
} catch (var3: ScriptException) {
} catch (_: ScriptException) {
null
}
}
@@ -240,7 +240,7 @@ object RhinoScriptEngine : AbstractScriptEngine(), Invocable, Compilable {
} else {
try {
implementor.getInterface(obj, paramClass)
} catch (var4: ScriptException) {
} catch (_: ScriptException) {
null
}
}
@@ -321,7 +321,7 @@ object RhinoScriptEngine : AbstractScriptEngine(), Invocable, Compilable {
override fun makeContext(): Context {
val cx = RhinoContext(this)
cx.languageVersion = Context.VERSION_ES6
cx.setInterpretedMode(true)
cx.isInterpretedMode = true
cx.setClassShutter(RhinoClassShutter)
cx.wrapFactory = RhinoWrapFactory
cx.instructionObserverThreshold = 10000
@@ -393,7 +393,7 @@ object RhinoScriptEngine : AbstractScriptEngine(), Invocable, Compilable {
if (System.getSecurityManager() != null) {
try {
AccessController.checkPermission(AllPermission())
} catch (var6: AccessControlException) {
} catch (_: AccessControlException) {
accessContext = AccessController.getContext()
}
}
@@ -413,7 +413,7 @@ object RhinoScriptEngine : AbstractScriptEngine(), Invocable, Compilable {
obj1 = Context.toObject(obj1, topLevel)
}
val engineScope = getRuntimeScope(context)
val localScope = if (obj1 != null) obj1 as Scriptable else engineScope
val localScope = obj1 ?: engineScope
val methods = clazz.methods
val methodsSize = methods.size
for (index in 0 until methodsSize) {
+2
View File
@@ -68,6 +68,7 @@
import API from '@api'
import { CircleCheckFilled, Edit } from '@element-plus/icons-vue'
import hotkeys from 'hotkeys-js'
import { getSourceName, isInvaildSource, normalizeSource } from '../utils/souce'
import { getSourceName, isInvaildSource } from '../utils/souce'
const store = useSourceStore()
@@ -168,6 +169,7 @@ const redo = () => {
const saveSource = () => {
const source = store.currentSource
if (isInvaildSource(source)) {
normalizeSource(source)
API.saveSource(source).then(({ data }) => {
const sourceName = getSourceName(source)
if (data.isSuccess) {
+4 -4
View File
@@ -13,8 +13,8 @@ const emptySource = isBookSource ? emptyBookSource : emptyRssSource
export const useSourceStore = defineStore('source', {
state: () => {
return {
bookSources: [] as BookSoure[], // 临时存放所有书源,
rssSources: [] as RssSource[], // 临时存放所有订阅源
bookSources: shallowRef([] as BookSoure[]), // 临时存放所有书源,
rssSources: shallowRef([] as RssSource[]), // 临时存放所有订阅源
savedSources: [] as Source[], // 批量保存到阅读app成功的源
currentSource: JSON.parse(JSON.stringify(emptySource)) as Source, // 当前编辑的源
currentTab: localStorage.getItem('tabName') || 'editTab',
@@ -51,9 +51,9 @@ export const useSourceStore = defineStore('source', {
//拉取源后保存
saveSources(data: Source[]) {
if (isBookSource) {
this.bookSources = data as BookSoure[]
this.bookSources = markRaw(data) as BookSoure[]
} else {
this.rssSources = data as RssSource[]
this.rssSources = markRaw(data) as RssSource[]
}
},
//批量推送
+16 -1
View File
@@ -49,12 +49,27 @@ export const convertSourcesToMap = (sources: Source[]): Map<string, Source> => {
return map
}
export const normalizeSource = (source: any) => {
for (const key in source) {
const value = source[key]
if (
value === '' ||
value === null ||
(typeof value === 'string' && !value.trim())
) {
delete source[key]
} else if (value instanceof Object) {
normalizeSource(value)
}
}
}
export const emptyBookSource = {
ruleSearch: {},
ruleBookInfo: {},
ruleToc: {},
ruleContent: {},
ruleReview: {},
//ruleReview: {},
ruleExplore: {},
} as BookSoure
export const emptyRssSource = {} as RssSource