mirror of
https://github.com/pure-admin/vue-pure-admin.git
synced 2025-11-03 13:44:47 +08:00
add: 添加外链功能
This commit is contained in:
@@ -220,7 +220,7 @@ export default defineComponent({
|
||||
padding: 0 10px;
|
||||
}
|
||||
.el-dropdown-menu {
|
||||
padding: 0;
|
||||
padding: 6px 0;
|
||||
}
|
||||
.el-dropdown-menu__item:focus,
|
||||
.el-dropdown-menu__item:not(.is-disabled):hover {
|
||||
|
||||
@@ -66,7 +66,7 @@
|
||||
<script lang='ts'>
|
||||
import panel from "../panel/index.vue";
|
||||
import { onMounted, reactive, toRefs, ref, unref } from "vue";
|
||||
import { storageLocal } from "/@/utils/storage";
|
||||
import { storageLocal, storageSession } from "/@/utils/storage";
|
||||
import { toggleClass } from "/@/utils/operate";
|
||||
import { emitter } from "/@/utils/mitt";
|
||||
import { useRouter } from "vue-router";
|
||||
@@ -145,6 +145,7 @@ export default {
|
||||
|
||||
function onReset() {
|
||||
storageLocal.clear();
|
||||
storageSession.clear();
|
||||
router.push("/login");
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,8 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { computed, defineComponent } from "vue";
|
||||
import { computed, defineComponent, unref } from "vue"
|
||||
import { isUrl } from "/@/utils/is.ts"
|
||||
|
||||
export default defineComponent({
|
||||
name: "Link",
|
||||
@@ -16,15 +17,36 @@ export default defineComponent({
|
||||
},
|
||||
},
|
||||
setup(props) {
|
||||
const linkProps = (to) => {
|
||||
|
||||
const isExternal = computed(() => {
|
||||
return isUrl(props.to)
|
||||
})
|
||||
|
||||
const type = computed(() => {
|
||||
if (unref(isExternal)) {
|
||||
return 'a'
|
||||
}
|
||||
return 'router-link'
|
||||
})
|
||||
|
||||
function linkProps(to) {
|
||||
if (unref(isExternal)) {
|
||||
return {
|
||||
href: to,
|
||||
target: '_blank',
|
||||
rel: 'noopener'
|
||||
}
|
||||
}
|
||||
return {
|
||||
to: to,
|
||||
};
|
||||
};
|
||||
to: to
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
type: "router-link",
|
||||
isExternal,
|
||||
type,
|
||||
linkProps,
|
||||
};
|
||||
}
|
||||
},
|
||||
});
|
||||
</script>
|
||||
|
||||
@@ -42,6 +42,8 @@ import path from "path";
|
||||
import AppLink from "./Link.vue";
|
||||
import { defineComponent, PropType, ref } from "vue";
|
||||
import { RouteRecordRaw } from "vue-router";
|
||||
import { isUrl } from "/@/utils/is.ts";
|
||||
|
||||
export default defineComponent({
|
||||
name: "SidebarItem",
|
||||
components: { AppLink },
|
||||
@@ -81,15 +83,27 @@ export default defineComponent({
|
||||
}
|
||||
|
||||
if (showingChildren.length === 0) {
|
||||
// @ts-ignore
|
||||
onlyOneChild.value = { ...parent, path: "", noShowingChildren: true };
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
const resolvePath = (routePath: string) => {
|
||||
// const resolvePath = (routePath: string) => {
|
||||
// return path.resolve(props.basePath, routePath);
|
||||
// };
|
||||
|
||||
function resolvePath(routePath) {
|
||||
if (isUrl(routePath)) {
|
||||
return routePath;
|
||||
}
|
||||
if (isUrl(this.basePath)) {
|
||||
return props.basePath;
|
||||
}
|
||||
// @ts-ignore
|
||||
return path.resolve(props.basePath, routePath);
|
||||
};
|
||||
}
|
||||
|
||||
return { hasOneShowingChild, resolvePath, onlyOneChild };
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user