| 162 | |
| 163 | |
| 164 | class TaskThread(QThread): |
| 165 | log_signal = Signal(str) |
| 166 | finished = Signal() # 添加完成信号 |
| 167 | |
| 168 | def __init__(self, task_service, production_window): |
| 169 | super().__init__() |
| 170 | self.task_service = task_service |
| 171 | self.production_window = production_window |
| 172 | self._running = True |
| 173 | |
| 174 | def stop(self): |
| 175 | """安全停止线程""" |
| 176 | self._running = False |
| 177 | self.wait() # 等待线程结束 |
| 178 | |
| 179 | def run(self): |
| 180 | try: |
| 181 | code = check_vip() |
| 182 | if code == 2000: |
| 183 | print("会员过期") |
| 184 | self.production_window.append_log("会员过期") |
| 185 | return |
| 186 | |
| 187 | selected_model, api_key, config = user_opt() |
| 188 | if False in [selected_model, api_key]: |
| 189 | self.production_window.append_log("请先配置模型和api_key") |
| 190 | time.sleep(10) |
| 191 | return |
| 192 | |
| 193 | while self._running: |
| 194 | print("11") |
| 195 | try: |
| 196 | if not self.production_window or not self.production_window.isVisible(): |
| 197 | break |
| 198 | |
| 199 | self.production_window.append_log("检测用户信息") |
| 200 | is_publish, is_not_full, api_key, selected_model, prompt = check_user_token() |
| 201 | print("是否可以发布:", is_publish) |
| 202 | print("是否使用我们的key:", is_not_full) |
| 203 | |
| 204 | if not is_publish: |
| 205 | self.production_window.append_log("用户配置无效") |
| 206 | break |
| 207 | |
| 208 | self.production_window.append_log("开始任务") |
| 209 | data = get_news_list() |
| 210 | if not data: |
| 211 | self.production_window.append_log("获取任务列表失败") |
| 212 | break |
| 213 | |
| 214 | task = [ |
| 215 | { |
| 216 | "id": t["id"], |
| 217 | "account": t["account"], |
| 218 | "platform": t["account_platform_name"], |
| 219 | "title": t["title"], |
| 220 | "article_info": t["article_info"], |
| 221 | "img_list": t["img_list"], |