| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559 |
- <template lang="pug">
- .dashboard(:class="{'is-inapp': isInApp}")
- client-only
- .sidebar-page
- .sidebar-layout
- b-sidebar.brd-sidebar(
- type="is-dark"
- :mobile="expanded ? 'fullwidth' : 'reduce'"
- :position="isInApp ? 'fixed' : 'static'"
- :reduce="reduce"
- :fullheight="true"
- open
- )
- .inner
- .brand(v-if="!isInApp")
- .logo
- .text
- span Dashboard
- sup Beta
- .navbar-burger.burger(v-else @click="triggerSidebar")
- span
- span
- span
- b-menu.is-custom-mobile
- b-menu-list
- b-menu-item(
- label="概览"
- icon-pack="progico"
- icon="progico-home"
- tag="router-link"
- to="/dashboard"
- :replace="isInApp"
- :active="curRoutePath === '/'"
- @click.native="onMenuClick"
- )
- b-menu-item(
- label="我的API"
- icon-pack="progico"
- icon="progico-api"
- tag="router-link"
- to="/dashboard/apis"
- :replace="isInApp"
- :active="curRoutePath === '/apis'"
- @click.native="onMenuClick"
- )
- //- b-menu-item(
- label="统计中心"
- icon-pack="progico"
- icon="progico-stats"
- tag="router-link"
- to="/dashboard/stats"
- :replace="isInApp"
- :active="curRoutePath === '/stats'"
- @click.native="onMenuClick"
- )
- b-menu-item(
- label="调试工具"
- icon-pack="progico"
- icon="progico-debug"
- tag="router-link"
- to="/dashboard/inspector"
- :replace="isInApp"
- :active="curRoutePath === '/inspector'"
- @click.native="onMenuClick"
- )
- .dashboard-container
- b-navbar(v-if="!isInApp")
- template(slot="end")
- b-navbar-item(href="/") 返回首页
- .navbar-split
- NavUserCell(
- v-if="userInfo"
- :user-info="userInfo"
- :clickable="false"
- )
- router-view.dashboard-main
- </template>
- <script lang="ts">
- import Vue from 'vue'
- import NavUserCell from '../../components/NavUserCell.vue'
- import bridge from '../../utils/bridge'
- export default Vue.extend({
- layout: 'kaifain_v2',
- components: {
- NavUserCell
- },
- data() {
- return {
- reduce: false,
- isInApp: false,
- expanded: false
- }
- },
- head: {
- title: '控制台'
- },
- computed: {
- userInfo(): any {
- return this.$store.state.userinfo
- },
- curRoutePath(): string {
- return this.$route.path.replace(/^\/dashboard\/?/, '/')
- }
- },
- methods: {
- triggerSidebar() {
- this.expanded = !this.expanded
- },
- onMenuClick() {
- if (this.expanded) {
- setTimeout(() => {
- this.expanded = false
- }, 32)
- }
- }
- },
- created() {
- if (process.client) {
- // @ts-ignore
- this.isInApp = bridge.isInApp || false
- }
- }
- })
- </script>
- <style lang="scss">
- @import '../../assets/styles/vars';
- $dashboard-bg: #f9f9fa;
- .dashboard {
- background: $dashboard-bg;
- .page-header {
- margin: -1.25rem 0.25rem 2rem 0.25rem;
- .title {
- font-size: 1.5rem;
- margin: 0 !important;
- }
- .actions {
- margin-bottom: -0.25rem;
- }
- }
- .modal {
- z-index: 42;
- }
- .sidebar-page {
- display: flex;
- flex-direction: column;
- width: 100%;
- min-height: 100%;
- .sidebar-layout {
- display: flex;
- flex-direction: row;
- min-height: 100%;
- }
- }
- .navbar {
- background: $dashboard-bg;
- color: #777;
- position: sticky;
- top: 0;
- }
- .navbar-end {
- padding-right: 1rem;
- }
- .navbar-item {
- font-size: 0.875rem;
- color: #777;
- }
- .navbar-split {
- background: #e7e7e7;
- width: 1px;
- height: 16px;
- margin: 1px 12px 0;
- align-self: center;
- }
- .dashboard-container {
- flex: 1;
- overflow-y: scroll;
- height: 100vh;
- }
- .dashboard-main {
- padding: 2rem;
- }
- .section {
- padding: 0;
- }
- .card {
- background: #fff;
- border-radius: 6px;
- box-shadow: 0 1px 6px rgba(0,0,0,0.02);
- .header {
- padding: 1.5rem;
- display: flex;
- justify-content: space-between;
- align-items: center;
- + .content {
- padding-top: 0;
- }
- }
- .caption {
- color: $ink;
- font-size: 1rem;
- font-weight: 500;
- }
- .content {
- padding: 1.5rem 1.5rem 2rem;
- min-height: 6rem;
- > .empty {
- font-size: 0.875rem;
- color: #999;
- text-align: center;
- padding: 1.5rem;
- }
- .is-link {
- color: $primary;
- }
- }
- .view-all {
- color: #999;
- font-size: 0.875rem;
- padding: 1rem 1.75rem;
- display: flex;
- align-items: center;
- border-top: 1px solid #eee;
- .icon {
- font-size: 0.8em;
- }
- &:hover {
- color: $primary;
- }
- }
- }
- .api-list {
- padding: 0 1.5rem;
- }
- .common-table {
- .table {
- font-size: 0.875rem;
- line-height: 1.35;
- td,
- th {
- vertical-align: middle;
- }
- th {
- padding: 0.75em 1em;
- border-bottom: 1px solid #eaeaea;
- }
- td {
- padding: 0.5em 1em;
- border-color: #f6f6f6;
- &::before {
- white-space: nowrap;
- margin-right: 1rem;
- }
- }
- .control {
- padding-right: 1.5rem;
- }
- }
- .skeleton-cell {
- padding: 0.5rem 0;
- }
- .empty {
- text-align: center;
- color: #8c8c8c;
- padding: 1rem;
- }
- .key {
- color: #777;
- }
- .value {
- word-break: break-all;
- }
- .desc {
- font-size: 0.9em;
- color: #777;
- padding-bottom: 0.5em;
- display: inline-block;
- word-break: break-all;
- }
- }
- &.is-inapp {
- .page-header {
- .title {
- display: none;
- }
- }
- .dashboard-container {
- padding-left: 56px;
- }
- }
- @media screen and (max-width: 1023px) {
- .navbar-menu {
- background: $dashboard-bg;
- box-shadow: none;
- }
- .navbar-split {
- height: 1px;
- width: auto;
- margin: 8px 12px;
- }
- }
- @media screen and (max-width: 768px) {
- .b-table .table-wrapper.has-mobile-cards {
- .control {
- width: 66%;
- }
- tr {
- border-radius: 4px;
- box-shadow: 0 1px 6px rgba(51, 49, 49, 0.03);
- }
- }
- .common-table .table {
- .control {
- padding-right: 0;
- }
- }
- .dashboard-main {
- padding: 0.25rem 0.25rem 2rem;
- }
- .page-header {
- margin: -0.25rem 1.25rem 1.5rem 1.25rem;
- }
- .card {
- .header {
- padding-top: 1.25rem;
- padding-bottom: 1.25rem;
- }
- .header,
- .content {
- padding-left: 1rem;
- padding-right: 1rem;
- }
- .caption {
- font-size: 0.9375rem;
- }
- }
- }
- @media screen and (max-width: 480px) {
- .is-float-btn {
- position: fixed;
- z-index: 30;
- bottom: 0.5rem;
- right: 16px;
- width: calc(100% - 88px);
- }
- .api-list {
- padding: 0 1.25rem;
- }
- .modal {
- justify-content: flex-start;
- }
- &.is-inapp {
- .page-header {
- margin: 0;
- }
- }
- }
- }
- .b-sidebar.brd-sidebar {
- .sidebar-content {
- width: 240px;
- > .inner {
- padding: 1em;
- }
- .navbar-burger {
- color: #fff;
- margin: -0.75rem -0.2rem 0.25rem -0.2rem;
- }
- &.is-dark {
- background: $ink;
- box-shadow: none;
- }
- &.is-fixed {
- transition: width 0.25s ease;
- }
- }
- .menu-list {
- a {
- margin-bottom: 0.5rem;
- padding: 0.75em 0.875em;
- color: #808080;
- white-space: nowrap;
- &.is-active {
- background: $primary;
- color: #fff;
- }
- }
- .icon + span {
- margin-left: 1rem;
- font-size: 0.9375rem;
- }
- }
- .brand {
- display: flex;
- align-items: center;
- color: #fff;
- margin: 0 0.5rem 2rem;
- .logo {
- background: url('../../assets/img/logo.png') center left no-repeat;
- background-size: auto 100%;
- width: 34px;
- height: 34px;
- opacity: 0.98;
- }
- .text {
- font-weight: 600;
- margin-left: 16px;
- sup {
- font-size: 0.625em;
- font-weight: 500;
- vertical-align: top;
- margin: 0 -5px 0 5px;
- color: lighten($primary, 4);
- display: inline-block;
- top: 0;
- }
- }
- }
- @media screen and (max-width: 768px) {
- .sidebar-content {
- > .inner {
- padding-left: 0.375rem;
- padding-right: 0.375rem;
- }
- &.is-fullwidth-mobile {
- width: 224px;
- }
- &.is-mini-mobile {
- width: 56px;
- .brand {
- margin: 0 0 1.5rem;
- justify-content: center;
- .logo {
- width: 32px;
- height: 32px;
- }
- .text {
- display: none;
- }
- }
- &:not(.is-mini-expanded),
- &.is-mini-expanded:not(:hover) {
- .menu-list {
- li {
- a {
- text-align: center;
- padding: 0.75em 0.5em;
- span:nth-child(2) {
- display: none;
- }
- }
- ul {
- padding-left: 0;
- li {
- a {
- display: inline-block;
- }
- }
- }
- }
- }
- .menu-label:not(:last-child) {
- margin-bottom: 0;
- }
- }
- }
- }
- }
- }
- </style>
|