index.vue 4.06 KB
<template>
  <Footer :class="prefixCls" v-if="getShowLayoutFooter" ref="footerRef">
    <div :class="`${prefixCls}__links`">
      <a @click="openWindow(SITE_URL)">{{ t('layout.footer.onlinePreview') }}</a>

      <!-- <GithubFilled @click="openWindow(GITHUB_URL)" :class="`${prefixCls}__github`" /> -->
      <span style="width: 50px; height: 50px; margin-left: 65px"></span>

      <a @click="openWindow(DOC_URL)">{{ t('layout.footer.onlineDocument') }}</a>
    </div>
    <div>Copyright &copy;2018-{{ isUpdateTime }} 云腾五洲</div>
  </Footer>
</template>

<script lang="ts">
  import { computed, defineComponent, unref, ref } from 'vue';
  import { Layout } from 'ant-design-vue';

  import { DOC_URL, GITHUB_URL, SITE_URL } from '/@/settings/siteSetting';
  import { openWindow } from '/@/utils';

  import { useI18n } from '/@/hooks/web/useI18n';
  import { useRootSetting } from '/@/hooks/setting/useRootSetting';
  import { useRouter } from 'vue-router';
  import { useDesign } from '/@/hooks/web/useDesign';
  import { useLayoutHeight } from '../content/useContentViewHeight';

  export default defineComponent({
    name: 'LayoutFooter',
    components: { Footer: Layout.Footer },
    setup() {
      const { t } = useI18n();
      const { getShowFooter } = useRootSetting();
      const { currentRoute } = useRouter();
      const { prefixCls } = useDesign('layout-footer');
      const footerRef = ref<ComponentRef>(null);
      const { setFooterHeight } = useLayoutHeight();
      const isUpdateTime: any = ref('');
      const doUpdateTime = () => {
        let year = getDateTime('year');
        isUpdateTime.value = year;
      };
      doUpdateTime();
      function getDateTime(type) {
        let date = new Date();
        let hengGang = '-';
        let maoHao = ':';
        let year = date.getFullYear();
        let month: any = date.getMonth() + 1;
        let curDate: any = date.getDate();
        let curHours: any = date.getHours();
        let curMinutes: any = date.getMinutes();
        let curSeconds: any = date.getSeconds();

        if (month >= 1 && month <= 9) {
          month = '0' + month;
        }
        if (curDate >= 0 && curDate <= 9) {
          curDate = '0' + curDate;
        }
        if (curHours >= 0 && curHours <= 9) {
          curHours = '0' + curHours;
        }
        if (curMinutes >= 0 && curMinutes <= 9) {
          curMinutes = '0' + curMinutes;
        }
        if (curSeconds >= 0 && curSeconds <= 9) {
          curSeconds = '0' + curSeconds;
        }
        let currentdate: any = '';
        if (type == 'year') {
          currentdate = year;
          return currentdate;
        } else if (type == 'month') {
          currentdate = year + hengGang + month;
          return currentdate;
        } else {
          currentdate =
            year +
            hengGang +
            month +
            hengGang +
            curDate +
            ' ' +
            curHours +
            maoHao +
            curMinutes +
            maoHao +
            curSeconds;
          return currentdate;
        }
      }
      const getShowLayoutFooter = computed(() => {
        if (unref(getShowFooter)) {
          const footerEl = unref(footerRef)?.$el;
          setFooterHeight(footerEl?.offsetHeight || 0);
        } else {
          setFooterHeight(0);
        }
        return unref(getShowFooter) && !unref(currentRoute).meta?.hiddenFooter;
      });

      return {
        getShowLayoutFooter,
        prefixCls,
        t,
        DOC_URL,
        GITHUB_URL,
        SITE_URL,
        openWindow,
        footerRef,
        isUpdateTime,
      };
    },
  });
</script>
<style lang="less" scoped>
  @prefix-cls: ~'@{namespace}-layout-footer';

  @normal-color: rgba(0, 0, 0, 0.45);

  @hover-color: rgba(0, 0, 0, 0.85);

  .@{prefix-cls} {
    color: @normal-color;
    text-align: center;

    &__links {
      margin-bottom: 8px;

      a {
        color: @normal-color;

        &:hover {
          color: @hover-color;
        }
      }
    }

    &__github {
      margin: 0 30px;

      &:hover {
        color: @hover-color;
      }
    }
  }
</style>