refactor: 确立独立子工程架构 (backend, admin, mpuniapp) 并同步更新 AGENTS.md 规范

这个提交包含在:
wikiboss
2026-09-20 17:05:22 +08:00
父节点 de3cf8b870
当前提交 9fa1d1fbd0
共有 1679 个文件被更改,包括 204798 次插入 和 16817 次删除

查看文件

@@ -0,0 +1,57 @@
const platformInfo = process.env.uniTestPlatformInfo.toLocaleLowerCase()
const isWeb = platformInfo.startsWith('web')
const isMP = platformInfo.startsWith('mp')
const isHarmony = platformInfo.startsWith('harmony')
const PAGE_PATH = '/pages/component/live-player/live-player'
const NAV_BAR_HEIGHT = 44
describe('component-live-player', () => {
if (isWeb || isMP || isHarmony) {
// 不支持program.swipe
it('skip', () => {
expect(1).toBe(1)
})
return
}
if (process.env.UNI_TEST_DEVICES_DIRECTION == 'landscape') {
it('跳过横屏模式', () => {
expect(1).toBe(1)
})
return
}
let page
beforeAll(async () => {
page = await program.reLaunch(PAGE_PATH)
await page.waitFor(800)
})
it('keeps vertical scroll-view from horizontal scrolling', async () => {
const windowInfo = await program.callUniMethod('getWindowInfo')
const scrollView = await page.$('#live-player-scroll-view')
const initialScrollLeft = await scrollView.property('scrollLeft')
const rect = await page.callMethod('getScrollViewRectForTest')
expect(rect).not.toBeNull()
const y = Math.round(rect.y + windowInfo.safeAreaInsets.top + NAV_BAR_HEIGHT + 50)
await program.swipe({
startPoint: {
x: 200,
y
},
endPoint: {
x: 100,
y
},
duration: 300,
})
await page.waitFor(500)
const scrollLeft = await scrollView.property('scrollLeft')
expect(initialScrollLeft).toBe(0)
expect(scrollLeft).toBe(0)
})
})

查看文件

@@ -0,0 +1,255 @@
<template>
<view class="uni-flex-item">
<live-player id="live-player" class="live-player" :src="src" :autoplay="autoplay" :muted="muted"
:object-fit="objectFit" :background-mute="backgroundMute" :sound-mode="soundMode" :orientation="orientation"
@statechange="statechange" @fullscreenchange="fullscreenchange" @error="error">
</live-player>
<scroll-view id="live-player-scroll-view" class="uni-padding-wrap uni-common-mt uni-flex-item">
<view class="uni-title">
<text class="uni-title-text">API示例</text>
</View>
<view class="uni-btn-v">
<button type="primary" @click="play" :disabled="playState">播放</button>
</view>
<view class="uni-btn-v">
<button type="primary" @click="pause" :disabled="!playState">暂停</button>
</view>
<view class="uni-btn-v">
<button type="primary" @click="resume" :disabled="initState || playState || stopState">恢复</button>
</view>
<view class="uni-btn-v">
<button type="primary" @click="stop" :disabled="!playState">停止</button>
</view>
<view class="uni-btn-v">
<button type="primary" @click="mute" :disabled="!playState">静音</button>
</view>
<view class="uni-btn-v">
<button type="primary" @click="requestFullScreen" :disabled="!playState">进入全屏</button>
</view>
<view class="uni-btn-v">
<button type="primary" @click="exitFullScreen" :disabled="!playState">退出全屏</button>
</view>
<view class="uni-title">
<text class="uni-title-text">属性示例</text>
</view>
<input class="input margin-10" type="string" placeholder="设置播放地址" @confirm="onSrcComfirm"></input>
<boolean-data title="设置是否自动播放" :defaultValue="autoplay" @change="onAutoplayChange"></boolean-data>
<boolean-data title="设置是否静音" :defaultValue="muted" @change="onMutedChange"></boolean-data>
<boolean-data title="设置进入后台时是否静音" :defaultValue="backgroundMute" @change="onBackgroundMuteChange"></boolean-data>
<enum-data title="设置填充模式" :items="objectFitItemTypes" @change="onObjectFitChange"></enum-data>
<enum-data title="设置声音输出方式" :items="soundModeItemTypes" @change="onSoundModeChange"></enum-data>
<enum-data title="设置画面方向" :items="orientationItemTypes" @change="onOrientationChange"></enum-data>
</scroll-view>
</view>
</template>
<script setup>
import { ItemType } from '@/components/enum-data/enum-data-types';
const context = ref(null as LivePlayerContext | null);
const src = ref("");
const autoplay = ref(false);
const muted = ref(false);
const objectFit = ref("contain");
const backgroundMute = ref(false);
const soundMode = ref("speaker");
const orientation = ref("vertical");
const initState = ref(true);
const playState = ref(false);
const stopState = ref(false);
onReady(() => {
context.value = uni.createLivePlayerContext("live-player", getCurrentInstance()!.proxy);
});
const statechange = (e : UniLivePlayerStatechangeEvent) => {
console.log("statechange", e);
switch (e.detail.code) {
case 10004:
initState.value = false;
playState.value = true;
stopState.value = false;
break;
case 10009:
stopState.value = true;
case 10006:
case 10007:
case 10010:
case 10011:
playState.value = false;
break;
}
};
const fullscreenchange = (e : UniLivePlayerFullscreenchangeEvent) => {
console.log("fullscreenchange", e);
};
const error = (e : UniLivePlayerErrorEvent) => {
console.log("error", e);
};
const isSrcValid = () : boolean => {
const length = src.value.length;
if (length <= 0) {
uni.showToast({
title: "请输入播放地址",
icon: "none"
});
}
return length > 0;
};
const play = () => {
if (!isSrcValid()) return;
context.value?.play({
success: (res) => {
console.log("play", JSON.stringify(res));
},
fail: (err) => {
console.log("play", JSON.stringify(err));
},
complete: (res) => {
console.log("play", JSON.stringify(res));
}
});
};
const pause = () => {
if (!isSrcValid()) return;
context.value?.pause({
success: (res) => {
console.log("pause", JSON.stringify(res));
},
fail: (err) => {
console.log("pause", JSON.stringify(err));
},
complete: (res) => {
console.log("pause", JSON.stringify(res));
}
});
};
const resume = () => {
if (!isSrcValid()) return;
context.value?.resume({
success: (res) => {
console.log("resume", JSON.stringify(res));
},
fail: (err) => {
console.log("resume", JSON.stringify(err));
},
complete: (res) => {
console.log("resume", JSON.stringify(res));
}
});
};
const stop = () => {
if (!isSrcValid()) return;
context.value?.stop({
success: (res) => {
console.log("stop", JSON.stringify(res));
},
fail: (err) => {
console.log("stop", JSON.stringify(err));
},
complete: (res) => {
console.log("stop", JSON.stringify(res));
}
});
};
const mute = () => {
if (!isSrcValid()) return;
context.value?.mute({
success: (res) => {
console.log("mute", JSON.stringify(res));
},
fail: (err) => {
console.log("mute", JSON.stringify(err));
},
complete: (res) => {
console.log("mute", JSON.stringify(res));
}
});
};
const requestFullScreen = () => {
if (!isSrcValid()) return;
context.value?.requestFullScreen({
success: (res) => {
console.log("requestFullScreen", JSON.stringify(res));
},
fail: (err) => {
console.log("requestFullScreen", JSON.stringify(err));
},
complete: (res) => {
console.log("requestFullScreen", JSON.stringify(res));
}
});
};
const exitFullScreen = () => {
if (!isSrcValid()) return;
context.value?.exitFullScreen({
success: (res) => {
console.log("exitFullScreen", JSON.stringify(res));
},
fail: (err) => {
console.log("exitFullScreen", JSON.stringify(err));
},
complete: (res) => {
console.log("exitFullScreen", JSON.stringify(res));
}
});
};
const objectFitItemTypes = [{ "value": 0, "name": "contain" }, { "value": 1, "name": "fillCrop" }] as ItemType[];
const objectFitItems = ["contain", "fillCrop"];
const soundModeItemTypes = [{ "value": 0, "name": "speaker" }, { "value": 1, "name": "ear" }] as ItemType[];
const soundModeItems = ["speaker", "ear"];
const orientationItemTypes = [{ "value": 0, "name": "vertical" }, { "value": 1, "name": "horizontal" }] as ItemType[];
const orientationItems = ["vertical", "horizontal"];
const onSrcComfirm = (event : UniInputConfirmEvent) => {
let value = event.detail.value;
if (value == '') return;
src.value = value;
console.log("src ->", value);
};
const onAutoplayChange = (value : boolean) => {
autoplay.value = value;
console.log("autoplay ->", autoplay.value);
};
const onMutedChange = (value : boolean) => {
muted.value = value;
console.log("muted ->", muted.value);
};
const onBackgroundMuteChange = (value : boolean) => {
backgroundMute.value = value;
console.log("background-mute ->", backgroundMute.value);
};
const onObjectFitChange = (value : number) => {
objectFit.value = objectFitItems[value];
console.log("object-fit ->", objectFit.value);
};
const onSoundModeChange = (value : number) => {
soundMode.value = soundModeItems[value];
console.log("sound-mode ->", soundMode.value);
};
const onOrientationChange = (value : number) => {
orientation.value = orientationItems[value];
console.log("orientation ->", orientation.value);
};
const getScrollViewRectForTest = () : DOMRect | null => {
return uni.getElementById('live-player-scroll-view')?.getBoundingClientRect() ?? null;
};
defineExpose({
getScrollViewRectForTest
});
</script>
<style>
.live-player {
width: 100%;
height: 40%;
}
.input {
height: 40px;
background: #FFF;
padding: 8px 13px;
}
</style>