perf: 同步代码
This commit is contained in:
parent
997e31e7be
commit
80e51e0f7a
10
README.md
10
README.md
@ -1 +1,11 @@
|
|||||||
<h1>vue-pure-admin精简版</h1>
|
<h1>vue-pure-admin精简版</h1>
|
||||||
|
|
||||||
|
## 配套视频教程
|
||||||
|
|
||||||
|
bilibili:https://www.bilibili.com/video/BV1534y1S7HV/
|
||||||
|
|
||||||
|
## 交流群
|
||||||
|
|
||||||
|
[微信交流群,点击扫码进群](https://juejin.cn/post/6948419379566477342/)
|
||||||
|
|
||||||
|
本人微信:18237613535,拉你进群
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref, PropType, getCurrentInstance, watch, nextTick, toRef } from "vue";
|
import { ref, PropType, getCurrentInstance, watch, nextTick, toRef } from "vue";
|
||||||
|
import { FormRulesMap } from "element-plus/lib/components/form/src/form.type";
|
||||||
import { useRouter, useRoute } from "vue-router";
|
import { useRouter, useRoute } from "vue-router";
|
||||||
import { initRouter } from "/@/router";
|
import { initRouter } from "/@/router";
|
||||||
import { storageSession } from "/@/utils/storage";
|
import { storageSession } from "/@/utils/storage";
|
||||||
@ -44,7 +45,7 @@ watch(
|
|||||||
{ immediate: true }
|
{ immediate: true }
|
||||||
);
|
);
|
||||||
|
|
||||||
const rules: Object = ref({
|
const rules = ref<FormRulesMap>({
|
||||||
userName: [{ required: true, message: "请输入用户名", trigger: "blur" }],
|
userName: [{ required: true, message: "请输入用户名", trigger: "blur" }],
|
||||||
passWord: [
|
passWord: [
|
||||||
{ required: true, message: "请输入密码", trigger: "blur" },
|
{ required: true, message: "请输入密码", trigger: "blur" },
|
||||||
|
@ -49,6 +49,7 @@ const router = useRouter();
|
|||||||
const showTags = ref(storageLocal.getItem("tagsVal") || false);
|
const showTags = ref(storageLocal.getItem("tagsVal") || false);
|
||||||
const containerDom = templateRef<HTMLElement | null>("containerDom", null);
|
const containerDom = templateRef<HTMLElement | null>("containerDom", null);
|
||||||
const activeIndex = ref(-1);
|
const activeIndex = ref(-1);
|
||||||
|
|
||||||
const tagsViews = ref<Array<tagsViewsType>>([
|
const tagsViews = ref<Array<tagsViewsType>>([
|
||||||
{
|
{
|
||||||
icon: refresh,
|
icon: refresh,
|
||||||
@ -173,9 +174,6 @@ function deleteDynamicTag(obj: any, current: any, tag?: string) {
|
|||||||
routerArrays.splice(start, end);
|
routerArrays.splice(start, end);
|
||||||
relativeStorage.routesInStorage = routerArrays;
|
relativeStorage.routesInStorage = routerArrays;
|
||||||
}
|
}
|
||||||
router.push(obj.path);
|
|
||||||
// 删除缓存路由
|
|
||||||
handleAliveRoute(route.matched, "delete");
|
|
||||||
};
|
};
|
||||||
|
|
||||||
if (tag === "other") {
|
if (tag === "other") {
|
||||||
@ -188,15 +186,32 @@ function deleteDynamicTag(obj: any, current: any, tag?: string) {
|
|||||||
// 从当前匹配到的路径中删除
|
// 从当前匹配到的路径中删除
|
||||||
spliceRoute(valueIndex, 1);
|
spliceRoute(valueIndex, 1);
|
||||||
}
|
}
|
||||||
|
let newRoute: any = routerArrays.slice(-1);
|
||||||
if (current === obj.path) {
|
if (current === route.path) {
|
||||||
|
// 删除缓存路由
|
||||||
|
handleAliveRoute(route.matched, "delete");
|
||||||
// 如果删除当前激活tag就自动切换到最后一个tag
|
// 如果删除当前激活tag就自动切换到最后一个tag
|
||||||
let newRoute: any = routerArrays.slice(-1);
|
if (tag === "left") return;
|
||||||
nextTick(() => {
|
nextTick(() => {
|
||||||
router.push({
|
router.push({
|
||||||
path: newRoute[0].path
|
path: newRoute[0].path
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
} else {
|
||||||
|
//保存跳转之前的路径
|
||||||
|
let oldPath = route.path;
|
||||||
|
router.push(obj.path);
|
||||||
|
// 删除缓存路由
|
||||||
|
handleAliveRoute(route.matched, "delete");
|
||||||
|
if (!routerArrays.length) return;
|
||||||
|
let isHasOldPath = routerArrays.some(item => {
|
||||||
|
return item.path === oldPath;
|
||||||
|
});
|
||||||
|
isHasOldPath
|
||||||
|
? router.push(oldPath)
|
||||||
|
: router.push({
|
||||||
|
path: newRoute[0].path
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -655,7 +670,6 @@ onBeforeMount(() => {
|
|||||||
.contextmenu {
|
.contextmenu {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
background: #fff;
|
background: #fff;
|
||||||
z-index: 3000;
|
|
||||||
position: absolute;
|
position: absolute;
|
||||||
list-style-type: none;
|
list-style-type: none;
|
||||||
padding: 5px 0;
|
padding: 5px 0;
|
||||||
|
@ -33,14 +33,12 @@ import {
|
|||||||
computed,
|
computed,
|
||||||
onMounted,
|
onMounted,
|
||||||
watchEffect,
|
watchEffect,
|
||||||
useCssModule,
|
|
||||||
onBeforeMount,
|
onBeforeMount,
|
||||||
getCurrentInstance
|
getCurrentInstance
|
||||||
} from "vue";
|
} from "vue";
|
||||||
import { setType } from "./types";
|
import { setType } from "./types";
|
||||||
import { useI18n } from "vue-i18n";
|
import { useI18n } from "vue-i18n";
|
||||||
import { emitter } from "/@/utils/mitt";
|
import { emitter } from "/@/utils/mitt";
|
||||||
import { toggleClass } from "/@/utils/operate";
|
|
||||||
import { useEventListener } from "@vueuse/core";
|
import { useEventListener } from "@vueuse/core";
|
||||||
import { storageLocal } from "/@/utils/storage";
|
import { storageLocal } from "/@/utils/storage";
|
||||||
import { useAppStoreHook } from "/@/store/modules/app";
|
import { useAppStoreHook } from "/@/store/modules/app";
|
||||||
@ -56,7 +54,6 @@ import Vertical from "./components/sidebar/vertical.vue";
|
|||||||
import Horizontal from "./components/sidebar/horizontal.vue";
|
import Horizontal from "./components/sidebar/horizontal.vue";
|
||||||
|
|
||||||
const pureSetting = useSettingStoreHook();
|
const pureSetting = useSettingStoreHook();
|
||||||
const { hiddenMainContainer } = useCssModule();
|
|
||||||
|
|
||||||
const instance =
|
const instance =
|
||||||
getCurrentInstance().appContext.app.config.globalProperties.$storage;
|
getCurrentInstance().appContext.app.config.globalProperties.$storage;
|
||||||
@ -128,21 +125,9 @@ const $_resizeHandler = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
function onFullScreen() {
|
function onFullScreen() {
|
||||||
if (unref(hiddenSideBar)) {
|
unref(hiddenSideBar)
|
||||||
hiddenSideBar.value = false;
|
? (hiddenSideBar.value = false)
|
||||||
toggleClass(
|
: (hiddenSideBar.value = true);
|
||||||
false,
|
|
||||||
hiddenMainContainer,
|
|
||||||
document.querySelector(".main-container")
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
hiddenSideBar.value = true;
|
|
||||||
toggleClass(
|
|
||||||
true,
|
|
||||||
hiddenMainContainer,
|
|
||||||
document.querySelector(".main-container")
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
@ -151,11 +136,6 @@ onMounted(() => {
|
|||||||
useAppStoreHook().toggleDevice("mobile");
|
useAppStoreHook().toggleDevice("mobile");
|
||||||
handleClickOutside(true);
|
handleClickOutside(true);
|
||||||
}
|
}
|
||||||
toggleClass(
|
|
||||||
unref(hiddenSideBar),
|
|
||||||
hiddenMainContainer,
|
|
||||||
document.querySelector(".main-container")
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
onBeforeMount(() => {
|
onBeforeMount(() => {
|
||||||
@ -175,7 +155,7 @@ onBeforeMount(() => {
|
|||||||
@click="handleClickOutside(false)"
|
@click="handleClickOutside(false)"
|
||||||
/>
|
/>
|
||||||
<Vertical v-show="!hiddenSideBar && layout.includes('vertical')" />
|
<Vertical v-show="!hiddenSideBar && layout.includes('vertical')" />
|
||||||
<div class="main-container">
|
<div :class="['main-container', hiddenSideBar ? 'main-hidden' : '']">
|
||||||
<div :class="{ 'fixed-header': set.fixedHeader }">
|
<div :class="{ 'fixed-header': set.fixedHeader }">
|
||||||
<!-- 顶部导航栏 -->
|
<!-- 顶部导航栏 -->
|
||||||
<navbar v-show="!hiddenSideBar && layout.includes('vertical')" />
|
<navbar v-show="!hiddenSideBar && layout.includes('vertical')" />
|
||||||
@ -196,12 +176,6 @@ onBeforeMount(() => {
|
|||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<style scoped module>
|
|
||||||
.hiddenMainContainer {
|
|
||||||
margin-left: 0 !important;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
@mixin clearfix {
|
@mixin clearfix {
|
||||||
&::after {
|
&::after {
|
||||||
@ -224,6 +198,10 @@ onBeforeMount(() => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.main-hidden {
|
||||||
|
margin-left: 0 !important;
|
||||||
|
}
|
||||||
|
|
||||||
.drawer-bg {
|
.drawer-bg {
|
||||||
background: #000;
|
background: #000;
|
||||||
opacity: 0.3;
|
opacity: 0.3;
|
||||||
|
@ -5,7 +5,7 @@ import {
|
|||||||
createWebHashHistory,
|
createWebHashHistory,
|
||||||
RouteRecordNormalized
|
RouteRecordNormalized
|
||||||
} from "vue-router";
|
} from "vue-router";
|
||||||
import { split } from "lodash-es";
|
import { split, uniqBy } from "lodash-es";
|
||||||
import { i18n } from "/@/plugins/i18n";
|
import { i18n } from "/@/plugins/i18n";
|
||||||
import { openLink } from "/@/utils/link";
|
import { openLink } from "/@/utils/link";
|
||||||
import NProgress from "/@/utils/progress";
|
import NProgress from "/@/utils/progress";
|
||||||
@ -215,7 +215,10 @@ router.beforeEach((to, _from, next) => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
storageLocal.setItem("responsive-routesInStorage", newLocalRoutes);
|
storageLocal.setItem(
|
||||||
|
"responsive-routesInStorage",
|
||||||
|
uniqBy(newLocalRoutes, "path")
|
||||||
|
);
|
||||||
});
|
});
|
||||||
next();
|
next();
|
||||||
}
|
}
|
||||||
|
@ -15,13 +15,6 @@
|
|||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
.el-dialog {
|
|
||||||
transform: none;
|
|
||||||
left: 0;
|
|
||||||
position: relative;
|
|
||||||
margin: 0 auto;
|
|
||||||
}
|
|
||||||
|
|
||||||
// refine element ui upload
|
// refine element ui upload
|
||||||
.upload-container {
|
.upload-container {
|
||||||
.el-upload {
|
.el-upload {
|
@ -1,6 +1,6 @@
|
|||||||
@import "./mixin.scss";
|
@import "./mixin.scss";
|
||||||
@import "./transition.scss";
|
@import "./transition.scss";
|
||||||
@import "./element-ui.scss";
|
@import "./element-plus.scss";
|
||||||
@import "./sidebar.scss";
|
@import "./sidebar.scss";
|
||||||
|
|
||||||
body {
|
body {
|
||||||
|
@ -27,11 +27,23 @@
|
|||||||
position: fixed;
|
position: fixed;
|
||||||
top: 0;
|
top: 0;
|
||||||
right: 0;
|
right: 0;
|
||||||
z-index: 9;
|
z-index: 1000;
|
||||||
width: calc(100% - 210px);
|
width: calc(100% - 210px);
|
||||||
transition: width 0.28s;
|
transition: width 0.28s;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.main-hidden {
|
||||||
|
margin-left: 0 !important;
|
||||||
|
|
||||||
|
.fixed-header {
|
||||||
|
width: 100% !important;
|
||||||
|
|
||||||
|
+ .app-main {
|
||||||
|
padding-top: 37px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
.el-popper.is-light {
|
.el-popper.is-light {
|
||||||
border: none !important;
|
border: none !important;
|
||||||
}
|
}
|
||||||
@ -334,6 +346,20 @@
|
|||||||
background-color: $menuHover !important;
|
background-color: $menuHover !important;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.el-menu-item,
|
||||||
|
.el-sub-menu {
|
||||||
|
i {
|
||||||
|
width: 20px;
|
||||||
|
text-align: center;
|
||||||
|
font-size: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
i.fa {
|
||||||
|
margin-right: 5px;
|
||||||
|
font-size: 16px;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// horizontal菜单折叠
|
// horizontal菜单折叠
|
||||||
|
@ -9,7 +9,7 @@ import svgLoader from "vite-svg-loader";
|
|||||||
import styleImport from "vite-plugin-style-import";
|
import styleImport from "vite-plugin-style-import";
|
||||||
import ElementPlus from "unplugin-element-plus/vite";
|
import ElementPlus from "unplugin-element-plus/vite";
|
||||||
|
|
||||||
const pathResolve = (dir: string): any => {
|
const pathResolve = (dir: string): string => {
|
||||||
return resolve(__dirname, ".", dir);
|
return resolve(__dirname, ".", dir);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user