v5.2.3 - 登录界面优化和Python解释器

更新来自 @NB-group 和 @User782Tec
- 改进了登录界面,增加电源操作
- 兼容开发环境,在本地开发时不启用缓存和PWA
- 新增了Python解释器(此项更改由@NB-Group提供灵感与框架,@User782Tec完善)
- 修复了终端选择不正常的问题
- 改进了终端,可通过应用标识符来打开应用
- 格式化部分文档
This commit is contained in:
User782Tec
2023-05-06 21:30:06 +08:00
parent 76eda5ae1e
commit 09b3f33918
7 changed files with 283 additions and 75 deletions
+3 -3
View File
@@ -26,7 +26,7 @@
border-radius: 50%;
background-color: #ffffffee;
backdrop-filter: blur(10px) saturate(1.3);
box-shadow: 0 0 0 4px #44444470, 0 0 0 7px #ffffffa0,1px 1px 15px 7px #00000090;
box-shadow: 0 0 0 4px #44444470, 0 0 0 7px #ffffffa0, 1px 1px 15px 7px #00000090;
transition: 200ms;
}
@@ -56,10 +56,10 @@
left: 0px;
}
#win-camera.h video{
#win-camera.h video {
height: 100%;
}
#win-camera.v video{
#win-camera.v video {
width: 100%;
}
+37 -2
View File
@@ -5,8 +5,11 @@
justify-content: center;
align-items: center;
flex-direction: column;
background: url(../../img/login.jpg) center;
/* background: linear-gradient(130deg, #ad6eca, #3b91d8); */
background-image: url('../../img/login.jpg'); /* Lucas Andrade, CC BY SA-4.0 */
background-size: cover;
background-repeat: no-repeat;
background-position: 50% 50%;
transition: filter 500ms, background-color 500ms, opacity 1500ms ease-in-out;
position: absolute;
width: 100%;
@@ -17,6 +20,7 @@
}
#login {
cursor: pointer;
padding: 4px 50px 4px 50px;
border: 2px solid #aaa;
background-color: #eeeeee80;
@@ -76,4 +80,35 @@
#loginback.close {
background-color: black;
}
}
#loginback .power {
display: flex;
position: absolute;
bottom: 20px;
right: 20px;
width: 165px;
justify-content: space-evenly;
color: #fff;
align-items: center;
}
#loginback .power>* {
cursor: pointer;
transition: all 300ms;
font-size: 44px;
display: flex;
justify-content: center;
align-items: center;
padding: 10px;
border-radius: 7px;
transition: transform cubic-bezier(0.14, 1.02, 0.17, 0.03) 300ms;
}
#loginback .power>*:hover {
background-color: var(--card);
}
#loginback .power>*:active {
transform: scale(0.95);
}
+28 -12
View File
@@ -1,4 +1,4 @@
.window.terminal{
.window.terminal-apps {
--text: #ddd;
--bg: #000000;
--bg30: #00000030;
@@ -7,41 +7,57 @@
--sd: #00000070;
--card: #72727240;
--hover: #ffffff40;
--hover-half:#ffffff20;
--hover-half: #ffffff20;
--hover-b: #ffffff30;
--bggrey: #444;
--bgul: url('./bg-dark.svg');
--mm: #ffffff50;
--cm: #252525bb;
--bar: #7272722a;
--hr:#00000050;
--unfoc:#333;
--hr: #00000050;
--unfoc: #333;
cursor: default;
}
#win-terminal>pre{
color: #fff;
margin: 5px 10px;
font-family:"Microsoft YaHei";
user-select: text;
.window.terminal-apps>.content {
padding-bottom: 55px;
}
#win-terminal>pre::selection{
.window.terminal-apps>.content {
overflow-y: auto !important;
overflow-x: hidden !important;
padding-bottom: 10px;
}
.window.terminal-apps>.content>pre {
color: #fff;
margin: 0px 15px;
font-family: "Consolas", "Microsoft YaHei", "monospace", system-ui;
user-select: text;
font-size: 16px;
}
.window.terminal-apps>.content * {
white-space: break-spaces;
}
.window.terminal-apps>.content *::selection {
background: #ddd;
background-clip: content-box;
color: #333;
}
#win-terminal>pre>input{
.window.terminal-apps>.content>pre>input {
background: none;
border: none;
outline: none;
padding: 0;
color: #fff;
cursor: default;
width: 100%;
}
#win-terminal>pre>input::selection{
.window.terminal-apps>pre>input::selection {
background: #ddd;
background-clip: content-box;
color: #333;
+62 -8
View File
@@ -3,10 +3,13 @@
<head>
<meta charset="UTF-8" />
<script src="https://cdn.jsdelivr.net/pyodide/v0.20.0/full/pyodide.js" async></script> <!-- Pyodide, 目前已采用 -->
<!-- <link rel="stylesheet" href="https://pyscript.net/latest/pyscript.css" />
<script defer src="https://pyscript.net/latest/pyscript.js"></script> --> <!-- PyScript, 已弃用 -->
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<meta name="format-detection" content="telephone=no" />
<!-- Windows 12 网页版 谭景元原创 -->
<!-- Windows 12 网页版是一个开放源项目,
@@ -137,8 +140,17 @@
<div id="login" onclick="
this.id = 'login-after';
this.innerText = '登录中...';
document.querySelector('#loginback').removeChild(document.querySelector('#loginback .power'));
var qwq = window.setInterval(() => {
if (this.innerText.match(/\.\.\./)) {
this.innerText = '登录中.';
}
else {
this.innerText += '.';
}
}, 500);
window.setTimeout(() => {
this.style.transition = 'none';
this.style.transition = 'color 500ms';
}, 100);
window.setTimeout(() => {
$('#loginback').addClass('close');
@@ -147,6 +159,7 @@
}, 500);
window.setTimeout(() => {
$('#loginback').css('display', 'none');
window.clearInterval(qwq);
}, 2000);
document.querySelector('audio#startup-music').play();
}, 1000);
@@ -154,6 +167,10 @@
">
登录
</div>
<a class="power" onclick="$(this).addClass('show')">
<i class="bi bi-power" onclick="setTimeout(() => {window.location='shutdown.html';},200);" win12_title="关机"></i>
<i class="bi bi-arrow-counterclockwise" onclick="setTimeout(() => {window.location='reload.html';},200);" win12_title="重启"></i>
</a>
</div>
<!-- <img src="https://bing.com/th?id=OHR.Trossachs_ZH-CN9299955040_UHD.jpg&qlt=100" alt=""> -->
<script src="./jq.min.js"></script>
@@ -195,6 +212,9 @@
<a onclick="apps.camera.notice();hide_startmenu()">
<img src="icon/camera.png"><p>相机</p>
</a>
<a onclick="openapp('python');hide_startmenu()">
<img src="icon/python.png"><p>Python 3.10.2</p>
</a>
<p class="text">Web 应用</p>
<a onclick="openapp('bilibili');hide_startmenu();">
<img src="icon/bilibili.png"><p>哔哩哔哩</p>
@@ -923,6 +943,15 @@
<div class="cnt update">
<h1 class="tit"><span></span>更新记录</h1>
<div style="margin-left: 20px;">
<details><summary><span>v5.2.3</span> 登录界面优化和Python解释器</summary><p>
&emsp;&emsp;<strong>更新来自 @NB-Group 和 @User782Tec</strong><br />
&emsp;&emsp;-改进了登录界面,增加锁定壁纸及电源操作<br />
&emsp;&emsp;-兼容开发环境,在本地开发时不启用缓存和PWA<br />
&emsp;&emsp;-新增了Python解释器(此项更改由@NB-Group提供灵感与框架,@User782Tec完善)<br />
&emsp;&emsp;-修复了终端选择不正常的问题<br />
&emsp;&emsp;-改进了终端,可通过应用标识符来打开应用<br />
&emsp;&emsp;-格式化部分文档<br /></p>
</details>
<details><summary><span>v5.2.2</span> 细节优化</summary><p>
&emsp;&emsp;-对相机外观和代码进行了优化<br />
&emsp;&emsp;-添加登录背景,一些外观优化<br />
@@ -1187,7 +1216,7 @@
</div>
</div>
</div>
<div class="window terminal" onmousedown="focwin('terminal')" ontouchstart="focwin('terminal')">
<div class="window terminal terminal-apps" onmousedown="focwin('terminal')" ontouchstart="focwin('terminal')">
<div class="titbar" oncontextmenu="return showcm(event,'titbar','terminal')" ondblclick="maxwin('terminal')">
<img src="icon/terminal.png" class="icon" onclick="return showcm(event,'titbar','terminal')">
<p>终端</p>
@@ -1200,12 +1229,37 @@
<div class="loadback">
<img src="icon/terminal.png" class="icon">
</div>
<div class="content" id="win-terminal">
<pre>Micrsotft Windosw [版本 12.0.39035.7324]
(c) Micrsotft Corparotoin。保所留有权利。
一个摆设,后续会完善。
C:\Windows\System32> <input type="text" oninput="setTimeout(() => {$('#win-terminal>pre')[0].innerHTML+=this.outerHTML;$('#win-terminal>pre>input').focus()}, 0);$('#win-terminal>pre')[0].innerText+=$(this).val();"></pre>
<div class="content" id="win-terminal">
<pre>
Microsoft Windows [版本 12.0.39035.7324]
(c) Microsoft Corporation。保留所有权利。
</pre>
<pre class="text-cmd"></pre>
<pre style="display: flex"><span class="prompt">C:\Windows\System32> </span><input type="text" onkeyup="if (event.keyCode == 13) { apps.terminal.run(); }"></pre>
</div>
</div>
<div class="window python terminal-apps" onmousedown="focwin('python')" ontouchstart="focwin('python')">
<div class="titbar" oncontextmenu="return showcm(event,'titbar','python')" ondblclick="maxwin('python')">
<img src="icon/python.png" class="icon" onclick="return showcm(event,'titbar','python')">
<p>Python 3.10.2</p>
<div>
<a class="a wbtg red" onclick="hidewin('python')"><i class="bi bi-x-lg"></i></a>
<a class="a wbtg max" onclick="maxwin('python')"><i class="bi bi-app"></i></a>
<a class="a wbtg" onclick="minwin('python')"><i class="bi bi-dash-lg"></i></a>
</div>
</div>
<div class="loadback">
<img src="icon/python.png" class="icon">
</div>
<div class="content" id="win-python">
<pre>
Python 3.10.2 [MSC v.1912 64 bit (AMD64)] :: Anaconda, Inc. on win32
Type "help", "copyright", "credits" or "license" for more information.
</pre>
<pre class="text-cmd"></pre>
<pre>>>> <input type="text" onkeyup="if (event.keyCode == 13) { apps.python.run(); }"></pre>
</div>
</div>
<div class="window edge" onmousedown="focwin('edge')" ontouchstart="focwin('edge')">
+152 -49
View File
@@ -408,13 +408,13 @@ let apps = {
apps.camera.downloadLink = document.querySelector('#win-camera a');
// apps.camera.control = document.querySelector('#win-camera>.control')
navigator.mediaDevices.getUserMedia({ video: true, audio: false })
.then(stream => {
apps.camera.video.srcObject = stream;
apps.camera.video.play();
})
.catch(() => {
hidewin('camera');
});
.then(stream => {
apps.camera.video.srcObject = stream;
apps.camera.video.play();
})
.catch(() => {
hidewin('camera');
});
apps.camera.video.addEventListener('canplay', () => {
if (!apps.camera.streaming) {
apps.camera.aspectRatio = apps.camera.video.videoWidth / apps.camera.video.videoHeight;
@@ -448,16 +448,16 @@ let apps = {
}
},
resize: () => {
let w=$('#win-camera')[0].offsetWidth,
h=$('#win-camera')[0].offsetHeight;
let w = $('#win-camera')[0].offsetWidth,
h = $('#win-camera')[0].offsetHeight;
if (w / apps.camera.aspectRatio <= h) {
if(!$('#win-camera').hasClass('v')){
if (!$('#win-camera').hasClass('v')) {
$('#win-camera').removeClass('h')
$('#win-camera').addClass('v');
}
}
else if (w / apps.camera.aspectRatio >= h) {
if(!$('#win-camera').hasClass('h')){
if (!$('#win-camera').hasClass('h')) {
$('#win-camera').removeClass('v')
$('#win-camera').addClass('h');
}
@@ -622,13 +622,107 @@ let apps = {
}, 200);
}
},
python: {
codeCache: '',
prompt: '>>> ',
indent: false,
init: () => {
$('#win-python').html(`
<pre>
Python 3.10.2 [MSC v.1912 64 bit (AMD64)] :: Anaconda, Inc. on win32
Type "help", "copyright", "credits" or "license" for more information.
</pre>
<pre class="text-cmd"></pre>
<pre style="display: flex;"><span class='prompt'>>>> </span><input type="text" onkeyup="if (event.keyCode == 13) { apps.python.run(); }"></pre>`);
},
run: () => {
if (apps.python.pyodide) {
const input = document.querySelector('#win-python>pre>input');
const _code = input.value;
const elt = document.querySelector('#win-python>pre.text-cmd');
const lastChar = _code[_code.length - 1];
var newD = document.createElement('div');
newD.innerText = `${apps.python.prompt}${_code}`;
elt.appendChild(newD);
if (lastChar != ':' && lastChar != '\\' && ((!apps.python.indent || _code == ''))) {
apps.python.prompt = '>>> ';
apps.python.codeCache += _code;
apps.python.indent = false;
const code = apps.python.codeCache;
apps.python.codeCache = '';
apps.python.pyodide.runPython('sys.stdout = io.StringIO()');
try {
const result = String(apps.python.pyodide.runPython(code));
if (apps.python.pyodide.runPython('sys.stdout.getvalue()')) {
var newD = document.createElement('div');
newD.innerText = `${apps.python.pyodide.runPython('sys.stdout.getvalue()')}`;
elt.appendChild(newD);
}
if (result && result != 'undefined') {
var newD = document.createElement('div');
if (result == 'false') {
newD.innerText = 'False';
}
else if (result == 'true') {
newD.innerText = 'True';
}
else {
newD.innerText = result;
}
elt.appendChild(newD);
}
}
catch (err) {
var newD = document.createElement('div');
newD.innerText = `${err.message}`;
elt.appendChild(newD);
}
}
else {
apps.python.prompt = '... ';
if (lastChar == ':') {
apps.python.indent = true;
}
apps.python.codeCache += _code + '\n';
}
input.value = "";
// 自动聚焦
input.blur();
input.focus();
document.querySelector('#win-python .prompt').innerText = apps.python.prompt;
}
}
},
terminal: {
init: () => {
$('#win-terminal>pre').html(`Micrsotft Windosw [版本 12.0.39035.7324]
(c) Micrsotft Corparotoin。保所留有权利。
一个摆设,后续不会完善
C:\Windows\System32> <input type="text" oninput="setTimeout(() => {$('#win-terminal>pre')[0].innerHTML+=this.outerHTML;$('#win-terminal>pre>input').focus()}, 0);$('#win-terminal>pre')[0].innerText+=$(this).val();">`)
$('#win-terminal').html(`<pre>
Microsoft Windows [版本 12.0.39035.7324]
(c) Microsoft Corporation。保留所有权利
</pre>
<pre class="text-cmd"></pre>
<pre style="display: flex"><span class="prompt">C:\\Windows\\System32> </span><input type="text" onkeyup="if (event.keyCode == 13) { apps.terminal.run(); }"></pre>`)
},
run: () => {
const elt = document.querySelector('#win-terminal>pre.text-cmd');
const input = document.querySelector('#win-terminal>pre>input');
const command = input.value;
var newD = document.createElement('div');
newD.innerText = `C:\\Windows\\System32> ${command}`;
elt.appendChild(newD);
if (document.querySelector('.window.' + command)) {
openapp(command);
}
else {
var newD = document.createElement('div');
newD.innerText = `"${command}"不是内部或外部命令,也不是可运行程序
或批处理文件`;
elt.appendChild(newD);
}
input.value = '';
input.blur();
input.focus();
}
},
search: {
@@ -1070,12 +1164,12 @@ function toggletheme() {
}
}
// 云母效果
let mica_difx=0,mica_dify=0;
window.addEventListener('resize',e=>{
let b=$('body')[0];
$(':root').css('--mica-size',`${Math.max(b.offsetHeight,b.offsetWidth)}px`);
mica_difx=(b.offsetHeight<b.offsetWidth)?0:(b.offsetWidth-b.offsetHeight)/2;
mica_dify=(b.offsetHeight<b.offsetWidth)?(b.offsetHeight-b.offsetWidth)/2:0;
let mica_difx = 0, mica_dify = 0;
window.addEventListener('resize', e => {
let b = $('body')[0];
$(':root').css('--mica-size', `${Math.max(b.offsetHeight, b.offsetWidth)}px`);
mica_difx = (b.offsetHeight < b.offsetWidth) ? 0 : (b.offsetWidth - b.offsetHeight) / 2;
mica_dify = (b.offsetHeight < b.offsetWidth) ? (b.offsetHeight - b.offsetWidth) / 2 : 0;
})
// 拖拽窗口
@@ -1357,36 +1451,45 @@ document.getElementsByTagName('body')[0].onload = function nupd() {
}, 1000);
}
apps.webapps.init();
(async function () {
apps.python.pyodide = await loadPyodide();
apps.python.pyodide.runPython(`
import sys
import io
`);
})();
};
// PWA 应用
navigator.serviceWorker.register('sw.js', { updateViaCache: 'none', scope: './' });
navigator.serviceWorker.controller.postMessage({
head: 'is_update'
});
// navigator.serviceWorker.controller.postMessage({
// head: 'get_userdata'
// });
navigator.serviceWorker.addEventListener('message', function (e) {
if (e.data.head == 'update') {
updated = true;
$('.msg.update>.main>.tit').html('<i class="bi bi-stars" style="background-image: linear-gradient(100deg, var(--theme-1), var(--theme-2));-webkit-background-clip: text;-webkit-text-fill-color: transparent;text-shadow:3px 3px 5px var(--sd);filter:saturate(200%) brightness(0.9);"></i> ' + $('#win-about>.cnt.update>div>details:first-child>summary').text());
$('.msg.update>.main>.cont').html($('#win-about>.cnt.update>div>details:first-child>p').html());
$('#loadbackupdate').css('display', 'block');
}
// else if (e.data.head == 'userdata') {
// const d = e.data.data;
// console.log(d);
// if (d.theme == 'dark') $(':root').addClass('dark');
// $(':root').css('--theme-1', d.color1);
// $(':root').css('--theme-2', d.color2);
// }
});
function setData(k, v) {
if (!location.href.match(/((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.){3}(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])(?::(?:[0-9]|[1-9][0-9]{1,3}|[1-5][0-9]{4}|6[0-4][0-9]{3}|65[0-4][0-9]{2}|655[0-2][0-9]|6553[0-5]))/) && !location.href.match('localhost')) {
navigator.serviceWorker.register('sw.js', { updateViaCache: 'none', scope: './' });
navigator.serviceWorker.controller.postMessage({
head: 'is_update'
});
// navigator.serviceWorker.controller.postMessage({
// head: 'set_userdata',
// key: k,
// value: v
// head: 'get_userdata'
// });
localStorage.setItem(k,v);
navigator.serviceWorker.addEventListener('message', function (e) {
if (e.data.head == 'update') {
updated = true;
$('.msg.update>.main>.tit').html('<i class="bi bi-stars" style="background-image: linear-gradient(100deg, var(--theme-1), var(--theme-2));-webkit-background-clip: text;-webkit-text-fill-color: transparent;text-shadow:3px 3px 5px var(--sd);filter:saturate(200%) brightness(0.9);"></i> ' + $('#win-about>.cnt.update>div>details:first-child>summary').text());
$('.msg.update>.main>.cont').html($('#win-about>.cnt.update>div>details:first-child>p').html());
$('#loadbackupdate').css('display', 'block');
}
// else if (e.data.head == 'userdata') {
// const d = e.data.data;
// console.log(d);
// if (d.theme == 'dark') $(':root').addClass('dark');
// $(':root').css('--theme-1', d.color1);
// $(':root').css('--theme-2', d.color2);
// }
});
function setData(k, v) {
// navigator.serviceWorker.controller.postMessage({
// head: 'set_userdata',
// key: k,
// value: v
// });
localStorage.setItem(k,v);
}
}
BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

+1 -1
View File
@@ -1,4 +1,4 @@
// v5.2.2
// v5.2.3
let userdata = {
'theme': 'light',
'color1': '#ad6eca',