From 0bd026bfdc8a74e3cc86dace1f82cdb7198b7cac Mon Sep 17 00:00:00 2001
From: Afeyer <1500527791@qq.com>
Date: Mon, 18 Oct 2021 22:38:35 +0800
Subject: [PATCH] feat: backtop support for dashboard
---
.../src/main/resources/static/config.html | 3 ++
.../scripts/controller/BackTopController.js | 39 +++++++++++++++++++
.../resources/static/styles/common-style.css | 30 +++++++++++++-
.../static/views/component/back-top.html | 19 +++++++++
4 files changed, 90 insertions(+), 1 deletion(-)
create mode 100644 apollo-portal/src/main/resources/static/scripts/controller/BackTopController.js
create mode 100644 apollo-portal/src/main/resources/static/views/component/back-top.html
diff --git a/apollo-portal/src/main/resources/static/config.html b/apollo-portal/src/main/resources/static/config.html
index 2c5ca67f791..c11b66440df 100644
--- a/apollo-portal/src/main/resources/static/config.html
+++ b/apollo-portal/src/main/resources/static/config.html
@@ -368,6 +368,8 @@
{{'Config.CreateBranchTips.DialogTitle' | translate}}
+
+
@@ -450,6 +452,7 @@ {{'Config.CreateBranchTips.DialogTitle' | translate}}
+
diff --git a/apollo-portal/src/main/resources/static/scripts/controller/BackTopController.js b/apollo-portal/src/main/resources/static/scripts/controller/BackTopController.js
new file mode 100644
index 00000000000..d8c46c61365
--- /dev/null
+++ b/apollo-portal/src/main/resources/static/scripts/controller/BackTopController.js
@@ -0,0 +1,39 @@
+/*
+ * Copyright 2021 Apollo Authors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+appService.controller("BackTopController",
+ ['$scope', BackTopController]);
+
+function BackTopController($scope) {
+ // scroll status
+ $scope.isScroll = false;
+
+ $scope.backToTop = function () {
+ window.scrollTo(0, 0)
+ }
+
+ window.addEventListener("scroll", function () {
+ if(!window.scrollY && $scope.isScroll) {
+ $scope.isScroll = false
+ document.body.click()
+ }
+
+ if(window.scrollY != 0 && !$scope.isScroll) {
+ $scope.isScroll = true
+ document.body.click()
+ }
+ })
+}
diff --git a/apollo-portal/src/main/resources/static/styles/common-style.css b/apollo-portal/src/main/resources/static/styles/common-style.css
index 764d538ae37..6c171a6db4d 100644
--- a/apollo-portal/src/main/resources/static/styles/common-style.css
+++ b/apollo-portal/src/main/resources/static/styles/common-style.css
@@ -15,7 +15,8 @@
*
*/
html, body {
- height: 100%
+ height: 100%;
+ scroll-behavior: smooth;
}
body {
@@ -1086,3 +1087,30 @@ table th {
line-height: 34px;
font-size: 14px;
}
+
+/*backTop component style*/
+.back-top {
+ position: fixed;
+ height: 40px;
+ width: 40px;
+ border-radius: 4px;
+ color: #ffffff;
+ z-index: 5;
+ cursor: pointer;
+ right: 40px;
+ bottom: 40px;
+ text-align: center;
+ line-height: 40px;
+ font-size: 16px;
+ background: #0c4c7f;
+ opacity: .2;
+ user-select: none;
+}
+
+.back-top:hover {
+ opacity: .4;
+}
+
+.back-top:active {
+ opacity: .6;
+}
\ No newline at end of file
diff --git a/apollo-portal/src/main/resources/static/views/component/back-top.html b/apollo-portal/src/main/resources/static/views/component/back-top.html
new file mode 100644
index 00000000000..95e2b35d8c4
--- /dev/null
+++ b/apollo-portal/src/main/resources/static/views/component/back-top.html
@@ -0,0 +1,19 @@
+
+
+
+