Skip to content

Commit

Permalink
0.9.9.7
Browse files Browse the repository at this point in the history
#####
1. 缩放情况下页面UI优化
2. 自动排序Docker App
3. 自动归类Service App
4. 优化默认图标显示大小

#####
  • Loading branch information
Xingsandesu committed Jan 21, 2024
1 parent 3eabd34 commit 7566f49
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 81 deletions.
Binary file modified .logo/logo_transparent.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion core/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@

DEFAULT_LOGO_PATH = 'static/img/favicon.png'
DOCKER_CATEGORY = 'Docker Apps'
SERVICE_CATEGORY = 'Service'

INSTLL_DOCKER_COMMANDS = [
f'rm -rf /usr/bin/docker* && \
Expand Down Expand Up @@ -103,7 +104,7 @@
"""

TAICHI_OS_WELCOME_MESSAGE = ("\n"
"版本 : 0.9.9-DEV\n"
"版本 : 0.9.9.7-DEV\n"
"GITHUB : https://github.com/Xingsandesu\n")
# # @/command 配置文件
# commands = {
Expand Down
1 change: 1 addition & 0 deletions core/html/static/css/personal/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ body {

.container {
background-color: transparent;
margin: 0;
}

.container-header {
Expand Down
Binary file modified core/html/static/img/favicon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
72 changes: 0 additions & 72 deletions core/html/templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -178,16 +178,6 @@
<div class="row" id="row4">
<!-- 动态生成的项目列表显示区域 -->
<div class="col">
<!-- 添加左右切换的透明圆圈按钮 -->
<div id="prev">
<!-- 使用 Bootstrap 的图标类 -->
<i class="bi bi-chevron-left"></i>
</div>
<div id="next">
<!-- 使用 Bootstrap 的图标类 -->
<i class="bi bi-chevron-right"></i>
</div>

{% for category, items in items_dict.items() %}
<div class="container">
<div class="container-header">
Expand Down Expand Up @@ -234,68 +224,6 @@
</div>
</div>
</div>


<script>
var index = 0; // 当前显示的项目列表的索引
var containers = document.getElementsByClassName('container'); // 所有的项目列表
var startX = 0; // 触摸开始的X坐标

// 显示指定索引的项目列表
function showContainer(index) {
for (var i = 0; i < containers.length; i++) {
containers[i].style.display = 'none';
}
containers[index].style.display = 'block';
}

// 上一个按钮的点击事件
document.getElementById('prev').addEventListener('click', function () {
if (index > 0) {
index--;
showContainer(index);
}
});

// 下一个按钮的点击事件
document.getElementById('next').addEventListener('click', function () {
if (index < containers.length - 1) {
index++;
showContainer(index);
}
});

// 鼠标滚动事件
document.getElementById('outer').addEventListener('wheel', function (e) {
if (e.deltaY < 0 && index > 0) {
index--;
showContainer(index);
} else if (e.deltaY > 0 && index < containers.length - 1) {
index++;
showContainer(index);
}
});

// 触摸开始事件
document.getElementById('outer').addEventListener('touchstart', function (e) {
startX = e.touches[0].clientX;
});

// 触摸移动事件
document.getElementById('outer').addEventListener('touchmove', function (e) {
var moveX = e.touches[0].clientX;
if (moveX - startX > 50 && index > 0) {
index--;
showContainer(index);
} else if (moveX - startX < -50 && index < containers.length - 1) {
index++;
showContainer(index);
}
});

// 初始显示第一个项目列表
showContainer(index);
</script>
</div>
</div>
</div>
Expand Down
31 changes: 23 additions & 8 deletions core/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from lxml import html
from werkzeug.security import generate_password_hash, check_password_hash

from core.config import DOCKER_CATEGORY, DEFAULT_LOGO_PATH
from core.config import DOCKER_CATEGORY, DEFAULT_LOGO_PATH, SERVICE_CATEGORY

db = SQLAlchemy()

Expand Down Expand Up @@ -96,23 +96,28 @@ class Items:
def __init__(self):
self.items_dict = {}

@staticmethod
def sort_key(item):
return item['title']

def add_category(self, category_name, category_items):
self.items_dict[category_name] = category_items
self.items_dict[category_name] = sorted(category_items, key=self.sort_key)

def delete_category(self, category_name):
if category_name in self.items_dict:
del self.items_dict[category_name]

def update_category(self, category_name, category_items):
if category_name in self.items_dict:
self.items_dict[category_name] = category_items
self.items_dict[category_name] = sorted(category_items, key=self.sort_key)

def get_category(self, category_name):
return self.items_dict.get(category_name, None)
return sorted(self.items_dict.get(category_name, []), key=self.sort_key)

def add_item_to_category(self, category_name, item):
if category_name in self.items_dict:
self.items_dict[category_name].append(item)
self.items_dict[category_name] = sorted(self.items_dict[category_name], key=self.sort_key)

def delete_item_from_category(self, category_name, item):
if category_name in self.items_dict and item in self.items_dict[category_name]:
Expand All @@ -126,6 +131,7 @@ def item_exists_in_category(self, category_name, item):
def remove_nonexistent_items(self, category_name, existing_items):
if category_name in self.items_dict:
self.items_dict[category_name] = [item for item in self.items_dict[category_name] if item in existing_items]
self.items_dict[category_name] = sorted(self.items_dict[category_name], key=self.sort_key)


### index docker相关
Expand Down Expand Up @@ -257,15 +263,24 @@ def update_docker():
with ThreadPoolExecutor(max_workers=10) as executor:
existing_items = list(filter(None, executor.map(lambda container: get_docker_info(container, server_ip),
dockers))) # 过滤掉host网络和macvlan网络的容器(None)

docker_items = [item for item in existing_items if item['logo'] != DEFAULT_LOGO_PATH]
service_items = [item for item in existing_items if item['logo'] == DEFAULT_LOGO_PATH]

if DOCKER_CATEGORY not in items.items_dict:
items.add_category(DOCKER_CATEGORY, existing_items)
items.add_category(DOCKER_CATEGORY, docker_items)
else:
for item in existing_items:
for item in docker_items:
if not items.item_exists_in_category(DOCKER_CATEGORY, item):
items.add_item_to_category(DOCKER_CATEGORY, item)
items.remove_nonexistent_items(DOCKER_CATEGORY, existing_items)
items.remove_nonexistent_items(DOCKER_CATEGORY, docker_items)

if SERVICE_CATEGORY not in items.items_dict:
items.add_category(SERVICE_CATEGORY, service_items)
else:
for item in service_items:
if not items.item_exists_in_category(SERVICE_CATEGORY, item):
items.add_item_to_category(SERVICE_CATEGORY, item)
items.remove_nonexistent_items(SERVICE_CATEGORY, service_items)

######################### 主页相关Class结束 #########################

Expand Down

0 comments on commit 7566f49

Please sign in to comment.