no message
Former-commit-id: 52d865e779f351aaf2d997ce8e6ffd21d86137ba [formerly 52d865e779f351aaf2d997ce8e6ffd21d86137ba [formerly 52d865e779f351aaf2d997ce8e6ffd21d86137ba [formerly 52d865e779f351aaf2d997ce8e6ffd21d86137ba [formerly 2fa6b0e38fb02edbe3e60769246e2c17644430e9 [formerly 2c5805e77e36984c4223260702bcae5c192099f1]]]]] Former-commit-id: 38153766c1c1af0b795597b1e26d2a8ddcaff71c Former-commit-id: 04bdb951f0de941e54b2a816c03217d8c9549ce8 Former-commit-id: f8b9a67da5782072b59066ba51890d396caa86b4 [formerly 81555a3d4c79740f2d6e121d19af66025384089d] Former-commit-id: 3bb86c0e2f5a9c317a4bda23e6f4455d874e22fb Former-commit-id: 91a3c0cad0a76d1739ef5a932b4d4e14908b49dd Former-commit-id: 73eef8bdf0c07819f1b952068728cc592e14736a Former-commit-id: 54de3cd9214c91a039edcf7e9cfc750b508d28ac Former-commit-id: 2de01843691d0a074972ce48da498943c289f7b1
This commit is contained in:
@@ -5,8 +5,8 @@
|
|||||||
<!-- 顶栏 -->
|
<!-- 顶栏 -->
|
||||||
<el-header>
|
<el-header>
|
||||||
<div class="logo-group" :style="{width: collapse ? asideWidthCollapse : asideWidth}">
|
<div class="logo-group" :style="{width: collapse ? asideWidthCollapse : asideWidth}">
|
||||||
<img v-if="collapse" :src="`${$assetsPublicPath}static/image/theme/${themeName}/logo/icon-only.png`">
|
<img v-if="collapse" :src="`${$assetsPublicPath}static/image/theme/${themeActive.value}/logo/icon-only.png`">
|
||||||
<img v-else :src="`${$assetsPublicPath}static/image/theme/${themeName}/logo/all.png`">
|
<img v-else :src="`${$assetsPublicPath}static/image/theme/${themeActive.value}/logo/all.png`">
|
||||||
</div>
|
</div>
|
||||||
<div class="toggle-aside-btn" @click="collapse = !collapse">
|
<div class="toggle-aside-btn" @click="collapse = !collapse">
|
||||||
<d2-icon name="bars"/>
|
<d2-icon name="bars"/>
|
||||||
@@ -65,24 +65,23 @@ export default {
|
|||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
...mapState({
|
...mapState({
|
||||||
themeName: state => state.theme.name,
|
themeActive: state => state.d2admin.themeActive
|
||||||
themeBackGroundImage: state => state.theme.backGroundImage
|
|
||||||
}),
|
}),
|
||||||
styleLayoutMainGroup () {
|
styleLayoutMainGroup () {
|
||||||
return {
|
return {
|
||||||
...this.themeBackGroundImage ? {
|
...this.themeActive.backgroundImage ? {
|
||||||
backgroundImage: `url('${this.$assetsPublicPath}${this.themeBackGroundImage}')`
|
backgroundImage: `url('${this.$assetsPublicPath}${this.themeActive.backgroundImage}')`
|
||||||
} : {}
|
} : {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
mounted () {
|
mounted () {
|
||||||
// 加载主题
|
// 加载主题
|
||||||
this.loadTheme()
|
this.d2adminThemeLoadFromLo()
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
...mapMutations([
|
...mapMutations([
|
||||||
'loadTheme'
|
'd2adminThemeLoadFromLo'
|
||||||
])
|
])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,11 @@
|
|||||||
<el-table :data="themeList" v-bind="table">
|
<el-table :data="themeList" v-bind="table">
|
||||||
<el-table-column prop="name" align="center" width="160"/>
|
<el-table-column prop="name" align="center" width="160"/>
|
||||||
<el-table-column label="预览" width="220">
|
<el-table-column label="预览" width="220">
|
||||||
<div slot-scope="scope" class="theme-preview" :style="{'backgroundImage': `url(${$assetsPublicPath}${scope.row.preview})`}"></div>
|
<div
|
||||||
|
slot-scope="scope"
|
||||||
|
class="theme-preview"
|
||||||
|
:style="{'backgroundImage': `url(${$assetsPublicPath}${scope.row.preview})`}">
|
||||||
|
</div>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column prop="address" align="center">
|
<el-table-column prop="address" align="center">
|
||||||
<template slot-scope="scope">
|
<template slot-scope="scope">
|
||||||
@@ -33,10 +37,10 @@ export default {
|
|||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
...mapMutations([
|
...mapMutations([
|
||||||
'setTheme'
|
'd2adminThemeSet'
|
||||||
]),
|
]),
|
||||||
handleSelectTheme (name) {
|
handleSelectTheme (value) {
|
||||||
this.setTheme(name)
|
this.d2adminThemeSet(value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
12
src/libs/db.js
Normal file
12
src/libs/db.js
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
import low from 'lowdb'
|
||||||
|
import LocalStorage from 'lowdb/adapters/LocalStorage'
|
||||||
|
|
||||||
|
const adapter = new LocalStorage('d2admin')
|
||||||
|
const db = low(adapter)
|
||||||
|
|
||||||
|
db.defaults({
|
||||||
|
themeActive: []
|
||||||
|
})
|
||||||
|
.write()
|
||||||
|
|
||||||
|
export default db
|
||||||
@@ -4,6 +4,7 @@ const userDB = [
|
|||||||
{
|
{
|
||||||
username: 'admin',
|
username: 'admin',
|
||||||
password: 'admin',
|
password: 'admin',
|
||||||
|
uuid: '0000000001',
|
||||||
name: '管理员'
|
name: '管理员'
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -93,10 +93,7 @@ export default {
|
|||||||
const setting = {
|
const setting = {
|
||||||
expires: 1
|
expires: 1
|
||||||
}
|
}
|
||||||
// 不要像下面这样写 请改写为你的保存用户逻辑
|
Cookies.set('uuid', res.uuid, setting)
|
||||||
// 保存用户名密码 不等于真正保存到了本地
|
|
||||||
// Cookies.set('username', res.username, setting)
|
|
||||||
// Cookies.set('password', res.password, setting)
|
|
||||||
Cookies.set('token', res.token, setting)
|
Cookies.set('token', res.token, setting)
|
||||||
// 跳转路由
|
// 跳转路由
|
||||||
this.$router.push({
|
this.$router.push({
|
||||||
|
|||||||
@@ -2,15 +2,19 @@ import util from '@/libs/util.js'
|
|||||||
|
|
||||||
import themeList from '@/assets/style/theme/list.js'
|
import themeList from '@/assets/style/theme/list.js'
|
||||||
|
|
||||||
|
import db from '@/libs/db.js'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
state: {
|
state: {
|
||||||
// 系统
|
// 系统
|
||||||
appName: 'D2Admin',
|
appName: 'D2Admin',
|
||||||
|
// 用户
|
||||||
|
userId: '',
|
||||||
// 全屏
|
// 全屏
|
||||||
isFullScreen: false,
|
isFullScreen: false,
|
||||||
// 主题
|
// 主题
|
||||||
themeList,
|
themeList,
|
||||||
themeActive: themeList[0]
|
themeActive: themeList[1]
|
||||||
},
|
},
|
||||||
mutations: {
|
mutations: {
|
||||||
/**
|
/**
|
||||||
@@ -25,6 +29,21 @@ export default {
|
|||||||
util.openFullScreen()
|
util.openFullScreen()
|
||||||
state.isFullScreen = true
|
state.isFullScreen = true
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
/**
|
||||||
|
* 激活新的主题
|
||||||
|
* @param {state} state vuex state
|
||||||
|
*/
|
||||||
|
d2adminThemeSet (state, themeActiveValue) {
|
||||||
|
console.log('d2adminThemeSet', themeActiveValue)
|
||||||
|
},
|
||||||
|
/**
|
||||||
|
* 从本地加载主题设置
|
||||||
|
* @param {state} state vuex state
|
||||||
|
*/
|
||||||
|
d2adminThemeLoadFromLo (state) {
|
||||||
|
console.log(db.get('themeActive').find({name: 'hhh'}).value())
|
||||||
|
// db.get('themeActive').push({name: 'hhh'}).write()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user