fix: merge replaced Object.assign

https://github.com/d2-projects/d2-admin/issues/342
This commit is contained in:
FairyEver 2021-07-23 11:17:33 +08:00
parent 10223f7aef
commit 37f63bf20c
5 changed files with 13 additions and 8 deletions

View File

@ -1,7 +1,7 @@
import { Message } from 'element-ui' import { Message } from 'element-ui'
import axios from 'axios' import axios from 'axios'
import Adapter from 'axios-mock-adapter' import Adapter from 'axios-mock-adapter'
import { get, isEmpty } from 'lodash' import { get, isEmpty, merge } from 'lodash'
import qs from 'qs' import qs from 'qs'
import util from '@/libs/util' import util from '@/libs/util'
import store from '@/store' import store from '@/store'
@ -132,7 +132,7 @@ function createRequest (service) {
baseURL: process.env.VUE_APP_API, baseURL: process.env.VUE_APP_API,
data: {} data: {}
} }
const option = Object.assign(configDefault, config) const option = merge(configDefault, config)
// 处理 get 请求的参数 // 处理 get 请求的参数
// 请根据实际需要修改 // 请根据实际需要修改
if (!isEmpty(option.params)) { if (!isEmpty(option.params)) {

View File

@ -1,4 +1,6 @@
import { merge } from 'lodash'
import BScroll from 'better-scroll' import BScroll from 'better-scroll'
export default { export default {
props: { props: {
// 滚动优化的选项 // 滚动优化的选项
@ -22,7 +24,7 @@ export default {
methods: { methods: {
scrollInit () { scrollInit () {
// 初始化 bs // 初始化 bs
this.BS = new BScroll(this.$refs.wrapper, Object.assign({ this.BS = new BScroll(this.$refs.wrapper, merge({
mouseWheel: true, mouseWheel: true,
click: true, click: true,
scrollbar: { scrollbar: {

View File

@ -3,8 +3,10 @@
</template> </template>
<script> <script>
import { merge } from 'lodash'
import SimpleMDE from 'simplemde' import SimpleMDE from 'simplemde'
import 'simplemde/dist/simplemde.min.css' import 'simplemde/dist/simplemde.min.css'
export default { export default {
name: 'd2-mde', name: 'd2-mde',
props: { props: {
@ -44,7 +46,7 @@ export default {
// //
init () { init () {
// //
const config = Object.assign({}, this.defaultConfig, this.config) const config = merge({}, this.defaultConfig, this.config)
// //
this.mde = new SimpleMDE({ this.mde = new SimpleMDE({
...config, ...config,

View File

@ -1,3 +1,4 @@
import { merge } from 'lodash'
import Cookies from 'js-cookie' import Cookies from 'js-cookie'
const cookies = {} const cookies = {}
@ -12,7 +13,7 @@ cookies.set = function (name = 'default', value = '', cookieSetting = {}) {
const currentCookieSetting = { const currentCookieSetting = {
expires: 1 expires: 1
} }
Object.assign(currentCookieSetting, cookieSetting) merge(currentCookieSetting, cookieSetting)
Cookies.set(`d2admin-${process.env.VUE_APP_VERSION}-${name}`, value, currentCookieSetting) Cookies.set(`d2admin-${process.env.VUE_APP_VERSION}-${name}`, value, currentCookieSetting)
} }

View File

@ -1,4 +1,4 @@
import { cloneDeep, uniq, get } from 'lodash' import { cloneDeep, uniq, get, merge } from 'lodash'
import router from '@/router' import router from '@/router'
import setting from '@/setting.js' import setting from '@/setting.js'
@ -64,7 +64,7 @@ export default {
valid.push(find ? 1 : 0) valid.push(find ? 1 : 0)
// 返回合并后的数据 新的覆盖旧的 // 返回合并后的数据 新的覆盖旧的
// 新的数据中一般不会携带 params 和 query, 所以旧的参数会留存 // 新的数据中一般不会携带 params 和 query, 所以旧的参数会留存
return Object.assign({}, opened, find) return merge({}, opened, find)
}) })
.filter((opened, index) => valid[index] === 1) .filter((opened, index) => valid[index] === 1)
// 标记已经加载多标签页数据 https://github.com/d2-projects/d2-admin/issues/201 // 标记已经加载多标签页数据 https://github.com/d2-projects/d2-admin/issues/201
@ -164,7 +164,7 @@ export default {
// 如果这里没有找到 page 代表这个路由虽然在框架内 但是不参与标签页显示 // 如果这里没有找到 page 代表这个路由虽然在框架内 但是不参与标签页显示
if (page) { if (page) {
await dispatch('add', { await dispatch('add', {
tag: Object.assign({}, page), tag: merge({}, page),
params, params,
query, query,
fullPath fullPath