mirror of
				https://github.com/pure-admin/vue-pure-admin.git
				synced 2025-11-03 13:44:47 +08:00 
			
		
		
		
	feat: add week model
This commit is contained in:
		
							parent
							
								
									485df5eb2f
								
							
						
					
					
						commit
						acef165783
					
				@ -4,12 +4,11 @@
 | 
				
			|||||||
    <ul class="setting">
 | 
					    <ul class="setting">
 | 
				
			||||||
      <li>
 | 
					      <li>
 | 
				
			||||||
        <span>灰色模式</span>
 | 
					        <span>灰色模式</span>
 | 
				
			||||||
        <vxe-switch
 | 
					        <vxe-switch v-model="greyVal" open-label="开" close-label="关" @change="greyChange"></vxe-switch>
 | 
				
			||||||
          v-model="greyVal"
 | 
					      </li>
 | 
				
			||||||
          open-label="开"
 | 
					      <li>
 | 
				
			||||||
          close-label="关"
 | 
					        <span>色弱模式</span>
 | 
				
			||||||
          @change="greyChange"
 | 
					        <vxe-switch v-model="weekVal" open-label="开" close-label="关" @change="weekChange"></vxe-switch>
 | 
				
			||||||
        ></vxe-switch>
 | 
					 | 
				
			||||||
      </li>
 | 
					      </li>
 | 
				
			||||||
    </ul>
 | 
					    </ul>
 | 
				
			||||||
  </panel>
 | 
					  </panel>
 | 
				
			||||||
@ -23,6 +22,13 @@ export default {
 | 
				
			|||||||
  name: "setting",
 | 
					  name: "setting",
 | 
				
			||||||
  components: { panel },
 | 
					  components: { panel },
 | 
				
			||||||
  setup() {
 | 
					  setup() {
 | 
				
			||||||
 | 
					    function toggleClass(flag: boolean, clsName: string, target?: HTMLElement) {
 | 
				
			||||||
 | 
					      const targetEl = target || document.body;
 | 
				
			||||||
 | 
					      let { className } = targetEl;
 | 
				
			||||||
 | 
					      className = className.replace(clsName, "");
 | 
				
			||||||
 | 
					      targetEl.className = flag ? `${className} ${clsName} ` : className;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    const localOperate = (key: string, value?: any, model?: string): any => {
 | 
					    const localOperate = (key: string, value?: any, model?: string): any => {
 | 
				
			||||||
      model && model === "set"
 | 
					      model && model === "set"
 | 
				
			||||||
        ? storageLocal.setItem(key, value)
 | 
					        ? storageLocal.setItem(key, value)
 | 
				
			||||||
@ -31,29 +37,48 @@ export default {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    const settings = reactive({
 | 
					    const settings = reactive({
 | 
				
			||||||
      greyVal: storageLocal.getItem("greyVal"),
 | 
					      greyVal: storageLocal.getItem("greyVal"),
 | 
				
			||||||
 | 
					      weekVal: storageLocal.getItem("weekVal")
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    settings.greyVal === null
 | 
					    settings.greyVal === null
 | 
				
			||||||
      ? localOperate("greyVal", false, "set")
 | 
					      ? localOperate("greyVal", false, "set")
 | 
				
			||||||
      : document.querySelector("html")?.setAttribute("class", "html-grey");
 | 
					      : document.querySelector("html")?.setAttribute("class", "html-grey");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    settings.weekVal === null
 | 
				
			||||||
 | 
					      ? localOperate("weekVal", false, "set")
 | 
				
			||||||
 | 
					      : document.querySelector("html")?.setAttribute("class", "html-weakness");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // 灰色模式设置
 | 
					    // 灰色模式设置
 | 
				
			||||||
    const greyChange = ({ value }): void => {
 | 
					    const greyChange = ({ value }): void => {
 | 
				
			||||||
      if (value) {
 | 
					      toggleClass(
 | 
				
			||||||
        localOperate("greyVal", true, "set");
 | 
					        settings.greyVal,
 | 
				
			||||||
        document.querySelector("html")?.setAttribute("class", "html-grey");
 | 
					        "html-grey",
 | 
				
			||||||
      } else {
 | 
					        document.querySelector("html")
 | 
				
			||||||
        localOperate("greyVal", false, "set");
 | 
					      );
 | 
				
			||||||
        document.querySelector("html")?.removeAttribute("class");
 | 
					      value
 | 
				
			||||||
      }
 | 
					        ? localOperate("greyVal", true, "set")
 | 
				
			||||||
 | 
					        : localOperate("greyVal", false, "set");
 | 
				
			||||||
 | 
					    };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // 色弱模式设置
 | 
				
			||||||
 | 
					    const weekChange = ({ value }): void => {
 | 
				
			||||||
 | 
					      toggleClass(
 | 
				
			||||||
 | 
					        settings.weekVal,
 | 
				
			||||||
 | 
					        "html-weakness",
 | 
				
			||||||
 | 
					        document.querySelector("html")
 | 
				
			||||||
 | 
					      );
 | 
				
			||||||
 | 
					      value
 | 
				
			||||||
 | 
					        ? localOperate("weekVal", true, "set")
 | 
				
			||||||
 | 
					        : localOperate("weekVal", false, "set");
 | 
				
			||||||
    };
 | 
					    };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    return {
 | 
					    return {
 | 
				
			||||||
      ...toRefs(settings),
 | 
					      ...toRefs(settings),
 | 
				
			||||||
      localOperate,
 | 
					      localOperate,
 | 
				
			||||||
      greyChange,
 | 
					      greyChange,
 | 
				
			||||||
 | 
					      weekChange
 | 
				
			||||||
    };
 | 
					    };
 | 
				
			||||||
  },
 | 
					  }
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
</script>
 | 
					</script>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -100,6 +100,7 @@ ul {
 | 
				
			|||||||
  top: 48px !important;
 | 
					  top: 48px !important;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// 灰色模式
 | 
				
			||||||
.html-grey {
 | 
					.html-grey {
 | 
				
			||||||
    filter: grayscale(100%);
 | 
					    filter: grayscale(100%);
 | 
				
			||||||
    -webkit-filter: grayscale(100%);
 | 
					    -webkit-filter: grayscale(100%);
 | 
				
			||||||
@ -111,6 +112,15 @@ ul {
 | 
				
			|||||||
    -webkit-filter: grayscale(1);
 | 
					    -webkit-filter: grayscale(1);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// 色弱模式
 | 
				
			||||||
 | 
					.html-weakness {
 | 
				
			||||||
 | 
					  filter: invert(80%);
 | 
				
			||||||
 | 
					  -webkit-filter: invert(80%);
 | 
				
			||||||
 | 
					  -moz-filter: invert(80%);
 | 
				
			||||||
 | 
					  -ms-filter: invert(80%);
 | 
				
			||||||
 | 
					  -o-filter: invert(80%);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
.el-loading-mask {
 | 
					.el-loading-mask {
 | 
				
			||||||
  z-index: -1;
 | 
					  z-index: -1;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user