util.db
Former-commit-id: 85a4564a9c26d25680e068390a9dce8081ff8301 [formerly 85a4564a9c26d25680e068390a9dce8081ff8301 [formerly 85a4564a9c26d25680e068390a9dce8081ff8301 [formerly 85a4564a9c26d25680e068390a9dce8081ff8301 [formerly 0c90f29ccfaf0af85cfee68a37e127969e1f403b [formerly 81d2e7a8b5e7b94b6707f2f7165948c23cb8fe97]]]]] Former-commit-id: 4be8876f52078af7d2f09d5be200e14c4b103b9d Former-commit-id: 0206f4b4d31c60ce01c43ceead230b7a242d6671 Former-commit-id: ca9b786629bc220dc77090732ec55ef682a65749 [formerly edc8fe2a03ccb155face81d2caa41898ffcc43da] Former-commit-id: 9bcb79d27c3671cdf2efa9bc8bb3bc746b536f76 Former-commit-id: ca8fa5fae99b3c2f29982295366d3b57dbd69ea8 Former-commit-id: ada47bd1e953a2977d08741b07f6dfa7a43a4c0f Former-commit-id: f7ae61fb796145f9e7cdc39c161876e4b1a70c3c Former-commit-id: eba7ec27792eebd4cc8cde53318b952a92f86a06
This commit is contained in:
@@ -1 +1 @@
|
|||||||
14be1e768a4e072ad8ea5ff5bfec5535088a3e4b
|
71c7a0f0efd0c1c51288f45b81f5c519d81068cb
|
||||||
@@ -1,8 +1,10 @@
|
|||||||
import log from './util.log.js'
|
import cookies from './util.cookies'
|
||||||
import cookies from './util.cookies.js'
|
import db from './util.db'
|
||||||
|
import log from './util.log'
|
||||||
|
|
||||||
let util = {
|
const util = {
|
||||||
cookies,
|
cookies,
|
||||||
|
db,
|
||||||
log
|
log
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -23,10 +25,10 @@ util.open = function (url) {
|
|||||||
var a = document.createElement('a')
|
var a = document.createElement('a')
|
||||||
a.setAttribute('href', url)
|
a.setAttribute('href', url)
|
||||||
a.setAttribute('target', '_blank')
|
a.setAttribute('target', '_blank')
|
||||||
a.setAttribute('id', 'd2admin-menu-link')
|
a.setAttribute('id', 'd2admin-link-temp')
|
||||||
document.body.appendChild(a)
|
document.body.appendChild(a)
|
||||||
a.click()
|
a.click()
|
||||||
document.body.removeChild(document.getElementById('d2admin-menu-link'))
|
document.body.removeChild(document.getElementById('d2admin-link-temp'))
|
||||||
}
|
}
|
||||||
|
|
||||||
export default util
|
export default util
|
||||||
|
|||||||
@@ -16,7 +16,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import db from '@/libs/db.js'
|
import util from '@/libs/util'
|
||||||
export default {
|
export default {
|
||||||
data () {
|
data () {
|
||||||
return {
|
return {
|
||||||
@@ -29,7 +29,7 @@ export default {
|
|||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
load () {
|
load () {
|
||||||
this.dbData = JSON.stringify(db.value(), null, 2)
|
this.dbData = JSON.stringify(util.db.value(), null, 2)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
import db from '@/libs/db.js'
|
import util from '@/libs/util'
|
||||||
import util from '@/libs/util.js'
|
|
||||||
import { cloneDeep } from 'lodash'
|
import { cloneDeep } from 'lodash'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -20,7 +19,7 @@ function pathInit ({
|
|||||||
}) {
|
}) {
|
||||||
const uuid = util.cookies.get('uuid') || 'ghost-uuid'
|
const uuid = util.cookies.get('uuid') || 'ghost-uuid'
|
||||||
const currentPath = `${dbName}.${user ? `user.${uuid}` : 'public'}${path ? `.${path}` : ''}`
|
const currentPath = `${dbName}.${user ? `user.${uuid}` : 'public'}${path ? `.${path}` : ''}`
|
||||||
const value = db.get(currentPath).value()
|
const value = util.db.get(currentPath).value()
|
||||||
// console.group('pathInit')
|
// console.group('pathInit')
|
||||||
// console.log('dbName', dbName)
|
// console.log('dbName', dbName)
|
||||||
// console.log('path', path)
|
// console.log('path', path)
|
||||||
@@ -29,7 +28,7 @@ function pathInit ({
|
|||||||
// console.log('value', value)
|
// console.log('value', value)
|
||||||
// console.groupEnd()
|
// console.groupEnd()
|
||||||
if (!(value !== undefined && validator(value))) {
|
if (!(value !== undefined && validator(value))) {
|
||||||
db
|
util.db
|
||||||
.set(currentPath, defaultValue)
|
.set(currentPath, defaultValue)
|
||||||
.write()
|
.write()
|
||||||
}
|
}
|
||||||
@@ -53,7 +52,7 @@ export default {
|
|||||||
value = '',
|
value = '',
|
||||||
user = false
|
user = false
|
||||||
}) {
|
}) {
|
||||||
db.set(pathInit({
|
util.db.set(pathInit({
|
||||||
dbName,
|
dbName,
|
||||||
path,
|
path,
|
||||||
user
|
user
|
||||||
@@ -74,7 +73,7 @@ export default {
|
|||||||
user = false
|
user = false
|
||||||
}) {
|
}) {
|
||||||
return new Promise(resolve => {
|
return new Promise(resolve => {
|
||||||
resolve(cloneDeep(db.get(pathInit({
|
resolve(cloneDeep(util.db.get(pathInit({
|
||||||
dbName,
|
dbName,
|
||||||
path,
|
path,
|
||||||
user,
|
user,
|
||||||
@@ -91,7 +90,7 @@ export default {
|
|||||||
user = false
|
user = false
|
||||||
} = {}) {
|
} = {}) {
|
||||||
return new Promise(resolve => {
|
return new Promise(resolve => {
|
||||||
resolve(db.get(pathInit({
|
resolve(util.db.get(pathInit({
|
||||||
dbName: 'database',
|
dbName: 'database',
|
||||||
path: '',
|
path: '',
|
||||||
user,
|
user,
|
||||||
@@ -108,7 +107,7 @@ export default {
|
|||||||
user = false
|
user = false
|
||||||
} = {}) {
|
} = {}) {
|
||||||
return new Promise(resolve => {
|
return new Promise(resolve => {
|
||||||
resolve(db.get(pathInit({
|
resolve(util.db.get(pathInit({
|
||||||
dbName: 'database',
|
dbName: 'database',
|
||||||
path: '',
|
path: '',
|
||||||
user,
|
user,
|
||||||
@@ -130,7 +129,7 @@ export default {
|
|||||||
user = false
|
user = false
|
||||||
} = {}) {
|
} = {}) {
|
||||||
return new Promise(resolve => {
|
return new Promise(resolve => {
|
||||||
resolve(db.get(pathInit({
|
resolve(util.db.get(pathInit({
|
||||||
dbName: 'database',
|
dbName: 'database',
|
||||||
path: `$page.${vm.$route[basis]}`,
|
path: `$page.${vm.$route[basis]}`,
|
||||||
user,
|
user,
|
||||||
@@ -151,7 +150,7 @@ export default {
|
|||||||
user = false
|
user = false
|
||||||
} = {}) {
|
} = {}) {
|
||||||
return new Promise(resolve => {
|
return new Promise(resolve => {
|
||||||
resolve(db.get(pathInit({
|
resolve(util.db.get(pathInit({
|
||||||
dbName: 'database',
|
dbName: 'database',
|
||||||
path: `$page.${vm.$route[basis]}`,
|
path: `$page.${vm.$route[basis]}`,
|
||||||
user,
|
user,
|
||||||
@@ -173,7 +172,7 @@ export default {
|
|||||||
user = false
|
user = false
|
||||||
}) {
|
}) {
|
||||||
return new Promise(resolve => {
|
return new Promise(resolve => {
|
||||||
resolve(db.get(pathInit({
|
resolve(util.db.get(pathInit({
|
||||||
dbName: 'database',
|
dbName: 'database',
|
||||||
path: `$page.${vm.$route[basis]}.$data`,
|
path: `$page.${vm.$route[basis]}.$data`,
|
||||||
user,
|
user,
|
||||||
@@ -195,7 +194,7 @@ export default {
|
|||||||
user = false
|
user = false
|
||||||
}) {
|
}) {
|
||||||
return new Promise(resolve => {
|
return new Promise(resolve => {
|
||||||
resolve(cloneDeep(db.get(pathInit({
|
resolve(cloneDeep(util.db.get(pathInit({
|
||||||
dbName: 'database',
|
dbName: 'database',
|
||||||
path: `$page.${vm.$route[basis]}.$data`,
|
path: `$page.${vm.$route[basis]}.$data`,
|
||||||
user,
|
user,
|
||||||
@@ -216,7 +215,7 @@ export default {
|
|||||||
user = false
|
user = false
|
||||||
}) {
|
}) {
|
||||||
return new Promise(resolve => {
|
return new Promise(resolve => {
|
||||||
resolve(db.get(pathInit({
|
resolve(util.db.get(pathInit({
|
||||||
dbName: 'database',
|
dbName: 'database',
|
||||||
path: `$page.${vm.$route[basis]}.$data`,
|
path: `$page.${vm.$route[basis]}.$data`,
|
||||||
user,
|
user,
|
||||||
|
|||||||
Reference in New Issue
Block a user