diff --git a/src/assets/style/theme/theme.scss b/src/assets/style/theme/theme.scss index 6ebf382f..b147ab7e 100644 --- a/src/assets/style/theme/theme.scss +++ b/src/assets/style/theme/theme.scss @@ -208,6 +208,12 @@ border-left-color: $theme-multiple-page-control-border-color; &:first-child { border-left: none; + &:hover { + padding: 0px 20px; + } + .el-icon-close { + display: none; + } } } .el-tabs__item.is-active { diff --git a/src/components/core/d2-multiple-page-control/index.vue b/src/components/core/d2-multiple-page-control/index.vue index 5ac95c0b..86dbabee 100644 --- a/src/components/core/d2-multiple-page-control/index.vue +++ b/src/components/core/d2-multiple-page-control/index.vue @@ -42,7 +42,9 @@ export default { }, handleTabsEdit(tagName, action) { if (action === 'remove') { - this.closeTag(tagName) + if (tagName !== 'index') { + this.closeTag(tagName) + } } }, /** diff --git a/src/store/modules/d2admin.js b/src/store/modules/d2admin.js index af13832d..cdb2a560 100644 --- a/src/store/modules/d2admin.js +++ b/src/store/modules/d2admin.js @@ -21,6 +21,21 @@ export default { pageCurrent: '' }, mutations: { + /** + * 将 state 中某一项存储到数据库 + * @param {state} state vuex state + */ + d2adminVuex2Db (state, key) { + const setting = db.get(key).find({uuid: util.uuid()}) + if (setting.value()) { + setting.assign({value: state[key]}).write() + } else { + db.get(key).push({ + uuid: util.uuid(), + value: state[key] + }).write() + } + }, /** * 设置当前激活的页面 name * @param {state} state vuex state @@ -41,15 +56,7 @@ export default { page.query = query || page.query state.pageOpenedList.splice(index, 1, page) // 更新设置到数据库 - const setting = db.get('pageOpenedList').find({uuid: util.uuid()}) - if (setting.value()) { - setting.assign({value: state.pageOpenedList}).write() - } else { - db.get('pageOpenedList').push({ - uuid: util.uuid(), - value: state.pageOpenedList - }).write() - } + this.commit('d2adminVuex2Db', 'pageOpenedList') }, /** * 保存 tagPool (候选池) @@ -72,15 +79,7 @@ export default { // 添加进当前显示的页面数组 state.pageOpenedList.push(newTag) // 更新设置到数据库 - const setting = db.get('pageOpenedList').find({uuid: util.uuid()}) - if (setting.value()) { - setting.assign({value: state.pageOpenedList}).write() - } else { - db.get('pageOpenedList').push({ - uuid: util.uuid(), - value: state.pageOpenedList - }).write() - } + this.commit('d2adminVuex2Db', 'pageOpenedList') }, /** * 关闭一个 tag (关闭一个页面) @@ -125,17 +124,17 @@ export default { /** * 激活一个主题(应用到dom上) * @param {state} state vuex state - * @param {string} themeActiveValue 需要激活的主题名称 + * @param {string} themeValue 需要激活的主题名称 */ - d2adminThemeSet (state, themeActiveValue) { + d2adminThemeSet (state, themeValue) { // 从列表里找到需要激活的主题的数据 - const theme = state.themeList.find(e => e.value === themeActiveValue) || state.themeList[0] + const theme = state.themeList.find(e => e.value === themeValue) || state.themeList[0] // 设置 state state.themeActive = theme // 设置 dom document.body.className = `theme-${state.themeActive.value}` // 保存到数据库 - this.commit('d2adminThemeSave', themeActiveValue) + this.commit('d2adminVuex2Db', 'themeActive') }, /** * 从数据库加载主题设置 @@ -144,23 +143,6 @@ export default { d2adminThemeLoad (state) { const themeActive = db.get('themeActive').find({uuid: util.uuid()}).value() this.commit('d2adminThemeSet', themeActive ? themeActive.value : state.themeList[0].value) - }, - /** - * 向数据保存一个主题 - * @param {state} state vuex state - * @param {string} themeActiveValue 需要保存的主题名称 - */ - d2adminThemeSave (state, themeActiveValue) { - // 检查这个用户是否有主题设置 - const setting = db.get('themeActive').find({uuid: util.uuid()}) - if (setting.value()) { - setting.assign({value: themeActiveValue}).write() - } else { - db.get('themeActive').push({ - uuid: util.uuid(), - value: themeActiveValue - }).write() - } } } }