summaryrefslogtreecommitdiff
path: root/src/config.js
diff options
context:
space:
mode:
authorEltrac <hi@guhub.cn>2025-09-17 22:03:19 +0800
committerEltrac <hi@guhub.cn>2025-09-17 22:03:19 +0800
commitfd25334f02282cba9c2cf456f99706d5589e64ee (patch)
tree1eb2eee9c828abe72ba93a9677ae4d6816a0c1b4 /src/config.js
parentbca54cbb5026564b4139fe850b286239c5a54929 (diff)
refactor: new config class
Diffstat (limited to 'src/config.js')
-rw-r--r--src/config.js27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/config.js b/src/config.js
new file mode 100644
index 0000000..eea8314
--- /dev/null
+++ b/src/config.js
@@ -0,0 +1,27 @@
+const config = {
+ selector: '[data-libra]',
+ margin: 50,
+ offset: { x: 0, y: 0 }
+}
+
+function deepMerge(target, source) {
+ for (const key in source) {
+ if (
+ typeof source[key] === 'object' &&
+ source[key] !== null &&
+ !Array.isArray(source[key])
+ ) {
+ if (!target[key]) target[key] = {};
+ deepMerge(target[key], source[key]);
+ } else {
+ target[key] = source[key];
+ }
+ }
+ return target;
+}
+
+export function setConfig(newConfig) {
+ deepMerge(config, newConfig);
+}
+
+export default config;