Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@
自VSCode发布以来,VSCode就受到了广大程序员的青睐。VSCode丰富的插件能够满足使用者各色各样的需求。
但VSCode使用受限于图形化界面的需求,只能安装在客户端而不能安装在服务器上。
code-server的出现完美的解决了VSCode不能安装在服务端的缺陷。
code-server是一款运行在浏览器界面上的可以安装在任何机器上的VSCode程序,code-server不仅继承了VSCode的使用逻辑,丰富的插件,在VSCode的基础上还提供了更多VSCode所没有的特性,满足更多的使用场景和业务需求。
code-server是一款运行在浏览器界面上的可以安装在任何机器上的VSCode程序,code-server不仅继承了VSCode的使用逻辑,丰富的插件,在VSCode的基础上还提供了更多
VSCode所没有的特性,由ctllo-bit提供内嵌飞牛界面,以满足更多的使用场景和业务需求。
9 changes: 7 additions & 2 deletions app/docker/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,16 @@ services:
container_name: code-server
restart: unless-stopped
ports:
- "${server_port}:8080" # 端口如果冲突请修改冒号前面的端口号,冒号后面的不要改。
- "5333:8080" # 端口如果冲突请修改冒号前面的端口号,冒号后面的不要改。
volumes:
- "/var/apps/vs-code/shares/data/.config:/home/coder/.config" # 配置文件路径
- "/var/apps/vs-code/shares/data/project:/home/coder/project" # 项目路径
- "/vol1/1000/VscodeProject:/home/coder/project" # 项目路径
user: "1000:1001"
environment:
- PASSWORD=${admin_password} #登陆密码修改成你自己的密码
- TZ=Asia/Shanghai
- PUID=1000
- PGID=1001
# 增加下面这一行,进入网页直接就是你的项目
command: --auth password --bind-addr 0.0.0.0:8080 /home/coder/project
network_mode: bridge
17 changes: 14 additions & 3 deletions app/ui/config
Original file line number Diff line number Diff line change
@@ -1,12 +1,23 @@
{
".url": {
"vs-code.Application": {
"title": "VS Code",
"vs-code.main": {
"title": "VS Code桌面版",
"icon": "images/icon_{0}.png",
"type": "iframe",
"url": "/cgi/ThirdParty/vs-code/index.cgi/",
"allUsers": true
},
"vs-code.Application": {
"title": "VS Code外链版",
"icon": "images/code_icon_{0}.png",
"type": "url",
"protocol": "http",
"port": "5333",
"url": "/",
"allUsers": false
}
}
}
}



41 changes: 41 additions & 0 deletions app/ui/env.cgi
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/bin/sh

# 添加 HTTP 响应头
echo "Content-Type: application/javascript; charset=utf-8"
echo ""

cat <<EOF
const host = window.location.hostname;
const isInternalIp = /^(?:10|127|172\.(?:1[6-9]|2\d|3[01])|192\.168|169\.254|100\.64)\./.test(host) || host === 'localhost';

const protocol= window.location.protocol;
const hostname=isInternalIp ? host : ('vs-code.'+ host);
const port = isInternalIp ? '5333' : window.location.port;
const airPort=port?(':'+port):'';

// 构建目标URL
const targetURL =protocol + "//" + hostname + airPort;

// 尝试获取当前父级 iframe 元素
let iframe = window.frameElement;
if(iframe){
iframe.frameBorder = "0";
iframe.setAttribute("webkitallowfullscreen", "true");
iframe.setAttribute("mozallowfullscreen", "true");
iframe.setAttribute('allow', 'clipboard-read; clipboard-write');

//沙盒属性
iframe.sandbox="allow-same-origin allow-scripts allow-forms allow-modals allow-popups allow-popups-to-escape-sandbox allow-downloads"
iframe.src =targetURL;

console.log('✅ 修改iframe成功!');
}else{
//飞牛APP因跨源(cross-origin)获取不了,则直接跳转
//window.location.href = targetURL;
window.open(targetURL, '_top');
window.alert(5 + 6);
}

console.log("CGI加载的JS文件成功!");
EOF

Binary file added app/ui/images/code_icon_256.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/ui/images/code_icon_64.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified app/ui/images/icon_256.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified app/ui/images/icon_64.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
96 changes: 96 additions & 0 deletions app/ui/index.cgi
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
#!/bin/bash

# 脚本名称: index.cgi
#   版本: 1.0.0
#   作者: FNOSP/xieguanru
#  协作者: FNOSP/MR_XIAOBO
# 创建日期: 2025-11-18
# 最后修改: 2025-11-19
#   描述: 这个脚本用于演示 Shell 脚本的各种注释方式
# 使用方式: 文件重命名,从 linux_shell_cgi_index.sh 改成 index.cgi,
#      放置应用包 /ui 路径下,记得 chmod +x index.cgi 赋权
#  许可证: MIT

# 【注意】修改你自己的静态文件根目录,以本应用为例:
BASE_PATH="/var/apps/vs-code/target/www"

# 1. 从 REQUEST_URI 里拿到 index.cgi 后面的路径
# 例如:/cgi/ThirdParty/App.Native.HelloFnosAppCenter/index.cgi/index.html?foo=bar
# 先去掉 ? 后面的 query string
URI_NO_QUERY="${REQUEST_URI%%\?*}"

# 默认值(如果没匹配到 index.cgi)
REL_PATH="/"

# 用 index.cgi 作为切割点,取后面的部分
case "$URI_NO_QUERY" in
*index.cgi*)
# 去掉前面所有直到 index.cgi 为止的内容,保留后面的
# /cgi/ThirdParty/App.Native.HelloFnosAppCenter/index.cgi/index.html -> /index.html
REL_PATH="${URI_NO_QUERY#*index.cgi}"
;;
esac

# 如果为空或只有 /,就默认 /index.html
if [ -z "$REL_PATH" ] || [ "$REL_PATH" = "/" ]; then
REL_PATH="/index.html"
fi

# 拼出真实文件路径:basePath + /ui + index.cgi 后面的路径
TARGET_FILE="${BASE_PATH}${REL_PATH}"

# 简单防御:禁止 .. 越级访问
if echo "$TARGET_FILE" | grep -q '\.\.'; then
echo "Status: 400 Bad Request"
echo "Content-Type: text/plain; charset=utf-8"
echo ""
echo "Bad Request"
exit 0
fi

# 2. 判断文件是否存在
if [ ! -f "$TARGET_FILE" ]; then
echo "Status: 404 Not Found"
echo "Content-Type: text/plain; charset=utf-8"
echo ""
echo "404 Not Found: ${REL_PATH}"
exit 0
fi

# 3. 根据扩展名简单判断 Content-Type
ext="${TARGET_FILE##*.}"
case "$ext" in
html|htm)
mime="text/html; charset=utf-8"
;;
css)
mime="text/css; charset=utf-8"
;;
js)
mime="application/javascript; charset=utf-8"
;;
jpg|jpeg)
mime="image/jpeg"
;;
png)
mime="image/png"
;;
gif)
mime="image/gif"
;;
svg)
mime="image/svg+xml"
;;
txt|log)
mime="text/plain; charset=utf-8"
;;
*)
mime="application/octet-stream"
;;
esac

# 4. 输出头 + 文件内容
echo "Content-Type: $mime"
echo ""

cat "$TARGET_FILE"
21 changes: 21 additions & 0 deletions app/www/css/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/* 基础尺寸保证 */
html, body {
width: 100%;
height: 100%;
margin: 0;
}

/* 盒模型统一 */
html {
box-sizing: border-box;
}
*, *::before, *::after {
box-sizing: inherit;
}

/* 只对根容器禁用滚动 */
#app, #root, .container {
width: 100%;
height: 100%;
overflow: hidden;
}
12 changes: 12 additions & 0 deletions app/www/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Monaco in fnOS</title>
<link rel="stylesheet" href="./css/style.css">
</head>
<body>
<script src="/cgi/ThirdParty/vs-code/env.cgi/"></script>
</body>
</html>
22 changes: 11 additions & 11 deletions manifest
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
appname=vs-code
version=1.0.0
display_name="VS Code"
desc="""<strong><span style="font-size: large;">运行在浏览器上的VSCode,项目地址:<a href="https://github.com/coder/code-server">code-server</a></span></strong>
appname = vs-code
version = 1.0.1
display_name = "VS Code"
desc ="""<strong><span style="font-size: large;">运行在浏览器上的VSCode,项目地址:<a href="https://github.com/coder/code-server">code-server</a></span></strong>
<strong><span style="font-size: large;"><a href="https://github.com/coder/code-server/discussions"><img src="https://camo.githubusercontent.com/30f4d3a87c758daa0e009abaca1225e6de0d02ff0d26658c88a064568ecc396d/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f2532304769744875622d25323044697363757373696f6e732d677261792e7376673f6c6f6e6743616368653d74727565266c6f676f3d67697468756226636f6c6f72423d707572706c65" alt="&quot;GitHub Discussions&quot;" data-canonical-src="https://img.shields.io/badge/%20GitHub-%20Discussions-gray.svg?longCache=true&amp;logo=github&amp;colorB=purple" /></a>&nbsp;<a href="https://coder.com/community" rel="nofollow"><img src="https://camo.githubusercontent.com/7204a179a57e7ce4cec9620c9060a9f0c24069aaa3676c070adc2c577c8c652a/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6a6f696e2d75732532306f6e253230736c61636b2d677261792e7376673f6c6f6e6743616368653d74727565266c6f676f3d736c61636b26636f6c6f72423d627269676874677265656e" alt="&quot;Join us on Slack&quot;" data-canonical-src="https://img.shields.io/badge/join-us%20on%20slack-gray.svg?longCache=true&amp;logo=slack&amp;colorB=brightgreen" /></a>&nbsp;<a href="https://twitter.com/coderhq" rel="nofollow"><img src="https://camo.githubusercontent.com/04ffc6959b39b7b2356210093bd2498d5a822be4858a596148e9e98f1a5699dd/68747470733a2f2f696d672e736869656c64732e696f2f747769747465722f666f6c6c6f772f436f64657248513f6c6162656c3d253430436f6465724851267374796c653d736f6369616c" alt="Twitter Follow" data-canonical-src="https://img.shields.io/twitter/follow/CoderHQ?label=%40CoderHQ&amp;style=social" /></a>&nbsp;<a href="https://discord.com/invite/coder" rel="nofollow"><img src="https://camo.githubusercontent.com/b17532440c201db8d083d613ecb7a70adbe26b0e9340cbae69605ff191f9a37a/68747470733a2f2f696d672e736869656c64732e696f2f646973636f72642f373437393333353932323733303237303933" alt="Discord" data-canonical-src="https://img.shields.io/discord/747933592273027093" /></a>&nbsp;<a href="https://codecov.io/gh/coder/code-server" rel="nofollow"><img src="https://camo.githubusercontent.com/09333db35ab0ce0d517af626d4558da7fce015b201263d9a25bddf52b346f56e/68747470733a2f2f636f6465636f762e696f2f67682f636f6465722f636f64652d7365727665722f6272616e63682f6d61696e2f67726170682f62616467652e7376673f746f6b656e3d35694d396661726a6e43" alt="codecov" data-canonical-src="https://codecov.io/gh/coder/code-server/branch/main/graph/badge.svg?token=5iM9farjnC" /></a>&nbsp;<a href="https://coder.com/docs/code-server/latest" rel="nofollow"><img src="https://camo.githubusercontent.com/d3f2deb23c5ced4be5dae69238c01441001db17ac63f535c9f4fc2832c5b5450/68747470733a2f2f696d672e736869656c64732e696f2f7374617469632f76313f6c6162656c3d446f6373266d6573736167653d7365652532306c617465737426636f6c6f723d626c7565" alt="See latest" data-canonical-src="https://img.shields.io/static/v1?label=Docs&amp;message=see%20latest&amp;color=blue" /></a></span></strong>
自VSCode发布以来,VSCode就受到了广大程序员的青睐。VSCode丰富的插件能够满足使用者各色各样的需求。
但VSCode使用受限于图形化界面的需求,只能安装在客户端而不能安装在服务器上。
code-server的出现完美的解决了VSCode不能安装在服务端的缺陷。
code-server是一款运行在浏览器界面上的可以安装在任何机器上的VSCode程序,code-server不仅继承了VSCode的使用逻辑,丰富的插件,在VSCode的基础上还提供了更多VSCode所没有的特性,满足更多的使用场景和业务需求。
"""
arch=x86_64
source=thirdparty
maintainer=code-server
maintainer_url=https://github.com/coder/code-server
distributor=MR_XIAOBO
desktop_uidir=ui
desktop_applaunchname="vs-code.Application"
arch = x86_64
source = thirdparty
maintainer = code-server
maintainer_url = https://github.com/coder/code-server
distributor = MR_XIAOBO
desktop_uidir = ui
desktop_applaunchname = vs-code.Application