浏览代码

无障碍:首页结构读屏

任一存 3 年之前
父节点
当前提交
d5a81dfa86
共有 5 个文件被更改,包括 68 次插入32 次删除
  1. 6 3
      web/README.md
  2. 18 6
      web/src/utils.js
  3. 8 2
      web/src/views/Home/index.vue
  4. 3 3
      web/src/views/accessibility.vue
  5. 33 18
      web/src/views/layout/index.vue

文件差异内容过多而无法显示
+ 6 - 3
web/README.md


+ 18 - 6
web/src/utils.js

@@ -17,6 +17,14 @@ function mapTags(tag) {
 }
 }
 
 
 function extractTextForMagnify(e) {
 function extractTextForMagnify(e) {
+  const ariaLabel = e.path[0].getAttribute('aria-label')
+  if (e.path[0].getAttribute('aria-label')) {
+    return {
+      elemDisc: '',
+      elemContent: ariaLabel
+    }
+  }
+  
   // console.log(e)
   // console.log(e)
   if (e.path[0].nodeName === 'HTML') {
   if (e.path[0].nodeName === 'HTML') {
     return
     return
@@ -65,7 +73,7 @@ function isSameObject(object1, object2) {
   return true
   return true
 }
 }
 
 
-function getAndFocusNextNodeWithClassName(className) {
+function getAndFocusNextNodeWithCustomAttribute(attriName) {
   const startNode = (document.activeElement || document.body)
   const startNode = (document.activeElement || document.body)
 
 
   const treeWalker = document.createTreeWalker(document.body, NodeFilter.SHOW_ELEMENT)
   const treeWalker = document.createTreeWalker(document.body, NodeFilter.SHOW_ELEMENT)
@@ -80,14 +88,14 @@ function getAndFocusNextNodeWithClassName(className) {
       console.log('往下没找到')
       console.log('往下没找到')
       break
       break
     }
     }
-    if (nextNode.classList && [...nextNode.classList].some(item => item === className)) {
+    if (nextNode.dataset[attriName] !== undefined) {
       console.log('往下找到了')
       console.log('往下找到了')
       targetNode = nextNode
       targetNode = nextNode
       break
       break
     }
     }
   }
   }
 
 
-  if (!targetNode && startNode !== document.body) {
+  if (!targetNode && (startNode !== document.body)) {
     treeWalker.currentNode = document.body
     treeWalker.currentNode = document.body
     // eslint-disable-next-line
     // eslint-disable-next-line
     while(true) {
     while(true) {
@@ -96,8 +104,8 @@ function getAndFocusNextNodeWithClassName(className) {
         console.log('往上也没找到')
         console.log('往上也没找到')
         break
         break
       }
       }
-      if (nextNode.classList && [...nextNode.classList].some(item => item === className)) {
-        console.log('上找到了')
+      if (nextNode.dataset[attriName] !== undefined) {
+        console.log('上找到了')
         targetNode = nextNode
         targetNode = nextNode
         break
         break
       }
       }
@@ -106,6 +114,10 @@ function getAndFocusNextNodeWithClassName(className) {
 
 
   if (targetNode) {
   if (targetNode) {
     targetNode.focus()
     targetNode.focus()
+    if (document.activeElement !== targetNode) {
+      targetNode.setAttribute('tabindex', '0')
+      targetNode.focus()
+    }
   }
   }
 
 
   return targetNode
   return targetNode
@@ -197,5 +209,5 @@ export default {
   isSameObject,
   isSameObject,
   iterateOnFocusableNode,
   iterateOnFocusableNode,
   debounce,
   debounce,
-  getAndFocusNextNodeWithClassName,
+  getAndFocusNextNodeWithCustomAttribute,
 }
 }

+ 8 - 2
web/src/views/Home/index.vue

@@ -1,7 +1,10 @@
 <template>
 <template>
   <div class="Home">
   <div class="Home">
     <!-- 轮播组件 -->
     <!-- 轮播组件 -->
-    <el-carousel>
+    <el-carousel
+      data-aria-viewport-area tabindex="0"
+      aria-label="You've reached the slider section. This section has four image URLs. To browse the content, please use the tab key."
+    >
       <el-carousel-item v-for="item in 4" :key="item">
       <el-carousel-item v-for="item in 4" :key="item">
         <img
         <img
           :src="require(`@/assets/images/swiper${item}.jpg`)"
           :src="require(`@/assets/images/swiper${item}.jpg`)"
@@ -11,7 +14,10 @@
       </el-carousel-item>
       </el-carousel-item>
     </el-carousel>
     </el-carousel>
     <!-- 底部 -->
     <!-- 底部 -->
-    <div class="bottomNav">
+    <div
+      class="bottomNav" data-aria-viewport-area tabindex="0"
+      aria-label="You've reached the pop-up window section; this section contains four URLs; please use the tab key to go through the content."
+    >
       <div class="t1" @click="$router.push('/Layout/Visit/2')">
       <div class="t1" @click="$router.push('/Layout/Visit/2')">
         <div class="title">
         <div class="title">
           <span>Reservation</span>
           <span>Reservation</span>

+ 3 - 3
web/src/views/accessibility.vue

@@ -669,11 +669,11 @@ export default {
           this.onClickMagnifier()
           this.onClickMagnifier()
         }
         }
       } else if (e.key === "1" && e.altKey && !e.ctrlKey && !e.shiftKey) {
       } else if (e.key === "1" && e.altKey && !e.ctrlKey && !e.shiftKey) {
-        utils.getAndFocusNextNodeWithClassName('aria-navigation-area')
+        utils.getAndFocusNextNodeWithCustomAttribute('ariaNavigationArea')
       } else if (e.key === "2" && e.altKey && !e.ctrlKey && !e.shiftKey) {
       } else if (e.key === "2" && e.altKey && !e.ctrlKey && !e.shiftKey) {
-        utils.getAndFocusNextNodeWithClassName('aria-viewport-area')
+        utils.getAndFocusNextNodeWithCustomAttribute('ariaViewportArea')
       } else if (e.key === "3" && e.altKey && !e.ctrlKey && !e.shiftKey) {
       } else if (e.key === "3" && e.altKey && !e.ctrlKey && !e.shiftKey) {
-        utils.getAndFocusNextNodeWithClassName('aria-interactive-area')
+        utils.getAndFocusNextNodeWithCustomAttribute('ariaInteractiveArea')
       }
       }
     },
     },
     loadStoredSettings() {
     loadStoredSettings() {

+ 33 - 18
web/src/views/layout/index.vue

@@ -8,7 +8,10 @@
           <h1 class="logo">
           <h1 class="logo">
             <img src="@/assets/images/logo.png" alt="" />
             <img src="@/assets/images/logo.png" alt="" />
           </h1>
           </h1>
-          <ul class="mainbav">
+          <ul
+            class="mainbav" tabindex="0" data-aria-navigation-area
+            aria-label="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
             <li
               @click="skipOne(item.url)"
               @click="skipOne(item.url)"
               :class="{ active: $route.meta.myName === item.name }"
               :class="{ active: $route.meta.myName === item.name }"
@@ -39,7 +42,12 @@
           </ul>
           </ul>
         </div>
         </div>
         <!-- 右侧的输入框 -->
         <!-- 右侧的输入框 -->
-        <div class="search" @keyup.enter="search" v-if="!menaInd.includes('Search')">
+        <div
+          class="search" @keyup.enter="search" v-if="!menaInd.includes('Search')"
+          data-aria-interactive-area
+          aria-label="You've reached the seach field, please use the tab key to browse the content."
+          tabindex="0"
+        >
           <el-input
           <el-input
             placeholder="search..."
             placeholder="search..."
             suffix-icon="el-icon-search"
             suffix-icon="el-icon-search"
@@ -49,25 +57,13 @@
           <div class="btnn" @click="search"></div>
           <div class="btnn" @click="search"></div>
         </div>
         </div>
       </div>
       </div>
-      <!-- 固定的二维码和游戏 -->
-      <div class="rightNav">
-        <ul class="rightIco">
-          <li title="game">
-            <img src="@/assets/images/game.png" alt="" />
-          </li>
-          <li>
-            <img src="@/assets/images/code.png" alt="" />
-            <div>
-              <img src="@/assets/images/index_ewm1.png" alt="" />
-              <img src="@/assets/images/index_ewm.jpg" alt="" />
-            </div>
-          </li>
-        </ul>
-      </div>
       <!-- 嵌套路由 -->
       <!-- 嵌套路由 -->
       <Router-view />
       <Router-view />
       <!-- 底部固定栏 -->
       <!-- 底部固定栏 -->
-      <div class="footer">
+      <div
+        class="footer" data-aria-viewport-area tabindex="0"
+        aria-label="You've reached footer section at the bottom of the website. This section contains five URLs. To browse the content, please use the tab key."
+      >
         <div>
         <div>
           <span
           <span
             @click="footTo(item.path)"
             @click="footTo(item.path)"
@@ -81,6 +77,24 @@
           100045, P.R.China.
           100045, P.R.China.
         </p>
         </p>
       </div>
       </div>
+      <!-- 固定的二维码和游戏 -->
+      <div
+        class="rightNav" data-aria-viewport-area tabindex="0"
+        aria-label="You've reached the pop-up window section, which has one URL and one image. Please use the tab key to go through the information."
+      >
+        <ul class="rightIco">
+          <li title="game">
+            <img src="@/assets/images/game.png" alt="" />
+          </li>
+          <li>
+            <img src="@/assets/images/code.png" alt="" />
+            <div>
+              <img src="@/assets/images/index_ewm1.png" alt="" />
+              <img src="@/assets/images/index_ewm.jpg" alt="" />
+            </div>
+          </li>
+        </ul>
+      </div>
     </div>
     </div>
   </div>
   </div>
 </template>
 </template>
@@ -210,6 +224,7 @@ export default {
       font-size: 14px;
       font-size: 14px;
       color: #fff;
       color: #fff;
       line-height: 60px;
       line-height: 60px;
+      overflow: hidden;
       & > li {
       & > li {
         cursor: pointer;
         cursor: pointer;
         float: left;
         float: left;