fix: 动画改用 setInterval (兼容动态 script 加载) + try-catch 保护
This commit is contained in:
@@ -328,5 +328,27 @@
|
|||||||
"framework.command.execute"
|
"framework.command.execute"
|
||||||
],
|
],
|
||||||
"timestamp": 28040.668302635
|
"timestamp": 28040.668302635
|
||||||
|
},
|
||||||
|
"2a0ced83": {
|
||||||
|
"plugin_name": "example_plugin",
|
||||||
|
"permissions": [
|
||||||
|
"plugin.example.read",
|
||||||
|
"plugin.example.write",
|
||||||
|
"plugin.example.execute",
|
||||||
|
"framework.event.subscribe",
|
||||||
|
"framework.command.execute"
|
||||||
|
],
|
||||||
|
"timestamp": 28375.085750685
|
||||||
|
},
|
||||||
|
"8a812834": {
|
||||||
|
"plugin_name": "sentinel",
|
||||||
|
"permissions": [
|
||||||
|
"plugin.sentinel.read",
|
||||||
|
"plugin.sentinel.write",
|
||||||
|
"plugin.network.access",
|
||||||
|
"framework.event.subscribe",
|
||||||
|
"framework.command.execute"
|
||||||
|
],
|
||||||
|
"timestamp": 28375.089465424
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -101,7 +101,7 @@ commands:
|
|||||||
permissions:
|
permissions:
|
||||||
- framework.command.test
|
- framework.command.test
|
||||||
source: internal
|
source: internal
|
||||||
last_updated: 28040.621524771
|
last_updated: 28375.06993407
|
||||||
plugin_commands:
|
plugin_commands:
|
||||||
example_plugin:
|
example_plugin:
|
||||||
echo: *id001
|
echo: *id001
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
http_port: 4200
|
http_port: 4200
|
||||||
last_updated: 28040.661568417
|
last_updated: 28375.086802768
|
||||||
plugin_routes:
|
plugin_routes:
|
||||||
example_plugin:
|
example_plugin:
|
||||||
- methods:
|
- methods:
|
||||||
|
|||||||
@@ -5,19 +5,21 @@ window.DashboardModule = {
|
|||||||
charts: {},
|
charts: {},
|
||||||
|
|
||||||
_animateNumber: function(el, newVal, decimals, suffix) {
|
_animateNumber: function(el, newVal, decimals, suffix) {
|
||||||
var self = this;
|
try {
|
||||||
var oldVal = parseFloat(el.getAttribute('data-val') || newVal);
|
var oldVal = parseFloat(el.getAttribute('data-val'));
|
||||||
if (Math.abs(oldVal - newVal) < 0.05) { el.textContent = newVal.toFixed(decimals) + suffix; return; }
|
if (isNaN(oldVal)) oldVal = newVal;
|
||||||
|
if (Math.abs(oldVal - newVal) < 0.05) { el.textContent = newVal.toFixed(decimals) + suffix; el.setAttribute('data-val', newVal); return; }
|
||||||
el.setAttribute('data-val', newVal);
|
el.setAttribute('data-val', newVal);
|
||||||
var start = performance.now();
|
var steps = 20, i = 0;
|
||||||
var duration = 900;
|
var stepMs = 50; // 20 steps × 50ms = 1000ms
|
||||||
function step(ts) {
|
var timer = setInterval(function(){
|
||||||
var p = Math.min((ts - start) / duration, 1);
|
i++;
|
||||||
|
var p = Math.min(i / steps, 1);
|
||||||
var eased = 1 - Math.pow(1 - p, 3);
|
var eased = 1 - Math.pow(1 - p, 3);
|
||||||
el.textContent = (oldVal + (newVal - oldVal) * eased).toFixed(decimals) + suffix;
|
el.textContent = (oldVal + (newVal - oldVal) * eased).toFixed(decimals) + suffix;
|
||||||
if (p < 1) requestAnimationFrame(step);
|
if (i >= steps) clearInterval(timer);
|
||||||
}
|
}, stepMs);
|
||||||
requestAnimationFrame(step);
|
} catch(e) { el.textContent = newVal.toFixed(decimals) + suffix; }
|
||||||
},
|
},
|
||||||
|
|
||||||
init: function() {
|
init: function() {
|
||||||
|
|||||||
Reference in New Issue
Block a user