Initial commit: GamePortrait 竖屏版 - 深色豪华主题

This commit is contained in:
li
2026-01-16 17:47:53 +08:00
commit 40976e4b45
26611 changed files with 2843638 additions and 0 deletions
+3
View File
@@ -0,0 +1,3 @@
import { InjectionKey } from 'vue';
export declare const POPUP_TOGGLE_KEY: InjectionKey<() => boolean>;
export declare function onPopupReopen(callback: () => void): void;
+16
View File
@@ -0,0 +1,16 @@
import { inject, watch } from "vue";
const POPUP_TOGGLE_KEY = Symbol();
function onPopupReopen(callback) {
const popupToggleStatus = inject(POPUP_TOGGLE_KEY, null);
if (popupToggleStatus) {
watch(popupToggleStatus, (show) => {
if (show) {
callback();
}
});
}
}
export {
POPUP_TOGGLE_KEY,
onPopupReopen
};
+1
View File
@@ -0,0 +1 @@
export declare function useExpose<T = Record<string, any>>(apis: T): void;
+11
View File
@@ -0,0 +1,11 @@
import { getCurrentInstance } from "vue";
import { extend } from "../utils/index.mjs";
function useExpose(apis) {
const instance = getCurrentInstance();
if (instance) {
extend(instance.proxy, apis);
}
}
export {
useExpose
};
+4
View File
@@ -0,0 +1,4 @@
/** the global z-index is automatically incremented after reading */
export declare const useGlobalZIndex: () => number;
/** reset the global z-index */
export declare const setGlobalZIndex: (val: number) => void;
+9
View File
@@ -0,0 +1,9 @@
let globalZIndex = 2e3;
const useGlobalZIndex = () => ++globalZIndex;
const setGlobalZIndex = (val) => {
globalZIndex = val;
};
export {
setGlobalZIndex,
useGlobalZIndex
};
+2
View File
@@ -0,0 +1,2 @@
import { Ref } from 'vue';
export declare const useHeight: (element: Element | Ref<Element | undefined>, withSafeArea?: boolean) => Ref<number | undefined>;
+24
View File
@@ -0,0 +1,24 @@
import { useRect } from "@vant/use";
import { ref, onMounted, nextTick, watch } from "vue";
import { windowHeight, windowWidth } from "../utils/index.mjs";
import { onPopupReopen } from "./on-popup-reopen.mjs";
const useHeight = (element, withSafeArea) => {
const height = ref();
const setHeight = () => {
height.value = useRect(element).height;
};
onMounted(() => {
nextTick(setHeight);
if (withSafeArea) {
for (let i = 1; i <= 3; i++) {
setTimeout(setHeight, 100 * i);
}
}
});
onPopupReopen(() => nextTick(setHeight));
watch([windowWidth, windowHeight], setHeight);
return height;
};
export {
useHeight
};
+1
View File
@@ -0,0 +1 @@
export declare function useId(): string;
+13
View File
@@ -0,0 +1,13 @@
import { getCurrentInstance } from "vue";
let current = 0;
function useId() {
const vm = getCurrentInstance();
const { name = "unknown" } = (vm == null ? void 0 : vm.type) || {};
if (process.env.NODE_ENV === "test") {
return name;
}
return `${name}-${++current}`;
}
export {
useId
};
+2
View File
@@ -0,0 +1,2 @@
import { WatchSource } from 'vue';
export declare function useLazyRender(show: WatchSource<boolean | undefined>): (render: () => JSX.Element) => () => JSX.Element | null;
+17
View File
@@ -0,0 +1,17 @@
import { ref, watch } from "vue";
function useLazyRender(show) {
const inited = ref(false);
watch(
show,
(value) => {
if (value) {
inited.value = value;
}
},
{ immediate: true }
);
return (render) => () => inited.value ? render() : null;
}
export {
useLazyRender
};
+2
View File
@@ -0,0 +1,2 @@
import { Ref } from 'vue';
export declare function useLockScroll(rootRef: Ref<HTMLElement | undefined>, shouldLock: () => boolean): void;
+58
View File
@@ -0,0 +1,58 @@
import { watch, onBeforeUnmount, onDeactivated } from "vue";
import { getScrollParent, onMountedOrActivated } from "@vant/use";
import { useTouch } from "./use-touch.mjs";
import { preventDefault } from "../utils/index.mjs";
let totalLockCount = 0;
const BODY_LOCK_CLASS = "van-overflow-hidden";
function useLockScroll(rootRef, shouldLock) {
const touch = useTouch();
const DIRECTION_UP = "01";
const DIRECTION_DOWN = "10";
const onTouchMove = (event) => {
touch.move(event);
const direction = touch.deltaY.value > 0 ? DIRECTION_DOWN : DIRECTION_UP;
const el = getScrollParent(
event.target,
rootRef.value
);
const { scrollHeight, offsetHeight, scrollTop } = el;
let status = "11";
if (scrollTop === 0) {
status = offsetHeight >= scrollHeight ? "00" : "01";
} else if (scrollTop + offsetHeight >= scrollHeight) {
status = "10";
}
if (status !== "11" && touch.isVertical() && !(parseInt(status, 2) & parseInt(direction, 2))) {
preventDefault(event, true);
}
};
const lock = () => {
document.addEventListener("touchstart", touch.start);
document.addEventListener("touchmove", onTouchMove, { passive: false });
if (!totalLockCount) {
document.body.classList.add(BODY_LOCK_CLASS);
}
totalLockCount++;
};
const unlock = () => {
if (totalLockCount) {
document.removeEventListener("touchstart", touch.start);
document.removeEventListener("touchmove", onTouchMove);
totalLockCount--;
if (!totalLockCount) {
document.body.classList.remove(BODY_LOCK_CLASS);
}
}
};
const init = () => shouldLock() && lock();
const destroy = () => shouldLock() && unlock();
onMountedOrActivated(init);
onDeactivated(destroy);
onBeforeUnmount(destroy);
watch(shouldLock, (value) => {
value ? lock() : unlock();
});
}
export {
useLockScroll
};
+3
View File
@@ -0,0 +1,3 @@
import { Ref } from 'vue';
import type { BEM } from '../utils/create';
export declare function usePlaceholder(contentRef: Ref<Element | undefined>, bem: BEM): (renderContent: () => JSX.Element) => JSX.Element;
+14
View File
@@ -0,0 +1,14 @@
import { createVNode as _createVNode } from "vue";
import { useHeight } from "./use-height.mjs";
function usePlaceholder(contentRef, bem) {
const height = useHeight(contentRef, true);
return (renderContent) => _createVNode("div", {
"class": bem("placeholder"),
"style": {
height: height.value ? `${height.value}px` : void 0
}
}, [renderContent()]);
}
export {
usePlaceholder
};
+2
View File
@@ -0,0 +1,2 @@
import { Ref } from 'vue';
export declare function useRefs<T = Element>(): readonly [Ref<T[]>, (index: number) => (el: unknown) => void];
+20
View File
@@ -0,0 +1,20 @@
import { ref, onBeforeUpdate } from "vue";
function useRefs() {
const refs = ref([]);
const cache = [];
onBeforeUpdate(() => {
refs.value = [];
});
const setRefs = (index) => {
if (!cache[index]) {
cache[index] = (el) => {
refs.value[index] = el;
};
}
return cache[index];
};
return [refs, setRefs];
}
export {
useRefs
};
+13
View File
@@ -0,0 +1,13 @@
/**
* Vue Router support
*/
import { type PropType, type ExtractPropTypes, type ComponentPublicInstance } from 'vue';
import type { RouteLocationRaw } from 'vue-router';
export declare const routeProps: {
to: PropType<RouteLocationRaw>;
url: StringConstructor;
replace: BooleanConstructor;
};
export type RouteProps = ExtractPropTypes<typeof routeProps>;
export declare function route({ to, url, replace, $router: router, }: ComponentPublicInstance<RouteProps>): void;
export declare function useRoute(): () => void;
+29
View File
@@ -0,0 +1,29 @@
import {
getCurrentInstance
} from "vue";
const routeProps = {
to: [String, Object],
url: String,
replace: Boolean
};
function route({
to,
url,
replace,
$router: router
}) {
if (to && router) {
router[replace ? "replace" : "push"](to);
} else if (url) {
replace ? location.replace(url) : location.href = url;
}
}
function useRoute() {
const vm = getCurrentInstance().proxy;
return () => route(vm);
}
export {
route,
routeProps,
useRoute
};
+2
View File
@@ -0,0 +1,2 @@
import { Ref } from 'vue';
export declare const useSyncPropRef: <T>(getProp: () => T, setProp: (value: T) => void) => Ref<T>;
+18
View File
@@ -0,0 +1,18 @@
import { ref, watch } from "vue";
const useSyncPropRef = (getProp, setProp) => {
const propRef = ref(getProp());
watch(getProp, (value) => {
if (value !== propRef.value) {
propRef.value = value;
}
});
watch(propRef, (value) => {
if (value !== getProp()) {
setProp(value);
}
});
return propRef;
};
export {
useSyncPropRef
};
+3
View File
@@ -0,0 +1,3 @@
import { ComputedRef, InjectionKey } from 'vue';
export declare const TAB_STATUS_KEY: InjectionKey<ComputedRef<boolean>>;
export declare const useTabStatus: () => ComputedRef<boolean> | null;
+7
View File
@@ -0,0 +1,7 @@
import { inject } from "vue";
const TAB_STATUS_KEY = Symbol();
const useTabStatus = () => inject(TAB_STATUS_KEY, null);
export {
TAB_STATUS_KEY,
useTabStatus
};
+16
View File
@@ -0,0 +1,16 @@
type Direction = '' | 'vertical' | 'horizontal';
export declare function useTouch(): {
move: EventListener;
start: EventListener;
reset: () => void;
startX: import("vue").Ref<number>;
startY: import("vue").Ref<number>;
deltaX: import("vue").Ref<number>;
deltaY: import("vue").Ref<number>;
offsetX: import("vue").Ref<number>;
offsetY: import("vue").Ref<number>;
direction: import("vue").Ref<Direction>;
isVertical: () => boolean;
isHorizontal: () => boolean;
};
export {};
+61
View File
@@ -0,0 +1,61 @@
import { ref } from "vue";
function getDirection(x, y) {
if (x > y) {
return "horizontal";
}
if (y > x) {
return "vertical";
}
return "";
}
function useTouch() {
const startX = ref(0);
const startY = ref(0);
const deltaX = ref(0);
const deltaY = ref(0);
const offsetX = ref(0);
const offsetY = ref(0);
const direction = ref("");
const isVertical = () => direction.value === "vertical";
const isHorizontal = () => direction.value === "horizontal";
const reset = () => {
deltaX.value = 0;
deltaY.value = 0;
offsetX.value = 0;
offsetY.value = 0;
direction.value = "";
};
const start = (event) => {
reset();
startX.value = event.touches[0].clientX;
startY.value = event.touches[0].clientY;
};
const move = (event) => {
const touch = event.touches[0];
deltaX.value = (touch.clientX < 0 ? 0 : touch.clientX) - startX.value;
deltaY.value = touch.clientY - startY.value;
offsetX.value = Math.abs(deltaX.value);
offsetY.value = Math.abs(deltaY.value);
const LOCK_DIRECTION_DISTANCE = 10;
if (!direction.value || offsetX.value < LOCK_DIRECTION_DISTANCE && offsetY.value < LOCK_DIRECTION_DISTANCE) {
direction.value = getDirection(offsetX.value, offsetY.value);
}
};
return {
move,
start,
reset,
startX,
startY,
deltaX,
deltaY,
offsetX,
offsetY,
direction,
isVertical,
isHorizontal
};
}
export {
useTouch
};
+2
View File
@@ -0,0 +1,2 @@
import { Ref } from 'vue';
export declare function useVisibilityChange(target: Ref<Element | undefined>, onChange: (visible: boolean) => void): void;
+30
View File
@@ -0,0 +1,30 @@
import { inBrowser } from "../utils/index.mjs";
import { onDeactivated, onBeforeUnmount } from "vue";
import { onMountedOrActivated } from "@vant/use";
function useVisibilityChange(target, onChange) {
if (!inBrowser || !window.IntersectionObserver) {
return;
}
const observer = new IntersectionObserver(
(entries) => {
onChange(entries[0].intersectionRatio > 0);
},
{ root: document.body }
);
const observe = () => {
if (target.value) {
observer.observe(target.value);
}
};
const unobserve = () => {
if (target.value) {
observer.unobserve(target.value);
}
};
onDeactivated(unobserve);
onBeforeUnmount(unobserve);
onMountedOrActivated(observe);
}
export {
useVisibilityChange
};