diff --git a/package-lock.json.REMOVED.git-id b/package-lock.json.REMOVED.git-id
index 2f1b1384..7347e8cb 100644
--- a/package-lock.json.REMOVED.git-id
+++ b/package-lock.json.REMOVED.git-id
@@ -1 +1 @@
-273bfaa679d4398e12f5270f76df4e1953da170b
\ No newline at end of file
+14be1e768a4e072ad8ea5ff5bfec5535088a3e4b
\ No newline at end of file
diff --git a/package.json b/package.json
index 305788dc..a0ec1396 100644
--- a/package.json
+++ b/package.json
@@ -35,6 +35,7 @@
"mockjs": "^1.0.1-beta3",
"nprogress": "^0.2.0",
"papaparse": "^4.3.6",
+ "qs": "^6.6.0",
"quill": "^1.3.4",
"screenfull": "^3.3.2",
"simplemde": "^1.11.2",
diff --git a/public/html/demo.html b/public/html/demo.html
new file mode 100644
index 00000000..e4823f04
--- /dev/null
+++ b/public/html/demo.html
@@ -0,0 +1,100 @@
+
+
+
+
+
+
+
+ demo
+
+
+
+
+
\ No newline at end of file
diff --git a/src/api/demo/business/issues/142/index.js b/src/api/demo/business/issues/142/index.js
new file mode 100644
index 00000000..b5b4464c
--- /dev/null
+++ b/src/api/demo/business/issues/142/index.js
@@ -0,0 +1,11 @@
+import request from '@/plugin/axios'
+
+export function get (id) {
+ return request({
+ url: '/demo/business/issues/142',
+ method: 'get',
+ params: {
+ id
+ }
+ })
+}
diff --git a/src/menu/modules/demo-business.js b/src/menu/modules/demo-business.js
index 78724af8..71b01f37 100644
--- a/src/menu/modules/demo-business.js
+++ b/src/menu/modules/demo-business.js
@@ -10,6 +10,13 @@ export default {
children: [
{ path: `${pre}table/1`, title: '表格 1' }
]
+ },
+ {
+ title: 'ISSUES',
+ icon: 'github',
+ children: [
+ { path: `${pre}issues/142`, title: '#142' }
+ ]
}
])('/demo/business/')
}
diff --git a/src/menu/modules/demo-frame.js b/src/menu/modules/demo-frame.js
index c00234bb..8b479bcb 100644
--- a/src/menu/modules/demo-frame.js
+++ b/src/menu/modules/demo-frame.js
@@ -3,6 +3,7 @@ export default {
title: '内嵌网页',
icon: 'globe',
children: (pre => [
- { path: `${pre}d2-doc`, title: 'D2Admin 中文文档', iconSvg: 'd2-admin' }
+ { path: `${pre}d2-doc`, title: 'D2Admin 中文文档', iconSvg: 'd2-admin' },
+ { path: `${pre}html`, title: '静态 HTML', icon: 'code' }
])('/demo/frame/')
}
diff --git a/src/mock/api/demo/business/issues/142/index.js b/src/mock/api/demo/business/issues/142/index.js
new file mode 100644
index 00000000..0c8933d8
--- /dev/null
+++ b/src/mock/api/demo/business/issues/142/index.js
@@ -0,0 +1,26 @@
+import Mock from 'mockjs'
+import qs from 'qs'
+
+const db = [
+ { id: '1', name: '王小虎1', address: '上海市普陀区金沙江路 1518 弄' },
+ { id: '2', name: '王小虎2', address: '上海市普陀区金沙江路 1517 弄' },
+ { id: '3', name: '王小虎3', address: '上海市普陀区金沙江路 1519 弄' },
+ { id: '4', name: '王小虎4', address: '上海市普陀区金沙江路 1516 弄' }
+]
+
+Mock.mock(RegExp('/api/demo/business/issues/142' + '.*'), 'get', ({ url, type, body }) => {
+ // 解析
+ const options = {
+ params: qs.parse(url.split('?').length > 1 ? url.split('?')[1] : ''),
+ body: qs.parse(body),
+ url: qs.parse(url.split('?')[0])
+ }
+ // 返回数据
+ return Mock.mock(
+ {
+ code: 0,
+ msg: '获取数据成功',
+ data: db.find(e => e.id === options.params.id)
+ }
+ )
+})
diff --git a/src/pages/demo/business/issues/142/edit-cache-db.vue b/src/pages/demo/business/issues/142/edit-cache-db.vue
new file mode 100644
index 00000000..e4af898f
--- /dev/null
+++ b/src/pages/demo/business/issues/142/edit-cache-db.vue
@@ -0,0 +1,98 @@
+
+
+
+
+
+
+
+
+
+
+ 修改
+
+
+
+
+
+
+
+
diff --git a/src/pages/demo/business/issues/142/edit.vue b/src/pages/demo/business/issues/142/edit.vue
new file mode 100644
index 00000000..48b96f63
--- /dev/null
+++ b/src/pages/demo/business/issues/142/edit.vue
@@ -0,0 +1,62 @@
+
+
+
+
+
+
+
+
+
+
+ 修改
+
+
+
+
+
+
+
+
diff --git a/src/pages/demo/business/issues/142/index.vue b/src/pages/demo/business/issues/142/index.vue
new file mode 100644
index 00000000..c52280ac
--- /dev/null
+++ b/src/pages/demo/business/issues/142/index.vue
@@ -0,0 +1,64 @@
+
+
+ goToEditPage('demo-business-issues-142-edit', row.id)"
+ @edit-cache-db="({ index, row }) => goToEditPage('demo-business-issues-142-edit-cache-db', row.id)"
+ style="margin: -15px 0;"/>
+
+
+
+
+
+
+
diff --git a/src/pages/demo/business/issues/142/mixins/index.js b/src/pages/demo/business/issues/142/mixins/index.js
new file mode 100644
index 00000000..524638fc
--- /dev/null
+++ b/src/pages/demo/business/issues/142/mixins/index.js
@@ -0,0 +1,54 @@
+import { get } from '@/api/demo/business/issues/142'
+
+export default {
+ props: {
+ id: {
+ type: String,
+ required: true
+ }
+ },
+ data () {
+ return {
+ form: {
+ name: '',
+ address: ''
+ }
+ }
+ },
+ methods: {
+ // [业务逻辑] 重置表单
+ resetFormData () {
+ this.form = {
+ name: '',
+ address: ''
+ }
+ },
+ // [业务逻辑] 根据 id 获取数据
+ getFormData (id) {
+ return new Promise((resolve, reject) => {
+ // 重置表单
+ this.resetFormData()
+ // 请求数据
+ get(id)
+ .then(res => {
+ const { name, address } = res
+ this.form = { name, address }
+ this.$message.success('getFormData')
+ resolve()
+ })
+ .catch(err => {
+ console.log('err', err)
+ reject(err)
+ })
+ })
+ },
+ // [业务逻辑] 提交
+ handleSubmit () {
+ this.$notify({
+ title: 'Submit',
+ message: '提交了表单',
+ type: 'info'
+ })
+ }
+ }
+}
diff --git a/src/pages/demo/frame/html/index.vue b/src/pages/demo/frame/html/index.vue
new file mode 100644
index 00000000..b916bfa4
--- /dev/null
+++ b/src/pages/demo/frame/html/index.vue
@@ -0,0 +1,13 @@
+
+
+
+
+
diff --git a/src/pages/demo/playground/store/page/index.vue b/src/pages/demo/playground/store/page/index.vue
index 813dec42..c100055e 100644
--- a/src/pages/demo/playground/store/page/index.vue
+++ b/src/pages/demo/playground/store/page/index.vue
@@ -61,28 +61,28 @@ export default {
// 关闭当前
handleCloseCurrent () {
this.close({
- tagName: this.$route.name,
+ tagName: this.$route.fullPath,
vm: this
})
},
// 关闭左侧
handleCloseLeft () {
this.closeLeft({
- tagName: this.$route.name,
+ tagName: this.$route.fullPath,
vm: this
})
},
// 关闭右侧
handleCloseRight () {
this.closeRight({
- tagName: this.$route.name,
+ tagName: this.$route.fullPath,
vm: this
})
},
// 关闭其他
handleCloseOther () {
this.closeOther({
- tagName: this.$route.name,
+ tagName: this.$route.fullPath,
vm: this
})
},
@@ -92,7 +92,7 @@ export default {
},
// 清空当前页缓存并刷新此页面
handleCleanCacheAndRefreshCurrent () {
- this.keepAliveRemove(this.$route.name)
+ this.keepAliveRemove(this.$route.fullPath)
this.$nextTick(this.$router.replace('/refresh'))
},
// 清空所有的缓存并刷新此页面
diff --git a/src/router/modules/business.js b/src/router/modules/business.js
index 7b8ad0c5..bf5a31af 100644
--- a/src/router/modules/business.js
+++ b/src/router/modules/business.js
@@ -9,7 +9,52 @@ export default {
redirect: { name: 'demo-business-index' },
component: layoutHeaderAside,
children: (pre => [
- { path: 'index', name: `${pre}index`, component: () => import('@/pages/demo/business/index'), meta: { ...meta, title: '示例首页' } },
- { path: 'table/1', name: `${pre}table-1`, component: () => import('@/pages/demo/business/table/1'), meta: { ...meta, title: '表格 1' } }
+ {
+ path: 'index',
+ name: `${pre}index`,
+ component: () => import('@/pages/demo/business/index'),
+ meta: {
+ ...meta,
+ title: '示例首页'
+ }
+ },
+ {
+ path: 'table/1',
+ name: `${pre}table-1`,
+ component: () => import('@/pages/demo/business/table/1'),
+ meta: {
+ ...meta,
+ title: '表格 1'
+ }
+ },
+ {
+ path: 'issues/142',
+ name: `${pre}issues-142`,
+ component: () => import('@/pages/demo/business/issues/142'),
+ meta: {
+ ...meta,
+ title: 'issue #142'
+ }
+ },
+ {
+ path: 'issues/142/edit/:id',
+ name: `${pre}issues-142-edit`,
+ component: () => import('@/pages/demo/business/issues/142/edit'),
+ props: true,
+ meta: {
+ ...meta,
+ title: '无缓存编辑'
+ }
+ },
+ {
+ path: 'issues/142/edit-cache-db/:id',
+ name: `${pre}issues-142-edit-cache-db`,
+ component: () => import('@/pages/demo/business/issues/142/edit-cache-db'),
+ props: true,
+ meta: {
+ ...meta,
+ title: '带缓存编辑 DB'
+ }
+ }
])('demo-business-')
}
diff --git a/src/router/modules/frame.js b/src/router/modules/frame.js
index cb6d3537..4e360ba7 100644
--- a/src/router/modules/frame.js
+++ b/src/router/modules/frame.js
@@ -9,6 +9,7 @@ export default {
redirect: { name: 'demo-frame-index' },
component: layoutHeaderAside,
children: (pre => [
+ { path: 'html', name: `${pre}html`, component: () => import('@/pages/demo/frame/html'), meta: { ...meta, title: '静态 HTML' } },
{ path: 'd2-doc', name: `${pre}d2-doc`, component: () => import('@/pages/demo/frame/d2-doc'), meta: { ...meta, title: 'D2Admin 中文文档' } }
])('demo-frame-')
}
diff --git a/src/store/modules/d2admin/modules/db.js b/src/store/modules/d2admin/modules/db.js
index b8045c71..4bf6dd15 100644
--- a/src/store/modules/d2admin/modules/db.js
+++ b/src/store/modules/d2admin/modules/db.js
@@ -1,5 +1,6 @@
import db from '@/libs/db.js'
import util from '@/libs/util.js'
+import { cloneDeep } from 'lodash'
/**
* @description 检查路径是否存在 不存在的话初始化
@@ -20,6 +21,13 @@ function pathInit ({
const uuid = util.cookies.get('uuid') || 'ghost-uuid'
const currentPath = `${dbName}.${user ? `user.${uuid}` : 'public'}${path ? `.${path}` : ''}`
const value = db.get(currentPath).value()
+ console.group('pathInit')
+ console.log('dbName', dbName)
+ console.log('path', path)
+ console.log('user', user)
+ console.log('defaultValue', defaultValue)
+ console.log('value', value)
+ console.groupEnd()
if (!(value !== undefined && validator(value))) {
db
.set(currentPath, defaultValue)
@@ -66,12 +74,12 @@ export default {
user = false
}) {
return new Promise(resolve => {
- resolve(db.get(pathInit({
+ resolve(cloneDeep(db.get(pathInit({
dbName,
path,
user,
defaultValue
- })).value())
+ })).value()))
})
},
/**
@@ -118,7 +126,7 @@ export default {
*/
databasePage (context, {
vm,
- basis = 'name',
+ basis = 'fullPath',
user = false
} = {}) {
return new Promise(resolve => {
@@ -139,7 +147,7 @@ export default {
*/
databasePageClear (context, {
vm,
- basis = 'name',
+ basis = 'fullPath',
user = false
} = {}) {
return new Promise(resolve => {
@@ -161,7 +169,7 @@ export default {
*/
pageSet (context, {
vm,
- basis = 'name',
+ basis = 'fullPath',
user = false
}) {
return new Promise(resolve => {
@@ -170,7 +178,7 @@ export default {
path: `$page.${vm.$route[basis]}.$data`,
user,
validator: () => false,
- defaultValue: vm.$data
+ defaultValue: cloneDeep(vm.$data)
})))
})
},
@@ -183,16 +191,16 @@ export default {
*/
pageGet (context, {
vm,
- basis = 'name',
+ basis = 'fullPath',
user = false
}) {
return new Promise(resolve => {
- resolve(db.get(pathInit({
+ resolve(cloneDeep(db.get(pathInit({
dbName: 'database',
path: `$page.${vm.$route[basis]}.$data`,
user,
- defaultValue: vm.$data
- })).value())
+ defaultValue: cloneDeep(vm.$data)
+ })).value()))
})
},
/**
@@ -204,7 +212,7 @@ export default {
*/
pageClear (context, {
vm,
- basis = 'name',
+ basis = 'fullPath',
user = false
}) {
return new Promise(resolve => {