0218 改变日期函数处理

This commit is contained in:
pm 2025-02-18 21:58:52 +08:00
parent 743f30cbb9
commit f1968de5d9
3 changed files with 124 additions and 107 deletions

View File

@ -8,7 +8,7 @@
<div class="search-area">
<div class="search-item">
<label for="year">年度:</label>
<input type="number" v-model="year" class="year-input"/>
<input type="number" v-model="year" class="year-input" @change="handleChangeYear" />
</div>
<div class="search-item">
<label for="taskName">任务名称:</label>
@ -116,9 +116,7 @@ export default {
try {
const data = {
command: "SearchTask",
year: this.year,
taskName: this.taskName
command: "LoadScenario"
}
webrtc.webrtc.emitUIInter(data);
} catch (error) {
@ -136,6 +134,18 @@ export default {
console.error('Error in emitCommand:', error);
}
},
handleChangeYear() {
const data = {
command: "LoadScenarioTask",
year: this.year
};
try {
webrtc.webrtc.emitUIInter(data);
} catch (error) {
console.error('Error in emitCommand:', error);
}
},
},
created() {
this.initData();
@ -216,7 +226,8 @@ h2 {
width: 100px;
}
input, select {
input,
select {
background-color: #1e2c42;
border: 1px solid #3a4b66;
color: white;
@ -238,7 +249,8 @@ table {
background-color: #1e2c42;
}
th, td {
th,
td {
border: 1px solid #3a4b66;
padding: 4px;
text-align: center;
@ -289,7 +301,8 @@ button {
line-height: 16px;
}
.search-btn, .reset-btn {
.search-btn,
.reset-btn {
padding: 2px 8px;
height: 20px;
line-height: 16px;

View File

@ -307,7 +307,7 @@ function sendStartLatencyTest() {
return;
}
let onTestStarted = function(StartTimeMs) {
let onTestStarted = function (StartTimeMs) {
let descriptor = {
StartTime: StartTimeMs
};
@ -372,8 +372,8 @@ function showTextOverlay(text) {
function playVideoStream() {
if (webRtcPlayerObj && webRtcPlayerObj.video) {
webRtcPlayerObj.video.muted=true;
webRtcPlayerObj.video.play().catch(function(onRejectedReason){
webRtcPlayerObj.video.muted = true;
webRtcPlayerObj.video.play().catch(function (onRejectedReason) {
console.error(onRejectedReason);
console.log("Browser does not support autoplaying video without interaction - to resolve this we are going to show the play button overlay.")
showPlayOverlay();
@ -424,7 +424,7 @@ function showAfkOverlay() {
document.exitPointerLock();
}
afk.countdownTimer = setInterval(function() {
afk.countdownTimer = setInterval(function () {
afk.countdown--;
if (afk.countdown == 0) {
// The user failed to click so disconnect them.
@ -507,7 +507,7 @@ function setupWebRtcPlayer(htmlElement, config) {
htmlElement.appendChild(webRtcPlayerObj.video);
htmlElement.appendChild(freezeFrameOverlay);
webRtcPlayerObj.onWebRtcOffer = function(offer) {
webRtcPlayerObj.onWebRtcOffer = function (offer) {
if (ws && ws.readyState === WS_OPEN_STATE) {
let offerStr = JSON.stringify(offer);
// console.log(`-> SS: offer:\n${offerStr}`);
@ -515,7 +515,7 @@ function setupWebRtcPlayer(htmlElement, config) {
}
};
webRtcPlayerObj.onWebRtcCandidate = function(candidate) {
webRtcPlayerObj.onWebRtcCandidate = function (candidate) {
if (ws && ws.readyState === WS_OPEN_STATE) {
//console.log(`-> SS: iceCandidate\n${JSON.stringify(candidate, undefined, 4)}`);
ws.send(JSON.stringify({
@ -525,7 +525,7 @@ function setupWebRtcPlayer(htmlElement, config) {
}
};
webRtcPlayerObj.onVideoInitialised = function() {
webRtcPlayerObj.onVideoInitialised = function () {
if (ws && ws.readyState === WS_OPEN_STATE) {
if (shouldShowPlayOverlay) {
showPlayOverlay();
@ -538,7 +538,7 @@ function setupWebRtcPlayer(htmlElement, config) {
}
};
webRtcPlayerObj.onDataChannelConnected = function() {
webRtcPlayerObj.onDataChannelConnected = function () {
if (ws && ws.readyState === WS_OPEN_STATE) {
showTextOverlay('WebRTC connected, waiting for video');
@ -552,7 +552,7 @@ function setupWebRtcPlayer(htmlElement, config) {
let base64 = btoa(freezeFrame.jpeg.reduce((data, byte) => data + String.fromCharCode(byte), ''));
let freezeFrameImage = document.getElementById("freezeFrameOverlay").childNodes[0];
freezeFrameImage.src = 'data:image/jpeg;base64,' + base64;
freezeFrameImage.onload = function() {
freezeFrameImage.onload = function () {
freezeFrame.height = freezeFrameImage.naturalHeight;
freezeFrame.width = freezeFrameImage.naturalWidth;
resizeFreezeFrameOverlay();
@ -613,7 +613,7 @@ function setupWebRtcPlayer(htmlElement, config) {
}
}
webRtcPlayerObj.onDataChannelMessage = function(data) {
webRtcPlayerObj.onDataChannelMessage = function (data) {
let view = new Uint8Array(data);
if (view[0] === ToClientMessageType.QualityControlOwnership) {
@ -691,7 +691,7 @@ function setupWebRtcPlayer(htmlElement, config) {
return webRtcPlayerObj.video;
}
let receivedBytesMeasurement=undefined;
let receivedBytesMeasurement = undefined;
let receivedBytes = undefined;
function onWebRtcAnswer(webRTCData) {
webRtcPlayerObj.receiveAnswer(webRTCData);
@ -735,11 +735,11 @@ function onWebRtcAnswer(webRTCData) {
let qualityStatus = document.getElementById("qualityStatus");
// "blinks" quality status element for 1 sec by making it transparent, speed = number of blinks
let blinkQualityStatus = function(speed) {
let blinkQualityStatus = function (speed) {
let iter = speed;
let opacity = 1; // [0..1]
let tickId = setInterval(
function() {
function () {
// opacity -= 0.1;
// // map `opacity` to [-0.5..0.5] range, decrement by 0.2 per step and take `abs` to make it blink: 1 -> 0 -> 1
@ -775,8 +775,7 @@ function onWebRtcAnswer(webRTCData) {
// qualityStatus.className = `${color}Status`;
statsText += `<div>Duration: ${timeFormat.format(runTimeHours)}:${timeFormat.format(runTimeMinutes)}:${timeFormat.format(runTimeSeconds)}</div>`;
statsText += `<div>Video Resolution: ${
aggregatedStats.hasOwnProperty('frameWidth') && aggregatedStats.frameWidth && aggregatedStats.hasOwnProperty('frameHeight') && aggregatedStats.frameHeight ?
statsText += `<div>Video Resolution: ${aggregatedStats.hasOwnProperty('frameWidth') && aggregatedStats.frameWidth && aggregatedStats.hasOwnProperty('frameHeight') && aggregatedStats.frameHeight ?
aggregatedStats.frameWidth + 'x' + aggregatedStats.frameHeight : 'Chrome only'
}</div>`;
statsText += `<div>Received (${receivedBytesMeasurement}): ${numberFormat.format(receivedBytes)}</div>`;
@ -808,9 +807,9 @@ function onWebRtcAnswer(webRTCData) {
}
};
webRtcPlayerObj.aggregateStats(1 * 1000 /*Check every 1 second*/ );
webRtcPlayerObj.aggregateStats(1 * 1000 /*Check every 1 second*/);
webRtcPlayerObj.latencyTestTimings.OnAllLatencyTimingsReady = function(timings) {
webRtcPlayerObj.latencyTestTimings.OnAllLatencyTimingsReady = function (timings) {
if (!timings.BrowserReceiptTimeMs) {
return;
@ -942,7 +941,7 @@ function resizePlayerStyleToActualSize(playerElement) {
function resizePlayerStyleToArbitrarySize(playerElement) {
let videoElement = playerElement.getElementsByTagName("VIDEO");
console.log("resizePlayerStyleToArbitrarySize ");
if(videoElement.length>0)console.log(videoElement[0].videoWidth+"/"+videoElement[0].videoHeight)
if (videoElement.length > 0) console.log(videoElement[0].videoWidth + "/" + videoElement[0].videoHeight)
//Video is now 100% of the playerElement, so set the playerElement style
playerElement.style = "top: 0px; left: 0px; width: " + styleWidth + "px; height: " + styleHeight + "px; cursor: " + styleCursor + "; " + styleAdditional;
}
@ -1034,7 +1033,7 @@ function resizePlayerStyle(event) {
if (!playerElement)
return;
console.log("resizePlayerStyle");
console.log("resizePlayerStyle");
updateVideoStreamSize();
if (playerElement.classList.contains('fixed-size')) {
@ -1046,7 +1045,7 @@ console.log("resizePlayerStyle");
let checkBox = document.getElementById('enlarge-display-to-fill-window-tgl');
let windowSmallerThanPlayer = window.innerWidth < playerElement.videoWidth || window.innerHeight < playerElement.videoHeight;
console.log(playerElement);
console.log(playerElement.videoWidth+" "+playerElement.videoHeight);
console.log(playerElement.videoWidth + " " + playerElement.videoHeight);
if (checkBox !== null) {
if (checkBox.checked || windowSmallerThanPlayer) {
resizePlayerStyleToFillWindow(playerElement);
@ -1082,7 +1081,7 @@ function updateVideoStreamSize() {
let descriptor = {
Console: 'setres ' + playerElement.clientWidth + 'x' + playerElement.clientHeight
};
console.log("updateVideoStreamSize:"+playerElement.clientWidth+"======="+playerElement.clientHeight);
console.log("updateVideoStreamSize:" + playerElement.clientWidth + "=======" + playerElement.clientHeight);
emitUIInteraction(descriptor);
console.log(descriptor);
lastTimeResized = new Date().getTime();
@ -1099,7 +1098,7 @@ let _orientationChangeTimeout;
function onOrientationChange(event) {
clearTimeout(_orientationChangeTimeout);
_orientationChangeTimeout = setTimeout(function() {
_orientationChangeTimeout = setTimeout(function () {
resizePlayerStyle();
}, 500);
}
@ -1210,7 +1209,7 @@ function requestQualityControl() {
let playerElementClientRect = undefined;
let normalizeAndQuantizeUnsigned = undefined;
let normalizeAndQuantizeSigned = undefined;
let unquantizeAndDenormalizeUnsigned=undefined;
let unquantizeAndDenormalizeUnsigned = undefined;
function setupNormalizeAndQuantize() {
let playerElement = document.getElementById('web_rtc_player');
@ -1448,7 +1447,7 @@ function createOnScreenKeyboardHelpers(htmlElement) {
// Hide the 'edit text' button.
editTextButton.classList.add('hiddenState');
editTextButton.addEventListener('click', function() {
editTextButton.addEventListener('click', function () {
// Show the on-screen keyboard.
hiddenInput.focus();
});
@ -1472,7 +1471,7 @@ function showOnScreenKeyboard(command) {
}
function registerMouseEnterAndLeaveEvents(playerElement) {
playerElement.onmouseenter = function(e) {
playerElement.onmouseenter = function (e) {
if (print_inputs) {
// console.log('mouse enter');
}
@ -1482,7 +1481,7 @@ function registerMouseEnterAndLeaveEvents(playerElement) {
playerElement.pressMouseButtons(e);
};
playerElement.onmouseleave = function(e) {
playerElement.onmouseleave = function (e) {
if (print_inputs) {
// console.log('mouse leave');
}
@ -1503,7 +1502,7 @@ function registerLockedMouseEvents(playerElement) {
playerElement.requestPointerLock = playerElement.requestPointerLock || playerElement.mozRequestPointerLock;
document.exitPointerLock = document.exitPointerLock || document.mozExitPointerLock;
playerElement.onclick = function() {
playerElement.onclick = function () {
playerElement.requestPointerLock();
};
@ -1540,23 +1539,23 @@ function registerLockedMouseEvents(playerElement) {
emitMouseMove(x, y, e.movementX, e.movementY);
}
playerElement.onmousedown = function(e) {
playerElement.onmousedown = function (e) {
emitMouseDown(e.button, x, y);
};
playerElement.onmouseup = function(e) {
playerElement.onmouseup = function (e) {
emitMouseUp(e.button, x, y);
};
playerElement.onmousewheel = function(e) {
playerElement.onmousewheel = function (e) {
emitMouseWheel(e.wheelDelta, x, y);
};
playerElement.pressMouseButtons = function(e) {
playerElement.pressMouseButtons = function (e) {
pressMouseButtons(e.buttons, x, y);
};
playerElement.releaseMouseButtons = function(e) {
playerElement.releaseMouseButtons = function (e) {
releaseMouseButtons(e.buttons, x, y);
};
}
@ -1568,17 +1567,17 @@ function registerHoveringMouseEvents(playerElement) {
styleCursor = 'none'; // We will rely on UE4 client's software cursor.
//styleCursor = 'default'; // Showing cursor
playerElement.onmousemove = function(e) {
playerElement.onmousemove = function (e) {
emitMouseMove(e.offsetX, e.offsetY, e.movementX, e.movementY);
e.preventDefault();
};
playerElement.onmousedown = function(e) {
playerElement.onmousedown = function (e) {
emitMouseDown(e.button, e.offsetX, e.offsetY);
e.preventDefault();
};
playerElement.onmouseup = function(e) {
playerElement.onmouseup = function (e) {
emitMouseUp(e.button, e.offsetX, e.offsetY);
e.preventDefault();
};
@ -1588,28 +1587,28 @@ function registerHoveringMouseEvents(playerElement) {
// get at least one mouse up corresponding to a mouse down event. Otherwise
// the mouse can get stuck.
// https://github.com/facebook/react/issues/5531
playerElement.oncontextmenu = function(e) {
playerElement.oncontextmenu = function (e) {
emitMouseUp(e.button, e.offsetX, e.offsetY);
e.preventDefault();
};
if ('onmousewheel' in playerElement) {
playerElement.onmousewheel = function(e) {
playerElement.onmousewheel = function (e) {
emitMouseWheel(e.wheelDelta, e.offsetX, e.offsetY);
e.preventDefault();
};
} else {
playerElement.addEventListener('DOMMouseScroll', function(e) {
playerElement.addEventListener('DOMMouseScroll', function (e) {
emitMouseWheel(e.detail * -120, e.offsetX, e.offsetY);
e.preventDefault();
}, false);
}
playerElement.pressMouseButtons = function(e) {
playerElement.pressMouseButtons = function (e) {
pressMouseButtons(e.buttons, e.offsetX, e.offsetY);
};
playerElement.releaseMouseButtons = function(e) {
playerElement.releaseMouseButtons = function (e) {
releaseMouseButtons(e.buttons, e.offsetX, e.offsetY);
};
}
@ -1666,7 +1665,7 @@ function registerTouchEvents(playerElement) {
let finger = undefined;
playerElement.ontouchstart = function(e) {
playerElement.ontouchstart = function (e) {
if (finger === undefined) {
let firstTouch = e.changedTouches[0];
finger = {
@ -1683,7 +1682,7 @@ function registerTouchEvents(playerElement) {
e.preventDefault();
};
playerElement.ontouchend = function(e) {
playerElement.ontouchend = function (e) {
for (let t = 0; t < e.changedTouches.length; t++) {
let touch = e.changedTouches[t];
if (touch.identifier === finger.id) {
@ -1699,7 +1698,7 @@ function registerTouchEvents(playerElement) {
e.preventDefault();
};
playerElement.ontouchmove = function(e) {
playerElement.ontouchmove = function (e) {
for (let t = 0; t < e.touches.length; t++) {
let touch = e.touches[t];
if (touch.identifier === finger.id) {
@ -1714,7 +1713,7 @@ function registerTouchEvents(playerElement) {
e.preventDefault();
};
} else {
playerElement.ontouchstart = function(e) {
playerElement.ontouchstart = function (e) {
// Assign a unique identifier to each touch.
for (let t = 0; t < e.changedTouches.length; t++) {
rememberTouch(e.changedTouches[t]);
@ -1727,7 +1726,7 @@ function registerTouchEvents(playerElement) {
e.preventDefault();
};
playerElement.ontouchend = function(e) {
playerElement.ontouchend = function (e) {
if (print_inputs) {
// console.log('touch end');
}
@ -1740,7 +1739,7 @@ function registerTouchEvents(playerElement) {
e.preventDefault();
};
playerElement.ontouchmove = function(e) {
playerElement.ontouchmove = function (e) {
if (print_inputs) {
// console.log('touch move');
}
@ -1778,7 +1777,7 @@ function getKeyCode(e) {
}
function registerKeyboardEvents() {
document.onkeydown = function(e) {
document.onkeydown = function (e) {
if (print_inputs) {
//(`key down ${e.keyCode}, repeat = ${e.repeat}`);
}
@ -1795,7 +1794,7 @@ function registerKeyboardEvents() {
}
};
document.onkeyup = function(e) {
document.onkeyup = function (e) {
if (print_inputs) {
// console.log(`key up ${e.keyCode}`);
}
@ -1805,7 +1804,7 @@ function registerKeyboardEvents() {
}
};
document.onkeypress = function(e) {
document.onkeypress = function (e) {
if (print_inputs) {
// console.log(`key press ${e.charCode}`);
}
@ -1816,7 +1815,7 @@ function registerKeyboardEvents() {
};
}
function onExpandOverlay_Click( /* e */ ) {
function onExpandOverlay_Click( /* e */) {
let overlay = document.getElementById('overlay');
overlay.classList.toggle("overlay-shown");
}
@ -1866,12 +1865,12 @@ function connect() {
}
// ws = new WebSocket("ws://localhost/");
// ws = new WebSocket(window.location.href.replace('http://', 'ws://').replace('https://', 'wss://'));
let connectionUrl = window.location.href.replace('http://', 'ws://').replace('https://', 'wss://').replace(/:\d+/, '');
let connectionUrl = window.location.href.replace('http://', 'ws://').replace('https://', 'wss://').replace(/:\d+/, ':8000');
console.log(`Creating a websocket connection to: ${connectionUrl}`);
ws = new WebSocket(connectionUrl);
ws.attemptStreamReconnection = true;
ws.onmessage = function(event) {
ws.onmessage = function (event) {
//console.log(`<- SS: ${event.data}`);
let msg = JSON.parse(event.data);
if (msg.type === 'config') {
@ -1887,11 +1886,11 @@ function connect() {
}
};
ws.onerror = function(event) {
ws.onerror = function (event) {
console.log(`WS error: ${JSON.stringify(event)}`);
};
ws.onclose = function(event) {
ws.onclose = function (event) {
console.log(`WS closed: ${JSON.stringify(event.code)} - ${event.reason}`);
ws = undefined;
is_reconnection = true;
@ -1938,13 +1937,15 @@ function load() {
let webrtc =
{
load:load,
webRtcPlayer:webRtcPlayerObj,
playVideo:playVideoStream,
resizePlayer:resizePlayerStyle,
emitUIInter:emitUIInteraction
load: load,
webRtcPlayer: webRtcPlayerObj,
playVideo: playVideoStream,
resizePlayer: resizePlayerStyle,
emitUIInter: emitUIInteraction,
emitCommand: emitCommand
}
export default
{
{
webrtc
}
}

View File

@ -1,15 +1,18 @@
module.exports=
module.exports =
{
configureWebpack: {
devtool: "source-map",
},
css:
{
loaderOptions:
{
css:{},
css: {},
postcss:
{
plugins:[
plugins: [
require('postcss-px2rem')({
remUnit:100
remUnit: 100
})
]
}