添加阿里镜像,修复依赖增加删除python/Scripts,fast/slow->测试版/稳定版
This commit is contained in:
parent
9e6001d0e0
commit
003769b8e4
4 changed files with 72 additions and 12 deletions
|
@ -3,14 +3,13 @@ import mimetypes
|
|||
from pathlib import Path
|
||||
from shutil import rmtree
|
||||
from subprocess import PIPE, STDOUT, Popen
|
||||
|
||||
import webview
|
||||
|
||||
mimetypes.add_type("text/html", ".html")
|
||||
mimetypes.add_type("text/css", ".css")
|
||||
mimetypes.add_type("application/javascript", ".js")
|
||||
|
||||
version = "2024-10-10"
|
||||
version = "2024-11-28"
|
||||
|
||||
config = {
|
||||
"page": "init",
|
||||
|
@ -34,6 +33,7 @@ def custom_event(data):
|
|||
|
||||
|
||||
mirror_list = {
|
||||
"aliyun": "https://mirrors.aliyun.com/pypi/simple/",
|
||||
"pypi": "https://pypi.org/simple",
|
||||
"tuna": "https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple",
|
||||
"sjtu": "https://mirror.sjtu.edu.cn/pypi/web/simple",
|
||||
|
@ -72,6 +72,10 @@ class Api:
|
|||
def set_mirror(self, mirror):
|
||||
config["mirror"] = mirror
|
||||
|
||||
def update_self(self):
|
||||
# 更新启动器本身
|
||||
pass
|
||||
|
||||
def rm_site_packages(self):
|
||||
site_packages_path = Path("./python/Lib/site-packages")
|
||||
if site_packages_path.exists():
|
||||
|
@ -79,6 +83,13 @@ class Api:
|
|||
return "移除成功"
|
||||
return "python\\Lib\\site-packages目录不存在"
|
||||
|
||||
def rm_python_script(self):
|
||||
python_script_path = Path("./python/Scripts")
|
||||
if python_script_path.exists():
|
||||
rmtree(python_script_path)
|
||||
return "移除成功"
|
||||
return "python\\Scripts目录不存在"
|
||||
|
||||
def run(self, command, cwd=None):
|
||||
command = command_list[command]
|
||||
if callable(command):
|
||||
|
@ -101,9 +112,7 @@ class Api:
|
|||
return "failed"
|
||||
|
||||
|
||||
window = webview.create_window(
|
||||
f"mower-ng launcher {version}", "ui/dist/index.html", js_api=Api()
|
||||
)
|
||||
window = webview.create_window("mower-ng launcher", "ui/dist/index.html", js_api=Api())
|
||||
webview.start()
|
||||
|
||||
with config_path.open("w") as f:
|
33
log.py
Normal file
33
log.py
Normal file
|
@ -0,0 +1,33 @@
|
|||
import logging
|
||||
from logging.handlers import RotatingFileHandler
|
||||
|
||||
|
||||
# 配置日志
|
||||
def setup_logger():
|
||||
logger = logging.getLogger("launcher.log")
|
||||
logger.setLevel(logging.DEBUG)
|
||||
|
||||
# 控制台输出
|
||||
console_handler = logging.StreamHandler()
|
||||
console_handler.setLevel(logging.DEBUG)
|
||||
|
||||
# 文件输出
|
||||
file_handler = RotatingFileHandler(
|
||||
"launcher.log", maxBytes=5 * 1024 * 1024, backupCount=3
|
||||
)
|
||||
file_handler.setLevel(logging.INFO)
|
||||
|
||||
# 设置格式化器
|
||||
formatter = logging.Formatter("%(asctime)s [%(levelname)s] - %(message)s")
|
||||
console_handler.setFormatter(formatter)
|
||||
file_handler.setFormatter(formatter)
|
||||
|
||||
# 添加 Handler
|
||||
logger.addHandler(console_handler)
|
||||
logger.addHandler(file_handler)
|
||||
|
||||
return logger
|
||||
|
||||
|
||||
# 创建全局 Logger 实例
|
||||
logger = setup_logger()
|
|
@ -16,23 +16,40 @@ async function rm_site_packages() {
|
|||
})
|
||||
running.value = false
|
||||
}
|
||||
|
||||
|
||||
async function rm_python_script() {
|
||||
running.value = true
|
||||
notification['info']({
|
||||
content: '提示',
|
||||
meta: '开始移除python/Script',
|
||||
duration: 3000
|
||||
})
|
||||
const response = await pywebview.api.rm_python_script()
|
||||
notification['info']({
|
||||
content: '提示',
|
||||
meta: response,
|
||||
duration: 3000
|
||||
})
|
||||
running.value = false
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<n-flex
|
||||
vertical
|
||||
style="
|
||||
<n-flex vertical style="
|
||||
gap: 16px;
|
||||
height: 100%;
|
||||
padding: 16px;
|
||||
box-sizing: border-box;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
"
|
||||
>
|
||||
">
|
||||
<n-button class="fix-btn" type="error" secondary size="large" @click="rm_site_packages">
|
||||
移除 site-packages
|
||||
</n-button>
|
||||
<n-button class="fix-btn" type="error" secondary size="large" @click="rm_python_script">
|
||||
移除 python/Script
|
||||
</n-button>
|
||||
</n-flex>
|
||||
</template>
|
||||
|
||||
|
|
|
@ -43,14 +43,15 @@ provide('current_state', current_state)
|
|||
<n-form-item label="mower-ng 代码分支">
|
||||
<n-radio-group v-model:value="branch">
|
||||
<n-flex>
|
||||
<n-radio value="fast">fast</n-radio>
|
||||
<n-radio value="slow">slow</n-radio>
|
||||
<n-radio value="fast">测试版</n-radio>
|
||||
<n-radio value="slow">稳定版</n-radio>
|
||||
</n-flex>
|
||||
</n-radio-group>
|
||||
</n-form-item>
|
||||
<n-form-item label="PyPI 仓库镜像">
|
||||
<n-radio-group v-model:value="mirror">
|
||||
<n-flex>
|
||||
<n-radio value="aliyun">阿里云镜像站</n-radio>
|
||||
<n-radio value="pypi">PyPI</n-radio>
|
||||
<n-radio value="sjtu">上海交通大学镜像站</n-radio>
|
||||
<n-radio value="tuna">清华大学镜像站</n-radio>
|
||||
|
|
Loading…
Reference in a new issue