Skip to content

Commit

Permalink
增加退出按钮
Browse files Browse the repository at this point in the history
  • Loading branch information
kingmo888 committed Jan 3, 2024
1 parent 5cbc4fc commit 0d777c5
Show file tree
Hide file tree
Showing 86 changed files with 103,448 additions and 10 deletions.
14 changes: 8 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<p align="center">
<i>一个 python 实现的 Rustdesk API 接口,支持 WebUI 管理</i>
<br/>
<img src ="https://img.shields.io/badge/Version-1.4.1-blueviolet.svg"/>
<img src ="https://img.shields.io/badge/Version-1.4.2-blueviolet.svg"/>
<img src ="https://img.shields.io/badge/Python-3.7|3.8|3.9|3.10|3.11-blue.svg" />
<img src ="https://img.shields.io/badge/Django-3.2+|4.x-yelow.svg" />
<br/>
Expand Down Expand Up @@ -43,13 +43,15 @@

## 安装

### 开箱即用
### 方法1:开箱即用

仅支持Windows,请前往 release 下载,无需安装环境,直接运行`启动.bat`即可。独立版截图:

![window独立绿色版](/images/windows_run.png)

### 代码运行
另外,该方式下的webui(暂时)无法使用,可以通过domain.com:21114/static/web-client/index.html来访问。需要修改`_internal/static/web-client/index.html`中的23行为你的中继服务器地址。

### 方法2:代码运行

```bash
# 将代码克隆到本地
Expand All @@ -71,17 +73,17 @@ python manage.py runserver 0.0.0.0:21114
from pysqlite3 import dbapi2 as Database # 启用pysqlite3
```

### Docker 运行
### 方法3:Docker 运行

#### 自行构建
#### Docker方法1:自行构建
```bash
git clone https://github.com/kingmo888/rustdesk-api-server.git
cd rustdesk-api-server
docker compose --compatibility up --build -d
```
感谢热心网友 @ferocknew 提供。

#### 预构建运行
#### Docker方法2:预构建运行

docker run 命令:

Expand Down
2 changes: 1 addition & 1 deletion api/templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
<li class="layui-nav-item"><a href="/admin" target="_blank">管理后台</a>
</li>
{% endif %}

<li class="layui-nav-item"><a href="/api/user_action?action=logout" target="_blank">退出</a></li>
</ul>

<fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
Expand Down
6 changes: 4 additions & 2 deletions api/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,18 @@
@author: lenovo
"""

import platform
import logging
from .models_user import UserProfile
logger = logging.getLogger(__name__)

from django.conf import settings as _settings

def settings(request):
"""
TEMPLATE_CONTEXT_PROCESSORS
"""
context = { 'settings': _settings }


try:
username = request.user
u = UserProfile.objects.get(username=username)
Expand All @@ -27,6 +27,8 @@ def settings(request):
context['is_admin'] = u.is_admin
context['is_active'] = u.is_active
context['domain'] = _settings.ID_SERVER
context['is_windows'] = True if platform.system() == 'Windows' else False


logger.info("set system status variable")
except Exception as e:
Expand Down
11 changes: 10 additions & 1 deletion api/views_front.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import json
import time
import hashlib
import sys

salt = 'xiaomo'
EFFECTIVE_SECONDS = 7200
Expand Down Expand Up @@ -100,6 +101,7 @@ def model_to_dict2(instance, fields=None, exclude=None, replace=None, default=No


def index(request):
print('sdf',sys.argv)
if request.user and request.user.username!='AnonymousUser':
return HttpResponseRedirect('/api/work')
return HttpResponseRedirect('/api/user_action?action=login')
Expand All @@ -113,6 +115,8 @@ def user_action(request):
return user_login(request)
if action == 'register':
return user_register(request)
if action == 'logout':
return user_logout(request)

def user_login(request):
if request.method == 'GET':
Expand Down Expand Up @@ -169,7 +173,12 @@ def user_register(request):
result['code'] = 1
return JsonResponse(result)


@login_required(login_url='/api/user_action?action=login')
def user_logout(request):
info = ''
auth.logout(request)
return HttpResponseRedirect('/api/user_action?action=login')

def get_single_info(uid):
peers = RustDeskPeer.objects.filter(Q(uid=uid))
rids = [x.rid for x in peers]
Expand Down
Binary file modified db/db.sqlite3
Binary file not shown.
1 change: 1 addition & 0 deletions static/web-client/assets/AssetManifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"assets/android.png":["assets/android.png"],"assets/gestures.ttf":["assets/gestures.ttf"],"assets/insecure.png":["assets/insecure.png"],"assets/insecure_relay.png":["assets/insecure_relay.png"],"assets/linux.png":["assets/linux.png"],"assets/mac.png":["assets/mac.png"],"assets/secure.png":["assets/secure.png"],"assets/secure_relay.png":["assets/secure_relay.png"],"assets/win.png":["assets/win.png"],"packages/cupertino_icons/assets/CupertinoIcons.ttf":["../fonts/CupertinoIcons.ttf"],"../js/no_sleep.js":["../js/no_sleep.js"]}
1 change: 1 addition & 0 deletions static/web-client/assets/FontManifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[{"family":"MaterialIcons","fonts":[{"asset":"fonts/MaterialIcons-Regular.otf"}]},{"family":"GestureIcons","fonts":[{"asset":"fonts/gestures.ttf"}]},{"family":"CupertinoIcons","fonts":[{"asset":"fonts/CupertinoIcons.ttf"}]}]
Binary file added static/web-client/assets/assets/android.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 static/web-client/assets/assets/insecure.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 static/web-client/assets/assets/linux.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 static/web-client/assets/assets/mac.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 static/web-client/assets/assets/secure.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 static/web-client/assets/assets/secure_relay.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 static/web-client/assets/assets/win.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 not shown.
Binary file not shown.
Binary file added static/web-client/assets/fonts/gestures.ttf
Binary file not shown.
281 changes: 281 additions & 0 deletions static/web-client/canvaskit@0.33.0/canvaskit.js

Large diffs are not rendered by default.

Binary file added static/web-client/canvaskit@0.33.0/canvaskit.wasm
Binary file not shown.
1 change: 1 addition & 0 deletions static/web-client/favicon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
170 changes: 170 additions & 0 deletions static/web-client/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,170 @@
<!DOCTYPE html>
<html>

<head>

<meta charset="UTF-8">
<meta content="IE=Edge" http-equiv="X-UA-Compatible">
<meta name="description" content="Remote Desktop.">

<!-- iOS meta tags & icons -->
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<meta name="apple-mobile-web-app-title" content="RustDesk">
<link rel="apple-touch-icon" href="icons/Icon-192.png">

<!-- Favicon -->
<link rel="icon" type="image/svg+xml" href="favicon.svg" />

<title>RustDesk</title>
<link rel="manifest" href="manifest.json">
<script src="ogvjs-1.8.6/ogv.js"></script>
<script>
var api = ["这里修改你的地址"];
</script>
<script type="module" crossorigin src="module/index.b7bb6fa2.js"></script>
<script src="js/yuv-canvas-1.2.6.js"></script>
<style>
.loading {
display: flex;
justify-content: center;
align-items: center;
margin: 0;
position: absolute;
top: 50%;
left: 50%;
-ms-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
}

.loader {
border: 16px solid #f3f3f3;
border-radius: 50%;
border: 15px solid;
border-top: 16px solid #024eff;
border-right: 16px solid white;
border-bottom: 16px solid #024eff;
border-left: 16px solid white;
width: 120px;
height: 120px;
-webkit-animation: spin 2s linear infinite;
animation: spin 2s linear infinite;
}

@-webkit-keyframes spin {
0% {
-webkit-transform: rotate(0deg);
}
100% {
-webkit-transform: rotate(360deg);
}
}

@keyframes spin {
0% {
transform: rotate(0deg);
}

100% {
transform: rotate(360deg);
}
}
</style>

</head>

<body>
<div class="loading">
<div class="loader"></div>
</div>
<!-- This script installs service_worker.js to provide PWA functionality to
application. For more information, see:
https://developers.google.com/web/fundamentals/primers/service-workers -->
<script>
var serviceWorkerVersion = null;
var scriptLoaded = false;
function loadMainDartJs() {
if (scriptLoaded) {
return;
}
scriptLoaded = true;
var scriptTag = document.createElement('script');
scriptTag.src = 'js/main.dart.js';
scriptTag.type = 'application/javascript';
document.body.append(scriptTag);
}

if ('serviceWorker' in navigator) {
// Service workers are supported. Use them.
window.addEventListener('load', function () {
// Wait for registration to finish before dropping the <script> tag.
// Otherwise, the browser will load the script multiple times,
// potentially different versions.
var serviceWorkerUrl = 'flutter_service_worker.js?v=' + serviceWorkerVersion;
navigator.serviceWorker.register(serviceWorkerUrl)
.then((reg) => {
function waitForActivation(serviceWorker) {
serviceWorker.addEventListener('statechange', () => {
if (serviceWorker.state == 'activated') {
console.log('Installed new service worker.');
loadMainDartJs();
}
});
}
if (!reg.active && (reg.installing || reg.waiting)) {
// No active web worker and we have installed or are installing
// one for the first time. Simply wait for it to activate.
waitForActivation(reg.installing || reg.waiting);
} else if (!reg.active.scriptURL.endsWith(serviceWorkerVersion)) {
// When the app updates the serviceWorkerVersion changes, so we
// need to ask the service worker to update.
console.log('New service worker available.');
reg.update();
waitForActivation(reg.installing);
} else {
// Existing service worker is still good.
console.log('Loading app from service worker.');
loadMainDartJs();
}
});

// If service worker doesn't succeed in a reasonable amount of time,
// fallback to plaint <script> tag.
setTimeout(() => {
if (!scriptLoaded) {
console.warn(
'Failed to load app from service worker. Falling back to plain <script> tag.',
);
loadMainDartJs();
}
}, 4000);
});
} else {
// Service workers not supported. Just drop the <script> tag.
loadMainDartJs();
}
</script>
<script src="libs/firebase-app.js?8.10.1"></script>

<script>
// Your web app's Firebase configuration
// For Firebase JS SDK v7.20.0 and later, measurementId is optional
const firebaseConfig = {
apiKey: "AIzaSyCgehIZk1aFP0E7wZtYRRqrfvNiNAF39-A",
authDomain: "rustdesk.firebaseapp.com",
databaseURL: "https://rustdesk.firebaseio.com",
projectId: "rustdesk",
storageBucket: "rustdesk.appspot.com",
messagingSenderId: "768133699366",
appId: "1:768133699366:web:d50faf0792cb208d7993e7",
measurementId: "G-9PEH85N6ZQ"
};

// Initialize Firebase
firebase.initializeApp(firebaseConfig);
//firebase.analytics();
</script>
</body>

</html>
Loading

0 comments on commit 0d777c5

Please sign in to comment.