增加注释
Showing
9 changed files
with
171 additions
and
2 deletions
| 1 | export const theme = { | 1 | export const theme = { |
| 2 | /** | ||
| 3 | * @description: bind | ||
| 4 | * @param {*} el | ||
| 5 | * @param {*} binding | ||
| 6 | * @param {*} vnode | ||
| 7 | * @author: renchao | ||
| 8 | */ | ||
| 2 | bind: function (el, binding, vnode) { | 9 | bind: function (el, binding, vnode) { |
| 3 | setEleStyleColorAttribute(el, binding); | 10 | setEleStyleColorAttribute(el, binding); |
| 4 | }, | 11 | }, |
| 12 | /** | ||
| 13 | * @description: update | ||
| 14 | * @param {*} el | ||
| 15 | * @param {*} binding | ||
| 16 | * @param {*} vnode | ||
| 17 | * @author: renchao | ||
| 18 | */ | ||
| 5 | update: function (el, binding, vnode) { | 19 | update: function (el, binding, vnode) { |
| 6 | setEleStyleColorAttribute(el, binding); | 20 | setEleStyleColorAttribute(el, binding); |
| 7 | }, | 21 | }, |
| 22 | /** | ||
| 23 | * @description: componentUpdated | ||
| 24 | * @param {*} el | ||
| 25 | * @param {*} binding | ||
| 26 | * @param {*} vnode | ||
| 27 | * @author: renchao | ||
| 28 | */ | ||
| 8 | componentUpdated: function (el, binding, vnode) { | 29 | componentUpdated: function (el, binding, vnode) { |
| 9 | setEleStyleColorAttribute(el, binding); | 30 | setEleStyleColorAttribute(el, binding); |
| 10 | } | 31 | } |
| 11 | } | 32 | } |
| 12 | 33 | ||
| 34 | /** | ||
| 35 | * @description: setEleStyleColorAttribute | ||
| 36 | * @param {*} el | ||
| 37 | * @param {*} binding | ||
| 38 | * @author: renchao | ||
| 39 | */ | ||
| 13 | function setEleStyleColorAttribute (el, binding) { | 40 | function setEleStyleColorAttribute (el, binding) { |
| 14 | const { name, value, arg, expression, modifiers } = binding; | 41 | const { name, value, arg, expression, modifiers } = binding; |
| 15 | const { background, font, border } = modifiers; | 42 | const { background, font, border } = modifiers; |
| 16 | if (background) el.style['background-color'] = value; | 43 | if (background) el.style['background-color'] = value; |
| 17 | if (font) el.style.color = value; | 44 | if (font) el.style.color = value; |
| 18 | if (border) el.style['border-color'] = value; | 45 | if (border) el.style['border-color'] = value; |
| 19 | } | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 46 | } | ... | ... |
| ... | @@ -39,6 +39,10 @@ | ... | @@ -39,6 +39,10 @@ |
| 39 | this.getBreadcrumb() | 39 | this.getBreadcrumb() |
| 40 | }, | 40 | }, |
| 41 | methods: { | 41 | methods: { |
| 42 | /** | ||
| 43 | * @description: getBreadcrumb | ||
| 44 | * @author: renchao | ||
| 45 | */ | ||
| 42 | getBreadcrumb () { | 46 | getBreadcrumb () { |
| 43 | // only show routes with meta.title | 47 | // only show routes with meta.title |
| 44 | let matched = this.$route.matched.filter(item => item.meta && item.meta.title) | 48 | let matched = this.$route.matched.filter(item => item.meta && item.meta.title) |
| ... | @@ -50,6 +54,11 @@ | ... | @@ -50,6 +54,11 @@ |
| 50 | 54 | ||
| 51 | this.levelList = matched.filter(item => item.meta && item.meta.title && item.meta.breadcrumb !== false) | 55 | this.levelList = matched.filter(item => item.meta && item.meta.title && item.meta.breadcrumb !== false) |
| 52 | }, | 56 | }, |
| 57 | /** | ||
| 58 | * @description: isDashboard | ||
| 59 | * @param {*} route | ||
| 60 | * @author: renchao | ||
| 61 | */ | ||
| 53 | isDashboard (route) { | 62 | isDashboard (route) { |
| 54 | const name = route && route.name | 63 | const name = route && route.name |
| 55 | if (!name) { | 64 | if (!name) { |
| ... | @@ -57,11 +66,21 @@ | ... | @@ -57,11 +66,21 @@ |
| 57 | } | 66 | } |
| 58 | return name.trim().toLocaleLowerCase() === 'Dashboard'.toLocaleLowerCase() | 67 | return name.trim().toLocaleLowerCase() === 'Dashboard'.toLocaleLowerCase() |
| 59 | }, | 68 | }, |
| 69 | /** | ||
| 70 | * @description: pathCompile | ||
| 71 | * @param {*} path | ||
| 72 | * @author: renchao | ||
| 73 | */ | ||
| 60 | pathCompile (path) { | 74 | pathCompile (path) { |
| 61 | const { params } = this.$route | 75 | const { params } = this.$route |
| 62 | var toPath = pathToRegexp.compile(path) | 76 | var toPath = pathToRegexp.compile(path) |
| 63 | return toPath(params) | 77 | return toPath(params) |
| 64 | }, | 78 | }, |
| 79 | /** | ||
| 80 | * @description: handleLink | ||
| 81 | * @param {*} item | ||
| 82 | * @author: renchao | ||
| 83 | */ | ||
| 65 | handleLink (item) { | 84 | handleLink (item) { |
| 66 | const { redirect, path } = item | 85 | const { redirect, path } = item |
| 67 | if (redirect) { | 86 | if (redirect) { | ... | ... |
| ... | @@ -32,13 +32,26 @@ export default { | ... | @@ -32,13 +32,26 @@ export default { |
| 32 | }, | 32 | }, |
| 33 | }, | 33 | }, |
| 34 | methods: { | 34 | methods: { |
| 35 | /** | ||
| 36 | * @description: handleDataView | ||
| 37 | * @author: renchao | ||
| 38 | */ | ||
| 35 | handleDataView() { | 39 | handleDataView() { |
| 36 | const { href } = this.$router.resolve("/dataView"); | 40 | const { href } = this.$router.resolve("/dataView"); |
| 37 | window.open(href, "_blank"); | 41 | window.open(href, "_blank"); |
| 38 | }, | 42 | }, |
| 43 | /** | ||
| 44 | * @description: themeChange | ||
| 45 | * @param {*} val | ||
| 46 | * @author: renchao | ||
| 47 | */ | ||
| 39 | themeChange(val) { | 48 | themeChange(val) { |
| 40 | this.$store.dispatch("app/updateTheme", val); | 49 | this.$store.dispatch("app/updateTheme", val); |
| 41 | }, | 50 | }, |
| 51 | /** | ||
| 52 | * @description: onCancel | ||
| 53 | * @author: renchao | ||
| 54 | */ | ||
| 42 | onCancel() { | 55 | onCancel() { |
| 43 | axios | 56 | axios |
| 44 | .post(window._config.services.management + "/management/logout") | 57 | .post(window._config.services.management + "/management/logout") | ... | ... |
| ... | @@ -10,6 +10,10 @@ export default { | ... | @@ -10,6 +10,10 @@ export default { |
| 10 | this.fixBugIniOS() | 10 | this.fixBugIniOS() |
| 11 | }, | 11 | }, |
| 12 | methods: { | 12 | methods: { |
| 13 | /** | ||
| 14 | * @description: fixBugIniOS | ||
| 15 | * @author: renchao | ||
| 16 | */ | ||
| 13 | fixBugIniOS() { | 17 | fixBugIniOS() { |
| 14 | const $subMenu = this.$refs.subMenu | 18 | const $subMenu = this.$refs.subMenu |
| 15 | if ($subMenu) { | 19 | if ($subMenu) { | ... | ... |
| ... | @@ -26,6 +26,11 @@ export default { | ... | @@ -26,6 +26,11 @@ export default { |
| 26 | } | 26 | } |
| 27 | }, | 27 | }, |
| 28 | methods: { | 28 | methods: { |
| 29 | /** | ||
| 30 | * @description: linkProps | ||
| 31 | * @param {*} to | ||
| 32 | * @author: renchao | ||
| 33 | */ | ||
| 29 | linkProps(to) { | 34 | linkProps(to) { |
| 30 | if (this.isExternal) { | 35 | if (this.isExternal) { |
| 31 | return { | 36 | return { | ... | ... |
| 1 | <!-- | 1 | <!-- |
| 2 | * @Description: | 2 | * @Description: |
| 3 | * @Autor: renchao | 3 | * @Autor: renchao |
| 4 | * @LastEditTime: 2023-06-08 14:01:11 | 4 | * @LastEditTime: 2023-06-08 14:01:11 |
| 5 | --> | 5 | --> |
| ... | @@ -58,6 +58,12 @@ | ... | @@ -58,6 +58,12 @@ |
| 58 | return {} | 58 | return {} |
| 59 | }, | 59 | }, |
| 60 | methods: { | 60 | methods: { |
| 61 | /** | ||
| 62 | * @description: hasOneShowingChild | ||
| 63 | * @param {*} children | ||
| 64 | * @param {*} parent | ||
| 65 | * @author: renchao | ||
| 66 | */ | ||
| 61 | hasOneShowingChild (children = [], parent) { | 67 | hasOneShowingChild (children = [], parent) { |
| 62 | const showingChildren = children.filter(item => { | 68 | const showingChildren = children.filter(item => { |
| 63 | if (item.hidden) { | 69 | if (item.hidden) { |
| ... | @@ -81,6 +87,11 @@ | ... | @@ -81,6 +87,11 @@ |
| 81 | 87 | ||
| 82 | return false | 88 | return false |
| 83 | }, | 89 | }, |
| 90 | /** | ||
| 91 | * @description: resolvePath | ||
| 92 | * @param {*} routePath | ||
| 93 | * @author: renchao | ||
| 94 | */ | ||
| 84 | resolvePath (routePath) { | 95 | resolvePath (routePath) { |
| 85 | if (isExternal(routePath)) { | 96 | if (isExternal(routePath)) { |
| 86 | return routePath | 97 | return routePath | ... | ... |
| ... | @@ -26,14 +26,28 @@ export default { | ... | @@ -26,14 +26,28 @@ export default { |
| 26 | this.scrollWrapper.removeEventListener('scroll', this.emitScroll) | 26 | this.scrollWrapper.removeEventListener('scroll', this.emitScroll) |
| 27 | }, | 27 | }, |
| 28 | methods: { | 28 | methods: { |
| 29 | /** | ||
| 30 | * @description: handleScroll | ||
| 31 | * @param {*} e | ||
| 32 | * @author: renchao | ||
| 33 | */ | ||
| 29 | handleScroll (e) { | 34 | handleScroll (e) { |
| 30 | const eventDelta = e.wheelDelta || -e.deltaY * 40 | 35 | const eventDelta = e.wheelDelta || -e.deltaY * 40 |
| 31 | const $scrollWrapper = this.scrollWrapper | 36 | const $scrollWrapper = this.scrollWrapper |
| 32 | $scrollWrapper.scrollLeft = $scrollWrapper.scrollLeft + eventDelta / 4 | 37 | $scrollWrapper.scrollLeft = $scrollWrapper.scrollLeft + eventDelta / 4 |
| 33 | }, | 38 | }, |
| 39 | /** | ||
| 40 | * @description: emitScroll | ||
| 41 | * @author: renchao | ||
| 42 | */ | ||
| 34 | emitScroll () { | 43 | emitScroll () { |
| 35 | this.$emit('scroll') | 44 | this.$emit('scroll') |
| 36 | }, | 45 | }, |
| 46 | /** | ||
| 47 | * @description: moveToTarget | ||
| 48 | * @param {*} currentTag | ||
| 49 | * @author: renchao | ||
| 50 | */ | ||
| 37 | moveToTarget (currentTag) { | 51 | moveToTarget (currentTag) { |
| 38 | const $container = this.$refs.scrollContainer.$el | 52 | const $container = this.$refs.scrollContainer.$el |
| 39 | const $containerWidth = $container.offsetWidth | 53 | const $containerWidth = $container.offsetWidth | ... | ... |
| ... | @@ -58,12 +58,28 @@ | ... | @@ -58,12 +58,28 @@ |
| 58 | this.addTags() | 58 | this.addTags() |
| 59 | }, | 59 | }, |
| 60 | methods: { | 60 | methods: { |
| 61 | /** | ||
| 62 | * @description: isActive | ||
| 63 | * @param {*} route | ||
| 64 | * @author: renchao | ||
| 65 | */ | ||
| 61 | isActive (route) { | 66 | isActive (route) { |
| 62 | return route.path === this.$route.path | 67 | return route.path === this.$route.path |
| 63 | }, | 68 | }, |
| 69 | /** | ||
| 70 | * @description: isAffix | ||
| 71 | * @param {*} tag | ||
| 72 | * @author: renchao | ||
| 73 | */ | ||
| 64 | isAffix (tag) { | 74 | isAffix (tag) { |
| 65 | return tag.meta && tag.meta.affix | 75 | return tag.meta && tag.meta.affix |
| 66 | }, | 76 | }, |
| 77 | /** | ||
| 78 | * @description: filterAffixTags | ||
| 79 | * @param {*} routes | ||
| 80 | * @param {*} basePath | ||
| 81 | * @author: renchao | ||
| 82 | */ | ||
| 67 | filterAffixTags (routes, basePath = '/') { | 83 | filterAffixTags (routes, basePath = '/') { |
| 68 | let tags = [] | 84 | let tags = [] |
| 69 | routes.forEach(route => { | 85 | routes.forEach(route => { |
| ... | @@ -85,6 +101,10 @@ | ... | @@ -85,6 +101,10 @@ |
| 85 | }) | 101 | }) |
| 86 | return tags | 102 | return tags |
| 87 | }, | 103 | }, |
| 104 | /** | ||
| 105 | * @description: initTags | ||
| 106 | * @author: renchao | ||
| 107 | */ | ||
| 88 | initTags () { | 108 | initTags () { |
| 89 | const affixTags = this.affixTags = this.filterAffixTags(this.routes) | 109 | const affixTags = this.affixTags = this.filterAffixTags(this.routes) |
| 90 | for (const tag of affixTags) { | 110 | for (const tag of affixTags) { |
| ... | @@ -94,6 +114,10 @@ | ... | @@ -94,6 +114,10 @@ |
| 94 | } | 114 | } |
| 95 | } | 115 | } |
| 96 | }, | 116 | }, |
| 117 | /** | ||
| 118 | * @description: addTags | ||
| 119 | * @author: renchao | ||
| 120 | */ | ||
| 97 | addTags () { | 121 | addTags () { |
| 98 | const { name } = this.$route | 122 | const { name } = this.$route |
| 99 | if (name) { | 123 | if (name) { |
| ... | @@ -101,6 +125,10 @@ | ... | @@ -101,6 +125,10 @@ |
| 101 | } | 125 | } |
| 102 | return false | 126 | return false |
| 103 | }, | 127 | }, |
| 128 | /** | ||
| 129 | * @description: moveToCurrentTag | ||
| 130 | * @author: renchao | ||
| 131 | */ | ||
| 104 | moveToCurrentTag () { | 132 | moveToCurrentTag () { |
| 105 | const tags = this.$refs.tag | 133 | const tags = this.$refs.tag |
| 106 | this.$nextTick(() => { | 134 | this.$nextTick(() => { |
| ... | @@ -116,6 +144,11 @@ | ... | @@ -116,6 +144,11 @@ |
| 116 | } | 144 | } |
| 117 | }) | 145 | }) |
| 118 | }, | 146 | }, |
| 147 | /** | ||
| 148 | * @description: refreshSelectedTag | ||
| 149 | * @param {*} view | ||
| 150 | * @author: renchao | ||
| 151 | */ | ||
| 119 | refreshSelectedTag (view) { | 152 | refreshSelectedTag (view) { |
| 120 | this.$store.dispatch('tagsView/delCachedView', view).then(() => { | 153 | this.$store.dispatch('tagsView/delCachedView', view).then(() => { |
| 121 | const { fullPath } = view | 154 | const { fullPath } = view |
| ... | @@ -126,6 +159,11 @@ | ... | @@ -126,6 +159,11 @@ |
| 126 | }) | 159 | }) |
| 127 | }) | 160 | }) |
| 128 | }, | 161 | }, |
| 162 | /** | ||
| 163 | * @description: closeSelectedTag | ||
| 164 | * @param {*} view | ||
| 165 | * @author: renchao | ||
| 166 | */ | ||
| 129 | closeSelectedTag (view) { | 167 | closeSelectedTag (view) { |
| 130 | this.$store.dispatch('tagsView/delView', view).then(({ visitedViews }) => { | 168 | this.$store.dispatch('tagsView/delView', view).then(({ visitedViews }) => { |
| 131 | if (this.isActive(view)) { | 169 | if (this.isActive(view)) { |
| ... | @@ -133,12 +171,21 @@ | ... | @@ -133,12 +171,21 @@ |
| 133 | } | 171 | } |
| 134 | }) | 172 | }) |
| 135 | }, | 173 | }, |
| 174 | /** | ||
| 175 | * @description: closeOthersTags | ||
| 176 | * @author: renchao | ||
| 177 | */ | ||
| 136 | closeOthersTags () { | 178 | closeOthersTags () { |
| 137 | this.$router.push(this.selectedTag) | 179 | this.$router.push(this.selectedTag) |
| 138 | this.$store.dispatch('tagsView/delOthersViews', this.selectedTag).then(() => { | 180 | this.$store.dispatch('tagsView/delOthersViews', this.selectedTag).then(() => { |
| 139 | this.moveToCurrentTag() | 181 | this.moveToCurrentTag() |
| 140 | }) | 182 | }) |
| 141 | }, | 183 | }, |
| 184 | /** | ||
| 185 | * @description: closeAllTags | ||
| 186 | * @param {*} view | ||
| 187 | * @author: renchao | ||
| 188 | */ | ||
| 142 | closeAllTags (view) { | 189 | closeAllTags (view) { |
| 143 | this.$store.dispatch('tagsView/delAllViews').then(({ visitedViews }) => { | 190 | this.$store.dispatch('tagsView/delAllViews').then(({ visitedViews }) => { |
| 144 | if (this.affixTags.some(tag => tag.path === view.path)) { | 191 | if (this.affixTags.some(tag => tag.path === view.path)) { |
| ... | @@ -147,6 +194,12 @@ | ... | @@ -147,6 +194,12 @@ |
| 147 | this.toLastView(visitedViews, view) | 194 | this.toLastView(visitedViews, view) |
| 148 | }) | 195 | }) |
| 149 | }, | 196 | }, |
| 197 | /** | ||
| 198 | * @description: toLastView | ||
| 199 | * @param {*} visitedViews | ||
| 200 | * @param {*} view | ||
| 201 | * @author: renchao | ||
| 202 | */ | ||
| 150 | toLastView (visitedViews, view) { | 203 | toLastView (visitedViews, view) { |
| 151 | const latestView = visitedViews.slice(-1)[0] | 204 | const latestView = visitedViews.slice(-1)[0] |
| 152 | if (latestView) { | 205 | if (latestView) { |
| ... | @@ -162,6 +215,12 @@ | ... | @@ -162,6 +215,12 @@ |
| 162 | } | 215 | } |
| 163 | } | 216 | } |
| 164 | }, | 217 | }, |
| 218 | /** | ||
| 219 | * @description: openMenu | ||
| 220 | * @param {*} tag | ||
| 221 | * @param {*} e | ||
| 222 | * @author: renchao | ||
| 223 | */ | ||
| 165 | openMenu (tag, e) { | 224 | openMenu (tag, e) { |
| 166 | const menuMinWidth = 105 | 225 | const menuMinWidth = 105 |
| 167 | const offsetLeft = this.$el.getBoundingClientRect().left - 210 // container margin left | 226 | const offsetLeft = this.$el.getBoundingClientRect().left - 210 // container margin left |
| ... | @@ -179,9 +238,17 @@ | ... | @@ -179,9 +238,17 @@ |
| 179 | this.visible = true | 238 | this.visible = true |
| 180 | this.selectedTag = tag | 239 | this.selectedTag = tag |
| 181 | }, | 240 | }, |
| 241 | /** | ||
| 242 | * @description: closeMenu | ||
| 243 | * @author: renchao | ||
| 244 | */ | ||
| 182 | closeMenu () { | 245 | closeMenu () { |
| 183 | this.visible = false | 246 | this.visible = false |
| 184 | }, | 247 | }, |
| 248 | /** | ||
| 249 | * @description: handleScroll | ||
| 250 | * @author: renchao | ||
| 251 | */ | ||
| 185 | handleScroll () { | 252 | handleScroll () { |
| 186 | this.closeMenu() | 253 | this.closeMenu() |
| 187 | } | 254 | } | ... | ... |
| ... | @@ -27,10 +27,19 @@ export default { | ... | @@ -27,10 +27,19 @@ export default { |
| 27 | methods: { | 27 | methods: { |
| 28 | // use $_ for mixins properties | 28 | // use $_ for mixins properties |
| 29 | // https://vuejs.org/v2/style-guide/index.html#Private-property-names-essential | 29 | // https://vuejs.org/v2/style-guide/index.html#Private-property-names-essential |
| 30 | /** | ||
| 31 | * @description: use $_ for mixins properties | ||
| 32 | * https://vuejs.org/v2/style-guide/index.html#Private-property-names-essential | ||
| 33 | * @author: renchao | ||
| 34 | */ | ||
| 30 | $_isMobile() { | 35 | $_isMobile() { |
| 31 | const rect = body.getBoundingClientRect() | 36 | const rect = body.getBoundingClientRect() |
| 32 | return rect.width - 1 < WIDTH | 37 | return rect.width - 1 < WIDTH |
| 33 | }, | 38 | }, |
| 39 | /** | ||
| 40 | * @description: $_resizeHandler | ||
| 41 | * @author: renchao | ||
| 42 | */ | ||
| 34 | $_resizeHandler() { | 43 | $_resizeHandler() { |
| 35 | if (!document.hidden) { | 44 | if (!document.hidden) { |
| 36 | const isMobile = this.$_isMobile() | 45 | const isMobile = this.$_isMobile() | ... | ... |
-
Please register or sign in to post a comment