diff --git a/apps/style/camera.css b/apps/style/camera.css index a3a091a..aed2db5 100644 --- a/apps/style/camera.css +++ b/apps/style/camera.css @@ -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%; } \ No newline at end of file diff --git a/apps/style/login.css b/apps/style/login.css index a05a161..68da89d 100644 --- a/apps/style/login.css +++ b/apps/style/login.css @@ -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; -} \ No newline at end of file +} + +#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); +} diff --git a/apps/style/terminal.css b/apps/style/terminal.css index 3c212f7..b91855a 100644 --- a/apps/style/terminal.css +++ b/apps/style/terminal.css @@ -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; diff --git a/desktop.html b/desktop.html index b861aa8..4d899ed 100644 --- a/desktop.html +++ b/desktop.html @@ -3,10 +3,13 @@ + + - + @@ -195,6 +212,9 @@

相机

+ +

Python 3.10.2

+

Web 应用

哔哩哔哩

@@ -923,6 +943,15 @@

更新记录

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

+   更新来自 @NB-Group 和 @User782Tec
+   -改进了登录界面,增加锁定壁纸及电源操作
+   -兼容开发环境,在本地开发时不启用缓存和PWA
+   -新增了Python解释器(此项更改由@NB-Group提供灵感与框架,@User782Tec完善)
+   -修复了终端选择不正常的问题
+   -改进了终端,可通过应用标识符来打开应用
+   -格式化部分文档

+
v5.2.2 细节优化

  -对相机外观和代码进行了优化
  -添加登录背景,一些外观优化
@@ -1187,7 +1216,7 @@

-
+

终端

@@ -1200,12 +1229,37 @@
-
-
Micrsotft Windosw [版本 12.0.39035.7324]
-(c) Micrsotft Corparotoin。保所留有权利。
-一个摆设,后续会完善。 
 
-C:\Windows\System32> 
+
+
+				Microsoft Windows [版本 12.0.39035.7324]
+				(c) Microsoft Corporation。保留所有权利。
+			
+

+			
C:\Windows\System32> 
+
+
+
+ +
+ +
+ +
+
+				Python 3.10.2  [MSC v.1912 64 bit (AMD64)] :: Anaconda, Inc. on win32
+				Type "help", "copyright", "credits" or "license" for more information.
+			
+

+            
>>> 
diff --git a/desktop.js b/desktop.js index f7fabc4..d6b2164 100644 --- a/desktop.js +++ b/desktop.js @@ -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(` +
+Python 3.10.2  [MSC v.1912 64 bit (AMD64)] :: Anaconda, Inc. on win32
+Type "help", "copyright", "credits" or "license" for more information.
+        
+

+        
>>> 
`); + }, + 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> `) + $('#win-terminal').html(`
+Microsoft Windows [版本 12.0.39035.7324]
+(c) Microsoft Corporation。保留所有权利。
+        
+

+        
C:\\Windows\\System32> 
`) + }, + 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 { + 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(' ' + $('#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(' ' + $('#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); + } } \ No newline at end of file diff --git a/icon/python.png b/icon/python.png new file mode 100644 index 0000000..a58cdf6 Binary files /dev/null and b/icon/python.png differ diff --git a/sw.js b/sw.js index 55acc41..4671237 100644 --- a/sw.js +++ b/sw.js @@ -1,4 +1,4 @@ -// v5.2.2 +// v5.2.3 let userdata = { 'theme': 'light', 'color1': '#ad6eca',