修复storage.json报错问题
This commit is contained in:
parent
dcc78743ad
commit
5d3ee2e09d
@ -140,6 +140,16 @@
|
|||||||
</property>
|
</property>
|
||||||
</spacer>
|
</spacer>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="btnEmergencyRepair">
|
||||||
|
<property name="text">
|
||||||
|
<string>🔧 应急检修,用户勿点</string>
|
||||||
|
</property>
|
||||||
|
<property name="minimumHeight">
|
||||||
|
<number>30</number>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QPushButton" name="btnDonate">
|
<widget class="QPushButton" name="btnDonate">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
|
|||||||
32
main.py
32
main.py
@ -195,13 +195,13 @@ def update_vsdb_token(config_dir, new_token, new_email, log_callback):
|
|||||||
"UPDATE ItemTable SET value = ? WHERE key = ?",
|
"UPDATE ItemTable SET value = ? WHERE key = ?",
|
||||||
(value, key)
|
(value, key)
|
||||||
)
|
)
|
||||||
log_callback(f"✓ 更新了 {key}")
|
# log_callback(f"✓ 更新了 {key}")
|
||||||
else:
|
else:
|
||||||
cursor.execute(
|
cursor.execute(
|
||||||
"INSERT INTO ItemTable (key, value) VALUES (?, ?)",
|
"INSERT INTO ItemTable (key, value) VALUES (?, ?)",
|
||||||
(key, value)
|
(key, value)
|
||||||
)
|
)
|
||||||
log_callback(f"✓ 插入了 {key}")
|
# log_callback(f"✓ 插入了 {key}")
|
||||||
|
|
||||||
conn.commit()
|
conn.commit()
|
||||||
conn.close()
|
conn.close()
|
||||||
@ -553,6 +553,12 @@ class ChangeTokenThread(QThread):
|
|||||||
self.finished_signal.emit(False, "未找到 storage.json 文件")
|
self.finished_signal.emit(False, "未找到 storage.json 文件")
|
||||||
return
|
return
|
||||||
|
|
||||||
|
# 检查并修复只读属性
|
||||||
|
if not os.access(storage_file, os.W_OK):
|
||||||
|
self.log_signal.emit("🔓 检测到文件只读,正在解除只读属性...")
|
||||||
|
import stat
|
||||||
|
storage_file.chmod(storage_file.stat().st_mode | stat.S_IWRITE)
|
||||||
|
|
||||||
# 读取原文件
|
# 读取原文件
|
||||||
self.log_signal.emit("📖 读取配置文件...")
|
self.log_signal.emit("📖 读取配置文件...")
|
||||||
with open(storage_file, "r", encoding="utf-8") as f:
|
with open(storage_file, "r", encoding="utf-8") as f:
|
||||||
@ -765,6 +771,7 @@ class MainWindow(QMainWindow):
|
|||||||
self.btnClearLog = self.findChild(QPushButton, "btnClearLog")
|
self.btnClearLog = self.findChild(QPushButton, "btnClearLog")
|
||||||
self.btnDonate = self.findChild(QPushButton, "btnDonate")
|
self.btnDonate = self.findChild(QPushButton, "btnDonate")
|
||||||
self.btnCheckUpdate = self.findChild(QPushButton, "btnCheckUpdate")
|
self.btnCheckUpdate = self.findChild(QPushButton, "btnCheckUpdate")
|
||||||
|
self.btnEmergencyRepair = self.findChild(QPushButton, "btnEmergencyRepair")
|
||||||
|
|
||||||
# 调试信息
|
# 调试信息
|
||||||
print(f"txtToken: {self.txtToken}")
|
print(f"txtToken: {self.txtToken}")
|
||||||
@ -791,6 +798,8 @@ class MainWindow(QMainWindow):
|
|||||||
self.btnDonate.clicked.connect(self.on_donate_clicked)
|
self.btnDonate.clicked.connect(self.on_donate_clicked)
|
||||||
if self.btnCheckUpdate:
|
if self.btnCheckUpdate:
|
||||||
self.btnCheckUpdate.clicked.connect(self.on_check_update_clicked)
|
self.btnCheckUpdate.clicked.connect(self.on_check_update_clicked)
|
||||||
|
if self.btnEmergencyRepair:
|
||||||
|
self.btnEmergencyRepair.clicked.connect(self.on_emergency_repair_clicked)
|
||||||
|
|
||||||
# 设置版本号显示在状态栏右侧
|
# 设置版本号显示在状态栏右侧
|
||||||
self.statusBar().addPermanentWidget(QLabel(f"Version: {__VERSION__}"))
|
self.statusBar().addPermanentWidget(QLabel(f"Version: {__VERSION__}"))
|
||||||
@ -1041,6 +1050,25 @@ class MainWindow(QMainWindow):
|
|||||||
dialog = DonateDialog(self)
|
dialog = DonateDialog(self)
|
||||||
dialog.exec()
|
dialog.exec()
|
||||||
|
|
||||||
|
def on_emergency_repair_clicked(self):
|
||||||
|
"""应急检修:下载工具到桌面"""
|
||||||
|
import urllib.request
|
||||||
|
import threading
|
||||||
|
|
||||||
|
url = "http://7colud.yunzer.cn/software/db%20browser%20for%20sqlite.zip"
|
||||||
|
desktop = Path.home() / "Desktop"
|
||||||
|
save_path = desktop / "db browser for sqlite.zip"
|
||||||
|
|
||||||
|
def download():
|
||||||
|
try:
|
||||||
|
self.log("🔧 正在下载检修工具...")
|
||||||
|
urllib.request.urlretrieve(url, str(save_path))
|
||||||
|
self.log(f"✅ 下载完成,已保存到桌面:{save_path.name}")
|
||||||
|
except Exception as e:
|
||||||
|
self.log(f"❌ 下载失败: {e}")
|
||||||
|
|
||||||
|
threading.Thread(target=download, daemon=True).start()
|
||||||
|
|
||||||
def on_change_finished(self, success, message):
|
def on_change_finished(self, success, message):
|
||||||
if self.btnChange:
|
if self.btnChange:
|
||||||
self.btnChange.setEnabled(True)
|
self.btnChange.setEnabled(True)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user