fix: 修复关闭SSH终端标签页时会话状态未更新的问题

This commit is contained in:
2026-04-18 02:35:38 +08:00
commit 6e2e2f9387
43467 changed files with 5489040 additions and 0 deletions
+172
View File
@@ -0,0 +1,172 @@
/// <reference lib="dom"/>
declare namespace screenfull {
type RawEventNames = {
readonly requestFullscreen: string;
readonly exitFullscreen: string;
readonly fullscreenElement: string;
readonly fullscreenEnabled: string;
readonly fullscreenchange: string;
readonly fullscreenerror: string;
};
type EventName = 'change' | 'error';
interface Screenfull {
/**
Whether fullscreen is active.
*/
readonly isFullscreen: boolean;
/**
The element currently in fullscreen, otherwise `null`.
*/
readonly element: Element | null;
/**
Whether you are allowed to enter fullscreen. If your page is inside an `<iframe>` you will need to add a `allowfullscreen` attribute (+ `webkitallowfullscreen` and `mozallowfullscreen`).
@example
```
if (screenfull.isEnabled) {
screenfull.request();
}
```
*/
readonly isEnabled: true;
/**
Exposes the raw properties (prefixed if needed) used internally.
*/
raw: RawEventNames;
/**
Make an element fullscreen.
If your page is inside an `<iframe>` you will need to add a `allowfullscreen` attribute (+ `webkitallowfullscreen` and `mozallowfullscreen`).
Keep in mind that the browser will only enter fullscreen when initiated by user events like click, touch, key.
@param element - Default is `<html>`. If called with another element than the currently active, it will switch to that if it's a descendant.
@param options - [`FullscreenOptions`](https://developer.mozilla.org/en-US/docs/Web/API/FullscreenOptions).
@returns A promise that resolves after the element enters fullscreen.
@example
```
// Fullscreen the page
document.getElementById('button').addEventListener('click', () => {
if (screenfull.isEnabled) {
screenfull.request();
} else {
// Ignore or do something else
}
});
// Fullscreen an element
const element = document.getElementById('target');
document.getElementById('button').addEventListener('click', () => {
if (screenfull.isEnabled) {
screenfull.request(element);
}
});
// Fullscreen an element with options
const element = document.getElementById('target');
document.getElementById('button').addEventListener('click', () => {
if (screenfull.isEnabled) {
screenfull.request(element, {navigationUI: 'hide'});
}
});
// Fullscreen an element with jQuery
const element = $('#target')[0]; // Get DOM element from jQuery collection
$('#button').on('click', () => {
if (screenfull.isEnabled) {
screenfull.request(element);
}
});
```
*/
request(element?: Element, options?: FullscreenOptions): Promise<void>;
/**
Brings you out of fullscreen.
@returns A promise that resolves after the element exits fullscreen.
*/
exit(): Promise<void>;
/**
Requests fullscreen if not active, otherwise exits.
@param element - Default is `<html>`. If called with another element than the currently active, it will switch to that if it's a descendant.
@param options - [`FullscreenOptions`](https://developer.mozilla.org/en-US/docs/Web/API/FullscreenOptions).
@returns A promise that resolves after the element enters/exits fullscreen.
@example
```
// Toggle fullscreen on a image with jQuery
$('img').on('click', event => {
if (screenfull.isEnabled) {
screenfull.toggle(event.target);
}
});
```
*/
toggle(element?: Element, options?: FullscreenOptions): Promise<void>;
/**
Add a listener for when the browser switches in and out of fullscreen or when there is an error.
@example
```
// Detect fullscreen change
if (screenfull.isEnabled) {
screenfull.on('change', () => {
console.log('Am I fullscreen?', screenfull.isFullscreen ? 'Yes' : 'No');
});
}
// Detect fullscreen error
if (screenfull.isEnabled) {
screenfull.on('error', event => {
console.error('Failed to enable fullscreen', event);
});
}
```
*/
on(name: EventName, handler: (event: Event) => void): void;
/**
Remove a previously registered event listener.
@example
```
screenfull.off('change', callback);
```
*/
off(name: EventName, handler: (event: Event) => void): void;
/**
Alias for `.on('change', function)`.
*/
onchange(handler: (event: Event) => void): void;
/**
Alias for `.on('error', function)`.
*/
onerror(handler: (event: Event) => void): void;
}
}
/**
Simple wrapper for cross-browser usage of the JavaScript [Fullscreen API](https://developer.mozilla.org/en/DOM/Using_full-screen_mode), which lets you bring the page or any element into fullscreen. Smoothens out the browser implementation differences, so you don't have to.
*/
declare const screenfull: screenfull.Screenfull;
export = screenfull;
export as namespace screenfull;
+184
View File
@@ -0,0 +1,184 @@
/*!
* screenfull
* v5.2.0 - 2021-11-03
* (c) Sindre Sorhus; MIT License
*/
(function () {
'use strict';
var document = typeof window !== 'undefined' && typeof window.document !== 'undefined' ? window.document : {};
var isCommonjs = typeof module !== 'undefined' && module.exports;
var fn = (function () {
var val;
var fnMap = [
[
'requestFullscreen',
'exitFullscreen',
'fullscreenElement',
'fullscreenEnabled',
'fullscreenchange',
'fullscreenerror'
],
// New WebKit
[
'webkitRequestFullscreen',
'webkitExitFullscreen',
'webkitFullscreenElement',
'webkitFullscreenEnabled',
'webkitfullscreenchange',
'webkitfullscreenerror'
],
// Old WebKit
[
'webkitRequestFullScreen',
'webkitCancelFullScreen',
'webkitCurrentFullScreenElement',
'webkitCancelFullScreen',
'webkitfullscreenchange',
'webkitfullscreenerror'
],
[
'mozRequestFullScreen',
'mozCancelFullScreen',
'mozFullScreenElement',
'mozFullScreenEnabled',
'mozfullscreenchange',
'mozfullscreenerror'
],
[
'msRequestFullscreen',
'msExitFullscreen',
'msFullscreenElement',
'msFullscreenEnabled',
'MSFullscreenChange',
'MSFullscreenError'
]
];
var i = 0;
var l = fnMap.length;
var ret = {};
for (; i < l; i++) {
val = fnMap[i];
if (val && val[1] in document) {
for (i = 0; i < val.length; i++) {
ret[fnMap[0][i]] = val[i];
}
return ret;
}
}
return false;
})();
var eventNameMap = {
change: fn.fullscreenchange,
error: fn.fullscreenerror
};
var screenfull = {
request: function (element, options) {
return new Promise(function (resolve, reject) {
var onFullScreenEntered = function () {
this.off('change', onFullScreenEntered);
resolve();
}.bind(this);
this.on('change', onFullScreenEntered);
element = element || document.documentElement;
var returnPromise = element[fn.requestFullscreen](options);
if (returnPromise instanceof Promise) {
returnPromise.then(onFullScreenEntered).catch(reject);
}
}.bind(this));
},
exit: function () {
return new Promise(function (resolve, reject) {
if (!this.isFullscreen) {
resolve();
return;
}
var onFullScreenExit = function () {
this.off('change', onFullScreenExit);
resolve();
}.bind(this);
this.on('change', onFullScreenExit);
var returnPromise = document[fn.exitFullscreen]();
if (returnPromise instanceof Promise) {
returnPromise.then(onFullScreenExit).catch(reject);
}
}.bind(this));
},
toggle: function (element, options) {
return this.isFullscreen ? this.exit() : this.request(element, options);
},
onchange: function (callback) {
this.on('change', callback);
},
onerror: function (callback) {
this.on('error', callback);
},
on: function (event, callback) {
var eventName = eventNameMap[event];
if (eventName) {
document.addEventListener(eventName, callback, false);
}
},
off: function (event, callback) {
var eventName = eventNameMap[event];
if (eventName) {
document.removeEventListener(eventName, callback, false);
}
},
raw: fn
};
if (!fn) {
if (isCommonjs) {
module.exports = {isEnabled: false};
} else {
window.screenfull = {isEnabled: false};
}
return;
}
Object.defineProperties(screenfull, {
isFullscreen: {
get: function () {
return Boolean(document[fn.fullscreenElement]);
}
},
element: {
enumerable: true,
get: function () {
return document[fn.fullscreenElement];
}
},
isEnabled: {
enumerable: true,
get: function () {
// Coerce to boolean in case of old WebKit
return Boolean(document[fn.fullscreenEnabled]);
}
}
});
if (isCommonjs) {
module.exports = screenfull;
} else {
window.screenfull = screenfull;
}
})();
+9
View File
@@ -0,0 +1,9 @@
MIT License
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+45
View File
@@ -0,0 +1,45 @@
{
"name": "screenfull",
"version": "5.2.0",
"description": "Simple wrapper for cross-browser usage of the JavaScript Fullscreen API, which lets you bring the page or any element into fullscreen.",
"license": "MIT",
"repository": "sindresorhus/screenfull.js",
"funding": "https://github.com/sponsors/sindresorhus",
"author": {
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
"url": "sindresorhus.com"
},
"main": "dist/screenfull.js",
"engines": {
"node": ">=0.10.0"
},
"scripts": {
"pretest": "grunt",
"test": "xo && tsd"
},
"files": [
"dist/screenfull.js",
"dist/screenfull.d.ts"
],
"keywords": [
"browser",
"fullscreen"
],
"devDependencies": {
"grunt": "^1.0.4",
"grunt-contrib-concat": "^1.0.1",
"grunt-contrib-copy": "^1.0.0",
"grunt-contrib-uglify": "^4.0.1",
"load-grunt-tasks": "^4.0.0",
"tsd": "^0.7.1",
"xo": "^0.16.0"
},
"types": "dist/screenfull.d.ts",
"xo": {
"envs": [
"node",
"browser"
]
}
}
+287
View File
@@ -0,0 +1,287 @@
# screenfull.js
> Simple wrapper for cross-browser usage of the JavaScript [Fullscreen API](https://developer.mozilla.org/en/DOM/Using_full-screen_mode), which lets you bring the page or any element into fullscreen. Smoothens out the browser implementation differences, so you don't have to.
**[Not supported on iPhone](#support)**
**This package is feature complete. No new features will be accepted.**
#### [Demo](https://sindresorhus.com/screenfull.js)
## Install
Only 0.7 kB gzipped.
Download the [production version][min] or the [development version][max].
[min]: https://github.com/sindresorhus/screenfull.js/raw/main/dist/screenfull.min.js
[max]: https://github.com/sindresorhus/screenfull.js/raw/main/dist/screenfull.js
```
$ npm install screenfull
```
Also available on [cdnjs](https://cdnjs.com/libraries/screenfull.js).
## Why?
### Screenfull
```js
if (screenfull.isEnabled) {
screenfull.request();
}
```
### Vanilla JavaScript
```js
document.fullscreenEnabled =
document.fullscreenEnabled ||
document.mozFullScreenEnabled ||
document.documentElement.webkitRequestFullScreen;
function requestFullscreen(element) {
if (element.requestFullscreen) {
element.requestFullscreen();
} else if (element.mozRequestFullScreen) {
element.mozRequestFullScreen();
} else if (element.webkitRequestFullScreen) {
element.webkitRequestFullScreen(Element.ALLOW_KEYBOARD_INPUT);
}
}
if (document.fullscreenEnabled) {
requestFullscreen(document.documentElement);
}
// This is not even entirely comprehensive. There's more.
```
## Support
[Supported browsers](https://caniuse.com/#feat=fullscreen)
**Note:** In order to use this package in Internet Explorer, you need a [`Promise` polyfill](https://github.com/stefanpenner/es6-promise).
**Note:** Safari is supported on desktop and iPad, but not on iPhone. This is a limitation in the browser, not in Screenfull.
## Documentation
### Examples
#### Fullscreen the page
```js
document.getElementById('button').addEventListener('click', () => {
if (screenfull.isEnabled) {
screenfull.request();
} else {
// Ignore or do something else
}
});
```
#### Fullscreen an element
```js
const element = document.getElementById('target');
document.getElementById('button').addEventListener('click', () => {
if (screenfull.isEnabled) {
screenfull.request(element);
}
});
```
#### Hide navigation user-interface on mobile devices
```js
const element = document.getElementById('target');
document.getElementById('button').addEventListener('click', () => {
if (screenfull.isEnabled) {
screenfull.request(element, {navigationUI: 'hide'});
}
});
```
#### Fullscreen an element with jQuery
```js
const element = $('#target')[0]; // Get DOM element from jQuery collection
$('#button').on('click', () => {
if (screenfull.isEnabled) {
screenfull.request(element);
}
});
```
#### Toggle fullscreen on a image with jQuery
```js
$('img').on('click', event => {
if (screenfull.isEnabled) {
screenfull.toggle(event.target);
}
});
```
#### Detect fullscreen change
```js
if (screenfull.isEnabled) {
screenfull.on('change', () => {
console.log('Am I fullscreen?', screenfull.isFullscreen ? 'Yes' : 'No');
});
}
```
Remove listeners with:
```js
screenfull.off('change', callback);
```
#### Detect fullscreen error
```js
if (screenfull.isEnabled) {
screenfull.on('error', event => {
console.error('Failed to enable fullscreen', event);
});
}
```
See the [demo](https://sindresorhus.com/screenfull.js) for more examples, and view the source.
#### Fullscreen an element with Angular.js
You can use the [Angular.js binding](https://github.com/hrajchert/angular-screenfull) to do something like:
```html
<div ngsf-fullscreen>
<p>This is a fullscreen element</p>
<button ngsf-toggle-fullscreen>Toggle fullscreen</button>
</div>
```
#### Fullscreen the page with Angular 2
```ts
import {Directive, HostListener} from '@angular/core';
import screenfull = require('screenfull');
@Directive({
selector: '[toggleFullscreen]'
})
export class ToggleFullscreenDirective {
@HostListener('click') onClick() {
if (screenfull.isEnabled) {
screenfull.toggle();
}
}
}
```
```html
<button toggleFullscreen>Toggle fullscreen<button>
```
### API
#### .request(element, options?)
Make an element fullscreen.
Accepts a DOM element and [`FullscreenOptions`](https://developer.mozilla.org/en-US/docs/Web/API/FullscreenOptions).
The default element is `<html>`. If called with another element than the currently active, it will switch to that if it's a descendant.
If your page is inside an `<iframe>` you will need to add a `allowfullscreen` attribute (+ `webkitallowfullscreen` and `mozallowfullscreen`).
Keep in mind that the browser will only enter fullscreen when initiated by user events like click, touch, key.
Returns a promise that resolves after the element enters fullscreen.
#### .exit()
Brings you out of fullscreen.
Returns a promise that resolves after the element exits fullscreen.
#### .toggle(element, options?)
Requests fullscreen if not active, otherwise exits.
Accepts a DOM element and [`FullscreenOptions`](https://developer.mozilla.org/en-US/docs/Web/API/FullscreenOptions).
Returns a promise that resolves after the element enters/exits fullscreen.
#### .on(event, function)
Events: `'change' | 'error'`
Add a listener for when the browser switches in and out of fullscreen or when there is an error.
#### .off(event, function)
Remove a previously registered event listener.
#### .onchange(function)
Alias for `.on('change', function)`
#### .onerror(function)
Alias for `.on('error', function)`
#### .isFullscreen
Returns a boolean whether fullscreen is active.
#### .element
Returns the element currently in fullscreen, otherwise `null`.
#### .isEnabled
Returns a boolean whether you are allowed to enter fullscreen. If your page is inside an `<iframe>` you will need to add a `allowfullscreen` attribute (+ `webkitallowfullscreen` and `mozallowfullscreen`).
#### .raw
Exposes the raw properties (prefixed if needed) used internally: `requestFullscreen`, `exitFullscreen`, `fullscreenElement`, `fullscreenEnabled`, `fullscreenchange`, `fullscreenerror`
## FAQ
### How can I navigate to a new page when fullscreen?
That's not supported by browsers for security reasons. There is, however, a dirty workaround. Create a seamless iframe that fills the screen and navigate to the page in that instead.
```js
$('#new-page-btn').click(() => {
const iframe = document.createElement('iframe')
iframe.setAttribute('id', 'external-iframe');
iframe.setAttribute('src', 'https://new-page-website.com');
iframe.setAttribute('frameborder', 'no');
iframe.style.position = 'absolute';
iframe.style.top = '0';
iframe.style.right = '0';
iframe.style.bottom = '0';
iframe.style.left = '0';
iframe.style.width = '100%';
iframe.style.height = '100%';
$(document.body).prepend(iframe);
document.body.style.overflow = 'hidden';
});
```
## Resources
- [Using the Fullscreen API in web browsers](https://hacks.mozilla.org/2012/01/using-the-fullscreen-api-in-web-browsers/)
- [MDN - Fullscreen API](https://developer.mozilla.org/en/DOM/Using_full-screen_mode)
- [W3C Fullscreen spec](https://fullscreen.spec.whatwg.org/)
- [Building an amazing fullscreen mobile experience](https://developers.google.com/web/fundamentals/native-hardware/fullscreen/)