From c2a2fec0670f20e4887a9df41465d012f5d65a49 Mon Sep 17 00:00:00 2001 From: Yulong Jing Date: Thu, 20 Dec 2018 14:49:14 +0800 Subject: [PATCH 001/300] fix[Example]: add wrapper for validate (#1428) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 创建文章里js里有验证规则,但是由于少了元素而不起作用。 --- src/views/example/components/ArticleDetail.vue | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/views/example/components/ArticleDetail.vue b/src/views/example/components/ArticleDetail.vue index ce22b3b467e..12a42f603cb 100644 --- a/src/views/example/components/ArticleDetail.vue +++ b/src/views/example/components/ArticleDetail.vue @@ -60,13 +60,16 @@ {{ contentShortLength }}字 -
- -
- -
- -
+ +
+ +
+
+ +
+ +
+
From 1b394ae41757a91e7288820f8e3a24e561ff095a Mon Sep 17 00:00:00 2001 From: Pan Date: Thu, 20 Dec 2018 15:01:22 +0800 Subject: [PATCH 002/300] refine[Example]: refine style --- src/components/Tinymce/index.vue | 1 + .../example/components/ArticleDetail.vue | 24 ++++--------------- 2 files changed, 6 insertions(+), 19 deletions(-) diff --git a/src/components/Tinymce/index.vue b/src/components/Tinymce/index.vue index 9032a6a8ab2..ce0fe6a9774 100644 --- a/src/components/Tinymce/index.vue +++ b/src/components/Tinymce/index.vue @@ -185,6 +185,7 @@ export default { From 07c3211989dbf519e27015227ca164c94deb5770 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=91=A3=E9=9B=A8?= Date: Wed, 26 Dec 2018 14:02:43 +0800 Subject: [PATCH 007/300] perf[ScrollPane]: refine moveToTarget code (#1460) --- src/components/ScrollPane/index.vue | 21 ++++----------------- 1 file changed, 4 insertions(+), 17 deletions(-) diff --git a/src/components/ScrollPane/index.vue b/src/components/ScrollPane/index.vue index 89998e80155..172afcccc50 100644 --- a/src/components/ScrollPane/index.vue +++ b/src/components/ScrollPane/index.vue @@ -28,8 +28,6 @@ export default { let firstTag = null let lastTag = null - let prevTag = null - let nextTag = null // find first tag and last tag if (tagList.length > 0) { @@ -37,26 +35,15 @@ export default { lastTag = tagList[tagList.length - 1] } - // find preTag and nextTag - for (let i = 0; i < tagList.length; i++) { - if (tagList[i] === currentTag) { - if (i === 0) { - nextTag = tagList[i].length > 1 && tagList[i + 1] - } else if (i === tagList.length - 1) { - prevTag = tagList[i].length > 1 && tagList[i - 1] - } else { - prevTag = tagList[i - 1] - nextTag = tagList[i + 1] - } - break - } - } - if (firstTag === currentTag) { $scrollWrapper.scrollLeft = 0 } else if (lastTag === currentTag) { $scrollWrapper.scrollLeft = $scrollWrapper.scrollWidth - $containerWidth } else { + // find preTag and nextTag + const currentIndex = tagList.findIndex(item => item === currentTag) + const prevTag = tagList[currentIndex - 1] + const nextTag = tagList[currentIndex + 1] // the tag's offsetLeft after of nextTag const afterNextTagOffsetLeft = nextTag.$el.offsetLeft + nextTag.$el.offsetWidth + tagAndTagSpacing From deb68401748cff8ec3af4fbfd2003255f8a8d54c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8A=B1=E8=A3=A4=E8=A1=A9?= Date: Thu, 27 Dec 2018 13:42:10 +0800 Subject: [PATCH 008/300] feature[PDF]: add PDF demo (#1469) --- src/icons/svg/edit.svg | 2 +- src/icons/svg/email.svg | 2 +- src/icons/svg/excel.svg | 2 +- src/icons/svg/language.svg | 2 +- src/icons/svg/link.svg | 2 +- src/icons/svg/pdf.svg | 1 + src/icons/svg/peoples.svg | 2 +- src/icons/svg/table.svg | 2 +- src/icons/svg/wechat.svg | 2 +- src/lang/en.js | 3 + src/lang/es.js | 3 + src/lang/zh.js | 3 + src/router/index.js | 20 ++++ src/views/pdf/content.js | 58 +++++++++++ src/views/pdf/download.vue | 199 +++++++++++++++++++++++++++++++++++++ src/views/pdf/index.vue | 9 ++ 16 files changed, 304 insertions(+), 8 deletions(-) create mode 100644 src/icons/svg/pdf.svg create mode 100644 src/views/pdf/content.js create mode 100644 src/views/pdf/download.vue create mode 100644 src/views/pdf/index.vue diff --git a/src/icons/svg/edit.svg b/src/icons/svg/edit.svg index 0306a8671ef..d26101f2989 100644 --- a/src/icons/svg/edit.svg +++ b/src/icons/svg/edit.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/src/icons/svg/email.svg b/src/icons/svg/email.svg index 055e5013905..74d25e21a6f 100644 --- a/src/icons/svg/email.svg +++ b/src/icons/svg/email.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/src/icons/svg/excel.svg b/src/icons/svg/excel.svg index 59d54b2ce53..74d97b802f8 100644 --- a/src/icons/svg/excel.svg +++ b/src/icons/svg/excel.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/src/icons/svg/language.svg b/src/icons/svg/language.svg index 96d00288a2a..0082b577ab2 100644 --- a/src/icons/svg/language.svg +++ b/src/icons/svg/language.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/src/icons/svg/link.svg b/src/icons/svg/link.svg index 07090147f5e..48197ba4da7 100644 --- a/src/icons/svg/link.svg +++ b/src/icons/svg/link.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/src/icons/svg/pdf.svg b/src/icons/svg/pdf.svg new file mode 100644 index 00000000000..957aa0cc359 --- /dev/null +++ b/src/icons/svg/pdf.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/icons/svg/peoples.svg b/src/icons/svg/peoples.svg index 2c911615dc6..aab852e52a3 100644 --- a/src/icons/svg/peoples.svg +++ b/src/icons/svg/peoples.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/src/icons/svg/table.svg b/src/icons/svg/table.svg index dbfe5d641aa..0e3dc9dea5a 100644 --- a/src/icons/svg/table.svg +++ b/src/icons/svg/table.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/src/icons/svg/wechat.svg b/src/icons/svg/wechat.svg index 9e18b7179df..c586e551172 100644 --- a/src/icons/svg/wechat.svg +++ b/src/icons/svg/wechat.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/src/lang/en.js b/src/lang/en.js index 930f0ad1ff2..656b746b1f8 100644 --- a/src/lang/en.js +++ b/src/lang/en.js @@ -142,6 +142,9 @@ export default { export: 'Export', placeholder: 'Please enter the file name(default file)' }, + pdf: { + tips: 'Here we use window.print() to implement the feature of downloading pdf.' + }, theme: { change: 'Change Theme', documentation: 'Theme documentation', diff --git a/src/lang/es.js b/src/lang/es.js index f16044c4316..69218ad2106 100755 --- a/src/lang/es.js +++ b/src/lang/es.js @@ -142,6 +142,9 @@ export default { export: 'Exportar', placeholder: 'Por favor escribe un nombre de fichero' }, + pdf: { + tips: 'Here we use window.print() to implement the feature of downloading pdf.' + }, theme: { change: 'Cambiar tema', documentation: 'Documentación del tema', diff --git a/src/lang/zh.js b/src/lang/zh.js index 46e96ccf5c5..021a5fa71ca 100644 --- a/src/lang/zh.js +++ b/src/lang/zh.js @@ -142,6 +142,9 @@ export default { export: '导出', placeholder: '请输入文件名(默认file)' }, + pdf: { + tips: '这里使用 window.print() 来实现下载pdf的功能' + }, theme: { change: '换肤', documentation: '换肤文档', diff --git a/src/router/index.js b/src/router/index.js index 73b09697689..f42046ee15b 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -293,6 +293,26 @@ export const asyncRouterMap = [ ] }, + { + path: '/pdf', + component: Layout, + redirect: '/pdf/index', + meta: { title: 'PDF', icon: 'pdf' }, + children: [ + { + path: 'index', + component: () => import('@/views/pdf/index'), + name: 'PDF', + meta: { title: 'PDF' } + } + ] + }, + { + path: '/pdf/download', + component: () => import('@/views/pdf/download'), + hidden: true + }, + { path: '/theme', component: Layout, diff --git a/src/views/pdf/content.js b/src/views/pdf/content.js new file mode 100644 index 00000000000..e62b1a2b17f --- /dev/null +++ b/src/views/pdf/content.js @@ -0,0 +1,58 @@ +const title = 'Plans for the Next Iteration of Vue.js' + +const content = `

Last week atVue.js LondonI gave a brief sneak peek of what’s coming in the next major version of Vue. This post provides an in-depth overview of the plan.

+

+

Why a new majorversion?

+

Vue 2.0 was releasedexactly two years ago(how time flies!). During this period, the core has remained backwards compatible with five minor releases. We’ve accumulated a number of ideas that would bring improvements, but they were held off because they would result in breaking changes. At the same time, the JavaScript ecosystem and the language itself has been evolving rapidly. There are greatly improved tools that could enhance our workflow, and many new language features that could unlock simpler, more complete, and more efficient solutions to the problems Vue is trying to solve. What’s more exciting is that we are seeing ES2015 support becoming a baseline for all major evergreen browsers. Vue 3.0 aims to leverage these new language features to make Vue core smaller, faster, and more powerful.

+

Vue 3.0 is currently in prototyping phase, and we have already implemented a runtime close to feature-parity with 2.x.Many of the items listed below are either already implemented, or confirmed to be feasible. Ones that are not yet implemented or still in exploration phase are marked with a *.

+

The Details

+

High-Level APIChanges

+
TL;DR: Everything except render function API and scoped-slots syntax will either remain the same or can be made 2.x compatible via a compatibility build.
+

Since it’s a new major, there is going to be some breaking changes. However, we take backwards compatibility seriously, so we want to start communicating these changes as soon as possible. Here’s the currently planned public API changes:

+
  • Template syntax will remain 99% the same. There may be small tweaks in scoped slots syntax, but other than that we have no plans to change anything else for templates.
  • 3.0 will support class-based components natively, with the aim to provide an API that is pleasant to use in native ES2015 without requiring any transpilation or stage-x features. Most current options will have a reasonable mapping in the class-based API. Stage-x features such as class fields and decorators can still be used optionally to enhance the authoring experience. In addition, the API is designed with TypeScript type inference in mind. The 3.x codebase will itself be written in TypeScript, and providing improved TypeScript support. (That said, usage of TypeScript in an application is still entirely optional.)
  • The 2.x object-based component format will still be supported by internally transforming the object to a corresponding class.
  • Mixins will still be supported.*
  • Top level APIs will likely receive an overhaul to avoid globally mutating the Vue runtime when installing plugins. Instead, plugins will be applied and scoped to a component tree. This will make it easier to test components that rely on specific plugins, and also make it possible to mount multiple Vue applications on the same page with different plugins, but using the same Vue runtime.*
  • Functional components can finally be plain functions —however, async components will now need to be explicitly created via a helper function.
  • The part that will receive the most changes is the Virtual DOM format used in render functions. We are currently collecting feedback from major library authors and will be sharing more details as we are more confident of the changes, but as long as you don’t heavily rely on hand-written (non-JSX) render functions in your app, upgrading should be a reasonably straightforward process.
+

Source Code Architecture

+
TL;DR: better decoupled internal modules, TypeScript, and a codebase that is easier to contribute to.
+

We are re-writing 3.0 from the ground up for a cleaner and more maintainable architecture, in particular trying to make it easier to contribute to. We are breaking some internal functionalities into individual packages in order to isolate the scope of complexity. For example, the observer module will become its own package, with its own public API and tests. Note this does not affect framework-level API— you will not have to manually import individual bits from multiple packages in order to use Vue. Instead, the final Vue package is assembled using these internal packages.

+

The codebase is also now written in TypeScript. Although this will make proficiency in TypeScript a pre-requisite for contributing to the new codebase, we believe the type information and IDE support will actually make it easier for a new contributor to make meaningful contributions.

+

Decoupling the observer and scheduler into separate packages also allows us to easily experiment with alternative implementations of these parts. For example, we can implement an IE11 compatible observer implementation with the same API, or an alternative scheduler that leveragesrequestIdleCallbackto yield to the browser during long updates.*

+

+

Observation Mechanism

+
TL;DR: more complete, precise, efficient and debuggable reactivity tracking & API for creating observables.
+

3.0 will ship with a Proxy-based observer implementation that provides reactivity tracking with full language coverage. This eliminates a number of limitations of Vue 2’s current implementation based onObject.defineProperty:

+

The new observer also features the following:

+

Easily understand why a component is re-rendering

+

+

Other Runtime Improvements

+
TL;DR: smaller, faster, tree-shakable features, fragments & portals, custom renderer API.
+

Compiler Improvements*

+
TL;DR: tree-shaking friendly output, more AOT optimizations, parser with better error info and source map support.
+

IE11 Support*

+
TL;DR: it will be supported, but in a separate build with the same reactivity limitations of Vue 2.x.
+

The new codebase currently targets evergreen browsers only and assumes baseline native ES2015 support. But alas, we know a lot of our users still need to support IE11 for the foreseeable future. Most of the ES2015 features used can be transpiled / polyfilled for IE11, with the exception for Proxies. Our plan is to implement an alternative observer with the same API, but using the good old ES5Object.definePropertyAPI. A separate build of Vue 3.x will be distributed using this observer implementation. However, this build will be subject to the same change detection caveats of Vue 2.x and thus not fully compatible with the “modern” build of 3.x. We are aware that this imposes some inconvenience for library authors as they will need to be aware of compatibility for two different builds, but we will make sure to provide clear guidelines on this when we reach that stage.

+

How Do We GetThere

+

First of all, although we are announcing it today, we do not have a definitive timeline yet. What we do know at the moment is the steps we will be taking to get there:

+

1. Internal Feedback for the Runtime Prototype

+

This is the phase we are in right now. Currently, we already have a working runtime prototype that includes the new observer, Virtual DOM and component implementation. We have invited a group of authors of influential community projects to provide feedback for the internal changes, and would like to make sure they are comfortable with the changes before moving forward. We want to ensure that important libraries in the ecosystem will be ready at the same time when we release 3.0, so that users relying on those projects can upgrade easily.

+

2. Public Feedback viaRFCs

+

Once we gain a certain level of confidence in the new design, for each breaking change we will be opening a dedicated RFC issue which includes:

+

We will anticipate public feedback from the wider community to help us consolidate these ideas.

+

3. Introduce Compatible Features in 2.x &2.x-next

+

We are not forgetting about 2.x! In fact, we plan to use 2.x to progressively accustom users to the new changes. We will be gradually introducing confirmed API changes into 2.x via opt-in adaptors, and 2.x-next will allow users to try out the new Proxy-based observer.

+

The last minor release in 2.x will become LTS and continue to receive bug and security fixes for 18 months when 3.0 is released.

+

4. AlphaPhase

+

Next, we will finish up the compiler and server-side rendering parts of 3.0 and start making alpha releases. These will mostly be for stability testing purposes in small greenfield apps.

+

5. BetaPhase

+

During beta phase, our main goal is updating support libraries and tools like Vue Router, Vuex, Vue CLI, Vue DevTools and make sure they work smoothly with the new core. We will also be working with major library authors from the community to help them get ready for 3.0.

+

6. RCPhase

+

Once we consider the API and codebase stable, we will enter RC phase with API freeze. During this phase we will also work on a “compat build”: a build of 3.0 that includes compatibility layers for 2.x API. This build will also ship with a flag you can turn on to emit deprecation warnings for 2.x API usage in your app. The compat build can be used as a guide to upgrade your app to 3.0.

+

7. IE11build

+

The last task before the final release will be the IE11 compatibility build as mentioned above.

+

8. FinalRelease

+

In all honesty, we don’t know when this will happen yet, but likely in 2019. Again, we care more about shipping something that is solid and stable rather than hitting specific dates. There is a lot of work to be done, but we are excited for what’s coming next!

` + +const data = { + title, + content +} + +export default data diff --git a/src/views/pdf/download.vue b/src/views/pdf/download.vue new file mode 100644 index 00000000000..b0f30f6f781 --- /dev/null +++ b/src/views/pdf/download.vue @@ -0,0 +1,199 @@ + + + + + diff --git a/src/views/pdf/index.vue b/src/views/pdf/index.vue new file mode 100644 index 00000000000..b7728152040 --- /dev/null +++ b/src/views/pdf/index.vue @@ -0,0 +1,9 @@ + + From cc7572820e7cec835548bcc54e2728be4c466f97 Mon Sep 17 00:00:00 2001 From: Pan Date: Thu, 27 Dec 2018 18:19:11 +0800 Subject: [PATCH 009/300] perf[v-permission]: refine v-permission demo --- src/lang/en.js | 3 +- src/lang/es.js | 3 +- src/lang/zh.js | 3 +- src/views/permission/directive.vue | 71 +++++++++++++++++++++--------- 4 files changed, 55 insertions(+), 25 deletions(-) diff --git a/src/lang/en.js b/src/lang/en.js index 656b746b1f8..2af355b1fc8 100644 --- a/src/lang/en.js +++ b/src/lang/en.js @@ -87,7 +87,8 @@ export default { }, permission: { roles: 'Your roles', - switchRoles: 'Switch roles' + switchRoles: 'Switch roles', + tips: 'In some cases it is not suitable to use v-permission, such as element Tab component or el-table-column and other asynchronous rendering dom cases which can only be achieved by manually setting the v-if.' }, guide: { description: 'The guide page is useful for some people who entered the project for the first time. You can briefly introduce the features of the project. Demo is based on ', diff --git a/src/lang/es.js b/src/lang/es.js index 69218ad2106..1268f0835b5 100755 --- a/src/lang/es.js +++ b/src/lang/es.js @@ -87,7 +87,8 @@ export default { }, permission: { roles: 'Tus permisos', - switchRoles: 'Cambiar permisos' + switchRoles: 'Cambiar permisos', + tips: 'In some cases it is not suitable to use v-permission, such as element Tab component or el-table-column and other asynchronous rendering dom cases which can only be achieved by manually setting the v-if.' }, guide: { description: 'The guide page is useful for some people who entered the project for the first time. You can briefly introduce the features of the project. Demo is based on ', diff --git a/src/lang/zh.js b/src/lang/zh.js index 021a5fa71ca..4371713fe4a 100644 --- a/src/lang/zh.js +++ b/src/lang/zh.js @@ -87,7 +87,8 @@ export default { }, permission: { roles: '你的权限', - switchRoles: '切换权限' + switchRoles: '切换权限', + tips: '在某些情况下,不适合使用 v-permission。例如:Element-UI 的 Tab 组件或 el-table-column 以及其它动态渲染 dom 的场景。你只能通过手动设置 v-if 来实现。' }, guide: { description: '引导页对于一些第一次进入项目的人很有用,你可以简单介绍下项目的功能。本 Demo 是基于', diff --git a/src/views/permission/directive.vue b/src/views/permission/directive.vue index 2817f1c5220..df277ddcffd 100644 --- a/src/views/permission/directive.vue +++ b/src/views/permission/directive.vue @@ -2,29 +2,53 @@
- - Only - admin can see this - - - Only - editor can see this - - - Both - admin and - editor can see this - +
+ + Only + admin can see this + + v-permission="['admin']" +
+ +
+ + Only + editor can see this + + v-permission="['editor']" +
+ +
+ + Both + admin and + editor can see this + + v-permission="['admin','editor']" +
-
- In some cases it is not suitable to use v-permission, such as element Tab component which can only be achieved by manually setting the v-if. +
+ + {{ $t('permission.tips') }}
e.g.
- - Admin can see this - Editor can see this - Both admin or editor can see this + + + + Admin can see this + v-if="checkPermission(['admin'])" + + + + Editor can see this + v-if="checkPermission(['editor'])" + + + + Both admin or editor can see this + v-if="checkPermission(['admin','editor'])" +
@@ -57,14 +81,17 @@ export default{ .app-container { /deep/ .permission-alert { width: 320px; - margin-top: 30px; + margin-top: 15px; background-color: #f0f9eb; color: #67c23a; padding: 8px 16px; border-radius: 4px; - display: block; + display: inline-block; + } + /deep/ .permission-sourceCode { + margin-left: 15px; } - /deep/ .permission-tag{ + /deep/ .permission-tag { background-color: #ecf5ff; } } From 311796a14b034fdd6e670fbb0f415dc12f3a3df6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8A=B1=E8=A3=A4=E8=A1=A9?= Date: Fri, 28 Dec 2018 15:28:26 +0800 Subject: [PATCH 010/300] perf[Sidebar]: refine sidebar store #1473 (#1474) --- src/store/modules/app.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/store/modules/app.js b/src/store/modules/app.js index bc4fb478a21..fba4b05c9d6 100644 --- a/src/store/modules/app.js +++ b/src/store/modules/app.js @@ -3,7 +3,7 @@ import Cookies from 'js-cookie' const app = { state: { sidebar: { - opened: !+Cookies.get('sidebarStatus'), + opened: Cookies.get('sidebarStatus') ? !!+Cookies.get('sidebarStatus') : true, withoutAnimation: false }, device: 'desktop', @@ -12,16 +12,16 @@ const app = { }, mutations: { TOGGLE_SIDEBAR: state => { + state.sidebar.opened = !state.sidebar.opened + state.sidebar.withoutAnimation = false if (state.sidebar.opened) { Cookies.set('sidebarStatus', 1) } else { Cookies.set('sidebarStatus', 0) } - state.sidebar.opened = !state.sidebar.opened - state.sidebar.withoutAnimation = false }, CLOSE_SIDEBAR: (state, withoutAnimation) => { - Cookies.set('sidebarStatus', 1) + Cookies.set('sidebarStatus', 0) state.sidebar.opened = false state.sidebar.withoutAnimation = withoutAnimation }, From c98d5787575e6048a7a65f1aed45cafcf7d3acd8 Mon Sep 17 00:00:00 2001 From: Pan Date: Mon, 31 Dec 2018 21:22:20 +0800 Subject: [PATCH 011/300] [release] 3.10.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 75d88dd43e4..66bfe78965c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "vue-element-admin", - "version": "3.9.3", + "version": "3.10.0", "description": "A magical vue admin. Typical templates for enterprise applications. Newest development stack of vue. Lots of awesome features", "author": "Pan ", "license": "MIT", From 3dd29ab07abba639e5ab581e699d3c4b03d53fbc Mon Sep 17 00:00:00 2001 From: Pan Date: Wed, 9 Jan 2019 14:48:19 +0800 Subject: [PATCH 012/300] chore: update webpack-dev-server --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 66bfe78965c..8ba9aadfce0 100644 --- a/package.json +++ b/package.json @@ -115,7 +115,7 @@ "webpack": "4.16.5", "webpack-bundle-analyzer": "2.13.1", "webpack-cli": "3.1.0", - "webpack-dev-server": "3.1.5", + "webpack-dev-server": "3.1.14", "webpack-merge": "4.1.4" }, "engines": { From 68a19d55deddec5c34ee2f81f49b9407b184a6ab Mon Sep 17 00:00:00 2001 From: Pan Date: Wed, 9 Jan 2019 14:53:36 +0800 Subject: [PATCH 013/300] fix[chore]: fix error when enable gzip --- build/webpack.prod.conf.js | 1 - package.json | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/build/webpack.prod.conf.js b/build/webpack.prod.conf.js index 946a134a55a..4f84e0c65ff 100644 --- a/build/webpack.prod.conf.js +++ b/build/webpack.prod.conf.js @@ -150,7 +150,6 @@ if (config.build.productionGzip) { webpackConfig.plugins.push( new CompressionWebpackPlugin({ - asset: '[path].gz[query]', algorithm: 'gzip', test: new RegExp( '\\.(' + config.build.productionGzipExtensions.join('|') + ')$' diff --git a/package.json b/package.json index 8ba9aadfce0..e5b0b9ecfe8 100644 --- a/package.json +++ b/package.json @@ -75,6 +75,7 @@ "babel-preset-env": "1.7.0", "babel-preset-stage-2": "6.24.1", "chalk": "2.4.1", + "compression-webpack-plugin": "2.0.0", "copy-webpack-plugin": "4.5.2", "cross-env": "5.2.0", "css-loader": "1.0.0", From 9cea3c3abe31746c044db1388d24ee86e343a623 Mon Sep 17 00:00:00 2001 From: Pan Date: Wed, 9 Jan 2019 16:04:24 +0800 Subject: [PATCH 014/300] refine: GetUserInfo error message --- src/permission.js | 2 +- src/store/modules/user.js | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/permission.js b/src/permission.js index 81f9d11395c..e556cb005b7 100644 --- a/src/permission.js +++ b/src/permission.js @@ -33,7 +33,7 @@ router.beforeEach((to, from, next) => { }) }).catch((err) => { store.dispatch('FedLogOut').then(() => { - Message.error(err || 'Verification failed, please login again') + Message.error(err) next({ path: '/' }) }) }) diff --git a/src/store/modules/user.js b/src/store/modules/user.js index 0f7e2296cd2..38e81a3603d 100644 --- a/src/store/modules/user.js +++ b/src/store/modules/user.js @@ -63,15 +63,16 @@ const user = { GetUserInfo({ commit, state }) { return new Promise((resolve, reject) => { getUserInfo(state.token).then(response => { - if (!response.data) { // 由于mockjs 不支持自定义状态码只能这样hack - reject('error') + // 由于mockjs 不支持自定义状态码只能这样hack + if (!response.data) { + reject('Verification failed, please login again.') } const data = response.data if (data.roles && data.roles.length > 0) { // 验证返回的roles是否是一个非空数组 commit('SET_ROLES', data.roles) } else { - reject('getInfo: roles must be a non-null array !') + reject('getInfo: roles must be a non-null array!') } commit('SET_NAME', data.name) From 1bb9283eddbba310b72c876dc8807a66b76c26c8 Mon Sep 17 00:00:00 2001 From: Nikita Sobolev Date: Thu, 10 Jan 2019 05:05:17 +0300 Subject: [PATCH 015/300] fix typo (#1505) --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index d0ff7d74a2c..cf67c757b6f 100644 --- a/README.md +++ b/README.md @@ -92,7 +92,7 @@ Become a sponsor and get your logo on our README on GitHub with a link to your s - Multiple dynamic themes - Dynamic sidebar (supports multi-level routing) - Dynamic breadcrumb - - Tags-view(Tab page Support right-click operation) + - Tags-view (Tab page Support right-click operation) - Svg Sprite - Mock data - Screenfull From 5ea614fe5d1fead70f62879410d2cd4358b34e7c Mon Sep 17 00:00:00 2001 From: Duy Nguyen Hoang Date: Fri, 11 Jan 2019 15:37:59 +0800 Subject: [PATCH 016/300] perf: add sidebar width to variables.scss (#1494) --- src/styles/sidebar.scss | 18 +++++++++--------- src/styles/variables.scss | 2 ++ 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/styles/sidebar.scss b/src/styles/sidebar.scss index faa7366efeb..2de9fd9149d 100644 --- a/src/styles/sidebar.scss +++ b/src/styles/sidebar.scss @@ -1,15 +1,15 @@ #app { - // 主体区域 + // 主体区域 Main container .main-container { min-height: 100%; transition: margin-left .28s; - margin-left: 180px; + margin-left: $sideBarWidth; position: relative; } - // 侧边栏 + // 侧边栏 Sidebar container .sidebar-container { transition: width 0.28s; - width: 180px !important; + width: $sideBarWidth !important; height: 100%; position: fixed; font-size: 0px; @@ -90,29 +90,29 @@ } .sidebar-container .nest-menu .el-submenu>.el-submenu__title, .sidebar-container .el-submenu .el-menu-item { - min-width: 180px !important; + min-width: $sideBarWidth !important; background-color: $subMenuBg !important; &:hover { background-color: $menuHover !important; } } .el-menu--collapse .el-menu .el-submenu { - min-width: 180px !important; + min-width: $sideBarWidth !important; } - //适配移动端 + // 适配移动端, Mobile responsive .mobile { .main-container { margin-left: 0px; } .sidebar-container { transition: transform .28s; - width: 180px !important; + width: $sideBarWidth !important; } &.hideSidebar { .sidebar-container { transition-duration: 0.3s; - transform: translate3d(-180px, 0, 0); + transform: translate3d(-$sideBarWidth, 0, 0); } } } diff --git a/src/styles/variables.scss b/src/styles/variables.scss index acc77a8218b..1af649c4228 100644 --- a/src/styles/variables.scss +++ b/src/styles/variables.scss @@ -11,3 +11,5 @@ $panGreen: #30B08F; $menuBg:#304156; $subMenuBg:#1f2d3d; $menuHover:#001528; + +$sideBarWidth: 180px; From c54e99d0a9c9a5ec18300ad60409b8b444771cd9 Mon Sep 17 00:00:00 2001 From: Pan Date: Fri, 11 Jan 2019 15:42:53 +0800 Subject: [PATCH 017/300] tweak --- src/styles/btn.scss | 7 +- src/styles/element-ui.scss | 129 +++++++++++++++++++------------------ src/styles/index.scss | 20 ++++-- src/styles/mixin.scss | 6 ++ src/styles/sidebar.scss | 40 ++++++++++-- src/styles/transition.scss | 3 +- src/styles/variables.scss | 2 +- 7 files changed, 128 insertions(+), 79 deletions(-) diff --git a/src/styles/btn.scss b/src/styles/btn.scss index 0c5ee7685c7..e6ba1a8e197 100644 --- a/src/styles/btn.scss +++ b/src/styles/btn.scss @@ -2,8 +2,10 @@ @mixin colorBtn($color) { background: $color; + &:hover { color: $color; + &:before, &:after { background: $color; @@ -49,14 +51,17 @@ transition: 600ms ease all; position: relative; display: inline-block; + &:hover { background: #fff; + &:before, &:after { width: 100%; transition: 600ms ease all; } } + &:before, &:after { content: ''; @@ -67,6 +72,7 @@ width: 0; transition: 400ms ease all; } + &::after { right: inherit; top: inherit; @@ -91,4 +97,3 @@ font-size: 14px; border-radius: 4px; } - diff --git a/src/styles/element-ui.scss b/src/styles/element-ui.scss index dc59591ec6f..494dcfa4f38 100644 --- a/src/styles/element-ui.scss +++ b/src/styles/element-ui.scss @@ -1,82 +1,85 @@ - //覆盖一些element-ui样式 +//覆盖一些element-ui样式 - .el-breadcrumb__inner, .el-breadcrumb__inner a{ - font-weight: 400!important; +.el-breadcrumb__inner, +.el-breadcrumb__inner a { + font-weight: 400 !important; } - .el-upload { - input[type="file"] { - display: none !important; - } - } +.el-upload { + input[type="file"] { + display: none !important; + } +} - .el-upload__input { - display: none; - } +.el-upload__input { + display: none; +} - .cell { - .el-tag { - margin-right: 0px; - } - } +.cell { + .el-tag { + margin-right: 0px; + } +} - .small-padding { - .cell { - padding-left: 5px; - padding-right: 5px; - } - } +.small-padding { + .cell { + padding-left: 5px; + padding-right: 5px; + } +} - .fixed-width{ - .el-button--mini{ +.fixed-width { + .el-button--mini { padding: 7px 10px; width: 60px; } - } +} - .status-col { - .cell { - padding: 0 10px; - text-align: center; - .el-tag { - margin-right: 0px; - } - } - } +.status-col { + .cell { + padding: 0 10px; + text-align: center; - //暂时性解决dialog 问题 https://github.com/ElemeFE/element/issues/2461 - .el-dialog { - transform: none; - left: 0; - position: relative; - margin: 0 auto; - } + .el-tag { + margin-right: 0px; + } + } +} + +//暂时性解决dialog 问题 https://github.com/ElemeFE/element/issues/2461 +.el-dialog { + transform: none; + left: 0; + position: relative; + margin: 0 auto; +} + +//文章页textarea修改样式 +.article-textarea { + textarea { + padding-right: 40px; + resize: none; + border: none; + border-radius: 0px; + border-bottom: 1px solid #bfcbd9; + } +} - //文章页textarea修改样式 - .article-textarea { - textarea { - padding-right: 40px; - resize: none; - border: none; - border-radius: 0px; - border-bottom: 1px solid #bfcbd9; - } - } +//element ui upload +.upload-container { + .el-upload { + width: 100%; - //element ui upload - .upload-container { - .el-upload { - width: 100%; - .el-upload-dragger { - width: 100%; - height: 200px; - } - } - } + .el-upload-dragger { + width: 100%; + height: 200px; + } + } +} //dropdown - .el-dropdown-menu{ - a{ +.el-dropdown-menu { + a { display: block } } diff --git a/src/styles/index.scss b/src/styles/index.scss index b6fd924ed4f..93f2157e393 100644 --- a/src/styles/index.scss +++ b/src/styles/index.scss @@ -22,7 +22,7 @@ html { box-sizing: border-box; } -#app{ +#app { height: 100%; } @@ -53,9 +53,9 @@ a:hover { text-decoration: none; } -div:focus{ +div:focus { outline: none; - } +} .fr { float: right; @@ -104,23 +104,26 @@ code { line-height: 36px; font-size: 15px; font-family: "Source Sans Pro", "Helvetica Neue", Arial, sans-serif; + a { color: #337ab7; cursor: pointer; + &:hover { color: rgb(32, 160, 255); } } } -.warn-content{ - background: rgba(66,185,131,.1); +.warn-content { + background: rgba(66, 185, 131, .1); border-radius: 2px; padding: 16px; padding: 1rem; line-height: 1.6rem; word-spacing: .05rem; - a{ + + a { color: #42b983; font-weight: 600; } @@ -153,13 +156,16 @@ code { padding-right: 20px; transition: 600ms ease position; background: linear-gradient(90deg, rgba(32, 182, 249, 1) 0%, rgba(32, 182, 249, 1) 0%, rgba(33, 120, 241, 1) 100%, rgba(33, 120, 241, 1) 100%); + .subtitle { font-size: 20px; color: #fff; } + &.draft { background: #d0d0d0; } + &.deleted { background: #d0d0d0; } @@ -169,6 +175,7 @@ code { .link-type:focus { color: #337ab7; cursor: pointer; + &:hover { color: rgb(32, 160, 255); } @@ -176,6 +183,7 @@ code { .filter-container { padding-bottom: 10px; + .filter-item { display: inline-block; vertical-align: middle; diff --git a/src/styles/mixin.scss b/src/styles/mixin.scss index 822ab92a993..06fa0612583 100644 --- a/src/styles/mixin.scss +++ b/src/styles/mixin.scss @@ -10,9 +10,11 @@ &::-webkit-scrollbar-track-piece { background: #d3dce6; } + &::-webkit-scrollbar { width: 6px; } + &::-webkit-scrollbar-thumb { background: #99a9bf; border-radius: 20px; @@ -37,21 +39,25 @@ $transparent-border-style: $width solid transparent; height: 0; width: 0; + @if $direction==up { border-bottom: $color-border-style; border-left: $transparent-border-style; border-right: $transparent-border-style; } + @else if $direction==right { border-left: $color-border-style; border-top: $transparent-border-style; border-bottom: $transparent-border-style; } + @else if $direction==down { border-top: $color-border-style; border-left: $transparent-border-style; border-right: $transparent-border-style; } + @else if $direction==left { border-right: $color-border-style; border-top: $transparent-border-style; diff --git a/src/styles/sidebar.scss b/src/styles/sidebar.scss index 2de9fd9149d..723f9a121c8 100644 --- a/src/styles/sidebar.scss +++ b/src/styles/sidebar.scss @@ -1,4 +1,5 @@ #app { + // 主体区域 Main container .main-container { min-height: 100%; @@ -6,6 +7,7 @@ margin-left: $sideBarWidth; position: relative; } + // 侧边栏 Sidebar container .sidebar-container { transition: width 0.28s; @@ -18,62 +20,79 @@ left: 0; z-index: 1001; overflow: hidden; + //reset element-ui css .horizontal-collapse-transition { transition: 0s width ease-in-out, 0s padding-left ease-in-out, 0s padding-right ease-in-out; } + .scrollbar-wrapper { - overflow-x: hidden!important; + overflow-x: hidden !important; + .el-scrollbar__view { height: 100%; } } - .el-scrollbar__bar.is-vertical{ + + .el-scrollbar__bar.is-vertical { right: 0px; } + .is-horizontal { display: none; } + a { display: inline-block; width: 100%; overflow: hidden; } + .svg-icon { margin-right: 16px; } + .el-menu { border: none; height: 100%; width: 100% !important; } - .is-active > .el-submenu__title{ - color: #f4f4f5!important; + + .is-active>.el-submenu__title { + color: #f4f4f5 !important; } } + .hideSidebar { .sidebar-container { width: 36px !important; } + .main-container { margin-left: 36px; } + .submenu-title-noDropdown { padding-left: 10px !important; position: relative; + .el-tooltip { padding: 0 10px !important; } } + .el-submenu { overflow: hidden; + &>.el-submenu__title { padding-left: 10px !important; + .el-submenu__icon-arrow { display: none; } } } + .el-menu--collapse { .el-submenu { &>.el-submenu__title { @@ -88,14 +107,17 @@ } } } + .sidebar-container .nest-menu .el-submenu>.el-submenu__title, .sidebar-container .el-submenu .el-menu-item { min-width: $sideBarWidth !important; background-color: $subMenuBg !important; + &:hover { background-color: $menuHover !important; } } + .el-menu--collapse .el-menu .el-submenu { min-width: $sideBarWidth !important; } @@ -105,10 +127,12 @@ .main-container { margin-left: 0px; } + .sidebar-container { transition: transform .28s; width: $sideBarWidth !important; } + &.hideSidebar { .sidebar-container { transition-duration: 0.3s; @@ -116,7 +140,9 @@ } } } + .withoutAnimation { + .main-container, .sidebar-container { transition: none; @@ -124,9 +150,9 @@ } } -.el-menu--vertical{ - & >.el-menu{ - .svg-icon{ +.el-menu--vertical { + &>.el-menu { + .svg-icon { margin-right: 16px; } } diff --git a/src/styles/transition.scss b/src/styles/transition.scss index 04e1627945e..ab68317d792 100644 --- a/src/styles/transition.scss +++ b/src/styles/transition.scss @@ -16,10 +16,12 @@ .fade-transform-enter-active { transition: all .5s; } + .fade-transform-enter { opacity: 0; transform: translateX(-30px); } + .fade-transform-leave-to { opacity: 0; transform: translateX(30px); @@ -44,4 +46,3 @@ .breadcrumb-leave-active { position: absolute; } - diff --git a/src/styles/variables.scss b/src/styles/variables.scss index 1af649c4228..09c3e9b0253 100644 --- a/src/styles/variables.scss +++ b/src/styles/variables.scss @@ -1,3 +1,4 @@ +// base color $blue:#324157; $light-blue:#3A71A8; $red:#C03639; @@ -11,5 +12,4 @@ $panGreen: #30B08F; $menuBg:#304156; $subMenuBg:#1f2d3d; $menuHover:#001528; - $sideBarWidth: 180px; From 109c393cc6ee0cb1fc7fe097645cd4ddf1bf980a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8A=B1=E8=A3=A4=E8=A1=A9?= Date: Mon, 14 Jan 2019 14:07:56 +0800 Subject: [PATCH 018/300] fix[ThemePicker]: fixed bug when oldVal is null (#1517) --- src/components/ThemePicker/index.vue | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/components/ThemePicker/index.vue b/src/components/ThemePicker/index.vue index e797d6c2f68..5d1ff8bdc88 100644 --- a/src/components/ThemePicker/index.vue +++ b/src/components/ThemePicker/index.vue @@ -18,7 +18,8 @@ export default { } }, watch: { - theme(val, oldVal) { + theme(val) { + const oldVal = this.theme if (typeof val !== 'string') return const themeCluster = this.getThemeCluster(val.replace('#', '')) const originalCluster = this.getThemeCluster(oldVal.replace('#', '')) From 77a40745bb702e3f99ce1d2e7110ad3cb7202c69 Mon Sep 17 00:00:00 2001 From: Pan Date: Tue, 15 Jan 2019 14:14:39 +0800 Subject: [PATCH 019/300] update README.md --- README.zh-CN.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.zh-CN.md b/README.zh-CN.md index 558821156a0..d6cacf56696 100644 --- a/README.zh-CN.md +++ b/README.zh-CN.md @@ -40,7 +40,7 @@ - [Wiki](https://github.com/PanJiaChen/vue-element-admin/wiki) -- [Donate](https://panjiachen.github.io/vue-element-admin-site/zh/donate/) +- [Donate](https://panjiachen.gitee.io/vue-element-admin-site/zh/donate) - [Gitee](https://panjiachen.gitee.io/vue-element-admin/) 国内用户可访问该地址在线预览 @@ -214,6 +214,8 @@ Detailed changes for each release are documented in the [release notes](https:// 如果你觉得这个项目帮助到了你,你可以帮作者买一杯果汁表示鼓励 :tropical_drink: ![donate](https://panjiachen.github.io/donate/donation.png) +[更多捐赠方式](https://panjiachen.gitee.io/vue-element-admin-site/zh/donate) + [Paypal Me](https://www.paypal.me/panfree23) ## Browsers support From f767fab4cc085361d6177c8ddd492cf4cf791f94 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8A=B1=E8=A3=A4=E8=A1=A9?= Date: Tue, 15 Jan 2019 16:36:03 +0800 Subject: [PATCH 020/300] fix[Breadcrumb]: fixed eslint error (#1521) --- src/components/Breadcrumb/index.vue | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/components/Breadcrumb/index.vue b/src/components/Breadcrumb/index.vue index 4b321e064f7..5bc7a1b8cf4 100644 --- a/src/components/Breadcrumb/index.vue +++ b/src/components/Breadcrumb/index.vue @@ -1,7 +1,7 @@ @@ -48,12 +35,8 @@ export default { cursor: pointer; width: 20px; height: 20px; - transform: rotate(90deg); - transition: .38s; - transform-origin: 50% 50%; } - .hamburger.is-active { - transform: rotate(0deg); + transform: rotate(180deg); } From ac8eddf3d7662a36c8ad3f3fde52af12e0a77150 Mon Sep 17 00:00:00 2001 From: Pan Date: Tue, 22 Jan 2019 16:35:53 +0800 Subject: [PATCH 023/300] update element-ui version --- README.md | 2 +- README.zh-CN.md | 2 +- package.json | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index cf67c757b6f..bf0e08be001 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ vue - element-ui + element-ui Build Status diff --git a/README.zh-CN.md b/README.zh-CN.md index d6cacf56696..5dc9f1d738d 100644 --- a/README.zh-CN.md +++ b/README.zh-CN.md @@ -7,7 +7,7 @@ vue - element-ui + element-ui Build Status diff --git a/package.json b/package.json index e5b0b9ecfe8..83e93bcebea 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,7 @@ "driver.js": "0.8.1", "dropzone": "5.2.0", "echarts": "4.1.0", - "element-ui": "2.4.6", + "element-ui": "2.4.11", "file-saver": "1.3.8", "js-cookie": "2.2.0", "jsonlint": "1.6.3", From 8cf279fbe1e6b698b147a869290138934e003455 Mon Sep 17 00:00:00 2001 From: Yuga Sun Date: Wed, 23 Jan 2019 11:18:02 +0800 Subject: [PATCH 024/300] perf[Login Form]: optimize eye icon style (#1545) * optimiz: eye icon style for login form * change eye-open svg --- src/icons/svg/eye-open.svg | 1 + src/views/login/index.vue | 28 +++++++++++++++++----------- 2 files changed, 18 insertions(+), 11 deletions(-) create mode 100644 src/icons/svg/eye-open.svg diff --git a/src/icons/svg/eye-open.svg b/src/icons/svg/eye-open.svg new file mode 100644 index 00000000000..88dcc98e6c8 --- /dev/null +++ b/src/icons/svg/eye-open.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/views/login/index.vue b/src/views/login/index.vue index 5e872595f93..a44c6ad3b56 100644 --- a/src/views/login/index.vue +++ b/src/views/login/index.vue @@ -1,11 +1,11 @@ From eb1d3381f48ff81632b22f944e1f53563ef22a86 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8A=B1=E8=A3=A4=E8=A1=A9?= Date: Thu, 24 Jan 2019 11:14:23 +0800 Subject: [PATCH 025/300] perf[Sticky]: export reset method (#1550) --- src/components/Sticky/index.vue | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/components/Sticky/index.vue b/src/components/Sticky/index.vue index e0fb7c57351..a287216d94c 100644 --- a/src/components/Sticky/index.vue +++ b/src/components/Sticky/index.vue @@ -56,10 +56,13 @@ export default { this.width = this.width + 'px' this.isSticky = true }, - reset() { + handleReset() { if (!this.active) { return } + this.reset() + }, + reset() { this.position = '' this.width = 'auto' this.active = false @@ -72,7 +75,7 @@ export default { this.sticky() return } - this.reset() + this.handleReset() }, handleReize() { if (this.isSticky) { From 8ef6c7ee7dc7cd78ccbc2545a1ec29fad5243cee Mon Sep 17 00:00:00 2001 From: Pan Date: Thu, 24 Jan 2019 13:48:19 +0800 Subject: [PATCH 026/300] perf[Sticky]: refine width default value --- src/components/Sticky/index.vue | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/components/Sticky/index.vue b/src/components/Sticky/index.vue index a287216d94c..5624a989a52 100644 --- a/src/components/Sticky/index.vue +++ b/src/components/Sticky/index.vue @@ -69,7 +69,8 @@ export default { this.isSticky = false }, handleScroll() { - this.width = this.$el.getBoundingClientRect().width + const width = this.$el.getBoundingClientRect().width + this.width = width || 'auto' const offsetTop = this.$el.getBoundingClientRect().top if (offsetTop < this.stickyTop) { this.sticky() From 23055c9b2c332930bddac1d25d099fde14390f76 Mon Sep 17 00:00:00 2001 From: xbigcat Date: Thu, 24 Jan 2019 15:32:35 +0800 Subject: [PATCH 027/300] perf[utils]: refine parseTime function (#1546) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 优化 parseTime 修复传入的时间戳是字符串类型,不能转换时间的问题 例:parseTime("1548221490638") * Update index.js --- src/utils/index.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/utils/index.js b/src/utils/index.js index 0445827b32e..821392e9b6d 100644 --- a/src/utils/index.js +++ b/src/utils/index.js @@ -11,7 +11,12 @@ export function parseTime(time, cFormat) { if (typeof time === 'object') { date = time } else { - if (('' + time).length === 10) time = parseInt(time) * 1000 + if ((typeof time === 'string') && (/^[0-9]+$/.test(time))) { + time = parseInt(time) + } + if ((typeof time === 'number') && (time.toString().length === 10)) { + time = time * 1000 + } date = new Date(time) } const formatObj = { From 3153a1b10bc32e1650c644d829f284d37ee044c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8A=B1=E8=A3=A4=E8=A1=A9?= Date: Fri, 25 Jan 2019 12:50:21 +0800 Subject: [PATCH 028/300] perf[UploadExcel]: optimized code (#1552) --- src/components/UploadExcel/index.vue | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/src/components/UploadExcel/index.vue b/src/components/UploadExcel/index.vue index 20e16398ed5..a6b8dbce8da 100644 --- a/src/components/UploadExcel/index.vue +++ b/src/components/UploadExcel/index.vue @@ -82,8 +82,7 @@ export default { const reader = new FileReader() reader.onload = e => { const data = e.target.result - const fixedData = this.fixData(data) - const workbook = XLSX.read(btoa(fixedData), { type: 'base64' }) + const workbook = XLSX.read(data, { type: 'array' }) const firstSheetName = workbook.SheetNames[0] const worksheet = workbook.Sheets[firstSheetName] const header = this.getHeaderRow(worksheet) @@ -95,14 +94,6 @@ export default { reader.readAsArrayBuffer(rawFile) }) }, - fixData(data) { - let o = '' - let l = 0 - const w = 10240 - for (; l < data.byteLength / w; ++l) o += String.fromCharCode.apply(null, new Uint8Array(data.slice(l * w, l * w + w))) - o += String.fromCharCode.apply(null, new Uint8Array(data.slice(l * w))) - return o - }, getHeaderRow(sheet) { const headers = [] const range = XLSX.utils.decode_range(sheet['!ref']) From 9daeb1cb340136fdbbec021fe20941a97dc41d5b Mon Sep 17 00:00:00 2001 From: Pan Date: Tue, 29 Jan 2019 16:54:38 +0800 Subject: [PATCH 029/300] perf: adjust the import order to make it more elegant #1537 --- src/main.js | 2 +- src/store/modules/permission.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main.js b/src/main.js index 1ce709c9025..7739639d82b 100644 --- a/src/main.js +++ b/src/main.js @@ -10,8 +10,8 @@ import 'element-ui/lib/theme-chalk/index.css' import '@/styles/index.scss' // global css import App from './App' -import router from './router' import store from './store' +import router from './router' import i18n from './lang' // Internationalization import './icons' // icon diff --git a/src/store/modules/permission.js b/src/store/modules/permission.js index 97de701e90a..13f60efb4f8 100644 --- a/src/store/modules/permission.js +++ b/src/store/modules/permission.js @@ -36,7 +36,7 @@ function filterAsyncRouter(routes, roles) { const permission = { state: { - routers: constantRouterMap, + routers: [], addRouters: [] }, mutations: { From 727c1a45dd15bd668cfe584a2af8b5b0a9cd28ec Mon Sep 17 00:00:00 2001 From: Pan Date: Tue, 29 Jan 2019 18:00:59 +0800 Subject: [PATCH 030/300] perf[Sidebar]: use sass variables in vue template --- src/styles/variables.scss | 12 ++++++++++++ src/views/layout/components/Sidebar/index.vue | 10 +++++++--- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/src/styles/variables.scss b/src/styles/variables.scss index 09c3e9b0253..87a5dd50d0d 100644 --- a/src/styles/variables.scss +++ b/src/styles/variables.scss @@ -12,4 +12,16 @@ $panGreen: #30B08F; $menuBg:#304156; $subMenuBg:#1f2d3d; $menuHover:#001528; +$menuText:#bfcbd9; +$menuActiveText:#409EFF; $sideBarWidth: 180px; + +// the :export directive is the magic sauce for webpack +:export { + menuBg: $menuBg; + subMenuBg: $subMenuBg; + menuHover: $menuHover; + menuText:$menuText; + menuActiveText:$menuActiveText; + sideBarWidth: $sideBarWidth; +} diff --git a/src/views/layout/components/Sidebar/index.vue b/src/views/layout/components/Sidebar/index.vue index dff85f18194..48407286805 100644 --- a/src/views/layout/components/Sidebar/index.vue +++ b/src/views/layout/components/Sidebar/index.vue @@ -4,10 +4,10 @@ :show-timeout="200" :default-active="$route.path" :collapse="isCollapse" + :background-color="variables.menuBg" + :text-color="variables.menuText" + :active-text-color="variables.menuActiveText" mode="vertical" - background-color="#304156" - text-color="#bfcbd9" - active-text-color="#409EFF" > @@ -17,6 +17,7 @@ - - diff --git a/src/components/Screenfull/index.vue b/src/components/Screenfull/index.vue index 4cdcb568fd5..5801ba4a8c0 100644 --- a/src/components/Screenfull/index.vue +++ b/src/components/Screenfull/index.vue @@ -1,29 +1,6 @@ @@ -32,20 +9,6 @@ import screenfull from 'screenfull' export default { name: 'Screenfull', - props: { - width: { - type: Number, - default: 22 - }, - height: { - type: Number, - default: 22 - }, - fill: { - type: String, - default: '#48576a' - } - }, data() { return { isFullscreen: false diff --git a/src/components/SizeSelect/index.vue b/src/components/SizeSelect/index.vue index a92a17c3696..6d3cd43a4f0 100644 --- a/src/components/SizeSelect/index.vue +++ b/src/components/SizeSelect/index.vue @@ -53,12 +53,3 @@ export default { } - - - diff --git a/src/components/ThemePicker/index.vue b/src/components/ThemePicker/index.vue index 5d1ff8bdc88..332b07e7408 100644 --- a/src/components/ThemePicker/index.vue +++ b/src/components/ThemePicker/index.vue @@ -136,7 +136,10 @@ export default { diff --git a/src/icons/svg/search.svg b/src/icons/svg/search.svg new file mode 100644 index 00000000000..84233ddaa98 --- /dev/null +++ b/src/icons/svg/search.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/views/layout/components/Navbar.vue b/src/views/layout/components/Navbar.vue index 018ef0f900a..dcb09ec1c90 100644 --- a/src/views/layout/components/Navbar.vue +++ b/src/views/layout/components/Navbar.vue @@ -6,24 +6,26 @@
- +
@@ -57,6 +59,7 @@ import Screenfull from '@/components/Screenfull' import SizeSelect from '@/components/SizeSelect' import LangSelect from '@/components/LangSelect' import ThemePicker from '@/components/ThemePicker' +import Search from '@/components/HeaderSearch' export default { components: { @@ -66,7 +69,8 @@ export default { Screenfull, SizeSelect, LangSelect, - ThemePicker + ThemePicker, + Search }, computed: { ...mapGetters([ @@ -100,6 +104,7 @@ export default { float: left; cursor: pointer; transition: background .3s; + &:hover { background: rgba(0, 0, 0, .025) } @@ -124,24 +129,30 @@ export default { } .right-menu-item { - cursor: pointer; display: inline-block; padding: 0 8px; height: 100%; - font-size: 20px; + font-size: 18px; color: #5a5e66; vertical-align: text-bottom; - transition: background .3s; - &:hover { - background: rgba(0, 0, 0, .025) + + &.hover-effect { + cursor: pointer; + transition: background .3s; + + &:hover { + background: rgba(0, 0, 0, .025) + } } } .avatar-container { margin-right: 30px; + .avatar-wrapper { margin-top: 5px; position: relative; + .user-avatar { cursor: pointer; width: 40px; From a1d6ad34530854699c38f3d5127c21b293083b93 Mon Sep 17 00:00:00 2001 From: Pan Date: Wed, 13 Feb 2019 16:10:23 +0800 Subject: [PATCH 040/300] fix[Screenfull]: fix screenfull click bug --- src/components/Screenfull/index.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/Screenfull/index.vue b/src/components/Screenfull/index.vue index 5801ba4a8c0..7f8e6fc3e8f 100644 --- a/src/components/Screenfull/index.vue +++ b/src/components/Screenfull/index.vue @@ -1,6 +1,6 @@ From 0fed69f367899c6f5d3321e5cb86b84faa08d2e9 Mon Sep 17 00:00:00 2001 From: Pan Date: Wed, 13 Feb 2019 16:34:03 +0800 Subject: [PATCH 041/300] perf[Screenfull]: refactor screenfull component --- package.json | 2 +- src/components/Screenfull/index.vue | 6 ++++-- src/icons/svg/exit-fullscreen.svg | 1 + src/icons/svg/{screenfull.svg => fullscreen.svg} | 0 src/lang/en.js | 1 - src/lang/es.js | 1 - src/lang/zh.js | 1 - src/views/layout/components/Navbar.vue | 4 +--- 8 files changed, 7 insertions(+), 9 deletions(-) create mode 100644 src/icons/svg/exit-fullscreen.svg rename src/icons/svg/{screenfull.svg => fullscreen.svg} (100%) diff --git a/package.json b/package.json index 5854b8d64ac..77c25de4060 100644 --- a/package.json +++ b/package.json @@ -50,7 +50,7 @@ "mockjs": "1.0.1-beta3", "normalize.css": "7.0.0", "nprogress": "0.2.0", - "screenfull": "3.3.3", + "screenfull": "4.0.0", "showdown": "1.8.6", "sortablejs": "1.7.0", "tui-editor": "1.2.7", diff --git a/src/components/Screenfull/index.vue b/src/components/Screenfull/index.vue index 7f8e6fc3e8f..8e7bcba4026 100644 --- a/src/components/Screenfull/index.vue +++ b/src/components/Screenfull/index.vue @@ -1,6 +1,6 @@ @@ -23,7 +23,9 @@ export default { }) return false } - screenfull.toggle() + screenfull.toggle().then(() => { + this.isFullscreen = screenfull.isFullscreen + }) } } } diff --git a/src/icons/svg/exit-fullscreen.svg b/src/icons/svg/exit-fullscreen.svg new file mode 100644 index 00000000000..485c128b613 --- /dev/null +++ b/src/icons/svg/exit-fullscreen.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/icons/svg/screenfull.svg b/src/icons/svg/fullscreen.svg similarity index 100% rename from src/icons/svg/screenfull.svg rename to src/icons/svg/fullscreen.svg diff --git a/src/lang/en.js b/src/lang/en.js index ef98af4bf2a..05b3459821d 100644 --- a/src/lang/en.js +++ b/src/lang/en.js @@ -69,7 +69,6 @@ export default { logOut: 'Log Out', dashboard: 'Dashboard', github: 'Github', - screenfull: 'Screenfull', theme: 'Theme', size: 'Global Size' }, diff --git a/src/lang/es.js b/src/lang/es.js index ed71fc15dd3..8575d382445 100755 --- a/src/lang/es.js +++ b/src/lang/es.js @@ -69,7 +69,6 @@ export default { logOut: 'Salir', dashboard: 'Panel de control', github: 'Github', - screenfull: 'Pantalla completa', theme: 'Tema', size: 'Tamaño global' }, diff --git a/src/lang/zh.js b/src/lang/zh.js index 7da0cceeb0a..1fd18355673 100644 --- a/src/lang/zh.js +++ b/src/lang/zh.js @@ -69,7 +69,6 @@ export default { logOut: '退出登录', dashboard: '首页', github: '项目地址', - screenfull: '全屏', theme: '换肤', size: '布局大小' }, diff --git a/src/views/layout/components/Navbar.vue b/src/views/layout/components/Navbar.vue index dcb09ec1c90..5c3bcda4063 100644 --- a/src/views/layout/components/Navbar.vue +++ b/src/views/layout/components/Navbar.vue @@ -10,9 +10,7 @@ - - - + From 9ed5db044f22bd9feb88dca6ce8ec7d08f7b8088 Mon Sep 17 00:00:00 2001 From: Pan Date: Thu, 14 Feb 2019 10:57:57 +0800 Subject: [PATCH 042/300] perf[deps]: move connect to devDependencies --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 77c25de4060..aef3052537c 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,6 @@ "axios": "0.18.0", "clipboard": "1.7.1", "codemirror": "5.39.2", - "connect": "3.6.6", "driver.js": "0.8.1", "dropzone": "5.2.0", "echarts": "4.1.0", @@ -77,6 +76,7 @@ "babel-preset-stage-2": "6.24.1", "chalk": "2.4.1", "compression-webpack-plugin": "2.0.0", + "connect": "3.6.6", "copy-webpack-plugin": "4.5.2", "cross-env": "5.2.0", "css-loader": "1.0.0", From 8c18c000d42d913be7bd03c933964d388852cc43 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8A=B1=E8=A3=A4=E8=A1=A9?= Date: Fri, 15 Feb 2019 10:03:34 +0800 Subject: [PATCH 043/300] fix[Screenfull]: fix screenfull bug (#1603) --- src/components/Screenfull/index.vue | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/components/Screenfull/index.vue b/src/components/Screenfull/index.vue index 8e7bcba4026..479bf3e3d45 100644 --- a/src/components/Screenfull/index.vue +++ b/src/components/Screenfull/index.vue @@ -14,6 +14,9 @@ export default { isFullscreen: false } }, + mounted() { + this.init() + }, methods: { click() { if (!screenfull.enabled) { @@ -23,9 +26,14 @@ export default { }) return false } - screenfull.toggle().then(() => { - this.isFullscreen = screenfull.isFullscreen - }) + screenfull.toggle() + }, + init() { + if (screenfull.enabled) { + screenfull.on('change', () => { + this.isFullscreen = screenfull.isFullscreen + }) + } } } } From 4e0559833fe7ec8ad13d3ca9ac26f3d1ee039927 Mon Sep 17 00:00:00 2001 From: Pan Date: Fri, 15 Feb 2019 14:54:57 +0800 Subject: [PATCH 044/300] fix typo --- src/router/index.js | 4 ++-- src/views/layout/components/Sidebar/FixiOSBug.js | 10 +++++----- src/views/layout/components/Sidebar/SidebarItem.vue | 2 +- src/views/layout/components/Sidebar/index.vue | 1 - 4 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/router/index.js b/src/router/index.js index dda18156df1..a86e3a13633 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -12,7 +12,7 @@ import chartsRouter from './modules/charts' import tableRouter from './modules/table' import nestedRouter from './modules/nested' -/** note: Submenu only appear when children.length>=1 +/** note: sub-menu only appear when children.length>=1 * detail see https://panjiachen.github.io/vue-element-admin-site/guide/essentials/router-and-nav.html **/ @@ -25,7 +25,7 @@ import nestedRouter from './modules/nested' * name:'router-name' the name is used by (must set!!!) * meta : { roles: ['admin','editor'] will control the page roles (you can set multiple roles) - title: 'title' the name show in submenu and breadcrumb (recommend set) + title: 'title' the name show in sub-menu and breadcrumb (recommend set) icon: 'svg-name' the icon show in the sidebar noCache: true if true, the page will no be cached(default is false) breadcrumb: false if false, the item will hidden in breadcrumb(default is true) diff --git a/src/views/layout/components/Sidebar/FixiOSBug.js b/src/views/layout/components/Sidebar/FixiOSBug.js index 5e0a92624dd..bc14856f076 100644 --- a/src/views/layout/components/Sidebar/FixiOSBug.js +++ b/src/views/layout/components/Sidebar/FixiOSBug.js @@ -5,16 +5,16 @@ export default { } }, mounted() { - // In order to fix the click on menu on the ios device will trigger the mouseeleave bug + // In order to fix the click on menu on the ios device will trigger the mouseleave bug // https://github.com/PanJiaChen/vue-element-admin/issues/1135 this.fixBugIniOS() }, methods: { fixBugIniOS() { - const $submenu = this.$refs.submenu - if ($submenu) { - const handleMouseleave = $submenu.handleMouseleave - $submenu.handleMouseleave = (e) => { + const $subMenu = this.$refs.subMenu + if ($subMenu) { + const handleMouseleave = $subMenu.handleMouseleave + $subMenu.handleMouseleave = (e) => { if (this.device === 'mobile') { return } diff --git a/src/views/layout/components/Sidebar/SidebarItem.vue b/src/views/layout/components/Sidebar/SidebarItem.vue index 56edf9f7519..f0381a90ba3 100644 --- a/src/views/layout/components/Sidebar/SidebarItem.vue +++ b/src/views/layout/components/Sidebar/SidebarItem.vue @@ -9,7 +9,7 @@ - + diff --git a/src/views/layout/components/Sidebar/index.vue b/src/views/layout/components/Sidebar/index.vue index 48407286805..11ef4c0257a 100644 --- a/src/views/layout/components/Sidebar/index.vue +++ b/src/views/layout/components/Sidebar/index.vue @@ -1,7 +1,6 @@ @@ -27,6 +28,7 @@ - - diff --git a/src/components/TreeTable/readme.md b/src/components/TreeTable/readme.md index 5b598e1109d..fe404ed04a2 100644 --- a/src/components/TreeTable/readme.md +++ b/src/components/TreeTable/readme.md @@ -1,89 +1,99 @@ ## 写在前面 -此组件仅提供一个创建TreeTable的解决思路 - -## prop说明 -#### *data* - **必填** - - 原始数据,要求是一个数组或者对象 - ```javascript - [{ - key1: value1, - key2: value2, - children: [{ - key1: value1 - }, - { - key1: value1 - }] - }, - { - key1: value1 - }] - ``` - 或者 - ```javascript - { - key1: value1, - key2: value2, - children: [{ - key1: value1 - }, - { - key1: value1 - }] - } - ``` - -#### columns - 列属性,要求是一个数组 - - 1. text: 显示在表头的文字 - 2. value: 对应data的key。treeTable将显示相应的value - 3. width: 每列的宽度,为一个数字(可选) - 如果你想要每个字段都有自定义的样式或者嵌套其他组件,columns可不提供,直接像在el-table一样写即可,如果没有自定义内容,提供columns将更加的便捷方便 +此组件仅提供一个创建 TreeTable 的解决思路,本组件充分利用 vue 插槽的特性,方便用户自定义 - 如果你有几个字段是需要自定义的,几个不需要,那么可以将不需要自定义的字段放入columns,将需要自定义的内容放入到slot中,详情见后文 - ```javascript - [{ - value:string, - text:string, - width:number - },{ - value:string, - text:string, - width:number - }] - ``` +evel.js 里面 `addAttrs` 方法会给数据添加几个属性,treeTotable 会对数组扁平化。这些操作都不会破坏源数据,只是会新增属性。 -#### expandAll - 是否默认全部展开,boolean值,默认为false +调用 addAttrs 后,因\_\_parent 属性,会造成数据循环引用,使用 JSON.stringify()报错,所以转成 JSON 之前需要清除\_\_parent 属性。 -#### evalFunc - 解析函数,function,非必须 +## prop 说明 - 如果不提供,将使用默认的[evalFunc](./eval.js) +- data(原始数据,要求是一个数组或者对象) +- columns(列属性,要求是一个数组) +- renderContent(数组扁平化方法(可选)) +- defaultExpandAll(默认是否全部展开,默认全部展开) +- defaultChildren(子元素名,默认为 children) +- spreadOffset(扩展符号的偏移量,默认为 50px) +- checkboxOffset(复选框的偏移量,默认为 50px) - 如果提供了evalFunc,那么会用提供的evalFunc去解析data,并返回treeTable渲染所需要的值。如何编写一个evalFunc,请参考[*eval.js*](https://github.com/PanJiaChen/vue-element-admin/blob/master/src/components/TreeTable/eval.js)或[*customEval.js*](https://github.com/PanJiaChen/vue-element-admin/blob/master/src/views/table/treeTable/customEval.js) +--- -#### evalArgs - 解析函数的参数,是一个数组 +### 代码示例 - **请注意,自定义的解析函数参数第一个为this.data,第二个参数为, this.expandAll,你不需要在evalArgs填写。一定记住,这两个参数是强制性的,并且位置不可颠倒** *this.data为需要解析的数据,this.expandAll为是否默认展开* +- data(**必填**) - 如你的解析函数需要的参数为`(this.data, this.expandAll,1,2,3,4)`,那么你只需要将`[1,2,3,4]`赋值给`evalArgs`就可以了 +原始数据, - 如果你的解析函数参数只有`(this.data, this.expandAll)`,那么就可以不用填写evalArgs了 - - 具体可参考[*customEval.js*](https://github.com/PanJiaChen/vue-element-admin/blob/master/src/views/table/treeTable/customEval.js)的函数参数和[customTreeTable](https://github.com/PanJiaChen/vue-element-admin/blob/master/src/views/table/treeTable/customTreeTable.vue)的`evalArgs`属性值 - - ## slot - 这是一个自定义列的插槽。 - - 默认情况下,treeTable只有一行行展示数据的功能。但是一般情况下,我们会要给行加上一个操作按钮或者根据当行数据展示不同的样式,这时我们就需要自定义列了。请参考[customTreeTable](https://github.com/PanJiaChen/vue-element-admin/blob/master/src/views/table/treeTable/customTreeTable.vue),[实例效果](https://panjiachen.github.io/vue-element-admin/#/table/tree-table) - - `slot`和`columns属性`可同时存在,columns里面的数据列会在slot自定义列的左边展示 - - ## 其他 - 如果有其他的需求,请参考[el-table](http://element-cn.eleme.io/#/en-US/component/table)的api自行修改index.vue +```js +const data = [ + { + key1: value1, + key2: value2, + children: [ + { + key1: value1 + }, + { + key1: value1 + } + ] + }, + { + key1: value1 + } +] +``` + +或者 + +```javascript + { + key1: value1, + key2: value2, + children: [{ + key1: value1 + }, + { + key1: value1 + }] + } +``` + +- columns + +1. label: 显示在表头的文字 +2. key: 对应 data 的 key。treeTable 将显示相应的 value +3. width: 每列的宽度,为一个数字(可选) + +树表组件将会根据 columns 的 key 属性生成具名插槽,如果你需要对列数据进行自定义,通过插槽即可实现 + +```javascript +const columns = [ + // 建议第一列做展开收缩操作 + { label: '', key: '__spread', width: '200' }, + // 如果添加复选框 + { label: '', key: '__checkbox', width: '200' }, + { + label: string, + key: string, + width: number + }, + { + label: string, + key: string, + width: number + } +] +``` + +#### renderContent + +解析函数,function,非必须 + +如果不提供,将使用默认的[evalFunc](./eval.js) + +如果提供了 evalFunc,那么会用提供的 evalFunc 去解析 data,并返回 treeTable 渲染所需要的值。 + +## 其他 + +如果有其他的需求,请参考[el-table](http://element-cn.eleme.io/#/en-US/component/table)的 api 自行修改 index.vue diff --git a/src/mock/table.js b/src/mock/table.js new file mode 100644 index 00000000000..e69de29bb2d diff --git a/src/views/table/treeTable/customEval.js b/src/views/table/treeTable/customEval.js deleted file mode 100644 index 73badb68109..00000000000 --- a/src/views/table/treeTable/customEval.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @Author: jianglei -* @Date: 2017-10-12 12:06:49 -*/ -'use strict' -import Vue from 'vue' -export default function treeToArray(data, expandAll, parent, level, item) { - const marLTemp = [] - let tmp = [] - Array.from(data).forEach(function(record) { - if (record._expanded === undefined) { - Vue.set(record, '_expanded', expandAll) - } - let _level = 1 - if (level !== undefined && level !== null) { - _level = level + 1 - } - Vue.set(record, '_level', _level) - // 如果有父元素 - if (parent) { - Vue.set(record, 'parent', parent) - // 如果父元素有偏移量,需要计算在this的偏移量中 - // 偏移量还与前面同级元素有关,需要加上前面所有元素的长度和 - if (!marLTemp[_level]) { - marLTemp[_level] = 0 - } - Vue.set(record, '_marginLeft', marLTemp[_level] + parent._marginLeft) - Vue.set(record, '_width', record[item] / parent[item] * parent._width) - // 在本次计算过偏移量后加上自己长度,以供下一个元素使用 - marLTemp[_level] += record._width - } else { - // 如果为根 - // 初始化偏移量存储map - marLTemp[record.id] = [] - // map中是一个数组,存储的是每级的长度和 - // 初始情况下为0 - marLTemp[record.id][_level] = 0 - Vue.set(record, '_marginLeft', 0) - Vue.set(record, '_width', 1) - } - tmp.push(record) - if (record.children && record.children.length > 0) { - const children = treeToArray(record.children, expandAll, record, _level, item) - tmp = tmp.concat(children) - } - }) - return tmp -} diff --git a/src/views/table/treeTable/customTreeTable.vue b/src/views/table/treeTable/customTreeTable.vue index 2a21617195f..1ed346fb5f9 100644 --- a/src/views/table/treeTable/customTreeTable.vue +++ b/src/views/table/treeTable/customTreeTable.vue @@ -1,137 +1,162 @@