correct the update method to get the return type[Task<T>]
昨天用rustup更新了一下,不知道为什么连info都会提示我调了unsafe方法,要求我把它放进unsafe块中,日了狗,先记录一下再说吧
This commit is contained in:
parent
656eceac07
commit
06549c35ab
@ -10,6 +10,7 @@ iced = { git = "https://github.com/iced-rs/iced.git", features = [
|
|||||||
"advanced",
|
"advanced",
|
||||||
"image",
|
"image",
|
||||||
"sipper",
|
"sipper",
|
||||||
|
"tokio",
|
||||||
] }
|
] }
|
||||||
tokio = { version = "1.45.1", features = ["full"] }
|
tokio = { version = "1.45.1", features = ["full"] }
|
||||||
reqwest = "0.12.20"
|
reqwest = "0.12.20"
|
||||||
@ -47,6 +48,8 @@ iced_futures = { version = "0.13.2", features = [
|
|||||||
"thread-pool",
|
"thread-pool",
|
||||||
] }
|
] }
|
||||||
num_enum = "0.7.4"
|
num_enum = "0.7.4"
|
||||||
|
trace = "0.1.7"
|
||||||
|
tracing = "0.1.41"
|
||||||
|
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
|
@ -23,4 +23,3 @@
|
|||||||
|
|
||||||
## 忐忑
|
## 忐忑
|
||||||
* 本软件的3D封装下载调用了jlc的api,不知道哪天就收到了某函,所以暂时只在本站开源了,在未想办法解决掉该可能引起纠纷的事项之前不想广泛传播,所以也请各位道友手下留情,不要随意传播本软件
|
* 本软件的3D封装下载调用了jlc的api,不知道哪天就收到了某函,所以暂时只在本站开源了,在未想办法解决掉该可能引起纠纷的事项之前不想广泛传播,所以也请各位道友手下留情,不要随意传播本软件
|
||||||
中 东奔西跑黑暗
|
|
@ -1,5 +1,5 @@
|
|||||||
use iced::{Length, alignment::Horizontal, widget::Column};
|
use iced::{Length, Task, alignment::Horizontal, widget::Column};
|
||||||
use log::info;
|
use tracing::info;
|
||||||
|
|
||||||
use crate::ui::main_window::{MainWindowMsg, TabContent};
|
use crate::ui::main_window::{MainWindowMsg, TabContent};
|
||||||
|
|
||||||
@ -14,12 +14,13 @@ pub enum DbBrowserMsg {
|
|||||||
impl TabContent for DbBrowser {
|
impl TabContent for DbBrowser {
|
||||||
type TabMessage = DbBrowserMsg;
|
type TabMessage = DbBrowserMsg;
|
||||||
|
|
||||||
fn update(&mut self, msg: Self::TabMessage) {
|
fn update(&mut self, msg: Self::TabMessage) -> Task<MainWindowMsg> {
|
||||||
match msg {
|
match msg {
|
||||||
DbBrowserMsg::Nothing => {
|
DbBrowserMsg::Nothing => {
|
||||||
info!("This function not allowed");
|
info!("This function not allowed");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Task::none()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn content(&self) -> iced::Element<'_, MainWindowMsg> {
|
fn content(&self) -> iced::Element<'_, MainWindowMsg> {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
use iced::{Length, alignment::Horizontal, widget::Column};
|
use iced::{Length, Task, alignment::Horizontal, widget::Column};
|
||||||
use log::info;
|
use tracing::info;
|
||||||
|
|
||||||
#[allow(unused_imports)]
|
#[allow(unused_imports)]
|
||||||
use crate::ui::main_window::{MainWindowMsg, TabContent};
|
use crate::ui::main_window::{MainWindowMsg, TabContent};
|
||||||
@ -66,7 +66,7 @@ impl TabContent for HomePage {
|
|||||||
|
|
||||||
type TabMessage = HomePageMsg;
|
type TabMessage = HomePageMsg;
|
||||||
|
|
||||||
fn update(&mut self, msg: Self::TabMessage) {
|
fn update(&mut self, msg: Self::TabMessage) -> Task<MainWindowMsg> {
|
||||||
match msg {
|
match msg {
|
||||||
HomePageMsg::Nothing => {
|
HomePageMsg::Nothing => {
|
||||||
info!("This way ok.");
|
info!("This way ok.");
|
||||||
@ -96,5 +96,6 @@ impl TabContent for HomePage {
|
|||||||
info!("Is the message you should process ? =====>> {msg:?}");
|
info!("Is the message you should process ? =====>> {msg:?}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Task::none()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
use crate::ui::main_window::{MainWindowMsg, TabContent};
|
use crate::ui::main_window::{MainWindowMsg, TabContent};
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use iced::{Length, alignment::Horizontal, widget::Column};
|
use iced::{Length, Task, alignment::Horizontal, widget::Column};
|
||||||
use log::info;
|
use tracing::info;
|
||||||
|
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
pub struct JlcDownloader {
|
pub struct JlcDownloader {
|
||||||
@ -19,7 +19,7 @@ pub enum JlcDownloaderMsg {
|
|||||||
impl TabContent for JlcDownloader {
|
impl TabContent for JlcDownloader {
|
||||||
type TabMessage = JlcDownloaderMsg;
|
type TabMessage = JlcDownloaderMsg;
|
||||||
|
|
||||||
fn update(&mut self, msg: Self::TabMessage) {
|
fn update(&mut self, msg: Self::TabMessage) -> Task<MainWindowMsg> {
|
||||||
match msg {
|
match msg {
|
||||||
JlcDownloaderMsg::Nothing => {
|
JlcDownloaderMsg::Nothing => {
|
||||||
info!("JlcDownloaderMsg::Nothing");
|
info!("JlcDownloaderMsg::Nothing");
|
||||||
@ -34,6 +34,7 @@ impl TabContent for JlcDownloader {
|
|||||||
info!("Whach out the msg: {msg:?}");
|
info!("Whach out the msg: {msg:?}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Task::none()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn content(&self) -> iced::Element<'_, MainWindowMsg> {
|
fn content(&self) -> iced::Element<'_, MainWindowMsg> {
|
||||||
@ -61,6 +62,13 @@ pub struct KeywordSearchItem {
|
|||||||
}
|
}
|
||||||
impl JlcDownloader {
|
impl JlcDownloader {
|
||||||
pub async fn search_keyword(keyword: &str) -> Result<Vec<KeywordSearchItem>> {
|
pub async fn search_keyword(keyword: &str) -> Result<Vec<KeywordSearchItem>> {
|
||||||
|
if keyword.is_empty() {
|
||||||
|
tokio::time::sleep(tokio::time::Duration::from_secs(1));
|
||||||
|
info!("The keyword is empty.");
|
||||||
|
return Err(anyhow::Error::msg(
|
||||||
|
"Please insert the keyword before search",
|
||||||
|
));
|
||||||
|
}
|
||||||
tokio::time::sleep(tokio::time::Duration::from_secs(2)).await;
|
tokio::time::sleep(tokio::time::Duration::from_secs(2)).await;
|
||||||
for i in 0..10 {
|
for i in 0..10 {
|
||||||
tokio::time::sleep(tokio::time::Duration::from_secs(2)).await;
|
tokio::time::sleep(tokio::time::Duration::from_secs(2)).await;
|
||||||
@ -68,6 +76,9 @@ impl JlcDownloader {
|
|||||||
}
|
}
|
||||||
Ok(Vec::new())
|
Ok(Vec::new())
|
||||||
}
|
}
|
||||||
|
pub async fn keyword_search_task() -> Result<Vec<KeywordSearchItem>> {
|
||||||
|
Ok(Vec::new())
|
||||||
|
}
|
||||||
pub async fn fetch_item_images(
|
pub async fn fetch_item_images(
|
||||||
item: &KeywordSearchItem,
|
item: &KeywordSearchItem,
|
||||||
) -> Result<Vec<iced::widget::image::Handle>> {
|
) -> Result<Vec<iced::widget::image::Handle>> {
|
||||||
|
@ -7,8 +7,8 @@ use crate::ui::part_viewer::PartViewerMsg;
|
|||||||
use crate::utils::step_downloader;
|
use crate::utils::step_downloader;
|
||||||
use iced::Subscription;
|
use iced::Subscription;
|
||||||
use iced::Task;
|
use iced::Task;
|
||||||
use log::info;
|
use tracing::info;
|
||||||
use log::warn;
|
use tracing::warn;
|
||||||
|
|
||||||
#[allow(unused_imports)]
|
#[allow(unused_imports)]
|
||||||
use super::db_browser;
|
use super::db_browser;
|
||||||
@ -65,7 +65,7 @@ impl MainWindow {
|
|||||||
(
|
(
|
||||||
Self::default(),
|
Self::default(),
|
||||||
Task::batch([
|
Task::batch([
|
||||||
Task::perform(JlcDownloader::search_keyword("test"), |x| match x {
|
Task::perform(JlcDownloader::search_keyword(""), |x| match x {
|
||||||
Ok(v) => MainWindowMsg::JlcDownloader(JlcDownloaderMsg::KeywordSearchResult(v)),
|
Ok(v) => MainWindowMsg::JlcDownloader(JlcDownloaderMsg::KeywordSearchResult(v)),
|
||||||
Err(e) => MainWindowMsg::JlcDownloader(JlcDownloaderMsg::KeywordSearchError(
|
Err(e) => MainWindowMsg::JlcDownloader(JlcDownloaderMsg::KeywordSearchError(
|
||||||
format!("{e:?}"),
|
format!("{e:?}"),
|
||||||
@ -192,7 +192,7 @@ impl MainWindow {
|
|||||||
let btn = button(txt).style(bstyle);
|
let btn = button(txt).style(bstyle);
|
||||||
btn.on_press(MainWindowMsg::TabSelected(tab)).into()
|
btn.on_press(MainWindowMsg::TabSelected(tab)).into()
|
||||||
}
|
}
|
||||||
fn update(&mut self, msg: MainWindowMsg) {
|
fn update(&mut self, msg: MainWindowMsg) -> Task<MainWindowMsg> {
|
||||||
info!("Process the msg: {msg:?}");
|
info!("Process the msg: {msg:?}");
|
||||||
match msg {
|
match msg {
|
||||||
MainWindowMsg::ThemeChanged(theme) => {
|
MainWindowMsg::ThemeChanged(theme) => {
|
||||||
@ -200,37 +200,35 @@ impl MainWindow {
|
|||||||
if let Some(idx) = Theme::ALL.iter().position(|x| x == &theme) {
|
if let Some(idx) = Theme::ALL.iter().position(|x| x == &theme) {
|
||||||
crate::utils::app_settings::set_curr_theme(idx as u32).unwrap();
|
crate::utils::app_settings::set_curr_theme(idx as u32).unwrap();
|
||||||
}
|
}
|
||||||
|
Task::none()
|
||||||
}
|
}
|
||||||
MainWindowMsg::TitleChanged(title) => {
|
MainWindowMsg::TitleChanged(title) => {
|
||||||
self.title = title;
|
self.title = title;
|
||||||
|
Task::none()
|
||||||
}
|
}
|
||||||
MainWindowMsg::Nothing => {
|
MainWindowMsg::Nothing => {
|
||||||
info!("Nothing");
|
info!("Nothing");
|
||||||
iced::debug::time("Test".to_owned());
|
iced::debug::time("Test".to_owned());
|
||||||
|
Task::none()
|
||||||
}
|
}
|
||||||
MainWindowMsg::TabSelected(i) => {
|
MainWindowMsg::TabSelected(i) => {
|
||||||
self.curr_tab = i;
|
self.curr_tab = i;
|
||||||
self.curr_tab.save();
|
self.curr_tab.save();
|
||||||
|
Task::none()
|
||||||
}
|
}
|
||||||
MainWindowMsg::HomePage(msg) => {
|
MainWindowMsg::HomePage(msg) => {
|
||||||
info!("update HomePage");
|
info!("update HomePage");
|
||||||
self.home_page.update(msg);
|
self.home_page.update(msg)
|
||||||
}
|
|
||||||
MainWindowMsg::JlcDownloader(msg) => {
|
|
||||||
self.jlc_downloader.update(msg);
|
|
||||||
}
|
|
||||||
MainWindowMsg::DbBrowser(msg) => {
|
|
||||||
self.db_browser.update(msg);
|
|
||||||
}
|
|
||||||
MainWindowMsg::PartViewer(part_viewer_msg) => {
|
|
||||||
self.part_viewer.update(part_viewer_msg);
|
|
||||||
}
|
|
||||||
MainWindowMsg::SearchKeywordChanged(k) => {
|
|
||||||
self.jlc_downloader
|
|
||||||
.update(JlcDownloaderMsg::KeywordChanged(k));
|
|
||||||
}
|
}
|
||||||
|
MainWindowMsg::JlcDownloader(msg) => self.jlc_downloader.update(msg),
|
||||||
|
MainWindowMsg::DbBrowser(msg) => self.db_browser.update(msg),
|
||||||
|
MainWindowMsg::PartViewer(part_viewer_msg) => self.part_viewer.update(part_viewer_msg),
|
||||||
|
MainWindowMsg::SearchKeywordChanged(k) => self
|
||||||
|
.jlc_downloader
|
||||||
|
.update(JlcDownloaderMsg::KeywordChanged(k)),
|
||||||
MainWindowMsg::StepDownloader(msg) => {
|
MainWindowMsg::StepDownloader(msg) => {
|
||||||
info!("StepDownloaderEvent: {msg:?}");
|
info!("StepDownloaderEvent: {msg:?}");
|
||||||
|
Task::none()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -254,7 +252,7 @@ impl MainWindow {
|
|||||||
|
|
||||||
pub trait TabContent {
|
pub trait TabContent {
|
||||||
type TabMessage;
|
type TabMessage;
|
||||||
fn update(&mut self, msg: Self::TabMessage);
|
fn update(&mut self, msg: Self::TabMessage) -> Task<MainWindowMsg>;
|
||||||
fn view(&self) -> Element<'_, MainWindowMsg> {
|
fn view(&self) -> Element<'_, MainWindowMsg> {
|
||||||
iced::widget::Container::new(self.content())
|
iced::widget::Container::new(self.content())
|
||||||
.width(Length::Fill)
|
.width(Length::Fill)
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
use iced::{Length, alignment::Horizontal, widget::Column};
|
use iced::{Length, Task, alignment::Horizontal, widget::Column};
|
||||||
use log::info;
|
use tracing::info;
|
||||||
|
|
||||||
use crate::ui::main_window::{MainWindowMsg, TabContent};
|
use crate::ui::main_window::{MainWindowMsg, TabContent};
|
||||||
|
|
||||||
@ -14,12 +14,13 @@ pub enum PartViewerMsg {
|
|||||||
impl TabContent for PartViewer {
|
impl TabContent for PartViewer {
|
||||||
type TabMessage = PartViewerMsg;
|
type TabMessage = PartViewerMsg;
|
||||||
|
|
||||||
fn update(&mut self, msg: Self::TabMessage) {
|
fn update(&mut self, msg: Self::TabMessage) -> Task<MainWindowMsg> {
|
||||||
match msg {
|
match msg {
|
||||||
PartViewerMsg::Nothing => {
|
PartViewerMsg::Nothing => {
|
||||||
info!("This function not allowed.");
|
info!("This function not allowed.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Task::none()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn content(&self) -> iced::Element<'_, MainWindowMsg> {
|
fn content(&self) -> iced::Element<'_, MainWindowMsg> {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user