完成注入页面未实现保存
This commit is contained in:
parent
4398c4a67f
commit
1bb0a91d66
|
@ -10,7 +10,7 @@ DownloadInstall = "在开始之前,我们需要下载一些依赖文件\n如
|
||||||
StartInstall = "开始安装"
|
StartInstall = "开始安装"
|
||||||
InstallVtoy = "安装 Ventoy"
|
InstallVtoy = "安装 Ventoy"
|
||||||
InstallVtoyTitle = "安装 Ventoy"
|
InstallVtoyTitle = "安装 Ventoy"
|
||||||
InstallVtoyInfo = "请在打开的 ventoy 安装程序手动完成安装\n若安装完毕,请点击 “扫描” 按钮并选择您安装完毕的U盘\n若您找不到您的U盘,请尝试点击 “显示所有设备”\n如果你在使用 arm 架构的设备或软件无法打开,请手动运行以下程序:\n Windows: software\\ventoy\\altexe\\你的架构对应程序.exe\n Linux: software/ventoy/altexe/你的架构对应程序\n注:请确保磁盘已经挂载。本版本ventoy已精简,与原版兼容"
|
InstallVtoyInfo = "请在打开的 ventoy 安装程序手动完成安装\n若安装完毕,请点击 “扫描” 按钮并选择您安装完毕的U盘\n若您找不到您的U盘,请尝试点击 “显示所有设备”\n如果你在使用 arm 架构的设备或软件无法打开,请手动运行以下程序:\n Windows: software\\ventoy\\altexe\\你的架构对应程序.exe\n Linux: software/ventoy/altexe/你的架构对应程序\n注:请确保磁盘已经挂载。本版本ventoy由原版精简文件且未修改其它任何文件"
|
||||||
ScanVtoy = "扫描"
|
ScanVtoy = "扫描"
|
||||||
RestartVtoy = "重启安装程序"
|
RestartVtoy = "重启安装程序"
|
||||||
ChooseVtoyDevice = "选择设备"
|
ChooseVtoyDevice = "选择设备"
|
||||||
|
@ -23,3 +23,6 @@ InstallFinishInfo = "PEinjector已经安装到您的设备\n点击下方按钮
|
||||||
InstallFinishBtn = "重启"
|
InstallFinishBtn = "重启"
|
||||||
HomeWelcome = "欢迎使用 PEinjector"
|
HomeWelcome = "欢迎使用 PEinjector"
|
||||||
HomeInfo = "一个增强 WindowsPE 的一个工具和平台\n点击下方版本号进行更新"
|
HomeInfo = "一个增强 WindowsPE 的一个工具和平台\n点击下方版本号进行更新"
|
||||||
|
InjectHead = "注入 ISO 镜像文件"
|
||||||
|
Save = "保存"
|
||||||
|
DownloadImg = "查找 ISO"
|
||||||
|
|
|
@ -0,0 +1,79 @@
|
||||||
|
import os
|
||||||
|
import json
|
||||||
|
from lib import vars
|
||||||
|
from logger.logger import *
|
||||||
|
|
||||||
|
|
||||||
|
isolist = []
|
||||||
|
|
||||||
|
|
||||||
|
def sync_iso():
|
||||||
|
global isolist
|
||||||
|
isolist = []
|
||||||
|
|
||||||
|
info("[sync_disk]start sync iso")
|
||||||
|
|
||||||
|
searchroot = ""
|
||||||
|
search_level = 3
|
||||||
|
if os.path.exists(vars.DISKMOUNT+f"{os.sep}ventoy{os.sep}ventoy.json"):
|
||||||
|
with open(vars.DISKMOUNT+f"{os.sep}ventoy{os.sep}ventoy.json", "r") as file:
|
||||||
|
ventoy_cfg = json.load(file)
|
||||||
|
|
||||||
|
if "control" in ventoy_cfg:
|
||||||
|
for i in ventoy_cfg["control"]:
|
||||||
|
if "VTOY_DEFAULT_SEARCH_ROOT" in i:
|
||||||
|
searchroot = i["VTOY_DEFAULT_SEARCH_ROOT"]
|
||||||
|
if "VTOY_MAX_SEARCH_LEVEL" in i:
|
||||||
|
if i["VTOY_MAX_SEARCH_LEVEL"] != "max":
|
||||||
|
search_level = int(i["VTOY_MAX_SEARCH_LEVEL"])
|
||||||
|
|
||||||
|
info(f"[sync_disk]sync in \"{searchroot}\" {str(search_level)} levels")
|
||||||
|
|
||||||
|
def dfs(deep, dir, search_levels):
|
||||||
|
global isolist
|
||||||
|
if deep > search_levels:
|
||||||
|
return
|
||||||
|
lists = os.listdir(vars.DISKMOUNT+dir)
|
||||||
|
for i in lists:
|
||||||
|
if os.path.isfile(vars.DISKMOUNT+dir+os.sep+i):
|
||||||
|
if ".iso" in i.lower():
|
||||||
|
isolist.append((dir+os.sep+i).replace(os.sep, "/"))
|
||||||
|
else:
|
||||||
|
dfs(deep+1, dir+os.sep+i, search_levels)
|
||||||
|
|
||||||
|
dfs(0, searchroot, search_level)
|
||||||
|
|
||||||
|
info(f"[sync_disk]sync finish, found {str(len(isolist))} iso files")
|
||||||
|
|
||||||
|
|
||||||
|
def get_isolist():
|
||||||
|
if (len(isolist) == 0):
|
||||||
|
sync_iso()
|
||||||
|
return isolist
|
||||||
|
|
||||||
|
|
||||||
|
def get_injected_iso():
|
||||||
|
global isolist
|
||||||
|
|
||||||
|
info("[sync_disk]get injected iso")
|
||||||
|
|
||||||
|
if os.path.exists(vars.DISKMOUNT+f"{os.sep}ventoy{os.sep}ventoy.json"):
|
||||||
|
with open(vars.DISKMOUNT+f"{os.sep}ventoy{os.sep}ventoy.json", "r") as file:
|
||||||
|
ventoy_cfg = json.load(file)
|
||||||
|
if "injection" in ventoy_cfg:
|
||||||
|
injected_list = []
|
||||||
|
for i in ventoy_cfg["injection"]:
|
||||||
|
if ("image" not in i or "archive" not in i):
|
||||||
|
warn(f"[sync_disk]error ventoy config \"{repr(i)}\"")
|
||||||
|
continue
|
||||||
|
if ("PEinjector" not in i["archive"]):
|
||||||
|
continue
|
||||||
|
if (i["image"] not in isolist):
|
||||||
|
continue
|
||||||
|
injected_list.append(i["image"])
|
||||||
|
info(f"[sync_disk]found injected iso \"{i['image']}\"")
|
||||||
|
return injected_list
|
||||||
|
else:
|
||||||
|
return []
|
||||||
|
else:
|
||||||
|
return []
|
|
@ -1 +1,2 @@
|
||||||
DISKMOUNT = ""
|
DISKMOUNT = ""
|
||||||
|
SHOWALLIMAGE = False
|
||||||
|
|
105
ui/injectimg.py
105
ui/injectimg.py
|
@ -5,19 +5,114 @@ from magictk import fontconfig
|
||||||
from ui.lang import l
|
from ui.lang import l
|
||||||
from logger.logger import *
|
from logger.logger import *
|
||||||
from lib import vars
|
from lib import vars
|
||||||
|
from lib import sync_disk
|
||||||
from tkinter import Label as tkLabel
|
from tkinter import Label as tkLabel
|
||||||
|
|
||||||
now_frame = None
|
now_frame = None
|
||||||
master: mtk.Frame = None
|
master: mtk.Frame = None
|
||||||
|
checkboxlist = []
|
||||||
|
img_list = []
|
||||||
|
iso_frame = None
|
||||||
|
|
||||||
|
|
||||||
def show_inject_page():
|
def show_inject_page():
|
||||||
global now_frame, master
|
global now_frame, master, checkboxlist
|
||||||
inject_page = mtk.Frame(master)
|
inject_page = mtk.Frame(master)
|
||||||
mtk.Frame(inject_page, w=10000).pack(fill="both", expand=True)
|
mtk.Frame(inject_page, w=10000, height=8).pack(fill="x", expand=True)
|
||||||
# TODO
|
head_frame = mtk.Frame(inject_page)
|
||||||
mtk.Frame(inject_page, w=10000).pack(fill="both", expand=True)
|
mtk.Frame(head_frame, w=10).pack(
|
||||||
inject_page.pack(fill="both", expand=True)
|
side="left", fill="y", expand=True)
|
||||||
|
mtk.Frame(inject_page, height=8).pack(fill="x", expand=True, side="left")
|
||||||
|
|
||||||
|
def show_download_list(obj):
|
||||||
|
posx = obj.root.main_tk.winfo_pointerx()-10
|
||||||
|
posy = obj.root.main_tk.winfo_pointery()-10
|
||||||
|
menuobjs = mtk.MenuObjs()
|
||||||
|
menuobjs.addmenu("-- Do not support WIM!--", lambda *args: True)
|
||||||
|
menuobjs.addmenu("WePE(stable)", lambda *args: __import__("webbrowser").open(
|
||||||
|
"https://www.wepe.com.cn/"))
|
||||||
|
menuobjs.addmenu("EdgelessPE(thanks)", lambda *args: __import__("webbrowser").open(
|
||||||
|
"https://home.edgeless.top/"))
|
||||||
|
menuobjs.addmenu("FirPE(unstable)", lambda *args: __import__("webbrowser").open(
|
||||||
|
"https://www.firpe.cn/"))
|
||||||
|
menuobjs.addmenu("HotPE(unstable)", lambda *args: __import__("webbrowser").open(
|
||||||
|
"https://www.hotpe.top/"))
|
||||||
|
menuobjs.addmenu("MicrosoftDoc", lambda *args: __import__("webbrowser").open(
|
||||||
|
"https://learn.microsoft.com/en-us/windows-hardware/manufacture/desktop/download-winpe--windows-pe?view=windows-11"))
|
||||||
|
menuobjs.addmenu("iTellYou", lambda *args: __import__("webbrowser").open(
|
||||||
|
"https://next.itellyou.cn//"))
|
||||||
|
mtk.Menu(obj.root, w=200, h=400, x=posx, y=posy, menuobj=menuobjs)
|
||||||
|
action_btn_frame = mtk.Frame(inject_page)
|
||||||
|
mtk.Frame(action_btn_frame, w=10).pack(expand=True, side="left")
|
||||||
|
savebtn = mtk.ButtonFill(action_btn_frame, text=l("Save"))
|
||||||
|
savebtn.pack(side="left")
|
||||||
|
mtk.Button(action_btn_frame, text=l("DownloadImg"),
|
||||||
|
func=show_download_list).pack(side="left")
|
||||||
|
mtk.Frame(action_btn_frame, w=10000).pack(
|
||||||
|
fill="x", expand=True, side="left")
|
||||||
|
|
||||||
|
mtk.Frame(inject_page, height=16).pack(fill="x", expand=True, side="left")
|
||||||
|
head_label = tkLabel(
|
||||||
|
head_frame,
|
||||||
|
width=10000,
|
||||||
|
text=l("InjectHead"),
|
||||||
|
background=color_tmpl.default_color["background"],
|
||||||
|
foreground=color_tmpl.default_color["primary_text"],
|
||||||
|
font=(fontconfig.getfont(), 14),
|
||||||
|
anchor='w'
|
||||||
|
)
|
||||||
|
head_label.pack(side="left", anchor='w')
|
||||||
|
head_frame.pack(fill="x", expand=True, anchor='w')
|
||||||
|
|
||||||
|
action_btn_frame.pack(fill="x", expand=True)
|
||||||
|
|
||||||
|
show_all_img = vars.SHOWALLIMAGE
|
||||||
|
|
||||||
|
def updatelist():
|
||||||
|
global checkboxlist, iso_frame, img_list
|
||||||
|
if (iso_frame is not None):
|
||||||
|
iso_frame.destroy() # 避免内存泄漏
|
||||||
|
del iso_frame
|
||||||
|
iso_frame = None
|
||||||
|
isolists = sync_disk.get_isolist()
|
||||||
|
imgsums = 0
|
||||||
|
for isopath in isolists:
|
||||||
|
if show_all_img or ('pe' in isopath.lower() or 'win' in isopath.lower()):
|
||||||
|
imgsums += 1
|
||||||
|
|
||||||
|
container_frame = mtk.Frame(inject_page)
|
||||||
|
mtk.Frame(container_frame, w=10).pack(expand=True, side="left")
|
||||||
|
iso_frame = mtk.Container(container_frame, w=10000, h=10000,
|
||||||
|
container_h=imgsums*20)
|
||||||
|
if (len(checkboxlist) > 0):
|
||||||
|
for i in checkboxlist:
|
||||||
|
i.canvas.destroy() # 避免内存泄漏
|
||||||
|
del i
|
||||||
|
checkboxlist = []
|
||||||
|
img_list = []
|
||||||
|
|
||||||
|
for isopath in isolists:
|
||||||
|
if show_all_img or ('pe' in isopath.lower() or 'win' in isopath.lower()):
|
||||||
|
isoname = isopath.split(os.sep)[-1]
|
||||||
|
if (len(isoname) > 40):
|
||||||
|
isoname = isoname[:37]+"..."
|
||||||
|
checkboxlist.append(mtk.Checkbox(
|
||||||
|
iso_frame, text=isoname, h=20, w=400))
|
||||||
|
img_list.append(isopath)
|
||||||
|
checkboxlist[-1].pack(fill="x", expand=True)
|
||||||
|
|
||||||
|
for injectedpath in sync_disk.get_injected_iso():
|
||||||
|
checkobj = checkboxlist[img_list.index(injectedpath)]
|
||||||
|
checkobj.ishover = 1
|
||||||
|
checkobj._update_color()
|
||||||
|
|
||||||
|
iso_frame.pack(fill="x", expand=True, side="left")
|
||||||
|
mtk.Frame(container_frame, w=20).pack(side="left")
|
||||||
|
container_frame.pack(fill="both", expand=True)
|
||||||
|
|
||||||
|
updatelist()
|
||||||
|
|
||||||
|
inject_page.pack(anchor="nw", side="top")
|
||||||
now_frame = inject_page
|
now_frame = inject_page
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -45,10 +45,11 @@ Options:
|
||||||
--help Show this help info and exit
|
--help Show this help info and exit
|
||||||
--version, -V Get hub version
|
--version, -V Get hub version
|
||||||
--lang=<zh_cn/en_us> Set language
|
--lang=<zh_cn/en_us> Set language
|
||||||
--install, -i Install PEinjector
|
--install, -I Install PEinjector
|
||||||
--upgrade, -U Upgrade PEinjector
|
--upgrade, -U Upgrade PEinjector
|
||||||
--device, -D Set device (mount path)
|
--device, -D Set device (mount path)
|
||||||
--clean Clean download cache
|
--clean Clean download cache
|
||||||
|
--show-all-img Show all images in inject page
|
||||||
|
|
||||||
Debug Options:
|
Debug Options:
|
||||||
--debug Open debug mode (raise all errors)
|
--debug Open debug mode (raise all errors)
|
||||||
|
@ -69,8 +70,10 @@ Debug Options:
|
||||||
NOTRACE = 1
|
NOTRACE = 1
|
||||||
elif (check_args(i, "--upgrade") or check_args(i, "-U")):
|
elif (check_args(i, "--upgrade") or check_args(i, "-U")):
|
||||||
UPGRADE = 1
|
UPGRADE = 1
|
||||||
elif (check_args(i, "--install") or check_args(i, "-i")):
|
elif (check_args(i, "--install") or check_args(i, "-I")):
|
||||||
UPGRADE = 2
|
UPGRADE = 2
|
||||||
|
elif (check_args(i, "--show-all-img")):
|
||||||
|
vars.SHOWALLIMAGE = True
|
||||||
elif (check_args(i, "--device") or check_args(i, "-D")):
|
elif (check_args(i, "--device") or check_args(i, "-D")):
|
||||||
DEVICE = i.split("=")[-1]
|
DEVICE = i.split("=")[-1]
|
||||||
elif (check_args(i, "--clean")):
|
elif (check_args(i, "--clean")):
|
||||||
|
|
Loading…
Reference in New Issue