(target: T, source: Partial<T>)
| 269 | } |
| 270 | |
| 271 | export function mergeObjects<T>(target: T, source: Partial<T>): T { |
| 272 | for (const key in source) { |
| 273 | if (Object.prototype.hasOwnProperty.call(source, key)) { |
| 274 | const sourceValue = source[key] |
| 275 | const targetValue = target[key] |
| 276 | |
| 277 | if (typeof sourceValue === 'object' && !Array.isArray(sourceValue) && sourceValue !== null) { |
| 278 | if ( |
| 279 | typeof targetValue === 'object' && |
| 280 | !Array.isArray(targetValue) && |
| 281 | targetValue !== null |
| 282 | ) { |
| 283 | target[key] = mergeObjects(targetValue, sourceValue) |
| 284 | } else { |
| 285 | target[key] = sourceValue as T[Extract<keyof T, string>] |
| 286 | } |
| 287 | } else { |
| 288 | // 如果不是对象,则直接覆盖 |
| 289 | target[key] = sourceValue as T[Extract<keyof T, string>] |
| 290 | } |
| 291 | } |
| 292 | } |
| 293 | return target |
| 294 | } |
| 295 | |
| 296 | export async function restartSelf() { |
| 297 | await invoke('restart_self') |
no outgoing calls
no test coverage detected