init commit

This commit is contained in:
iqudoo
2026-04-30 10:16:43 +08:00
commit 2c8eb4f587
44 changed files with 17574 additions and 0 deletions

19
src/utils/hook.js Normal file
View File

@@ -0,0 +1,19 @@
export function addHook(target, methodName, hook, upsert = false) {
if (!target) {
return;
}
let method = target[methodName];
if (!method && !upsert) {
return;
}
if (method) {
// bind original method to target
method = method.bind(target);
}
Object.defineProperty(target, methodName, {
value: (...params) => hook(target, methodName, method, ...params),
enumerable: true,
writable: true,
configurable: true,
});
}