bugfix: 修复超级面板浅拷贝问题

This commit is contained in:
muwoo 2021-08-23 11:13:25 +08:00
parent b58c37842a
commit 7dd5407bbe
3 changed files with 29 additions and 3 deletions

View File

@ -1,6 +1,6 @@
{
"name": "rubick2",
"version": "0.0.3-beta.4",
"version": "0.0.3-beta.5",
"author": "muwoo <2424880409@qq.com>",
"description": "An electron-vue project",
"license": null,
@ -81,6 +81,7 @@
"robotjs": "git+https://github.com/Toinane/robotjs.git",
"semver": "^7.3.5",
"sudo-prompt": "^9.2.1",
"systeminformation": "^5.8.0",
"unzip": "^0.1.11",
"uuid": "^8.3.2",
"vue": "^2.5.16",

View File

@ -4,6 +4,7 @@ const path = require('path');
const fs = require('fs');
const { spawn } = require ('child_process');
const mineType = require("mime-types");
const {extend} = require('../../utils');
new Vue({
el: '#app',
@ -116,7 +117,8 @@ new Vue({
this.targetOptions = this.options.common;
} else {
// 有文件选择
this.targetOptions = JSON.parse(JSON.stringify(this.options.selected));
this.targetOptions = [];
extend(this.targetOptions, this.options.selected, true);
// 检测上传
(this.selectData.optionPlugin || []).forEach(plugin => {
plugin.features.forEach(fe => {

View File

@ -20,8 +20,31 @@ function getData(path, defaultValue) {
}
}
const isArray = Array.isArray ||
function(object){ return object instanceof Array }
function isPlainObject(obj) {
return isObject(obj) && Object.getPrototypeOf(obj) == Object.prototype
}
function isObject(obj) { return typeof obj == "object" }
function extend(target, source, deep) {
for (let key in source)
if (deep && (isPlainObject(source[key]) || isArray(source[key]))) {
if (isPlainObject(source[key]) && !isPlainObject(target[key]))
target[key] = {}
if (isArray(source[key]) && !isArray(target[key]))
target[key] = []
extend(target[key], source[key], deep)
}
else if (source[key] !== undefined) target[key] = source[key]
}
module.exports = {
getlocalDataFile,
saveData,
getData
getData,
extend
}