增加admin管理帐号和项目的界面--初步实现
This commit is contained in:
+3
@@ -0,0 +1,3 @@
|
||||
export { useContainer } from './useContainer';
|
||||
export { useResize } from './useResize';
|
||||
export { useSize, isPct, isPx, getPct, getPx } from './useSize';
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
export { useContainer } from './useContainer.mjs';
|
||||
export { useResize } from './useResize.mjs';
|
||||
export { getPct, getPx, isPct, isPx, useSize } from './useSize.mjs';
|
||||
//# sourceMappingURL=index.mjs.map
|
||||
Generated
Vendored
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;"}
|
||||
Generated
Vendored
+5
@@ -0,0 +1,5 @@
|
||||
import type { Ref } from 'vue';
|
||||
export declare function useContainer(layout: Ref<'horizontal' | 'vertical'>): {
|
||||
containerEl: Ref<HTMLDivElement | undefined>;
|
||||
containerSize: import("vue").ComputedRef<number>;
|
||||
};
|
||||
Generated
Vendored
+14
@@ -0,0 +1,14 @@
|
||||
import { ref, computed } from 'vue';
|
||||
import { useElementSize } from '@vueuse/core';
|
||||
|
||||
function useContainer(layout) {
|
||||
const containerEl = ref();
|
||||
const { width, height } = useElementSize(containerEl);
|
||||
const containerSize = computed(() => {
|
||||
return layout.value === "horizontal" ? width.value : height.value;
|
||||
});
|
||||
return { containerEl, containerSize };
|
||||
}
|
||||
|
||||
export { useContainer };
|
||||
//# sourceMappingURL=useContainer.mjs.map
|
||||
Generated
Vendored
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"useContainer.mjs","sources":["../../../../../../../packages/components/splitter/src/hooks/useContainer.ts"],"sourcesContent":["import { computed, ref } from 'vue'\nimport { useElementSize } from '@vueuse/core'\n\nimport type { Ref } from 'vue'\n\nexport function useContainer(layout: Ref<'horizontal' | 'vertical'>) {\n const containerEl = ref<HTMLDivElement>()\n const { width, height } = useElementSize(containerEl)\n\n const containerSize = computed(() => {\n return layout.value === 'horizontal' ? width.value : height.value\n })\n\n return { containerEl, containerSize }\n}\n"],"names":[],"mappings":";;;AAEO,SAAS,YAAY,CAAC,MAAM,EAAE;AACrC,EAAE,MAAM,WAAW,GAAG,GAAG,EAAE,CAAC;AAC5B,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,cAAc,CAAC,WAAW,CAAC,CAAC;AACxD,EAAE,MAAM,aAAa,GAAG,QAAQ,CAAC,MAAM;AACvC,IAAI,OAAO,MAAM,CAAC,KAAK,KAAK,YAAY,GAAG,KAAK,CAAC,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC;AACtE,GAAG,CAAC,CAAC;AACL,EAAE,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,CAAC;AACxC;;;;"}
|
||||
Generated
Vendored
+9
@@ -0,0 +1,9 @@
|
||||
import type { PanelItemState } from '../type';
|
||||
export declare function getCollapsible(collapsible: boolean | {
|
||||
start?: boolean;
|
||||
end?: boolean;
|
||||
}): {
|
||||
start?: boolean;
|
||||
end?: boolean;
|
||||
};
|
||||
export declare function isCollapsible(panel: PanelItemState | null | undefined, size: number, nextPanel: PanelItemState | null | undefined, nextSize: number): boolean;
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
import { isObject } from '@vue/shared';
|
||||
|
||||
function getCollapsible(collapsible) {
|
||||
if (collapsible && isObject(collapsible)) {
|
||||
return collapsible;
|
||||
}
|
||||
return {
|
||||
start: !!collapsible,
|
||||
end: !!collapsible
|
||||
};
|
||||
}
|
||||
function isCollapsible(panel, size, nextPanel, nextSize) {
|
||||
if ((panel == null ? void 0 : panel.collapsible.end) && size > 0) {
|
||||
return true;
|
||||
}
|
||||
if ((nextPanel == null ? void 0 : nextPanel.collapsible.start) && nextSize === 0 && size > 0) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
export { getCollapsible, isCollapsible };
|
||||
//# sourceMappingURL=usePanel.mjs.map
|
||||
Generated
Vendored
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"usePanel.mjs","sources":["../../../../../../../packages/components/splitter/src/hooks/usePanel.ts"],"sourcesContent":["import { isObject } from '@element-plus/utils'\n\nimport type { PanelItemState } from '../type'\n\nexport function getCollapsible(\n collapsible: boolean | { start?: boolean; end?: boolean }\n) {\n if (collapsible && isObject(collapsible)) {\n return collapsible\n }\n return {\n start: !!collapsible,\n end: !!collapsible,\n }\n}\n\nexport function isCollapsible(\n panel: PanelItemState | null | undefined,\n size: number,\n nextPanel: PanelItemState | null | undefined,\n nextSize: number\n) {\n // If the current panel is collapsible and has size, then it can be collapsed\n if (panel?.collapsible.end && size > 0) {\n return true\n }\n\n // If the next panel is collapsible and has no size, but the current panel has size, then it can be collapsed\n if (nextPanel?.collapsible.start && nextSize === 0 && size > 0) {\n return true\n }\n\n return false\n}\n"],"names":[],"mappings":";;AACO,SAAS,cAAc,CAAC,WAAW,EAAE;AAC5C,EAAE,IAAI,WAAW,IAAI,QAAQ,CAAC,WAAW,CAAC,EAAE;AAC5C,IAAI,OAAO,WAAW,CAAC;AACvB,GAAG;AACH,EAAE,OAAO;AACT,IAAI,KAAK,EAAE,CAAC,CAAC,WAAW;AACxB,IAAI,GAAG,EAAE,CAAC,CAAC,WAAW;AACtB,GAAG,CAAC;AACJ,CAAC;AACM,SAAS,aAAa,CAAC,KAAK,EAAE,IAAI,EAAE,SAAS,EAAE,QAAQ,EAAE;AAChE,EAAE,IAAI,CAAC,KAAK,IAAI,IAAI,GAAG,KAAK,CAAC,GAAG,KAAK,CAAC,WAAW,CAAC,GAAG,KAAK,IAAI,GAAG,CAAC,EAAE;AACpE,IAAI,OAAO,IAAI,CAAC;AAChB,GAAG;AACH,EAAE,IAAI,CAAC,SAAS,IAAI,IAAI,GAAG,KAAK,CAAC,GAAG,SAAS,CAAC,WAAW,CAAC,KAAK,KAAK,QAAQ,KAAK,CAAC,IAAI,IAAI,GAAG,CAAC,EAAE;AAChG,IAAI,OAAO,IAAI,CAAC;AAChB,GAAG;AACH,EAAE,OAAO,KAAK,CAAC;AACf;;;;"}
|
||||
Generated
Vendored
+13
@@ -0,0 +1,13 @@
|
||||
import type { ComputedRef, Ref } from 'vue';
|
||||
import type { PanelItemState } from '../type';
|
||||
export declare function useResize(panels: Ref<PanelItemState[]>, containerSize: ComputedRef<number>, pxSizes: ComputedRef<number[]>, lazy: Ref<boolean>): {
|
||||
lazyOffset: Ref<number>;
|
||||
onMoveStart: (index: number) => void;
|
||||
onMoving: (index: number, offset: number) => void;
|
||||
onMoveEnd: () => void;
|
||||
movingIndex: Ref<{
|
||||
index: number;
|
||||
confirmed: boolean;
|
||||
} | null>;
|
||||
onCollapse: (index: number, type: "start" | "end") => void;
|
||||
};
|
||||
Generated
Vendored
+125
@@ -0,0 +1,125 @@
|
||||
import { ref, computed, watch } from 'vue';
|
||||
import { isPct, getPct, isPx, getPx } from './useSize.mjs';
|
||||
import { NOOP } from '@vue/shared';
|
||||
|
||||
function useResize(panels, containerSize, pxSizes, lazy) {
|
||||
const ptg2px = (ptg) => ptg * containerSize.value || 0;
|
||||
function getLimitSize(str, defaultLimit) {
|
||||
if (isPct(str)) {
|
||||
return ptg2px(getPct(str));
|
||||
} else if (isPx(str)) {
|
||||
return getPx(str);
|
||||
}
|
||||
return str != null ? str : defaultLimit;
|
||||
}
|
||||
const lazyOffset = ref(0);
|
||||
const movingIndex = ref(null);
|
||||
let cachePxSizes = [];
|
||||
let updatePanelSizes = NOOP;
|
||||
const limitSizes = computed(() => panels.value.map((item) => [item.min, item.max]));
|
||||
watch(lazy, () => {
|
||||
if (lazyOffset.value) {
|
||||
const mouseup = new MouseEvent("mouseup", { bubbles: true });
|
||||
window.dispatchEvent(mouseup);
|
||||
}
|
||||
});
|
||||
const onMoveStart = (index) => {
|
||||
lazyOffset.value = 0;
|
||||
movingIndex.value = { index, confirmed: false };
|
||||
cachePxSizes = pxSizes.value;
|
||||
};
|
||||
const onMoving = (index, offset) => {
|
||||
var _a, _b;
|
||||
let confirmedIndex = null;
|
||||
if ((!movingIndex.value || !movingIndex.value.confirmed) && offset !== 0) {
|
||||
if (offset > 0) {
|
||||
confirmedIndex = index;
|
||||
movingIndex.value = { index, confirmed: true };
|
||||
} else {
|
||||
for (let i = index; i >= 0; i -= 1) {
|
||||
if (cachePxSizes[i] > 0) {
|
||||
confirmedIndex = i;
|
||||
movingIndex.value = { index: i, confirmed: true };
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
const mergedIndex = (_b = confirmedIndex != null ? confirmedIndex : (_a = movingIndex.value) == null ? void 0 : _a.index) != null ? _b : index;
|
||||
const numSizes = [...cachePxSizes];
|
||||
const nextIndex = mergedIndex + 1;
|
||||
const startMinSize = getLimitSize(limitSizes.value[mergedIndex][0], 0);
|
||||
const endMinSize = getLimitSize(limitSizes.value[nextIndex][0], 0);
|
||||
const startMaxSize = getLimitSize(limitSizes.value[mergedIndex][1], containerSize.value || 0);
|
||||
const endMaxSize = getLimitSize(limitSizes.value[nextIndex][1], containerSize.value || 0);
|
||||
let mergedOffset = offset;
|
||||
if (numSizes[mergedIndex] + mergedOffset < startMinSize) {
|
||||
mergedOffset = startMinSize - numSizes[mergedIndex];
|
||||
}
|
||||
if (numSizes[nextIndex] - mergedOffset < endMinSize) {
|
||||
mergedOffset = numSizes[nextIndex] - endMinSize;
|
||||
}
|
||||
if (numSizes[mergedIndex] + mergedOffset > startMaxSize) {
|
||||
mergedOffset = startMaxSize - numSizes[mergedIndex];
|
||||
}
|
||||
if (numSizes[nextIndex] - mergedOffset > endMaxSize) {
|
||||
mergedOffset = numSizes[nextIndex] - endMaxSize;
|
||||
}
|
||||
numSizes[mergedIndex] += mergedOffset;
|
||||
numSizes[nextIndex] -= mergedOffset;
|
||||
lazyOffset.value = mergedOffset;
|
||||
updatePanelSizes = () => {
|
||||
panels.value.forEach((panel, index2) => {
|
||||
panel.size = numSizes[index2];
|
||||
});
|
||||
updatePanelSizes = NOOP;
|
||||
};
|
||||
if (!lazy.value) {
|
||||
updatePanelSizes();
|
||||
}
|
||||
};
|
||||
const onMoveEnd = () => {
|
||||
if (lazy.value) {
|
||||
updatePanelSizes();
|
||||
}
|
||||
lazyOffset.value = 0;
|
||||
movingIndex.value = null;
|
||||
cachePxSizes = [];
|
||||
};
|
||||
const cacheCollapsedSize = [];
|
||||
const onCollapse = (index, type) => {
|
||||
if (!cacheCollapsedSize.length) {
|
||||
cacheCollapsedSize.push(...pxSizes.value);
|
||||
}
|
||||
const currentSizes = pxSizes.value;
|
||||
const currentIndex = type === "start" ? index : index + 1;
|
||||
const targetIndex = type === "start" ? index + 1 : index;
|
||||
const currentSize = currentSizes[currentIndex];
|
||||
const targetSize = currentSizes[targetIndex];
|
||||
if (currentSize !== 0 && targetSize !== 0) {
|
||||
currentSizes[currentIndex] = 0;
|
||||
currentSizes[targetIndex] += currentSize;
|
||||
cacheCollapsedSize[index] = currentSize;
|
||||
} else {
|
||||
const totalSize = currentSize + targetSize;
|
||||
const targetCacheCollapsedSize = cacheCollapsedSize[index];
|
||||
const currentCacheCollapsedSize = totalSize - targetCacheCollapsedSize;
|
||||
currentSizes[targetIndex] = targetCacheCollapsedSize;
|
||||
currentSizes[currentIndex] = currentCacheCollapsedSize;
|
||||
}
|
||||
panels.value.forEach((panel, index2) => {
|
||||
panel.size = currentSizes[index2];
|
||||
});
|
||||
};
|
||||
return {
|
||||
lazyOffset,
|
||||
onMoveStart,
|
||||
onMoving,
|
||||
onMoveEnd,
|
||||
movingIndex,
|
||||
onCollapse
|
||||
};
|
||||
}
|
||||
|
||||
export { useResize };
|
||||
//# sourceMappingURL=useResize.mjs.map
|
||||
Generated
Vendored
+1
File diff suppressed because one or more lines are too long
+10
@@ -0,0 +1,10 @@
|
||||
import type { ComputedRef, Ref } from 'vue';
|
||||
import type { PanelItemState } from '../type';
|
||||
export declare function getPct(str: string): number;
|
||||
export declare function getPx(str: string): number;
|
||||
export declare function isPct(itemSize: string | number | undefined): itemSize is string;
|
||||
export declare function isPx(itemSize: string | number | undefined): itemSize is string;
|
||||
export declare function useSize(panels: Ref<PanelItemState[]>, containerSize: ComputedRef<number>): {
|
||||
percentSizes: Ref<number[]>;
|
||||
pxSizes: ComputedRef<number[]>;
|
||||
};
|
||||
+56
@@ -0,0 +1,56 @@
|
||||
import { computed, ref, watch } from 'vue';
|
||||
import { isString } from '@vue/shared';
|
||||
|
||||
function getPct(str) {
|
||||
return Number(str.slice(0, -1)) / 100;
|
||||
}
|
||||
function getPx(str) {
|
||||
return Number(str.slice(0, -2));
|
||||
}
|
||||
function isPct(itemSize) {
|
||||
return isString(itemSize) && itemSize.endsWith("%");
|
||||
}
|
||||
function isPx(itemSize) {
|
||||
return isString(itemSize) && itemSize.endsWith("px");
|
||||
}
|
||||
function useSize(panels, containerSize) {
|
||||
const propSizes = computed(() => panels.value.map((i) => i.size));
|
||||
const panelCounts = computed(() => panels.value.length);
|
||||
const percentSizes = ref([]);
|
||||
watch([propSizes, panelCounts, containerSize], () => {
|
||||
var _a;
|
||||
let ptgList = [];
|
||||
let emptyCount = 0;
|
||||
for (let i = 0; i < panelCounts.value; i += 1) {
|
||||
const itemSize = (_a = panels.value[i]) == null ? void 0 : _a.size;
|
||||
if (isPct(itemSize)) {
|
||||
ptgList[i] = getPct(itemSize);
|
||||
} else if (isPx(itemSize)) {
|
||||
ptgList[i] = getPx(itemSize) / containerSize.value;
|
||||
} else if (itemSize || itemSize === 0) {
|
||||
const num = Number(itemSize);
|
||||
if (!Number.isNaN(num)) {
|
||||
ptgList[i] = num / containerSize.value;
|
||||
}
|
||||
} else {
|
||||
emptyCount += 1;
|
||||
ptgList[i] = void 0;
|
||||
}
|
||||
}
|
||||
const totalPtg = ptgList.reduce((acc, ptg) => acc + (ptg || 0), 0);
|
||||
if (totalPtg > 1 || !emptyCount) {
|
||||
const scale = 1 / totalPtg;
|
||||
ptgList = ptgList.map((ptg) => ptg === void 0 ? 0 : ptg * scale);
|
||||
} else {
|
||||
const avgRest = (1 - totalPtg) / emptyCount;
|
||||
ptgList = ptgList.map((ptg) => ptg === void 0 ? avgRest : ptg);
|
||||
}
|
||||
percentSizes.value = ptgList;
|
||||
});
|
||||
const ptg2px = (ptg) => ptg * containerSize.value;
|
||||
const pxSizes = computed(() => percentSizes.value.map(ptg2px));
|
||||
return { percentSizes, pxSizes };
|
||||
}
|
||||
|
||||
export { getPct, getPx, isPct, isPx, useSize };
|
||||
//# sourceMappingURL=useSize.mjs.map
|
||||
Generated
Vendored
+1
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user