js+css实现包含文件系统及命令行浏览器的webos虚拟操作系统代码

代码语言:html

所属分类:其他

代码描述:js+css实现包含文件系统及命令行浏览器的webos虚拟操作系统代码,支持多窗口切换、登录、设置、音乐播放、代码在线编辑运行等。

代码标签: js css 包含 文件 系统 命令行 浏览器 webos 虚拟 操作系统 代码

下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开

<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>WebOS</title>
<style>
*, *::before, *::after {
  margin: 0; padding: 0; box-sizing: border-box;
}

:root {
  --accent: #0078d4;
  --accent-hover: #1a86d9;
  --glass-bg: rgba(255,255,255,0.12);
  --glass-border: rgba(255,255,255,0.18);
  --glass-bg-dark: rgba(30,30,40,0.75);
  --text: #fff;
  --text-dark: #222;
  --taskbar-h: 48px;
  --shadow: 0 8px 32px rgba(0,0,0,0.35);
  --radius: 12px;
}

@font-face {
  font-family: 'Sys';
  src: local('Segoe UI'), local('SF Pro Display'), local('PingFang SC'), local('Microsoft YaHei');
}

body {
  font-family: 'Sys', system-ui, -apple-system, sans-serif;
  overflow: hidden;
  height: 100vh;
  width: 100vw;
  user-select: none;
  color: var(--text);
}

/* ===== LOGIN SCREEN ===== */
#login-screen {
  position: fixed; inset: 0; z-index: 99999;
  background: linear-gradient(135deg, #0f0c29, #302b63, #24243e);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  transition: opacity 0.6s, transform 0.6s;
}
#login-screen.hidden {
  opacity: 0; transform: scale(1.05); pointer-events: none;
}
#login-screen .clock {
  font-size: 72px; font-weight: 200; margin-bottom: 8px;
  text-shadow: 0 2px 20px rgba(0,0,0,0.3);
}
#login-screen .date {
  font-size: 18px; opacity: 0.8; margin-bottom: 60px;
}
.login-box {
  background: rgba(255,255,255,0.1);
  backdrop-filter: blur(20px);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 20px;
  padding: 40px;
  width: 380px;
  display: flex; flex-direction: column; align-items: center;
}
.avatar {
  width: 100px; height: 100px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), #00d4aa);
  display: flex; align-items: center; justify-content: center;
  font-size: 42px; margin-bottom: 16px;
  box-shadow: 0 4px 20px rgba(0,120,212,0.4);
}
.login-box h2 {
  font-weight: 400; margin-bottom: 24px; font-size: 20px;
}
.login-box input {
  width: 100%; padding: 12px 16px;
  border: 2px solid rgba(255,255,255,0.2);
  border-radius: 10px;
  background: rgba(255,255,255,0.08);
  color: #fff; font-size: 15px;
  outline: none; margin-bottom: 16px;
  transition: border-color 0.3s;
}
.login-box input:focus {
  border-color: var(--accent);
}
.login-box input::placeholder { color: rgba(255,255,255,0.4); }
.login-box button {
  width: 100%; padding: 12px;
  border: none; border-radius: 10px;
  background: var(--accent);
  color: #fff; font-size: 16px;
  cursor: pointer; transition: all 0.3s;
  font-weight: 500;
}
.login-box button:hover { background: var(--accent-hover); transform: translateY(-1px); }
.login-error {
  color: #ff6b6b; font-size: 13px;
  margin-top: 8px; min-height: 20px;
}

/* ===== DESKTOP ===== */
#desktop {
  position: fixed; inset: 0;
  background: linear-gradient(135deg, #1a1a2e, #16213e, #0f3460);
  background-size: cover;
  display: none;
}
#desktop.active { display: block; }

#wallpaper-canvas {
  position: absolute; inset: 0; z-index: 0;
}

#desktop-icons {
  position: absolute;
  top: 20px; left: 20px;
  display: grid;
  grid-template-columns: repeat(auto-fill, 90px);
  grid-auto-rows: 100px;
  gap: 8px;
  z-index: 1;
  max-height: calc(100vh - var(--taskbar-h) - 40px);
}

.desktop-icon {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 8px;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s;
  text-align: center;
}
.desktop-icon:hover {
  background: rgba(255,255,255,0.12);
}
.desktop-icon:active {
  transform: scale(0.92);
}
.desktop-icon .icon {
  width: 48px; height: 48px;
  display: flex; align-items: center; justify-content: center;
  font-size: 32px;
  margin-bottom: 6px;
  border-radius: 12px;
  background: rgba(255,255,255,0.08);
  backdrop-filter: blur(10px);
}
.desktop-icon .label {
  font-size: 11px;
  text-shadow: 0 1px 4px rgba(0,0,0,0.8);
  line-height: 1.3;
  max-width: 80px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ===== WINDOWS ===== */
#windows-container {
  position: absolute; inset: 0;
  z-index: 10;
  pointer-events: none;
}

.window {
  position: absolute;
  min-width: 400px; min-height: 300px;
  background: rgba(30, 30, 45, 0.92);
  backdrop-filter: blur(24px) saturate(1.5);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: flex; flex-direction: column;
  overflow: hidden;
  pointer-events: auto;
  transition: box-shadow 0.3s;
  animation: windowOpen 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes windowOpen {
  from { opacity: 0; transform: scale(0.9) translateY(20px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}
.window.closing {
  animation: windowClose 0.25s forwards;
}
@keyframes windowClose {
  to { opacity: 0; transform: scale(0.9) translateY(20px); }
}
.window.focused {
  box-shadow: 0 12px 48px rgba(0,120,212,0.25), var(--shadow);
  border-color: rgba(0,120,212,0.3);
}
.window.maximized {
  border-radius: 0;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}
.window.minimized {
  transform: scale(0.8) translateY(100vh);
  opacity: 0;
  pointer-events: none;
  transition: all 0.3s;
}

.window-header {
  height: 38px;
  background: rgba(255,255,255,0.04);
  display: flex; align-items: center;
  padding: 0 8px 0 14px;
  cursor: default;
  flex-shrink: 0;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.window-header .win-icon {
  font-size: 16px; margin-right: 10px;
}
.window-header .win-title {
  flex: 1; font-size: 13px; font-weight: 400;
  opacity: 0.9;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.window-controls {
  display: flex; gap: 2px;
}
.window-controls button {
  width: 36px; height: 30px;
  border: none; background: transparent;
  color: rgba(255,255,255,0.8);
  cursor: pointer; border-radius: 6px;
  font-size: 14px;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.15s;
}
.window-controls button:hover {
  background: rgba(255,255,255,0.1);
}
.window-controls .btn-close:hover {
  background: #e81123;
  color: #fff;
}

.window-body {
  flex: 1; overflow: auto;
  position: relative;
}

/* Resize handles */
.resize-handle {
  position: absolute; z-index: 2;
}
.resize-handle.n { top: -4px; left: 8px; right: 8px; height: 8px; cursor: n-resize; }
.resize-handle.s { bottom: -4px; left: 8px; right: 8px; height: 8px; cursor: s-resize; }
.resize-handle.e { right: -4px; top: 8px; bottom: 8px; width: 8px; cursor: e-resize; }
.resize-handle.w { left: -4px; top: 8px; bottom: 8px; width: 8px; cursor: w-resize; }
.resize-handle.ne { top: -4px; right: -4px; width: 16px; height: 16px; cursor: ne-resize; }
.resize-handle.nw { top: -4px; left: -4px; width: 16px; height: 16px; cursor: nw-resize; }
.resize-handle.se { bottom: -4px; right: -4px; width: 16px; height: 16px; cursor: se-resize; }
.resize-handle.sw { bottom: -4px; left: -4px; width: 16px; height: 16px; cursor: sw-resize; }

/* ===== TASKBAR ===== */
#taskbar {
  position: fixed; bottom: 0; left: 0; right: 0;
  height: var(--taskbar-h);
  background: rgba(20, 20, 30, 0.85);
  backdrop-filter: blur(24px) saturate(1.5);
  border-top: 1px solid rgba(255,255,255,0.08);
  display: flex; align-items: center;
  padding: 0 12px;
  z-index: 1000;
}

#start-btn {
  width: 40px; height: 40px;
  border: none; border-radius: 8px;
  background: transparent;
  color: #fff; font-size: 20px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.2s;
  margin-right: 4px;
}
#start-btn:hover { background: rgba(255,255,255,0.1); }
#start-btn.active { background: rgba(0,120,212,0.3); }

#search-box {
  height: 34px; width: 220px;
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 17px;
  background: rgba(255,255,255,0.06);
  color: #fff;
  padding: 0 16px;
  font-size: 13px;
  outline: none;
  margin-right: 8px;
  transition: all 0.3s;
}
#search-box:focus {
  border-color: var(--accent);
  background: rgba(255,255,255,0.1);
  width: 280px;
}
#search-box::placeholder { color: rgba(255,255,255,0.35); }

#task-list {
  flex: 1; display: flex;
  align-items: center; gap: 3px;
  margin: 0 8px;
  overflow-x: auto;
}
#task-list::-webkit-scrollbar { height: 0; }

.task-item {
  height: 38px; min-width: 44px;
  max-width: 180px;
  border: none; border-radius: 8px;
  background: rgba(255,255,255,0.06);
  color: #fff; font-size: 12px;
  cursor: pointer;
  display: flex; align-items: center;
  padding: 0 12px; gap: 8px;
  transition: all 0.2s;
  white-space: nowrap;
  overflow: hidden;
  position: relative;
}
.task-item:hover { background: rgba(255,255,255,0.12); }
.task-item.active {
  background: rgba(0,120,212,0.25);
}
.task-item.active::after {
  content: '';
  position: absolute; bottom: 2px;
  left: 50%; transform: translateX(-50%);
  width: 20px; height: 3px;
  background: var(--accent);
  border-radius: 2px;
}
.task-item .task-icon { font-size: 16px; flex-shrink: 0; }
.task-item .task-title {
  overflow: hidden; text-overflow: ellipsis;
}

#system-tray {
  display: flex; align-items: center; gap: 4px;
  margin-left: auto;
}
.tray-btn {
  width: 36px; height: 36px;
  border: none; border-radius: 8px;
  background: transparent;
  color: rgba(255,255,255,0.7);
  cursor: pointer; font-size: 16px;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.2s;
}
.tray-btn:hover { background: rgba(255,255,255,0.08); color: #fff; }
#taskbar-clock {
  font-size: 12px; padding: 4px 12px;
  text-align: right; line-height: 1.5;
  cursor: pointer; border-radius: 8px;
  transition: background 0.2s;
}
#taskbar-clock:hover { background: rgba(255,255,255,0.08); }

/* ===== START MENU ===== */
#start-menu {
  position: fixed;
  bottom: calc(var(--taskbar-h) + 12px);
  left: 12px;
  width: 580px;
  max-height: 620px;
  backgr.........完整代码请登录后点击上方下载按钮下载查看

网友评论0