Skip to content

Commit 69021f4

Browse files
author
cht
committed
准备多订阅支持
1 parent edb1fe2 commit 69021f4

1 file changed

Lines changed: 31 additions & 1 deletion

File tree

src/subscribe/state.rs

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,11 @@ pub(crate) fn subscribe_state(app: &mut AppSub) -> io::Result<IFEXIT> {
7777
InputMode::Select => {
7878
if app.stateoflist {
7979
match key.code {
80-
KeyCode::Left => app.unselect(),
80+
//KeyCode::Left => app.unselect(),
8181
KeyCode::Down => app.next(),
8282
KeyCode::Up => app.previous(),
8383
KeyCode::Esc => {
84+
app.unselect();
8485
app.input_mode = InputMode::Normal;
8586
}
8687
KeyCode::F(5) => {
@@ -149,6 +150,35 @@ pub(crate) fn subscribe_state(app: &mut AppSub) -> io::Result<IFEXIT> {
149150
utils::create_json_file(utils::Save::Subscribes, subscribe_json)
150151
.unwrap_or_else(|err| panic!("{}", err));
151152
// .collect();
153+
let get_list = spider::get_the_key(app.subscription.clone());
154+
if let Ok(list) = get_list {
155+
let mut storge: String = String::new();
156+
storge.push('[');
157+
storge.push('\n');
158+
if !list[0].is_empty() {
159+
//app.subs = list[0].clone();
160+
app.stateoflist = true;
161+
app.state.select(Some(0));
162+
for alist in &list[0] {
163+
let information = spider::Information::new(alist.to_string());
164+
app.informations.push(information.clone());
165+
storge.push_str(information.get_the_json_node().as_str());
166+
}
167+
app.subs = app
168+
.informations
169+
.iter()
170+
.map(|ainformation| {
171+
spider::remove_quotation(ainformation.ps.clone())
172+
})
173+
.collect();
174+
}
175+
storge.pop();
176+
storge.pop();
177+
storge.push('\n');
178+
storge.push(']');
179+
utils::create_json_file(utils::Save::Storage, storge)
180+
.unwrap_or_else(|err| panic!("err {}", err));
181+
}
152182
}
153183
_ => {}
154184
},

0 commit comments

Comments
 (0)