From 25329e68b7c4feac565562f22cf3732c7dc5630e Mon Sep 17 00:00:00 2001 From: liyang <1711467488@qq.com> Date: Wed, 1 Aug 2018 22:55:40 +0800 Subject: [PATCH 01/14] =?UTF-8?q?=E6=96=B0=E5=BB=BA=E7=9B=B8=E5=85=B3?= =?UTF-8?q?=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Former-commit-id: a8bf514c7999f8be7e16a1ce0a11c80ddb7669be [formerly a8bf514c7999f8be7e16a1ce0a11c80ddb7669be [formerly a8bf514c7999f8be7e16a1ce0a11c80ddb7669be [formerly a8bf514c7999f8be7e16a1ce0a11c80ddb7669be [formerly 4b80b101b9b441edfc3a52a7ef7be4d7a1eb673a [formerly 083338976fea668a05c241b503a1759bc98123ba]]]]] Former-commit-id: f7cb601687755202fd6e9ef2270b1b68016997e0 Former-commit-id: 9ff05052fe6b6e6146c26da66f7ed484e2d84bca Former-commit-id: c3faaf4377a616ff4473449de17ebfcbc1edb7b8 [formerly 50c632cab919970ffa8bcb4675cc163fc1404c18] Former-commit-id: 865165843bb9c82a11312a5a9aa8a6514f486bb6 Former-commit-id: 1cafbbc8c25bad67bde221860be54af8b98b30b8 Former-commit-id: 31b05c2304e9a876c9ad4938ac7adfd885580e36 Former-commit-id: 9b18591f9ab4b78128c3112048ea30cd0334699d Former-commit-id: 899b9c72d1c12a8ee1601cad0694689a4c7ed5bd --- src/components/d2-error-log-list/index.vue | 11 ++++++++ src/components/index.js | 1 + .../components/header-error-log/index.vue | 26 +++++++++++++++++++ .../components/header-help/index.vue | 6 ++++- src/layout/header-aside/layout.vue | 23 +++++++--------- 5 files changed, 52 insertions(+), 15 deletions(-) create mode 100644 src/components/d2-error-log-list/index.vue create mode 100644 src/layout/header-aside/components/header-error-log/index.vue diff --git a/src/components/d2-error-log-list/index.vue b/src/components/d2-error-log-list/index.vue new file mode 100644 index 00000000..620b9ee4 --- /dev/null +++ b/src/components/d2-error-log-list/index.vue @@ -0,0 +1,11 @@ + + + diff --git a/src/components/index.js b/src/components/index.js index ca6a67f0..e2dd374e 100644 --- a/src/components/index.js +++ b/src/components/index.js @@ -16,6 +16,7 @@ Vue.component('d2-container', d2Container) Vue.component('d2-link-btn', d2LinkBtn) Vue.component('d2-page-cover', () => import('./d2-page-cover')) Vue.component('d2-count-up', () => import('./d2-count-up')) +Vue.component('d2-error-log-list', () => import('./d2-error-log-list')) Vue.component('d2-highlight', () => import('./d2-highlight')) Vue.component('d2-icon', () => import('./d2-icon')) Vue.component('d2-icon-select', () => import('./d2-icon-select/index.vue')) diff --git a/src/layout/header-aside/components/header-error-log/index.vue b/src/layout/header-aside/components/header-error-log/index.vue new file mode 100644 index 00000000..7bef5398 --- /dev/null +++ b/src/layout/header-aside/components/header-error-log/index.vue @@ -0,0 +1,26 @@ + + + diff --git a/src/layout/header-aside/components/header-help/index.vue b/src/layout/header-aside/components/header-help/index.vue index 6aeaa638..23fa633c 100644 --- a/src/layout/header-aside/components/header-help/index.vue +++ b/src/layout/header-aside/components/header-help/index.vue @@ -5,7 +5,11 @@ - +
diff --git a/src/layout/header-aside/layout.vue b/src/layout/header-aside/layout.vue index 41c56f3d..d6b053ea 100644 --- a/src/layout/header-aside/layout.vue +++ b/src/layout/header-aside/layout.vue @@ -19,6 +19,7 @@
+ @@ -55,23 +56,17 @@ From c2f5bfdbfff5558069babf2cc3b128842bcf6a0b Mon Sep 17 00:00:00 2001 From: liyang <1711467488@qq.com> Date: Thu, 2 Aug 2018 14:08:36 +0800 Subject: [PATCH 03/14] =?UTF-8?q?=E5=BC=80=E5=8F=91=E5=AD=98=E6=A1=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Former-commit-id: a52163c9c3dad22bdb40f020967e4f94edba9323 [formerly a52163c9c3dad22bdb40f020967e4f94edba9323 [formerly a52163c9c3dad22bdb40f020967e4f94edba9323 [formerly a52163c9c3dad22bdb40f020967e4f94edba9323 [formerly b393934c68c9a9fe59b96135512380c69c85f6fa [formerly 5760d5421930a548c6a3980ad76f79e9d8103027]]]]] Former-commit-id: 5577a549703aca87a8052549d2ed6de11abac845 Former-commit-id: a29a725d6512f9c03ee9670e5764d42335de21a5 Former-commit-id: 100e09fae2c373d4e7a662460c55da1fa7d3a22a [formerly f4e93720482bb8c31fc3effb1b74cb78aa691647] Former-commit-id: 13acfdec41ae665da4cfb5ae19160fd3a1e2fa44 Former-commit-id: babbed7319218019876bbf1b76c03ddf68886835 Former-commit-id: 642437c40f03db3ac8340ffee916c18cca9ebdc0 Former-commit-id: c8535dc780a1dd5aee99769d1863ba799221bdc6 Former-commit-id: 286ba818b9545ad4d34c67085ee342f99263cf9d --- docs/zh/guide/change-log.md | 4 ++ src/libs/util.js | 48 ++++++++++++++++--- src/main.js | 8 +++- src/menu/modules/demo-playground.js | 8 ++++ src/pages/demo/playground/log/error/index.vue | 17 +++++++ src/plugin/error/index.js | 21 ++++++++ src/router/routes.js.REMOVED.git-id | 2 +- src/store/modules/d2admin.js.REMOVED.git-id | 2 +- 8 files changed, 101 insertions(+), 9 deletions(-) create mode 100644 src/pages/demo/playground/log/error/index.vue create mode 100644 src/plugin/error/index.js diff --git a/docs/zh/guide/change-log.md b/docs/zh/guide/change-log.md index 3dbf2834..672b00d7 100644 --- a/docs/zh/guide/change-log.md +++ b/docs/zh/guide/change-log.md @@ -1,5 +1,9 @@ # 更新日志 +## v1.1.6 + +* [ 新增 ] 新增加了多页控制组件 tab 按钮上的右键操作菜单,现在你可以在 D2Admin 中像使用浏览器一样操作多标签页 + ## v1.1.5 * [ 修改 ] vue-cli3 项目重构,目录调整 diff --git a/src/libs/util.js b/src/libs/util.js index 1e821fed..bac289d6 100644 --- a/src/libs/util.js +++ b/src/libs/util.js @@ -5,7 +5,8 @@ import UaParser from 'ua-parser-js' import { version } from '../../package.json' let util = { - cookies: {} + cookies: {}, + log: {} } /** @@ -73,20 +74,55 @@ util.isOneOf = function (ele, targetArr) { } } +/** + * @description 返回这个样式的颜色值 + * @param {String} type 样式名称 [ primary | success | warning | danger | text ] + */ +util.typeColor = function (type = 'default') { + let color = '' + switch (type) { + case 'default': color = '35495E'; break + case 'primary': color = '#3488ff'; break + case 'success': color = '#43B883'; break + case 'warning': color = '#e6a23c'; break + case 'danger': color = '#f56c6c'; break + default:; break + } + return color +} + /** * @description 打印一个 “胶囊” 样式的信息 * @param {String} title title text * @param {String} info info text + * @param {String} type style */ -util.logCapsule = function (title, info) { +util.log.capsule = function (title, info, type = 'primary') { console.log( `%c ${title} %c ${info} %c`, - 'background:#29384b; padding: 1px; border-radius: 3px 0 0 3px; color: #fff', - 'background:#3488ff; padding: 1px; border-radius: 0 3px 3px 0; color: #fff', + 'background:#35495E; padding: 1px; border-radius: 3px 0 0 3px; color: #fff;', + `background:${util.typeColor(type)}; padding: 1px; border-radius: 0 3px 3px 0; color: #fff;`, 'background:transparent' ) } +/** + * @description 打印彩色文字 + */ +util.log.colorful = function (textArr) { + console.log( + `%c ${textArr.map(t => t.text).join(' %c ')}`, + ...textArr.map(t => `color: ${util.typeColor(t.type)};`) + ) +} + +/** + * @description 打印 danger 样式的文字 + */ +util.log.error = function (text) { + util.log.colorful([{ text, type: 'danger' }]) +} + /** * @description 检查版本更新 * @param {Object} vm vue @@ -100,7 +136,7 @@ util.checkUpdate = function (vm) { let versionGet = res.tag_name const update = semver.lt(version, versionGet) if (update) { - util.logCapsule('D2Admin', `New version ${res.name}`) + util.log.capsule('D2Admin', `New version ${res.name}`) console.log(`版本号: ${res.tag_name} | 详情${res.html_url}`) vm.$store.commit('d2adminReleasesUpdateSet', true) } @@ -115,7 +151,7 @@ util.checkUpdate = function (vm) { * @description 显示版本信息 */ util.showInfo = function showInfo () { - util.logCapsule('D2Admin', `v${version}`) + util.log.capsule('D2Admin', `v${version}`) console.log('Github https://github.com/d2-projects/d2-admin') console.log('Doc http://d2admin.fairyever.com/zh/') } diff --git a/src/main.js b/src/main.js index 57483b5c..adda84f9 100644 --- a/src/main.js +++ b/src/main.js @@ -15,8 +15,9 @@ import util from '@/libs/util.js' import store from '@/store/index' import '@/assets/svg-icons' import '@/components' -import '@/plugin/axios' import '@/mock/register' +import '@/plugin/axios' +import pluginError from '@/plugin/error' import pluginImport from '@/plugin/import' import pluginExport from '@/plugin/export' import pluginOpen from '@/plugin/open' @@ -29,6 +30,7 @@ import { frameInRoutes } from '@/router/routes' Vue.use(ElementUI) Vue.use(VCharts) Vue.use(contentmenu) +Vue.use(pluginError) Vue.use(pluginImport) Vue.use(pluginExport) Vue.use(pluginOpen) @@ -61,6 +63,10 @@ new Vue({ this.$store.commit('d2adminLoginSuccessLoad') // 初始化全屏监听 this.fullscreenListenerInit() + window.onerror = function (message, url, line, column, error) { + console.log('onerror') + console.log(message, url, line, column, error) + } }, watch: { // 监听路由 控制侧边栏显示 diff --git a/src/menu/modules/demo-playground.js b/src/menu/modules/demo-playground.js index b8a8ba02..c94c3d40 100644 --- a/src/menu/modules/demo-playground.js +++ b/src/menu/modules/demo-playground.js @@ -45,6 +45,14 @@ export default { { path: `${pre}db/public`, title: '公用数据', icon: 'users' } ] }, + { + path: `${pre}log`, + title: '日志', + icon: 'bullseye', + children: [ + { path: `${pre}log/error`, title: '错误捕捉', icon: 'bug' } + ] + }, { path: `${pre}env`, title: '环境信息', icon: 'exclamation-circle' } ])('/demo/playground/') } diff --git a/src/pages/demo/playground/log/error/index.vue b/src/pages/demo/playground/log/error/index.vue new file mode 100644 index 00000000..e67b6dc4 --- /dev/null +++ b/src/pages/demo/playground/log/error/index.vue @@ -0,0 +1,17 @@ + + + diff --git a/src/plugin/error/index.js b/src/plugin/error/index.js new file mode 100644 index 00000000..7b6f02b5 --- /dev/null +++ b/src/plugin/error/index.js @@ -0,0 +1,21 @@ +import store from '@/store' +import util from '@/libs/util' + +export default { + install (Vue, options) { + Vue.config.errorHandler = function (err, vm, info) { + Vue.nextTick(() => { + store.commit('d2adminLogAdd', { + err, vm, info + }) + util.log.capsule('D2Admin', 'ErrorHandler', 'danger') + util.log.error('>>>>> err') + console.log(err) + util.log.error('>>>>> vm') + console.log(vm) + util.log.error('>>>>> info') + console.log(info) + }) + } + } +} diff --git a/src/router/routes.js.REMOVED.git-id b/src/router/routes.js.REMOVED.git-id index 1e67b886..1fa7ded1 100644 --- a/src/router/routes.js.REMOVED.git-id +++ b/src/router/routes.js.REMOVED.git-id @@ -1 +1 @@ -0fa9b5a2bdc57841e4f19831dc3e2a913399a280 \ No newline at end of file +51f901f963b0802a69efe93ef5d40b60bcd1a2fd \ No newline at end of file diff --git a/src/store/modules/d2admin.js.REMOVED.git-id b/src/store/modules/d2admin.js.REMOVED.git-id index 2ea59ae8..e1ffd471 100644 --- a/src/store/modules/d2admin.js.REMOVED.git-id +++ b/src/store/modules/d2admin.js.REMOVED.git-id @@ -1 +1 @@ -f6b747b5dbf484da5c8b5876c9d54212c90c3550 \ No newline at end of file +1325e2be4603dde2cf094397e4fca98a542e4ba5 \ No newline at end of file From c2ffca2f14b564362f9acd9695e0766cd5d38668 Mon Sep 17 00:00:00 2001 From: liyang <1711467488@qq.com> Date: Thu, 2 Aug 2018 14:48:54 +0800 Subject: [PATCH 04/14] =?UTF-8?q?=E5=9B=9B=E7=A7=8D=E5=BF=AB=E9=80=9F?= =?UTF-8?q?=E6=89=93=E5=8D=B0=E5=BD=A9=E8=89=B2=E6=96=87=E5=AD=97=E7=9A=84?= =?UTF-8?q?=E5=B7=A5=E5=85=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Former-commit-id: 35179f73b9531b2525331d0a9815df6fb8d64bde [formerly 09d5ded45c36c36a811e3fe25c34856abc98f092] [formerly 35179f73b9531b2525331d0a9815df6fb8d64bde [formerly 09d5ded45c36c36a811e3fe25c34856abc98f092] [formerly 35179f73b9531b2525331d0a9815df6fb8d64bde [formerly 09d5ded45c36c36a811e3fe25c34856abc98f092] [formerly 09d5ded45c36c36a811e3fe25c34856abc98f092 [formerly 4c018feec65dbbda9026f0c6fc911cf42f290eac [formerly 4cf28c7a2788ee5b985a6707e94fe698782a6efb]]]]] Former-commit-id: 012f63e69f8fdbc177021b43ecb591c0f85841b8 Former-commit-id: 185c9af381750eef11c663b860b29d44d54128fc Former-commit-id: dbed36b0c90d46e0f48ab155986bc798a18ee0e2 [formerly 6e05d568fd23bb4b59179eeeac5722dfcf7bca33] Former-commit-id: 8068579e0c30280518dca37c2176623a522d1094 Former-commit-id: f77e82a8a9c1621d6022eb7687adccb68b00d45d Former-commit-id: 628d1680af0687a1eff97c9b4ca44e271ba13273 Former-commit-id: d962816743d7f8518e5a6258261ee456fe2aa5ac Former-commit-id: 14ac0e88b6525cb206a3bc7e1431006e64f5a9ec --- src/libs/util.js | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/src/libs/util.js b/src/libs/util.js index bac289d6..74ac78b7 100644 --- a/src/libs/util.js +++ b/src/libs/util.js @@ -116,10 +116,31 @@ util.log.colorful = function (textArr) { ) } +/** + * @description 打印 primary 样式的文字 + */ +util.log.primary = function (text) { + util.log.colorful([{ text, type: 'primary' }]) +} + +/** + * @description 打印 success 样式的文字 + */ +util.log.success = function (text) { + util.log.colorful([{ text, type: 'success' }]) +} + +/** + * @description 打印 warning 样式的文字 + */ +util.log.warning = function (text) { + util.log.colorful([{ text, type: 'warning' }]) +} + /** * @description 打印 danger 样式的文字 */ -util.log.error = function (text) { +util.log.danger = function (text) { util.log.colorful([{ text, type: 'danger' }]) } From 924f3f75b02434d68b1700c03bc827d7473dfc93 Mon Sep 17 00:00:00 2001 From: liyang <1711467488@qq.com> Date: Thu, 2 Aug 2018 14:49:00 +0800 Subject: [PATCH 05/14] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Former-commit-id: 518325287c1e6e0f203ff95a68a6bc9e10d8176d [formerly 518325287c1e6e0f203ff95a68a6bc9e10d8176d [formerly 518325287c1e6e0f203ff95a68a6bc9e10d8176d [formerly 518325287c1e6e0f203ff95a68a6bc9e10d8176d [formerly 3076b15aa6adcfe557f59ab6e5a6d4e46b077e1c [formerly 5fd8c763d74870c0d08713cec0535e0d8db54e29]]]]] Former-commit-id: 8f2c087320cad50b9296fa694a0f4e19f67e3e29 Former-commit-id: b58d6ac8670dd34d02b47e06376b9323b3783bd8 Former-commit-id: a0e51048197a5c3c8b2d86bde6a646b2337ebad3 [formerly 03da21fa80f8e9aa841caac11fbc4ea6d50ec1b2] Former-commit-id: e282f586620f996c959c788da13ebf94d19356e1 Former-commit-id: 6157b36ac59e42d0c2551ee232917615b4e234ef Former-commit-id: 713ab622619120f3f4d6f6b862ef7e431ef258ae Former-commit-id: 533d7705a18e963117a805546c81589b5134ff28 Former-commit-id: 96ae542246f8eac3ddf0356f3cb9a22ddb7b7c48 --- src/plugin/error/index.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/plugin/error/index.js b/src/plugin/error/index.js index 7b6f02b5..e20aff33 100644 --- a/src/plugin/error/index.js +++ b/src/plugin/error/index.js @@ -6,14 +6,16 @@ export default { Vue.config.errorHandler = function (err, vm, info) { Vue.nextTick(() => { store.commit('d2adminLogAdd', { - err, vm, info + err, + vm, + info }) util.log.capsule('D2Admin', 'ErrorHandler', 'danger') - util.log.error('>>>>> err') + util.log.danger('>>>>>> 错误对象 >>>>>>') console.log(err) - util.log.error('>>>>> vm') + util.log.danger('>>>>>> 报错 Vue 实例 >>>>>>') console.log(vm) - util.log.error('>>>>> info') + util.log.danger('>>>>>> 错误信息 >>>>>>') console.log(info) }) } From a20f12629acae8d9c24ff4aceac4e366b84a8404 Mon Sep 17 00:00:00 2001 From: liyang <1711467488@qq.com> Date: Thu, 2 Aug 2018 19:44:45 +0800 Subject: [PATCH 06/14] =?UTF-8?q?=E5=BF=AB=E9=80=9F=E6=89=93=E5=8D=B0log?= =?UTF-8?q?=E6=8F=92=E4=BB=B6=E5=92=8C=E8=AE=B0=E5=BD=95log=E6=8F=92?= =?UTF-8?q?=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Former-commit-id: c60fd22146486b9ae40a017f54eac22861d63cfe [formerly c60fd22146486b9ae40a017f54eac22861d63cfe [formerly c60fd22146486b9ae40a017f54eac22861d63cfe [formerly c60fd22146486b9ae40a017f54eac22861d63cfe [formerly b19f1dba3b8716c4ec0693a83882bf9f0c10ee3e [formerly 163a31502dcf1a0e10a73b65e29e7260d36afcc9]]]]] Former-commit-id: e5b3780565f7a1645b4fe207c41035513515ca0b Former-commit-id: ef544bb7604fc43b2b88c3890e4b3cc799df7845 Former-commit-id: 915e4dc616ce563853356e5839acd156fd4fd69f [formerly e920289a8782940d1b5c3f498afd483c364462a0] Former-commit-id: 0085d6c633ce61d78083afdfbff15a2a77d5db42 Former-commit-id: 1eea98ae975cb2f3d79a81eaf39e7b3865264f82 Former-commit-id: 1cf7126ab22e15afbf99c7bbb1e250e6dfcae5e9 Former-commit-id: a680edf65c0ce825cc494e085e9f0e90f2775127 Former-commit-id: c400c163f351492944c53fbd1a59e27c4bb25fa5 --- src/main.js | 2 ++ src/menu/modules/demo-playground.js | 1 + src/pages/demo/playground/log/error/index.vue | 2 +- src/pages/demo/playground/log/log/index.vue | 27 +++++++++++++++++++ src/plugin/error/index.js | 17 +++++++----- src/plugin/log/index.js | 16 +++++++++++ src/router/routes.js.REMOVED.git-id | 2 +- src/store/modules/d2admin.js.REMOVED.git-id | 2 +- 8 files changed, 59 insertions(+), 10 deletions(-) create mode 100644 src/pages/demo/playground/log/log/index.vue create mode 100644 src/plugin/log/index.js diff --git a/src/main.js b/src/main.js index adda84f9..3e84a151 100644 --- a/src/main.js +++ b/src/main.js @@ -17,6 +17,7 @@ import '@/assets/svg-icons' import '@/components' import '@/mock/register' import '@/plugin/axios' +import pluginLog from '@/plugin/log' import pluginError from '@/plugin/error' import pluginImport from '@/plugin/import' import pluginExport from '@/plugin/export' @@ -30,6 +31,7 @@ import { frameInRoutes } from '@/router/routes' Vue.use(ElementUI) Vue.use(VCharts) Vue.use(contentmenu) +Vue.use(pluginLog) Vue.use(pluginError) Vue.use(pluginImport) Vue.use(pluginExport) diff --git a/src/menu/modules/demo-playground.js b/src/menu/modules/demo-playground.js index c94c3d40..b0b4ed77 100644 --- a/src/menu/modules/demo-playground.js +++ b/src/menu/modules/demo-playground.js @@ -50,6 +50,7 @@ export default { title: '日志', icon: 'bullseye', children: [ + { path: `${pre}log/log`, title: '日志记录', icon: 'sticky-note-o' }, { path: `${pre}log/error`, title: '错误捕捉', icon: 'bug' } ] }, diff --git a/src/pages/demo/playground/log/error/index.vue b/src/pages/demo/playground/log/error/index.vue index e67b6dc4..5661d5a8 100644 --- a/src/pages/demo/playground/log/error/index.vue +++ b/src/pages/demo/playground/log/error/index.vue @@ -1,6 +1,6 @@