2020-03-05 16:18:17 +08:00
|
|
|
import Prism from 'prismjs'
|
2020-04-17 03:12:31 +08:00
|
|
|
import 'prismjs/components/prism-jsx.js'
|
2020-11-18 21:37:35 +08:00
|
|
|
import 'prismjs/components/prism-typescript.js'
|
2020-04-18 05:35:07 +08:00
|
|
|
import 'prismjs/components/prism-scss.js'
|
2020-10-13 00:42:47 +08:00
|
|
|
import PortalVue from 'portal-vue'
|
2021-01-30 03:56:53 +08:00
|
|
|
import iframeResize from 'iframe-resizer/js/iframeResizer'
|
2020-04-17 23:06:55 +08:00
|
|
|
import App from '~/layouts/App'
|
2019-12-08 04:02:22 +08:00
|
|
|
|
2020-11-19 00:52:23 +08:00
|
|
|
Prism.manual = true
|
|
|
|
|
2021-02-04 07:10:03 +08:00
|
|
|
export default function (Vue) {
|
2020-12-01 17:25:00 +08:00
|
|
|
// fix docsearch
|
2020-12-02 00:33:20 +08:00
|
|
|
if (typeof window === 'object' && !window.process) {
|
2020-12-01 17:25:00 +08:00
|
|
|
window.process = {
|
|
|
|
env: {
|
|
|
|
NODE_ENV: 'production',
|
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-10-13 00:42:47 +08:00
|
|
|
Vue.use(PortalVue)
|
2021-01-30 03:56:53 +08:00
|
|
|
|
|
|
|
Vue.directive('resize', {
|
2021-02-02 18:37:24 +08:00
|
|
|
bind: (el, { value = {} }) => {
|
|
|
|
el.addEventListener('load', () => {
|
|
|
|
iframeResize({
|
|
|
|
...value,
|
|
|
|
messageCallback(messageData) {
|
2021-02-03 05:20:16 +08:00
|
|
|
if (messageData.message.type !== 'resize') {
|
|
|
|
return
|
2021-02-02 18:37:24 +08:00
|
|
|
}
|
2021-02-03 05:20:16 +08:00
|
|
|
|
|
|
|
const style = window.getComputedStyle(el.parentElement)
|
|
|
|
const maxHeight = parseInt(style.getPropertyValue('max-height'), 10)
|
|
|
|
|
|
|
|
if (messageData.message.height > maxHeight) {
|
|
|
|
el.setAttribute('scrolling', 'auto')
|
|
|
|
} else {
|
|
|
|
el.setAttribute('scrolling', 'no')
|
|
|
|
}
|
|
|
|
|
2021-02-20 00:29:56 +08:00
|
|
|
el?.iFrameResizer?.resize?.()
|
2021-02-02 18:37:24 +08:00
|
|
|
},
|
|
|
|
}, el)
|
|
|
|
})
|
2021-01-30 03:56:53 +08:00
|
|
|
},
|
|
|
|
unbind(el) {
|
2021-02-20 00:29:56 +08:00
|
|
|
el?.iFrameResizer?.removeListeners?.()
|
2021-01-30 03:56:53 +08:00
|
|
|
},
|
|
|
|
})
|
|
|
|
|
2020-04-17 23:06:55 +08:00
|
|
|
Vue.component('Layout', App)
|
2020-10-02 16:55:55 +08:00
|
|
|
Vue.component('Demo', () => import(/* webpackChunkName: "demo" */ '~/components/Demo'))
|
2021-03-20 01:36:27 +08:00
|
|
|
Vue.component('Demos', () => import(/* webpackChunkName: "demos" */ '~/components/Demos'))
|
2021-05-01 01:42:44 +08:00
|
|
|
Vue.component('ContentMissing', () => import(/* webpackChunkName: "contentMissing" */ '~/components/ContentMissing'))
|
2019-12-08 04:02:22 +08:00
|
|
|
}
|