fixed 弹幕修复 bug
This commit is contained in:
1 parent
a4c74cbb0d
commit
0714b8eb48
11 files changed
+446
-139
No files matched your search
@@ -76,9 +76,36 @@ window.initArtalk = function() {
|
||||
var remoteConf = artalk.conf || (artalk.ctx && artalk.ctx.conf);
|
||||
|
||||
if (remoteConf) {
|
||||
// We only really want to cache the fields that come from the server,
|
||||
// but saving the whole object is easier. We just have to be careful when merging.
|
||||
localStorage.setItem(confKey, JSON.stringify(remoteConf));
|
||||
// Filter out non-serializable properties (like DOM elements, circular refs)
|
||||
var safeConf = {};
|
||||
for (var key in remoteConf) {
|
||||
var val = remoteConf[key];
|
||||
// Skip if value is a DOM element
|
||||
if (val instanceof Element || val instanceof Node) continue;
|
||||
// Skip if value is window or document
|
||||
if (val === window || val === document) continue;
|
||||
// Skip internal private properties starting with $ or _
|
||||
if (key.startsWith('$') || key.startsWith('_')) continue;
|
||||
// Only allow simple types or simple objects
|
||||
var type = typeof val;
|
||||
if (type === 'string' || type === 'number' || type === 'boolean' || val === null) {
|
||||
safeConf[key] = val;
|
||||
} else if (type === 'object') {
|
||||
// Simple array check
|
||||
if (Array.isArray(val)) {
|
||||
safeConf[key] = val;
|
||||
} else {
|
||||
// For objects, deep check might be too expensive/complex here.
|
||||
// We'll try to shallow copy if it looks like a plain object
|
||||
// and doesn't have circular markers like 'el'
|
||||
if (val.constructor === Object && !val.el && !val.$el) {
|
||||
safeConf[key] = val;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
localStorage.setItem(confKey, JSON.stringify(safeConf));
|
||||
// console.log('Artalk: Config cached to', confKey);
|
||||
}
|
||||
} catch(e) {
|
||||
|
||||
Reference in new issue
Block a user