代码优化 - 使用对象枚举,将switch语句优化
Before:
switch (path) { case "/options/store": return "store"; case "/options/tiktok": return "tiktok"; case "/options/kuaishou": return "kuaishou"; case "/options/hamaqi": return "hamaqi"; }
After:
routerFilter () { const path = this.$route.path; const operators = { "/shareholder/basics": "basics", "/shareholder/setting": "setting", }; return operators[path]; }