完成跳转外部链接功能
Former-commit-id: f3efcfeef6aa80e71d58a283c7a012daf7e9b8f3 [formerly f3efcfeef6aa80e71d58a283c7a012daf7e9b8f3 [formerly f3efcfeef6aa80e71d58a283c7a012daf7e9b8f3 [formerly f3efcfeef6aa80e71d58a283c7a012daf7e9b8f3 [formerly 1992b24b60b05040dc05d5560346e588d67e6177 [formerly e739f55c37f694cb22cde32fee3d66745ef80906]]]]] Former-commit-id: 5a431444072fcd4a43866a458173da85d7380a6c Former-commit-id: 51c7bc03498d69ffe207436c0a470e2fd41407a0 Former-commit-id: 6fe58189034659f8c767ddb97fd3d6397f24d7bf [formerly 0b495976f82bf0633b3ded3e28dd1568c14be1ca] Former-commit-id: e6ddea0e2a683272a5a757271442ab62fdfeb5ce Former-commit-id: 07d0fad901b750296655a22fbe2fa29893d33f7c Former-commit-id: 9f718c52da8302b33f3d0c0c80628e6a6a92c4df Former-commit-id: 7b5db07e1542a42a3d0d3af1bca0606db47b5dbb Former-commit-id: 204199da27a137c4d4edde0fc88680810743e771
This commit is contained in:
@@ -1,8 +1,12 @@
|
||||
import util from '@/libs/util.js'
|
||||
|
||||
export default {
|
||||
methods: {
|
||||
handleMenuSelect (index, indexPath) {
|
||||
if (/^d2-menu-empty-\d+$/.test(index)) {
|
||||
this.$message.warning('临时菜单')
|
||||
} else if (/^https:\/\/|http:\/\//.test(index)) {
|
||||
util.open(index)
|
||||
} else {
|
||||
this.$router.push({
|
||||
path: index
|
||||
|
||||
@@ -17,6 +17,20 @@ util.title = function (titleText) {
|
||||
window.document.title = `${process.env.VUE_APP_TITLE}${titleText ? ` | ${titleText}` : ''}`
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 打开新页面
|
||||
* @param {String} url 地址
|
||||
*/
|
||||
util.open = function (url) {
|
||||
var a = document.createElement('a')
|
||||
a.setAttribute('href', url)
|
||||
a.setAttribute('target', '_blank')
|
||||
a.setAttribute('id', 'd2admin-menu-link')
|
||||
document.body.appendChild(a)
|
||||
a.click()
|
||||
document.body.removeChild(document.getElementById('d2admin-menu-link'))
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 判断是否在其内
|
||||
* @param {*} ele element
|
||||
|
||||
@@ -20,7 +20,6 @@ import pluginLog from '@/plugin/log'
|
||||
import pluginError from '@/plugin/error'
|
||||
import pluginImport from '@/plugin/import'
|
||||
import pluginExport from '@/plugin/export'
|
||||
import pluginOpen from '@/plugin/open'
|
||||
|
||||
// 菜单和路由设置
|
||||
import router from './router'
|
||||
@@ -34,7 +33,6 @@ Vue.use(pluginLog)
|
||||
Vue.use(pluginError)
|
||||
Vue.use(pluginImport)
|
||||
Vue.use(pluginExport)
|
||||
Vue.use(pluginOpen)
|
||||
Vue.use(vueJsonTreeView)
|
||||
|
||||
Vue.config.productionTip = false
|
||||
@@ -42,6 +40,8 @@ Vue.config.productionTip = false
|
||||
Vue.prototype.$env = process.env.NODE_ENV
|
||||
Vue.prototype.$baseUrl = process.env.BASE_URL
|
||||
|
||||
Vue.prototype.$open = util.open
|
||||
|
||||
new Vue({
|
||||
router,
|
||||
store,
|
||||
|
||||
@@ -37,6 +37,18 @@ export const menuHeader = [
|
||||
demoCharts,
|
||||
demoPlugins,
|
||||
demoPlayground,
|
||||
{
|
||||
title: '跳转外部链接',
|
||||
icon: 'link',
|
||||
children: [
|
||||
{ path: 'https://github.com/d2-projects/d2-admin', title: 'D2Admin Github', icon: 'github' },
|
||||
{ path: 'https://juejin.im/user/57a48b632e958a006691b946/posts', title: '掘金', icon: 'globe' },
|
||||
{ path: 'https://my.oschina.net/u/3871516', title: '开源中国', icon: 'globe' },
|
||||
{ path: 'https://www.zhihu.com/people/fairy-ever/activities', title: '知乎', icon: 'globe' },
|
||||
{ path: 'https://segmentfault.com/blog/liyang-note-book', title: 'segmentfault 专栏', icon: 'globe' },
|
||||
{ path: 'http://www.fairyever.com/', title: 'www.fairyever.com', icon: 'globe' }
|
||||
]
|
||||
},
|
||||
{
|
||||
title: '空菜单演示',
|
||||
icon: 'folder-o',
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
export default {
|
||||
install (Vue, options) {
|
||||
// 打开一个url
|
||||
Vue.prototype.$open = (url = 'https://github.com/d2-projects') => {
|
||||
window.open(url)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user