添加主页

This commit is contained in:
cxykevin 2024-05-04 21:27:20 +08:00
parent 1e01289d53
commit 01a31a2578
8 changed files with 111 additions and 18 deletions

View File

@ -1,4 +1,4 @@
{ {
"python.analysis.typeCheckingMode": "off", "python.analysis.typeCheckingMode": "off",
"python.analysis.autoImportCompletions": true "python.analysis.autoImportCompletions": false
} }

1
VERSION Normal file
View File

@ -0,0 +1 @@
0.0.1

View File

@ -2,7 +2,9 @@ UnsupportedSystem = "当前操作系统不受支持"
PermissionDeniedLinux = "在 linux 操作系统系统下,请使用 root 权限进行安装" PermissionDeniedLinux = "在 linux 操作系统系统下,请使用 root 权限进行安装"
PermissionDeniedWin = "权限不足,请以管理员身份运行此程序" PermissionDeniedWin = "权限不足,请以管理员身份运行此程序"
InstallWelcome = "欢迎安装 PEInjector" InstallWelcome = "欢迎安装 PEInjector"
UpgradeWelcome = "更新 PEInjector"
InstallInfo = "PEinjector 是增强 WindowsPE 的一个工具和平台" InstallInfo = "PEinjector 是增强 WindowsPE 的一个工具和平台"
UpgradeInfo = "接下来将更新 PEinjector 和 ventoy"
DownloadInstallTitle = "下载必要文件" DownloadInstallTitle = "下载必要文件"
DownloadInstall = "在开始之前,我们需要下载一些依赖文件\n如果您的网络状况不佳请手动下载 peinjector 和 ventoy 并解压到 software 文件夹" DownloadInstall = "在开始之前,我们需要下载一些依赖文件\n如果您的网络状况不佳请手动下载 peinjector 和 ventoy 并解压到 software 文件夹"
StartInstall = "开始安装" StartInstall = "开始安装"
@ -17,5 +19,7 @@ InstallIjTitle = "安装 PEinjector"
InstallIjInfo = "PEinjector主程序正在安装中请稍等" InstallIjInfo = "PEinjector主程序正在安装中请稍等"
FinishInstall = "完成安装" FinishInstall = "完成安装"
InstallFinishTitle = "安装已完成" InstallFinishTitle = "安装已完成"
InstallFinishInfo = "PEinjector已经安装到您的设备\n点击下方按钮关闭程序并重新启动以管理 PEinjector" InstallFinishInfo = "PEinjector已经安装到您的设备\n点击下方按钮重新启动程序以管理 PEinjector"
InstallFinishBtn = "关闭" InstallFinishBtn = "重启"
HomeWelcome = "欢迎使用 PEinjector"
HomeInfo = "一个增强 WindowsPE 的一个工具和平台\n点击下方版本号进行更新"

1
lib/vars.py Normal file
View File

@ -0,0 +1 @@
DISKMOUNT = ""

BIN
res/smile.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

65
ui/homeui.py Normal file
View File

@ -0,0 +1,65 @@
import os
import sys
from magictk import mtk, color_tmpl
from magictk import fontconfig
from ui.lang import l
from logger.logger import *
from lib import vars
from tkinter import Label as tkLabel
now_frame = None
master: mtk.Frame = None
def show_home_page():
global now_frame, master
first_page = mtk.Frame(master)
mtk.Frame(first_page, w=10000).pack(fill="both", expand=True)
smileimg = mtk.PhotoImage(file="res"+os.sep+"smile.gif")
frames = mtk.Frame(first_page)
smilelabel = tkLabel(frames, image=smileimg,
background=color_tmpl.default_color["background"])
smilelabel.pack()
smilelabel.image = smileimg
frames.pack(fill='x')
mtk.Frame(first_page, w=10000, height=40).pack(fill="x")
mtk.Label(first_page, text=l("HomeWelcome"),
anchor='center', font=(fontconfig.getfont(), 20), background=color_tmpl.default_color["background"], foreground=color_tmpl.default_color["primary_text"]).pack(fill='x')
mtk.Label(first_page, text="\n"+l("HomeInfo"),
anchor='center', font=(fontconfig.getfont(), 10), background=color_tmpl.default_color["background"], foreground=color_tmpl.default_color["secondary_text"]).pack(fill='x')
mtk.Frame(first_page, height=30).pack()
buttonlist = mtk.Frame(first_page)
with open(vars.DISKMOUNT+os.sep+"PEinjector"+os.sep+"VERSION", 'r') as file:
version = file.read().replace("\n", "")
with open("VERSION", 'r') as file:
hubversion = file.read().replace("\n", "")
def restart_to_update(*args):
warn("[homeui]start update, exit")
python_path = sys.executable
os.execl(python_path, python_path, __file__.replace(
"ui"+os.sep+"homeui.py", "main.py"), "--upgrade", "--dis-permission-error")
def open_update(*args):
info("[homeui]open in webbrowser")
__import__("webbrowser").open(
"http://git.hmtsai.cn/cxykevin/injectorHub")
mtk.Frame(buttonlist, height=10).pack(side="left")
mtk.ButtonLight(buttonlist, text="PEinjector "+version,
w=140, func=restart_to_update, color_type="success").pack(side="left")
mtk.ButtonLight(buttonlist, text="Hub "+hubversion,
w=100, color_type="primary", func=open_update).pack(side="left")
buttonlist.pack()
mtk.Frame(first_page, w=10000).pack(fill="both", expand=True)
first_page.pack(fill="both", expand=True)
now_frame = first_page
def home_ui(root: mtk.Frame):
global master
install_root_frame = mtk.Frame(root)
master = install_root_frame
show_home_page()
install_root_frame.pack(fill="both", expand=True)

View File

@ -1,6 +1,5 @@
import json import json
import os import os
from turtle import bgcolor
from magictk import mtk, color_tmpl from magictk import mtk, color_tmpl
from magictk import fontconfig from magictk import fontconfig
from ui.lang import l from ui.lang import l
@ -12,13 +11,20 @@ from logger.logger import *
now_frame = None now_frame = None
master: mtk.Frame = None master: mtk.Frame = None
UPGRADE = 0
def show_first_page(): def show_first_page():
global now_frame, master global now_frame, master
first_page = mtk.Frame(master,) first_page = mtk.Frame(master,)
mtk.Frame(first_page, w=10000).pack(fill="both", expand=True) mtk.Frame(first_page, w=10000).pack(fill="both", expand=True)
mtk.Label(first_page, text=l("InstallWelcome"), if (UPGRADE):
mtk.Label(first_page, text=l("UpgradeWelcome"),
anchor='center', font=(fontconfig.getfont(), 22), background=color_tmpl.default_color["background"], foreground=color_tmpl.default_color["primary_text"]).pack(fill='x')
mtk.Label(first_page, text="\n"+l("InstallInfo"),
anchor='center', font=(fontconfig.getfont(), 12), background=color_tmpl.default_color["background"], foreground=color_tmpl.default_color["secondary_text"]).pack(fill='x')
else:
mtk.Label(first_page, text=l("UpgradeWelcome"),
anchor='center', font=(fontconfig.getfont(), 22), background=color_tmpl.default_color["background"], foreground=color_tmpl.default_color["primary_text"]).pack(fill='x') anchor='center', font=(fontconfig.getfont(), 22), background=color_tmpl.default_color["background"], foreground=color_tmpl.default_color["primary_text"]).pack(fill='x')
mtk.Label(first_page, text="\n"+l("InstallInfo"), mtk.Label(first_page, text="\n"+l("InstallInfo"),
anchor='center', font=(fontconfig.getfont(), 12), background=color_tmpl.default_color["background"], foreground=color_tmpl.default_color["secondary_text"]).pack(fill='x') anchor='center', font=(fontconfig.getfont(), 12), background=color_tmpl.default_color["background"], foreground=color_tmpl.default_color["secondary_text"]).pack(fill='x')
@ -279,8 +285,10 @@ def change_page_finish():
anchor='center', font=(fontconfig.getfont(), 12), background=color_tmpl.default_color["background"], foreground=color_tmpl.default_color["secondary_text"]).pack(fill='x') anchor='center', font=(fontconfig.getfont(), 12), background=color_tmpl.default_color["background"], foreground=color_tmpl.default_color["secondary_text"]).pack(fill='x')
def closecallback(*args): def closecallback(*args):
info("close from installer") warn("restart from installer")
finish_page.root.quit() python_path = sys.executable
os.execl(python_path, python_path, __file__.replace(
"ui"+os.sep+"installer.py", "main.py"))
btnframe = mtk.Frame(finish_page, height=30) btnframe = mtk.Frame(finish_page, height=30)
mtk.ButtonFill(finish_page, text=l( mtk.ButtonFill(finish_page, text=l(

View File

@ -1,11 +1,13 @@
from doctest import debug import shutil
from tkinter import messagebox from tkinter import messagebox
from magictk import mtk from magictk import mtk
from logger.logger import * from logger.logger import *
from logger import config from logger import config
from ui import nav from ui import nav
from ui import installer from ui import installer
from ui import homeui
from lib import get_disk from lib import get_disk
from lib import vars
from ui.lang import load_lang, l from ui.lang import load_lang, l
import sys import sys
import getpass import getpass
@ -29,17 +31,20 @@ def check_args(arg, check):
DISPERMISSION = 0 DISPERMISSION = 0
DEBUG = 0 DEBUG = 0
NOTRACE = 0 NOTRACE = 0
UPGRADE = 0
for i in sys.argv[1:]: for i in sys.argv[1:]:
if (check_args(i, "--lang")): if (check_args(i, "--lang")):
nlang = i.split("=")[-1] nlang = i.split("=")[-1]
if (check_args(i, "--dis-permission-error")): elif (check_args(i, "--dis-permission-error")):
DISPERMISSION = 1 DISPERMISSION = 1
if (check_args(i, "--log-level")): elif (check_args(i, "--log-level")):
config.LOGLEVEL = i.split("=")[-1] config.LOGLEVEL = i.split("=")[-1]
if (check_args(i, "--debug")): elif (check_args(i, "--debug")):
DEBUG = 1 DEBUG = 1
if (check_args(i, "--no-trace")): elif (check_args(i, "--no-trace")):
NOTRACE = 1 NOTRACE = 1
elif (check_args(i, "--upgrade")):
UPGRADE = 1
if (nlang+".toml" not in os.listdir("lang")): if (nlang+".toml" not in os.listdir("lang")):
nlang = "en_us" nlang = "en_us"
@ -65,8 +70,11 @@ def main():
if (errno == 1): if (errno == 1):
messagebox.showerror("Injector Hub Error", root_disk) messagebox.showerror("Injector Hub Error", root_disk)
sys.exit(1) sys.exit(1)
elif (errno == 2): elif (errno == 2 or UPGRADE == 1):
if (UPGRADE == 0):
info("[win]cannot find installed disk") info("[win]cannot find installed disk")
else:
info("[win]upgrade")
if DISPERMISSION == 0: if DISPERMISSION == 0:
if (platform.system() == "Linux" and getpass.getuser() != "root"): if (platform.system() == "Linux" and getpass.getuser() != "root"):
err("permission denied in linux") err("permission denied in linux")
@ -84,13 +92,19 @@ def main():
sys.exit(1) sys.exit(1)
else: else:
sys.exit() sys.exit()
installer.UPGRADE = 1
if (UPGRADE == 1):
if (os.path.exists("software")):
info("[win]clean install cache")
shutil.rmtree("software")
nav_list = [ nav_list = [
{"icon": "lightning", "frame": installer.installer_ui, "side": "top"} {"icon": "lightning", "frame": installer.installer_ui, "side": "top"}
] ]
else: else:
vars.DISKMOUNT = root_disk
info(f"[win]found installed disk \"{root_disk}\"") info(f"[win]found installed disk \"{root_disk}\"")
nav_list = [ nav_list = [
{"icon": "home-filled", "frame": None, "side": "top"}, {"icon": "home-filled", "frame": homeui.home_ui, "side": "top"},
{"icon": "dvd", "frame": None, "side": "top"}, {"icon": "dvd", "frame": None, "side": "top"},
{"icon": "plugin", "frame": None, "side": "top"}, {"icon": "plugin", "frame": None, "side": "top"},
{"icon": "setting", "frame": None, "side": "bottom"} {"icon": "setting", "frame": None, "side": "bottom"}