chore: some changes
This commit is contained in:
parent
9ce80f55d2
commit
86f115c3d0
|
|
@ -64,10 +64,6 @@ export default {
|
|||
'body__footer--border': props.footerBorder
|
||||
}))
|
||||
|
||||
function getScrollbarVertical () {
|
||||
return scrollbarRef.value.$el.getElementsByClassName('os-scrollbar-vertical')[0]
|
||||
}
|
||||
|
||||
function refreshSlotStatus () {
|
||||
headerActive.value = !!slots.header
|
||||
footerActive.value = !!slots.footer
|
||||
|
|
@ -80,16 +76,17 @@ export default {
|
|||
}
|
||||
|
||||
refreshSlotStatus()
|
||||
|
||||
onUpdated(() => {
|
||||
refreshSlotStatus()
|
||||
})
|
||||
|
||||
onMounted(() => {
|
||||
watchPostEffect(() => {
|
||||
getScrollbarVertical().style.top = px(scrollbarVerticalTop)
|
||||
scrollbarRef.value.scrollbarVertical.style.top = px(scrollbarVerticalTop)
|
||||
})
|
||||
watchPostEffect(() => {
|
||||
getScrollbarVertical().style.bottom = px(bodyFooterHeight)
|
||||
scrollbarRef.value.scrollbarVertical.style.bottom = px(bodyFooterHeight)
|
||||
})
|
||||
})
|
||||
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ import { makeName, makeClassName } from 'd2/utils/framework/component.js'
|
|||
import os from 'overlayscrollbars'
|
||||
import 'overlayscrollbars/css/OverlayScrollbars.css'
|
||||
|
||||
export const callbacks = [
|
||||
export const osCallbacks = [
|
||||
'onInitialized',
|
||||
'onInitializationWithdrawn',
|
||||
'onDestroyed',
|
||||
|
|
@ -20,7 +20,9 @@ export const callbacks = [
|
|||
'onUpdated'
|
||||
]
|
||||
|
||||
export const emits = callbacks.map(name => kebabCase(name.replace(/^on/, '')))
|
||||
const osCallbackToEmitName = name => kebabCase(name.replace(/^on/, ''))
|
||||
|
||||
export const emits = osCallbacks.map(osCallbackToEmitName)
|
||||
|
||||
const name = 'scroll'
|
||||
|
||||
|
|
@ -46,7 +48,10 @@ export default defineComponent({
|
|||
'scroll-bottom'
|
||||
],
|
||||
setup (props, { emit, attrs }) {
|
||||
const target = ref(null)
|
||||
const scrollbarTarget = ref(null)
|
||||
|
||||
const scrollbarVertical = ref(null)
|
||||
const scrollbarHorizontal = ref(null)
|
||||
|
||||
const instance = ref(null)
|
||||
|
||||
|
|
@ -58,18 +63,18 @@ export default defineComponent({
|
|||
autoHide: 'leave',
|
||||
autoHideDelay: 300
|
||||
},
|
||||
callbacks: fromPairs(callbacks.map(name => {
|
||||
const emitName = kebabCase(name.replace(/^on/, ''))
|
||||
callbacks: fromPairs(osCallbacks.map(name => {
|
||||
const emitName = osCallbackToEmitName(name)
|
||||
let callback = () => {}
|
||||
switch (name) {
|
||||
case 'onScroll':
|
||||
callback = event => {
|
||||
const information = unref(instance).scroll()
|
||||
const ratioY = information.ratio.y
|
||||
const info = unref(instance).scroll()
|
||||
const ratioY = info.ratio.y
|
||||
emit(emitName, event)
|
||||
const cordonY = information.max.y - information.position.y
|
||||
const cordonX = information.max.x - information.position.x
|
||||
if (cordonY <= -props.cordonY) emit('in-cordon-y', event)
|
||||
const cordonY = info.max.y - info.position.y
|
||||
const cordonX = info.max.x - info.position.x
|
||||
if (cordonY <= props.cordonY) emit('in-cordon-y', event)
|
||||
if (cordonX <= props.cordonX) emit('in-cordon-x', event)
|
||||
if (ratioY === 0) emit('scroll-top', event)
|
||||
if (ratioY === 1) emit('scroll-bottom', event)
|
||||
|
|
@ -96,7 +101,7 @@ export default defineComponent({
|
|||
}
|
||||
}
|
||||
})
|
||||
}``
|
||||
}
|
||||
}
|
||||
|
||||
const merge = options => mergeWith({}, unref(optionsDefault), options, customizer)
|
||||
|
|
@ -111,7 +116,7 @@ export default defineComponent({
|
|||
|
||||
function init () {
|
||||
instance.value = os(
|
||||
unref(target),
|
||||
unref(scrollbarTarget),
|
||||
unref(options),
|
||||
props.extensions
|
||||
)
|
||||
|
|
@ -131,7 +136,9 @@ export default defineComponent({
|
|||
const classnames = computed(() => makeClassnames(classname, attrs.class))
|
||||
|
||||
return {
|
||||
target,
|
||||
scrollbarTarget,
|
||||
scrollbarVertical,
|
||||
scrollbarHorizontal,
|
||||
classnames,
|
||||
instance
|
||||
}
|
||||
|
|
@ -141,7 +148,7 @@ export default defineComponent({
|
|||
classnames
|
||||
} = this
|
||||
return (
|
||||
<div ref="target" class="os-host" class={ classnames }>
|
||||
<div ref="scrollbarTarget" class="os-host" class={ classnames }>
|
||||
<div class="os-resize-observer-host"/>
|
||||
<div class="os-padding">
|
||||
<div class="os-viewport">
|
||||
|
|
@ -150,12 +157,12 @@ export default defineComponent({
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="os-scrollbar os-scrollbar-horizontal">
|
||||
<div ref="scrollbarHorizontal" class="os-scrollbar os-scrollbar-horizontal">
|
||||
<div class="os-scrollbar-track">
|
||||
<div class="os-scrollbar-handle"/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="os-scrollbar os-scrollbar-vertical">
|
||||
<div ref="scrollbarVertical" class="os-scrollbar os-scrollbar-vertical">
|
||||
<div class="os-scrollbar-track">
|
||||
<div class="os-scrollbar-handle"/>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -96,11 +96,11 @@ const routesFlat = flattenObjectArray(
|
|||
(item, _) => pick(item, ['name', 'path', 'meta'])
|
||||
)
|
||||
|
||||
function filterRoutes (rule) {
|
||||
return routesFlat.filter(route => rule.test(route.name))
|
||||
export function filterRoutes (routeNameExp) {
|
||||
return routesFlat.filter(route => routeNameExp.test(route.name))
|
||||
}
|
||||
|
||||
function createRouteMenu (route, baseUrl) {
|
||||
export function createRouteMenu (route, baseUrl) {
|
||||
const url = baseUrl + route.path
|
||||
const title = get(route.meta, 'd2admin.menu.title', route.path)
|
||||
const menu = new Menu(title)
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
<route>
|
||||
{
|
||||
"meta": {
|
||||
"d2admin.menu.title": "-"
|
||||
"d2admin.menu.title": "基础"
|
||||
}
|
||||
}
|
||||
</route>
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
<route>
|
||||
{
|
||||
"meta": {
|
||||
"d2admin.menu.title": "-"
|
||||
"d2admin.menu.title": "绑定数据"
|
||||
}
|
||||
}
|
||||
</route>
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
<route>
|
||||
{
|
||||
"meta": {
|
||||
"d2admin.menu.title": "-"
|
||||
"d2admin.menu.title": "基础"
|
||||
}
|
||||
}
|
||||
</route>
|
||||
|
|
|
|||
|
|
@ -1,15 +1,8 @@
|
|||
<style lang="scss" scoped>
|
||||
.d2-scroll--demo {
|
||||
height: 200px;
|
||||
width: 200px;
|
||||
@apply border-2 border-gray-400 rounded bg-gray-50 w-60 h-60;
|
||||
.row {
|
||||
@apply px-4 py-2 text-gray-100 bg-gray-700 border-b border-gray-800 cursor-pointer;
|
||||
&:hover {
|
||||
@apply text-gray-200 bg-gray-800;
|
||||
}
|
||||
&:last-child {
|
||||
@apply border-b-0;
|
||||
}
|
||||
@apply px-1 py-1 text-gray-400 cursor-pointer;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
|
@ -17,7 +10,7 @@
|
|||
<route>
|
||||
{
|
||||
"meta": {
|
||||
"d2admin.menu.title": "-"
|
||||
"d2admin.menu.title": "基础"
|
||||
}
|
||||
}
|
||||
</route>
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
<route>
|
||||
{
|
||||
"meta": {
|
||||
"d2admin.menu.title": "-"
|
||||
"d2admin.menu.title": "基础"
|
||||
}
|
||||
}
|
||||
</route>
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
<route>
|
||||
{
|
||||
"meta": {
|
||||
"d2admin.menu.title": "-"
|
||||
"d2admin.menu.title": "尺寸"
|
||||
}
|
||||
}
|
||||
</route>
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
<route>
|
||||
{
|
||||
"meta": {
|
||||
"d2admin.menu.title": "-"
|
||||
"d2admin.menu.title": "基础"
|
||||
}
|
||||
}
|
||||
</route>
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
<route>
|
||||
{
|
||||
"meta": {
|
||||
"d2admin.menu.title": "-"
|
||||
"d2admin.menu.title": "文档页面 1"
|
||||
}
|
||||
}
|
||||
</route>
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
<route>
|
||||
{
|
||||
"meta": {
|
||||
"d2admin.menu.title": "-"
|
||||
"d2admin.menu.title": "文档页面 2"
|
||||
}
|
||||
}
|
||||
</route>
|
||||
|
|
|
|||
|
|
@ -1,11 +1,3 @@
|
|||
<route>
|
||||
{
|
||||
"meta": {
|
||||
"d2admin.menu.title": "-"
|
||||
}
|
||||
}
|
||||
</route>
|
||||
|
||||
<template>
|
||||
<d2-admin-layout-dashboard>
|
||||
<template #footer>
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
<route>
|
||||
{
|
||||
"meta": {
|
||||
"d2admin.menu.title": "-"
|
||||
"d2admin.menu.title": "第一个页面"
|
||||
}
|
||||
}
|
||||
</route>
|
||||
|
|
|
|||
|
|
@ -1,11 +1,3 @@
|
|||
<route>
|
||||
{
|
||||
"meta": {
|
||||
"d2admin.menu.title": "-"
|
||||
}
|
||||
}
|
||||
</route>
|
||||
|
||||
<template>
|
||||
<demo-page-placeholder/>
|
||||
</template>
|
||||
|
|
|
|||
|
|
@ -1,11 +1,3 @@
|
|||
<route>
|
||||
{
|
||||
"meta": {
|
||||
"d2admin.menu.title": "-"
|
||||
}
|
||||
}
|
||||
</route>
|
||||
|
||||
<template>
|
||||
<router-link to="/dashboard">
|
||||
<a-button type="link">控制台</a-button>
|
||||
|
|
|
|||
|
|
@ -1,11 +1,3 @@
|
|||
<route>
|
||||
{
|
||||
"meta": {
|
||||
"d2admin.menu.title": "-"
|
||||
}
|
||||
}
|
||||
</route>
|
||||
|
||||
<template>
|
||||
<div>
|
||||
登录
|
||||
|
|
|
|||
Loading…
Reference in New Issue