123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583 |
- <template>
- <div :class="['layout', THEME_MAP[themeIdx]]">
- <Accessibility
- ref="accessibility"
- @show="loveSwitch = true"
- @hide="loveSwitch = false"
- />
- <div class="aria-control-target layout-main">
- <!-- 顶部top -->
- <div class="topnav-wrap">
- <div class="topnav">
- <div class="topnav-container">
- <img
- :src="
- [
- THEME_COLOR.DEFAULT,
- THEME_COLOR.BLUE,
- THEME_COLOR.BLACK,
- ].includes(themeIdx)
- ? Logo
- : Logo2
- "
- aria-label="Image"
- aria-description="CAPTIAL MUSEUM.CHINA"
- />
- <ul
- class="topnav-list"
- data-aria-navigation-area
- aria-description="You have reached the horizontal menu at the top of the website. There are eight dropdown menus and 34 options in this section. To browse the content, please use the tab key."
- >
- <li
- v-for="item in topData.filter((i) => !i.hideNav)"
- :key="item.id"
- tabindex="0"
- aria-label="Link"
- :aria-description="item.name"
- :class="{
- active:
- $route.path
- .toLowerCase()
- .indexOf(((item.routeParams as RouteLocationNamedRaw)!.name as string).toLowerCase()) > -1,
- }"
- @click="$router.push(item.routeParams!)"
- @keydown.enter.passive="$router.push(item.routeParams!)"
- >
- <span>{{ item.name }}</span>
- <ul class="main_nav_sub">
- <li
- v-for="(val, index) in item.children"
- :key="index"
- tabindex="0"
- :class="{ active2: $route.path === val.routeParams }"
- aria-label="Link"
- :aria-description="val.name"
- @click.stop="$router.push(val.routeParams!)"
- @keydown.enter.passive.stop="$router.push(val.routeParams!)"
- >
- <span>{{ val.name }}</span>
- </li>
- </ul>
- </li>
- <!-- 中文网 -->
- <li class="language" aria-description="English">
- <a
- href="http://www.capitalmuseum.org.cn/"
- target="_blank"
- aria-description="Chinese"
- >
- 中文
- </a>
- </li>
- <!-- 爱心模式 -->
- <li class="love">
- <p @click="loveSwitch = !loveSwitch">Assistive Mode</p>
- <van-switch
- v-model="loveSwitch"
- active-color="var(--van-primary-color)"
- inactive-color="#dcdfe6"
- aria-label="Button"
- aria-description="Assistive Mode"
- />
- </li>
- </ul>
- <!-- 搜索 -->
- <div
- class="search"
- data-aria-interaction-area
- aria-description="You've reached the search field, please use the tab key to browse the content."
- >
- <template v-if="$route.name !== 'Search'">
- <input
- v-model="searchTxt"
- placeholder="search..."
- @keyup.enter="handleSearch(searchTxt)"
- />
- <svg-icon
- name="search"
- color="var(--van-primary-color)"
- @click="handleSearch(searchTxt)"
- />
- </template>
- </div>
- </div>
- </div>
- </div>
- <RouterView />
- <!-- 固定的二维码和游戏 -->
- <div class="rightNav">
- <ul
- class="rightIco"
- data-aria-viewport-area
- aria-description="You've reached the pop-up window section, which has one search field, one URL and one image. Please use the tab key to go through the information."
- >
- <li
- class="searchLi"
- v-if="$route.name !== 'Search'"
- aria-description="You've reached the search field, please use the tab key to browse the content."
- >
- <div class="searchHover">
- <div class="ll" @click="handleSearch(searchTxt2)">
- <img src="@/assets/images/LayoutSearch2.jpg" alt="" />
- </div>
- <div class="rr">
- <input
- type="text"
- placeholder="search"
- v-model="searchTxt2"
- :aria-description="searchTxt2 || 'search'"
- @keyup.enter="handleSearch(searchTxt2)"
- />
- </div>
- </div>
- <svg-icon name="search2" color="var(--van-white)" size="32" />
- </li>
- <li title="game">
- <a
- href="/game/index.html#/?lang=en-us"
- target="_blank"
- tabindex="0"
- aria-description="shadow art game"
- >
- <svg-icon name="game" color="var(--van-white)" size="50" />
- </a>
- </li>
- <li>
- <svg-icon name="code" color="var(--van-white)" size="50" />
- <div>
- <img src="@/assets/images/index_ewm1.png" alt="" />
- <img
- src="@/assets/images/index_ewm.jpg"
- aria-description="Official microblog and wechat QR code"
- />
- </div>
- </li>
- </ul>
- </div>
- <!-- 底部固定栏 -->
- <div
- class="footer"
- data-aria-viewport-area
- aria-label="Footer"
- aria-description="You've reached footer section at the bottom of the website. This section contains four URLs. To browse the content, please use the tab key."
- >
- <div>
- <template v-for="item in footerData" :key="item.name">
- |
- <RouterLink
- class="router-link"
- replace
- :to="item.path"
- v-html="item.name"
- :aria-description="item.name"
- />
- </template>
- </div>
- <p>
- Capital Museum. China 16 Fuxingmenwai Street, Xicheng District,
- Beijing 100045, P.R.China.
- </p>
- </div>
- </div>
- </div>
- </template>
- <script setup lang="ts">
- import { ref, watch } from "vue";
- import { useRoute, useRouter, type RouteLocationNamedRaw } from "vue-router";
- import Accessibility from "@/components/Accessibility/index.vue";
- import { useTheme, THEME_COLOR } from "@/components/Accessibility/hooks";
- import { topData, footerData } from "./data";
- import Logo from "@/assets/images/logo.png";
- import Logo2 from "@/assets/images/logo2.png";
- const THEME_MAP: Record<THEME_COLOR, string> = {
- [THEME_COLOR.DEFAULT]: "",
- [THEME_COLOR.WHITE]: "white",
- [THEME_COLOR.BLUE]: "blue",
- [THEME_COLOR.YELLOW]: "yellow",
- [THEME_COLOR.BLACK]: "black",
- };
- const themeIdx = useTheme();
- const route = useRoute();
- const router = useRouter();
- /** 是否开启爱心模式 */
- const loveSwitch = ref(false);
- const accessibility = ref();
- const searchTxt = ref("");
- const searchTxt2 = ref("");
- watch(loveSwitch, (v) => {
- if (v) {
- accessibility.value?.requestToShowMenu();
- } else {
- accessibility.value?.requestToHideMenu();
- }
- });
- watch(
- route,
- () => {
- searchTxt.value = "";
- },
- {
- immediate: true,
- }
- );
- const handleSearch = (txt: string) => {
- router.push({
- name: "Search",
- query: { keyword: encodeURIComponent(txt) },
- });
- searchTxt2.value = "";
- searchTxt.value = "";
- };
- </script>
- <style lang="scss">
- .layout {
- --van-primary-color: #ca000a;
- --topnav-bg-color: rgba(0, 0, 0, 0.8);
- --primary-hover-bg: rgba(204, 0, 3, 0.8);
- --black-text-color: black;
- --black2-text-color: #101010;
- --gray-text-color: #666;
- --gray2-text-color: #a6a6a6;
- --white-bg: white;
- --white-text-color: white;
- --page-bg-color: #f1f1f1;
- font-family: "SourceHanSans-Regular";
- min-width: 1200px;
- background-color: var(--page-bg-color);
- &.white {
- --topnav-bg-color: white;
- --van-white: black;
- --primary-hover-bg: white;
- --black-text-color: black;
- --black2-text-color: black;
- --gray-text-color: #666;
- --gray2-text-color: #a6a6a6;
- --white-bg: white;
- --white-text-color: black;
- --page-bg-color: white;
- }
- &.blue {
- --topnav-bg-color: #00f;
- --van-white: #ff0;
- --primary-hover-bg: #00f;
- --black-text-color: #ff0;
- --black2-text-color: #ff0;
- --gray-text-color: #ff0;
- --gray2-text-color: #ff0;
- --white-bg: #00f;
- --white-text-color: #ff0;
- --page-bg-color: #00f;
- }
- &.yellow {
- --topnav-bg-color: #ff0;
- --van-white: black;
- --primary-hover-bg: #ff0;
- --black-text-color: black;
- --black2-text-color: black;
- --gray-text-color: black;
- --gray2-text-color: black;
- --white-bg: #ff0;
- --white-text-color: black;
- --page-bg-color: #ff0;
- }
- &.black {
- --topnav-bg-color: black;
- --van-white: #ff0;
- --primary-hover-bg: black;
- --black-text-color: #ff0;
- --black2-text-color: #ff0;
- --gray-text-color: #ff0;
- --gray2-text-color: #ff0;
- --white-bg: black;
- --white-text-color: #ff0;
- --page-bg-color: black;
- }
- &-main {
- position: relative;
- min-height: 100vh;
- padding-bottom: 45px;
- }
- }
- .topnav {
- position: absolute;
- top: 0;
- left: 0;
- right: 0;
- display: flex;
- align-items: center;
- justify-content: flex-end;
- padding: 0 40px 0 5px;
- height: inherit;
- background: var(--topnav-bg-color);
- z-index: 2;
- &-wrap {
- position: relative;
- height: 60px;
- }
- &-container {
- display: flex;
- align-items: center;
- flex: 1;
- max-width: calc(1300px + 240px + 30px);
- height: inherit;
- }
- &-list {
- flex: 1;
- display: flex;
- justify-content: space-between;
- padding: 0 70px;
- height: inherit;
- line-height: 60px;
- font-size: 14px;
- color: var(--van-white);
- > li {
- position: relative;
- cursor: pointer;
- user-select: none;
- > span {
- white-space: nowrap;
- }
- &:hover,
- &:focus-within {
- & > span {
- border-bottom: 2px solid var(--van-primary-color);
- }
- .main_nav_sub {
- display: block;
- }
- }
- &.active {
- & > span {
- border-bottom: 2px solid var(--van-primary-color);
- }
- }
- .main_nav_sub {
- display: none;
- position: absolute;
- z-index: 1;
- span {
- border-left: 2px solid #660005;
- font-size: 14px;
- color: inherit;
- height: 40px;
- line-height: 40px;
- background-color: var(--topnav-bg-color);
- white-space: nowrap;
- display: block;
- padding: 0 20px 0 10px;
- &:hover {
- background-color: var(--primary-hover-bg);
- border-left: 2px solid var(--van-primary-color);
- }
- }
- .active2 {
- background-color: var(--primary-hover-bg);
- border-left: 2px solid var(--van-primary-color);
- }
- }
- }
- }
- .language {
- width: 73px;
- background: url("@/assets/images/dh1.png") no-repeat 0 18px;
- & > a {
- color: #fff;
- text-decoration: none;
- display: inline-block;
- margin-left: 40px;
- padding-right: 5px;
- &:hover {
- border-bottom: 2px solid var(--van-primary-color);
- }
- }
- }
- .love {
- --van-switch-width: 40px;
- --van-switch-height: 20px;
- --van-switch-node-size: calc(var(--van-switch-height) - 4px);
- display: flex;
- align-items: center;
- gap: 8px;
- }
- .search {
- margin-left: 40px;
- position: relative;
- width: 240px;
- height: 30px;
- .svg-icon {
- position: absolute;
- top: 50%;
- right: 8px;
- transform: translateY(-50%);
- }
- input {
- font-size: 14px;
- background-color: #fff;
- border: 1px solid #dcdfe6;
- box-sizing: border-box;
- color: #606266;
- display: inline-block;
- outline: 0;
- padding: 0 30px 0 15px;
- transition: border-color 0.2s cubic-bezier(0.645, 0.045, 0.355, 1);
- width: 100%;
- height: 30px;
- border-radius: 15px;
- line-height: 30px;
- &:focus {
- border-color: var(--van-primary-color);
- }
- &::placeholder {
- color: black;
- }
- }
- }
- }
- .footer {
- position: absolute;
- left: 0;
- right: 0;
- bottom: 0;
- display: flex;
- justify-content: space-between;
- padding: 0 100px;
- font-size: 14px;
- color: var(--van-white);
- line-height: 45px;
- background: var(--topnav-bg-color);
- .router-link {
- color: inherit;
- margin: 0 10px;
- }
- }
- .rightNav {
- position: fixed;
- top: 60%;
- right: 0;
- height: 164px;
- width: 60px;
- z-index: var(--el-index-popper);
- .rightIco {
- width: 100%;
- height: 100%;
- & > li {
- background: var(--topnav-bg-color);
- text-align: center;
- width: 60px;
- padding: 10px 0;
- position: relative;
- cursor: pointer;
- & > div {
- display: none;
- width: 252px;
- position: absolute;
- top: 0;
- right: 0;
- & > img {
- float: left;
- }
- }
- &:hover,
- &:focus-within {
- background: var(--primary-hover-bg);
- & > div {
- display: block;
- }
- }
- }
- .searchLi {
- padding-top: 18px;
- position: relative;
- .searchHover {
- position: absolute;
- top: 0;
- right: 0;
- width: 300px;
- height: 60px;
- display: flex !important;
- opacity: 0;
- pointer-events: none;
- .ll {
- width: 60px;
- height: 60px;
- display: flex;
- justify-content: center;
- align-items: center;
- background-color: #fff;
- border: 1px solid #a3a3a3;
- }
- .rr {
- width: 240px;
- background-color: var(--van-primary-color);
- padding: 8px;
- input {
- padding: 0 5px;
- width: 200px;
- height: 38px;
- line-height: 44px;
- &:focus {
- border-color: #000 !important;
- outline: 2px solid #000 !important;
- }
- }
- }
- }
- &:hover,
- &:focus-within {
- .searchHover {
- opacity: 1;
- pointer-events: auto;
- }
- }
- }
- }
- }
- @media screen and (max-width: 1430px) {
- .topnav {
- padding-right: 5px;
- &-list {
- padding: 0 20px;
- font-size: 12px;
- }
- .search {
- margin-left: 0;
- }
- }
- }
- </style>
|