diff --git a/src/api/article.js b/src/api/article.js
index 9eacd90d..f54b8af6 100644
--- a/src/api/article.js
+++ b/src/api/article.js
@@ -8,10 +8,11 @@ export function fetchList(query) {
})
}
-export function fetchArticle() {
+export function fetchArticle(id) {
return request({
url: '/article/detail',
- method: 'get'
+ method: 'get',
+ params: { id }
})
}
diff --git a/src/components/Tinymce/components/editorImage.vue b/src/components/Tinymce/components/editorImage.vue
index eee2c5f2..dd46916a 100644
--- a/src/components/Tinymce/components/editorImage.vue
+++ b/src/components/Tinymce/components/editorImage.vue
@@ -87,9 +87,10 @@ export default {
diff --git a/src/icons/svg/edit.svg b/src/icons/svg/edit.svg
new file mode 100644
index 00000000..5c77d97a
--- /dev/null
+++ b/src/icons/svg/edit.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/src/icons/svg/list.svg b/src/icons/svg/list.svg
new file mode 100644
index 00000000..c45f4591
--- /dev/null
+++ b/src/icons/svg/list.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/src/lang/en.js b/src/lang/en.js
index f84f0de2..a7b1fa00 100644
--- a/src/lang/en.js
+++ b/src/lang/en.js
@@ -37,8 +37,9 @@ export default {
customTreeTable: 'Custom TreeTable',
tab: 'Tab',
form: 'Form',
- createForm: 'Create Form',
- editForm: 'Edit Form',
+ createArticle: 'Create Article',
+ editArticle: 'Edit Article',
+ articleList: 'Article List',
errorPages: 'Error Pages',
page401: '401',
page404: '404',
diff --git a/src/lang/zh.js b/src/lang/zh.js
index 6ef13eec..2b081331 100644
--- a/src/lang/zh.js
+++ b/src/lang/zh.js
@@ -37,8 +37,9 @@ export default {
customTreeTable: '自定义树表',
tab: 'Tab',
form: '表单',
- createForm: '创建表单',
- editForm: '编辑表单',
+ createArticle: '创建文章',
+ editArticle: '编辑文章',
+ articleList: '文章列表',
errorPages: '错误页面',
page401: '401',
page404: '404',
diff --git a/src/mock/article.js b/src/mock/article.js
index 2f5b4583..45923ddd 100644
--- a/src/mock/article.js
+++ b/src/mock/article.js
@@ -4,6 +4,9 @@ import { param2Obj } from '@/utils'
const List = []
const count = 100
+const baseContent = '
我是测试数据我是测试数据
'
+const image_uri = 'https://wpimg.wallstcn.com/e4558086-631c-425c-9430-56ffb46e70b3'
+
for (let i = 0; i < count; i++) {
List.push(Mock.mock({
id: '@increment',
@@ -11,12 +14,17 @@ for (let i = 0; i < count; i++) {
author: '@first',
reviewer: '@first',
title: '@title(5, 10)',
+ content_short: '我是测试数据',
+ content: baseContent,
forecast: '@float(0, 100, 2, 2)',
importance: '@integer(1, 3)',
'type|1': ['CN', 'US', 'JP', 'EU'],
'status|1': ['published', 'draft', 'deleted'],
display_time: '@datetime',
- pageviews: '@integer(300, 5000)'
+ comment_disabled: true,
+ pageviews: '@integer(300, 5000)',
+ image_uri,
+ platforms: ['a-platform']
}))
}
@@ -45,22 +53,14 @@ export default {
getPv: () => ({
pvData: [{ key: 'PC', pv: 1024 }, { key: 'mobile', pv: 1024 }, { key: 'ios', pv: 1024 }, { key: 'android', pv: 1024 }]
}),
- getArticle: () => ({
- id: 120000000001,
- author: { key: 'mockPan' },
- source_name: '原创作者',
- category_item: [{ key: 'global', name: '全球' }],
- comment_disabled: true,
- content: '我是测试数据我是测试数据
"',
- content_short: '我是测试数据',
- display_time: +new Date(),
- image_uri: 'https://wpimg.wallstcn.com/e4558086-631c-425c-9430-56ffb46e70b3',
- platforms: ['a-platform'],
- source_uri: 'https://github.com/PanJiaChen/vue-element-admin',
- status: 'published',
- tags: [],
- title: 'vue-element-admin'
- }),
+ getArticle: (config) => {
+ const { id } = param2Obj(config.url)
+ for (const article of List) {
+ if (article.id === +id) {
+ return article
+ }
+ }
+ },
createArticle: () => ({
data: 'success'
}),
diff --git a/src/router/index.js b/src/router/index.js
index ce43eec2..72eb22db 100644
--- a/src/router/index.js
+++ b/src/router/index.js
@@ -127,7 +127,6 @@ export const asyncRouterMap = [
{ path: 'tinymce', component: _import('components-demo/tinymce'), name: 'tinymce-demo', meta: { title: 'tinymce' }},
{ path: 'markdown', component: _import('components-demo/markdown'), name: 'markdown-demo', meta: { title: 'markdown' }},
{ path: 'json-editor', component: _import('components-demo/jsonEditor'), name: 'jsonEditor-demo', meta: { title: 'jsonEditor' }},
- { path: 'dnd-list', component: _import('components-demo/dndList'), name: 'dndList-demo', meta: { title: 'dndList' }},
{ path: 'splitpane', component: _import('components-demo/splitpane'), name: 'splitpane-demo', meta: { title: 'splitPane' }},
{ path: 'avatar-upload', component: _import('components-demo/avatarUpload'), name: 'avatarUpload-demo', meta: { title: 'avatarUpload' }},
{ path: 'dropzone', component: _import('components-demo/dropzone'), name: 'dropzone-demo', meta: { title: 'dropzone' }},
@@ -136,6 +135,7 @@ export const asyncRouterMap = [
{ path: 'mixin', component: _import('components-demo/mixin'), name: 'componentMixin-demo', meta: { title: 'componentMixin' }},
{ path: 'back-to-top', component: _import('components-demo/backToTop'), name: 'backToTop-demo', meta: { title: 'backToTop' }},
{ path: 'drag-dialog', component: _import('components-demo/dragDialog'), name: 'dragDialog-demo', meta: { title: 'dragDialog' }},
+ { path: 'dnd-list', component: _import('components-demo/dndList'), name: 'dndList-demo', meta: { title: 'dndList' }},
{ path: 'drag-kanban', component: _import('components-demo/dragKanban'), name: 'dragKanban-demo', meta: { title: 'dragKanban' }}
]
},
@@ -156,50 +156,49 @@ export const asyncRouterMap = [
]
},
+ {
+ path: '/tab',
+ component: Layout,
+ children: [{
+ path: 'index',
+ component: _import('tab/index'),
+ name: 'tab',
+ meta: { title: 'tab', icon: 'tab' }
+ }]
+ },
+
+ {
+ path: '/table',
+ component: Layout,
+ redirect: '/table/complex-table',
+ name: 'table',
+ meta: {
+ title: 'Table',
+ icon: 'table'
+ },
+ children: [
+ { path: 'dynamic-table', component: _import('table/dynamicTable/index'), name: 'dynamicTable', meta: { title: 'dynamicTable' }},
+ { path: 'drag-table', component: _import('table/dragTable'), name: 'dragTable', meta: { title: 'dragTable' }},
+ { path: 'inline-edit-table', component: _import('table/inlineEditTable'), name: 'inlineEditTable', meta: { title: 'inlineEditTable' }},
+ { path: 'tree-table', component: _import('table/treeTable/treeTable'), name: 'treeTableDemo', meta: { title: 'treeTable' }},
+ { path: 'custom-tree-table', component: _import('table/treeTable/customTreeTable'), name: 'customTreeTableDemo', meta: { title: 'customTreeTable' }},
+ { path: 'complex-table', component: _import('table/complexTable'), name: 'complexTable', meta: { title: 'complexTable' }}
+ ]
+ },
+
{
path: '/example',
component: Layout,
- redirect: '/example/table/complex-table',
+ redirect: '/example/list',
name: 'example',
meta: {
title: 'example',
icon: 'example'
},
children: [
- {
- path: '/example/table',
- component: _import('example/table/index'),
- redirect: '/example/table/complex-table',
- name: 'Table',
- meta: {
- title: 'Table',
- icon: 'table'
- },
- children: [
- { path: 'dynamic-table', component: _import('example/table/dynamicTable/index'), name: 'dynamicTable', meta: { title: 'dynamicTable' }},
- { path: 'drag-table', component: _import('example/table/dragTable'), name: 'dragTable', meta: { title: 'dragTable' }},
- { path: 'inline-edit-table', component: _import('example/table/inlineEditTable'), name: 'inlineEditTable', meta: { title: 'inlineEditTable' }},
- { path: 'tree-table', component: _import('example/table/treeTable/treeTable'), name: 'treeTableDemo', meta: { title: 'treeTable' }},
- { path: 'custom-tree-table', component: _import('example/table/treeTable/customTreeTable'), name: 'customTreeTableDemo', meta: { title: 'customTreeTable' }},
- { path: 'complex-table', component: _import('example/table/complexTable'), name: 'complexTable', meta: { title: 'complexTable' }}
- ]
- },
- { path: 'tab/index', icon: 'tab', component: _import('example/tab/index'), name: 'tab', meta: { title: 'tab' }}
- ]
- },
-
- {
- path: '/form',
- component: Layout,
- redirect: 'noredirect',
- name: 'form',
- meta: {
- title: 'form',
- icon: 'form'
- },
- children: [
- { path: 'create-form', component: _import('form/create'), name: 'createForm', meta: { title: 'createForm', icon: 'table' }},
- { path: 'edit-form', component: _import('form/edit'), name: 'editForm', meta: { title: 'editForm', icon: 'table' }}
+ { path: 'create', component: _import('example/create'), name: 'createArticle', meta: { title: 'createArticle', icon: 'edit' }},
+ { path: 'edit/:id(\\d+)', component: _import('example/edit'), name: 'editArticle', meta: { title: 'editArticle', noCache: true }, hidden: true },
+ { path: 'list', component: _import('example/list'), name: 'articleList', meta: { title: 'articleList', icon: 'list' }}
]
},
diff --git a/src/utils/index.js b/src/utils/index.js
index 285cd19a..431fda2d 100644
--- a/src/utils/index.js
+++ b/src/utils/index.js
@@ -261,3 +261,7 @@ export function deepClone(source) {
})
return targetObj
}
+
+export function uniqueArr(arr) {
+ return Array.from(new Set(arr))
+}
diff --git a/src/views/form/components/ArticleDetail.vue b/src/views/example/components/ArticleDetail.vue
similarity index 52%
rename from src/views/form/components/ArticleDetail.vue
rename to src/views/example/components/ArticleDetail.vue
index ce9dc03d..8528db44 100644
--- a/src/views/form/components/ArticleDetail.vue
+++ b/src/views/example/components/ArticleDetail.vue
@@ -3,100 +3,51 @@
-
-
-
- 创建form
-
-
-
- {{!postForm.comment_disabled?'评论已打开':'评论已关闭'}}
-
-
-
-
-
- 关闭评论
- 打开评论
-
-
-
-
-
-
- 平台
-
-
-
-
-
- {{item.name}}
-
-
-
-
-
-
-
- 外链
-
-
-
-
-
- 填写url
-
-
-
-
-
- 发布
-
- 草稿
-
-
-
- 发送异常错误,刷新页面,或者联系程序员
-
-
+
+
+
+ 发布
+
+ 草稿
+
+
+
标题
- app可能会显示不全
-
- 无结果
-
+
+
+
+
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
@@ -109,11 +60,11 @@
-
+
-
+
@@ -131,6 +82,8 @@ import Sticky from '@/components/Sticky' // 粘性header组件
import { validateURL } from '@/utils/validate'
import { fetchArticle } from '@/api/article'
import { userSearch } from '@/api/remoteSearch'
+import Warning from './Warning'
+import { CommentDropdown, PlatformDropdown, SourceUrlDropdown } from './Dropdown'
const defaultForm = {
status: 'draft',
@@ -139,16 +92,16 @@ const defaultForm = {
content_short: '', // 文章摘要
source_uri: '', // 文章外链
image_uri: '', // 文章图片
- source_name: '', // 文章外部作者
display_time: undefined, // 前台展示时间
id: undefined,
platforms: ['a-platform'],
- comment_disabled: false
+ comment_disabled: false,
+ importance: 0
}
export default {
name: 'articleDetail',
- components: { Tinymce, MDinput, Upload, Multiselect, Sticky },
+ components: { Tinymce, MDinput, Upload, Multiselect, Sticky, Warning, CommentDropdown, PlatformDropdown, SourceUrlDropdown },
props: {
isEdit: {
type: Boolean,
@@ -184,14 +137,8 @@ export default {
}
return {
postForm: Object.assign({}, defaultForm),
- fetchSuccess: true,
loading: false,
- userLIstOptions: [],
- platformsOptions: [
- { key: 'a-platform', name: 'a-platform' },
- { key: 'b-platform', name: 'b-platform' },
- { key: 'c-platform', name: 'c-platform' }
- ],
+ userListOptions: [],
rules: {
image_uri: [{ validator: validateRequire }],
title: [{ validator: validateRequire }],
@@ -207,17 +154,20 @@ export default {
},
created() {
if (this.isEdit) {
- this.fetchData()
+ const id = this.$route.params && this.$route.params.id
+ this.fetchData(id)
} else {
this.postForm = Object.assign({}, defaultForm)
}
},
methods: {
- fetchData() {
- fetchArticle().then(response => {
+ fetchData(id) {
+ fetchArticle(id).then(response => {
this.postForm = response.data
+ // Just for test
+ this.postForm.title += ` Article Id:${this.postForm.id}`
+ this.postForm.content_short += ` Article Id:${this.postForm.id}`
}).catch(err => {
- this.fetchSuccess = false
console.log(err)
})
},
@@ -260,10 +210,7 @@ export default {
getRemoteUserList(query) {
userSearch(query).then(response => {
if (!response.data.items) return
- console.log(response)
- this.userLIstOptions = response.data.items.map(v => ({
- key: v.name
- }))
+ this.userListOptions = response.data.items.map(v => v.name)
})
}
}
@@ -271,44 +218,36 @@ export default {
-
diff --git a/src/views/example/components/Dropdown/Comment.vue b/src/views/example/components/Dropdown/Comment.vue
new file mode 100644
index 00000000..da217599
--- /dev/null
+++ b/src/views/example/components/Dropdown/Comment.vue
@@ -0,0 +1,31 @@
+
+
+ {{!comment_disabled?'评论已打开':'评论已关闭'}}
+
+
+
+
+
+ 关闭评论
+ 打开评论
+
+
+
+
+
+
+
diff --git a/src/views/example/components/Dropdown/Platform.vue b/src/views/example/components/Dropdown/Platform.vue
new file mode 100644
index 00000000..a20321dd
--- /dev/null
+++ b/src/views/example/components/Dropdown/Platform.vue
@@ -0,0 +1,40 @@
+
+
+
+ 平台({{platforms.length}})
+
+
+
+
+
+ {{item.name}}
+
+
+
+
+
+
+
diff --git a/src/views/example/components/Dropdown/SourceUrl.vue b/src/views/example/components/Dropdown/SourceUrl.vue
new file mode 100644
index 00000000..f09eb69d
--- /dev/null
+++ b/src/views/example/components/Dropdown/SourceUrl.vue
@@ -0,0 +1,31 @@
+
+
+
+ 外链
+
+
+
+
+
+ 填写url
+
+
+
+
+
+
+
diff --git a/src/views/example/components/Dropdown/index.js b/src/views/example/components/Dropdown/index.js
new file mode 100644
index 00000000..bc0c171b
--- /dev/null
+++ b/src/views/example/components/Dropdown/index.js
@@ -0,0 +1,3 @@
+export { default as CommentDropdown } from './Comment'
+export { default as PlatformDropdown } from './Platform'
+export { default as SourceUrlDropdown } from './SourceUrl'
diff --git a/src/views/example/components/Warning.vue b/src/views/example/components/Warning.vue
new file mode 100644
index 00000000..a0012ede
--- /dev/null
+++ b/src/views/example/components/Warning.vue
@@ -0,0 +1,9 @@
+
+
+ 创建和编辑页面是不能被keep-alive 缓存的,因为keep-alive 的include 目前不支持根据路由来缓存,所以目前都是基于component name 来缓存的,如果你想要实现缓存的效果,可以使用localstorage 等游览器缓存方案。或者不要使用keep-alive
+ 的include,直接缓存所有页面。详情见
+ 文档
+
+
+
diff --git a/src/views/form/create.vue b/src/views/example/create.vue
similarity index 100%
rename from src/views/form/create.vue
rename to src/views/example/create.vue
diff --git a/src/views/form/edit.vue b/src/views/example/edit.vue
similarity index 100%
rename from src/views/form/edit.vue
rename to src/views/example/edit.vue
diff --git a/src/views/example/list.vue b/src/views/example/list.vue
new file mode 100644
index 00000000..7dccafa6
--- /dev/null
+++ b/src/views/example/list.vue
@@ -0,0 +1,121 @@
+
+
+
+
+
+
+ {{scope.row.id}}
+
+
+
+
+
+ {{scope.row.timestamp | parseTime('{y}-{m}-{d} {h}:{i}')}}
+
+
+
+
+
+ {{scope.row.author}}
+
+
+
+
+
+
+
+
+
+
+
+ {{scope.row.status}}
+
+
+
+
+
+
+
+ {{ scope.row.title }}
+
+
+
+
+
+
+
+ Edit
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/views/example/table/index.vue b/src/views/example/table/index.vue
deleted file mode 100644
index de92c020..00000000
--- a/src/views/example/table/index.vue
+++ /dev/null
@@ -1,18 +0,0 @@
-
-
-
-
-
-
-
-
-
diff --git a/src/views/layout/components/AppMain.vue b/src/views/layout/components/AppMain.vue
index 8e10a9e5..770ab432 100644
--- a/src/views/layout/components/AppMain.vue
+++ b/src/views/layout/components/AppMain.vue
@@ -2,7 +2,7 @@
@@ -14,10 +14,10 @@ export default {
computed: {
cachedViews() {
return this.$store.state.tagsView.cachedViews
+ },
+ key() {
+ return this.$route.fullPath
}
- // key() {
- // return this.$route.name !== undefined ? this.$route.name + +new Date() : this.$route + +new Date()
- // }
}
}
diff --git a/src/views/layout/components/TagsView.vue b/src/views/layout/components/TagsView.vue
index c3199338..55467fc9 100644
--- a/src/views/layout/components/TagsView.vue
+++ b/src/views/layout/components/TagsView.vue
@@ -59,7 +59,7 @@ export default {
return false
},
isActive(route) {
- return route.path === this.$route.path || route.name === this.$route.name
+ return route.path === this.$route.path
},
addViewTags() {
const route = this.generateRoute()
diff --git a/src/views/example/tab/components/tabPane.vue b/src/views/tab/components/tabPane.vue
similarity index 100%
rename from src/views/example/tab/components/tabPane.vue
rename to src/views/tab/components/tabPane.vue
diff --git a/src/views/example/tab/index.vue b/src/views/tab/index.vue
similarity index 85%
rename from src/views/example/tab/index.vue
rename to src/views/tab/index.vue
index 2a3239a3..7f4b9bfa 100644
--- a/src/views/example/tab/index.vue
+++ b/src/views/tab/index.vue
@@ -1,6 +1,8 @@
mounted times :{{createdTimes}}
+
+
diff --git a/src/views/example/table/complexTable.vue b/src/views/table/complexTable.vue
similarity index 99%
rename from src/views/example/table/complexTable.vue
rename to src/views/table/complexTable.vue
index a5442ce1..f6171c5f 100644
--- a/src/views/example/table/complexTable.vue
+++ b/src/views/table/complexTable.vue
@@ -1,5 +1,5 @@
-
+
diff --git a/src/views/example/table/dragTable.vue b/src/views/table/dragTable.vue
similarity index 98%
rename from src/views/example/table/dragTable.vue
rename to src/views/table/dragTable.vue
index 9e411e64..f13dcb32 100644
--- a/src/views/example/table/dragTable.vue
+++ b/src/views/table/dragTable.vue
@@ -1,5 +1,5 @@
-
+
diff --git a/src/views/example/table/dynamicTable/fixedThead.vue b/src/views/table/dynamicTable/fixedThead.vue
similarity index 100%
rename from src/views/example/table/dynamicTable/fixedThead.vue
rename to src/views/table/dynamicTable/fixedThead.vue
diff --git a/src/views/example/table/dynamicTable/index.vue b/src/views/table/dynamicTable/index.vue
similarity index 100%
rename from src/views/example/table/dynamicTable/index.vue
rename to src/views/table/dynamicTable/index.vue
diff --git a/src/views/example/table/dynamicTable/unfixedThead.vue b/src/views/table/dynamicTable/unfixedThead.vue
similarity index 100%
rename from src/views/example/table/dynamicTable/unfixedThead.vue
rename to src/views/table/dynamicTable/unfixedThead.vue
diff --git a/src/views/example/table/inlineEditTable.vue b/src/views/table/inlineEditTable.vue
similarity index 98%
rename from src/views/example/table/inlineEditTable.vue
rename to src/views/table/inlineEditTable.vue
index 3d2ad00f..c44efccc 100644
--- a/src/views/example/table/inlineEditTable.vue
+++ b/src/views/table/inlineEditTable.vue
@@ -1,5 +1,5 @@
-
+
diff --git a/src/views/example/table/treeTable/customEval.js b/src/views/table/treeTable/customEval.js
similarity index 100%
rename from src/views/example/table/treeTable/customEval.js
rename to src/views/table/treeTable/customEval.js
diff --git a/src/views/example/table/treeTable/customTreeTable.vue b/src/views/table/treeTable/customTreeTable.vue
similarity index 100%
rename from src/views/example/table/treeTable/customTreeTable.vue
rename to src/views/table/treeTable/customTreeTable.vue
diff --git a/src/views/example/table/treeTable/treeTable.vue b/src/views/table/treeTable/treeTable.vue
similarity index 100%
rename from src/views/example/table/treeTable/treeTable.vue
rename to src/views/table/treeTable/treeTable.vue