Skip to content

Commit

Permalink
[*] fix bug and release v0.4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
heng30 committed Mar 29, 2024
1 parent 5436ca2 commit 424b271
Show file tree
Hide file tree
Showing 25 changed files with 142 additions and 380 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ tool-gen-rss-build:
tool-gen-rss-run:
RUST_BACKTRACE=1 RUST_LOG=error,warn,info cargo run --bin tool-gen-rss --features=tool-gen-rss

tool-gen-rss-build:
RUST_LOG=error,warn,info cargo build --bin tool-gen-rss --features=tool-gen-rss
tool-gen-rss-run-local:
RUST_LOG=error,warn,info ./target/debug/tool-gen-rss

test:
$(build-evn) $(run-evn) cargo test -- --nocapture
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,4 @@ It is a remote bitcoin wallet. Using blockstream API to broadcast transaction an
- [Viewer for Slint](https://github.com/slint-ui/slint/tree/master/tools/viewer)
- [LSP (Language Server Protocol) Server for Slint](https://github.com/slint-ui/slint/tree/master/tools/lsp)
- [top-rss-list](https://github.com/weekend-project-space/top-rss-list)
- [rss-list](https://github.com/saveweb/rss-list)
338 changes: 1 addition & 337 deletions data/top-rss-list-valid.json

Large diffs are not rendered by default.

24 changes: 17 additions & 7 deletions src/config/conf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ pub fn appid() -> String {
CONFIG.lock().unwrap().appid.clone()
}

pub fn is_first_run() -> bool {
CONFIG.lock().unwrap().is_first_run
}

pub fn all() -> data::Config {
CONFIG.lock().unwrap().clone()
}
Expand Down Expand Up @@ -115,15 +119,21 @@ impl Config {
self.sync = c.sync;
Ok(())
}
Err(_) => match toml::to_string_pretty(self) {
Err(_) => {
self.is_first_run = true;
match toml::to_string_pretty(self) {
Ok(text) => Ok(fs::write(&self.config_path, text)?),
Err(e) => Err(e.into()),
}
}
},
Err(_) => {
self.is_first_run = true;
match toml::to_string_pretty(self) {
Ok(text) => Ok(fs::write(&self.config_path, text)?),
Err(e) => Err(e.into()),
},
},
Err(_) => match toml::to_string_pretty(self) {
Ok(text) => Ok(fs::write(&self.config_path, text)?),
Err(e) => Err(e.into()),
},
}
}
}
}

Expand Down
3 changes: 3 additions & 0 deletions src/config/data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ pub struct Config {
#[serde(default = "appid_default")]
pub appid: String,

#[serde(skip)]
pub is_first_run: bool,

pub ui: UI,

pub reading: Reading,
Expand Down
2 changes: 1 addition & 1 deletion src/config/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
mod conf;
mod data;

pub use conf::{all, appid, db_path, init, proxy, reading, save, sync, ui};
pub use conf::{all, appid, db_path, init, is_first_run, proxy, reading, save, sync, ui};
2 changes: 1 addition & 1 deletion src/logic/find.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const FIND_UUID: &str = "find-uuid";
const RSS_ENTRY_URL: &str = "https://heng30.xyz/apisvr/rssbox/rss/list/cn";
const TOP_RSS_LIST_CN: &str = include_str!("../../data/top-rss-list-valid.json");

#[derive(Serialize, Deserialize, Debug, Clone)]
#[derive(Serialize, Deserialize, Hash, Eq, PartialEq, Debug, Clone)]
pub struct FindEntry {
pub name: String,
pub url: String,
Expand Down
4 changes: 2 additions & 2 deletions src/logic/rss.rs
Original file line number Diff line number Diff line change
Expand Up @@ -325,9 +325,9 @@ pub fn init(ui: &AppWindow) {
match _edit_rss(rss).await {
Err(e) => async_message_warn(
ui.clone(),
format!("{}. {}: {e:?}", tr("新建失败"), tr("原因")),
format!("{}. {}: {e:?}", tr("编辑失败"), tr("原因")),
),
_ => async_message_success(ui.clone(), tr("新建成功")),
_ => async_message_success(ui.clone(), tr("编辑成功")),
}
});

Expand Down
3 changes: 3 additions & 0 deletions src/logic/setting.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ const FEEDBACK_URL: &str = "https://heng30.xyz/apisvr/rssbox/android/feedback";
pub fn init(ui: &AppWindow) {
init_setting(&ui);

ui.global::<Store>()
.set_is_first_run(config::is_first_run());

let ui_handle = ui.as_weak();
ui.global::<Logic>().on_get_setting_ui(move || {
let ui = ui_handle.unwrap();
Expand Down
11 changes: 6 additions & 5 deletions src/tool-gen-rss.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use anyhow::Result;
use atom_syndication::Feed;
use rss::Channel;
use rssbox::{logic::top_rss_list_cn, util::http};
use std::{io::BufReader, time::Duration};
use std::{collections::HashSet, io::BufReader, time::Duration};
use tokio::{fs::File, io::AsyncWriteExt, sync::mpsc};

const TOP_RSS_LIST_CN: &str = include_str!("../data/top-rss-list.json");
Expand All @@ -16,8 +16,7 @@ async fn main() -> Result<()> {
log::info!("start...");
rssbox::init_logger();

// let mut file = File::create(TOP_RSS_LIST_CN_VALID).await?;
// file.write_all(b"[]").await?;
let _assert = File::create(TOP_RSS_LIST_CN_VALID).await?;

let items = top_rss_list_cn(TOP_RSS_LIST_CN)?;
let total_len = items.len();
Expand All @@ -42,10 +41,12 @@ async fn main() -> Result<()> {
}

drop(tx);
let mut valid_items = vec![];

let mut valid_items = HashSet::new();
while let Some(item) = rx.recv().await {
valid_items.push(item);
valid_items.insert(item);
}
let valid_items = valid_items.into_iter().collect::<Vec<_>>();

let text = serde_json::to_string::<Vec<_>>(&valid_items)?;
log::info!("{text}");
Expand Down
13 changes: 7 additions & 6 deletions src/util/translator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,14 @@ pub fn tr(text: &str) -> String {
items.insert("下载成功", "Download success");
items.insert("下载失败", "Download failed");
items.insert("加载失败", "Load failed");
items.insert("密码错误", "Password invalid");
items.insert("创建账户成功", "Create account success");
items.insert("创建账户失败", "Create account failed");
items.insert("密码错误", "Wrong password");
items.insert("非法输入", "Invalid input");
items.insert("打开链接失败", "Open link failed");

items.insert("新建成功", "New success");
items.insert("新建失败", "New failed");
items.insert("编辑成功", "Edit success");
items.insert("编辑失败", "Edit failed");

items.insert("微信支付", "Wechat pay");
items.insert("小狐狸(加密)支付", "MetaMask crypto pay");

Expand Down Expand Up @@ -86,7 +87,7 @@ pub fn tr(text: &str) -> String {
items.insert("图标库", "Icons");
items.insert("请选择条目", "Please select entry");
items.insert("请添加RSS源", "Please add RSS URL");
items.insert("请选择浏览器", "Please select browser");
items.insert("选择浏览器", "Select browser");
items.insert("已启用阅后即焚", "Enabled delete after reading");
items.insert("未启用阅后即焚", "Disable delete after reading");

Expand Down Expand Up @@ -119,7 +120,7 @@ pub fn tr(text: &str) -> String {

items.insert("没有数据", "No Data");
items.insert("没有消息", "No Message");
items.insert("输入关键字", "input keyword");
items.insert("输入关键字", "Input keyword");

if let Some(txt) = items.get(text) {
return txt.to_string();
Expand Down
2 changes: 1 addition & 1 deletion src/version.rs
Original file line number Diff line number Diff line change
@@ -1 +1 @@
pub static VERSION: &str = "v0.2.0";
pub static VERSION: &str = "v0.3.0";
23 changes: 14 additions & 9 deletions ui/appwindow.slint
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Logic } from "./logic.slint";
import { Store } from "./store.slint";
import { Util } from "./util.slint";
import { Panel } from "./panel/panel.slint";
import { Message, IconsDialog, OkCancelDialog, Blanket } from "./base/widgets.slint";
import { Message, IconsDialog, OkCancelDialog, Blanket, LanguageDialog } from "./base/widgets.slint";

export component AppWindow inherits Window {
default-font-size: Theme.default-font-size;
Expand All @@ -25,16 +25,21 @@ export component AppWindow inherits Window {
panel := Panel { }
}

Rectangle {
if oc-dialog.visible || icons-dialog.visible : Blanket { }
if Store.icons-dialog-setting.show ||
Store.ok-cancel-dialog-setting.body-text != "" ||
Store.is-first-run : Blanket { }

if Store.icons-dialog-setting.show : IconsDialog {
select-index(index) => { panel.icon-index = index; }
}

icons-dialog := IconsDialog {
select-index(index) => { panel.icon-index = index; }
}
if Store.ok-cancel-dialog-setting.body-text != "" : OkCancelDialog {
width: Math.min(root.width * 0.95, 380px);
}

oc-dialog := OkCancelDialog {
width: Math.min(root.width * 0.95, 380px);
}
if Store.is-first-run : LanguageDialog {
is-hide-close-btns: true;
width: Math.min(300px, root.width * 0.8);
}

Message {
Expand Down
6 changes: 3 additions & 3 deletions ui/base/dialog.slint
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ export component Dialog inherits Rectangle {
in-out property title <=> txt.text;
in-out property<color> title-bg: Theme.brand-color;
in-out property<bool> is-hide-btns: false;
in-out property<bool> is-hide-close-btns: false;

callback cancel-clicked();
callback ok-clicked();

visible: false;
width: 800px;
height: vbox.preferred-height;
background: Theme.base-background-light;
Expand All @@ -29,7 +29,7 @@ export component Dialog inherits Rectangle {
font-size: Theme.title3-font-size;
}

if (is-hide-btns) : HorizontalLayout {
if is-hide-btns && !is-hide-close-btns : HorizontalLayout {
alignment: end;
padding-right: Theme.padding;
CenterLayout {
Expand All @@ -47,7 +47,7 @@ export component Dialog inherits Rectangle {
@children
}

if (!is-hide-btns) : HorizontalLayout {
if !is-hide-btns : HorizontalLayout {
alignment: center;
spacing: Theme.spacing * 8;
padding: Theme.padding * 2;
Expand Down
1 change: 0 additions & 1 deletion ui/base/icons-dialog.slint
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { Store } from "../store.slint";
import { Logic } from "../logic.slint";

export component IconsDialog inherits Dialog {
visible: Store.icons-dialog-setting.show;
title: Logic.tr(Store.is-cn, "图标库");
title-bg: Theme.brand-color;
width: (icon-size + icon-spacing) * column-count - icon-spacing + Theme.padding * 2;
Expand Down
65 changes: 65 additions & 0 deletions ui/base/language-dialog.slint
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
import { CheckBox } from "std-widgets.slint";
import { Dialog } from "./dialog.slint";
import { Theme } from "../theme.slint";
import { Store } from "../store.slint";
import { Logic } from "../logic.slint";
import { ConfirmBtn } from "./btn.slint";

export component LanguageDialog inherits Dialog {
title: Logic.tr(Store.is-cn, "请选择语言");
is-hide-btns: true;

in-out property<string> language: "cn";

VerticalLayout {
padding: Theme.padding * 4;
spacing: Theme.spacing * 4;

VerticalLayout {
alignment: center;
spacing: Theme.spacing * 4;

cn-checkbox := CheckBox {
width: 50%; text: "中文";
checked: root.language != "en";
toggled => {
if (!self.checked) {
self.checked = true;
return;
}

en-checkbox.checked = !self.checked;
root.language = "cn";
}
}

en-checkbox := CheckBox {
text: "English";
checked: root.language == "en";
toggled => {
if (!self.checked) {
self.checked = true;
return;
}

cn-checkbox.checked = !self.checked;
root.language = "en";
}
}
}

HorizontalLayout {
alignment: end;

ConfirmBtn {
text: Logic.tr(Store.is-cn, "确认");
clicked => {
Store.setting-ui.language = root.language;
Logic.set-setting-ui(Store.setting-ui);
Store.is-first-run = false;
}
}
}
}

}
1 change: 0 additions & 1 deletion ui/base/ok-cancel.slint
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { Logic } from "../logic.slint";
import { Theme } from "../theme.slint";

export component OkCancelDialog inherits Dialog {
visible: Store.ok-cancel-dialog-setting.body-text != "";
title: Store.ok-cancel-dialog-setting.title-text;
title-bg: Util.text-color(Store.ok-cancel-dialog-setting.title-type);
preferred-width: 200px;
Expand Down
4 changes: 3 additions & 1 deletion ui/base/widgets.slint
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { SettingEntry } from "./setting-entry.slint";
import { SettingDetail, SettingDetailInner, SettingDetailLabel, SettingDetailInnerVbox } from "./setting-detail.slint";
import { Brand } from "./brand.slint";
import { TxtEdit } from "./txtedit.slint";
import { LanguageDialog } from "./language-dialog.slint";

export {
Message,
Expand All @@ -43,5 +44,6 @@ export {
SettingDetailLabel,
SettingDetailInnerVbox,
TxtEdit,
Brand
Brand,
LanguageDialog
}
1 change: 1 addition & 0 deletions ui/images/rss-light.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions ui/images/setting-light.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion ui/panel/bodyer/find.slint
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ component FHead inherits Head {
search-lineedit := LineEdit {
height: 100%; width: 100%;
horizontal-stretch: 1;
placeholder-text: Logic.tr(Store.is-cn, "关键字");
placeholder-text: Logic.tr(Store.is-cn, "输入关键字");
accepted => { Logic.update-find-entrylist(self.text); }
}
}
Expand Down
4 changes: 4 additions & 0 deletions ui/panel/bodyer/rss.slint
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,10 @@ export component Entry inherits Rectangle {
text: root.summary;
}

if root.summary == "" : Rectangle {
height: 20px;
}

HorizontalLayout {
alignment: end;
spacing: Theme.padding * 4;
Expand Down
4 changes: 2 additions & 2 deletions ui/panel/footer.slint
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export component Footer inherits Rectangle {
TabBtn {
width: root.btn-width;
height: root.btn-height;
icon: Icons.rss-fill;
icon: Icons.rss-light;
text: Logic.tr(Store.is-cn, "订阅");
checked: Store.current-tab-index == TabIndex.Rss;

Expand Down Expand Up @@ -72,7 +72,7 @@ export component Footer inherits Rectangle {
TabBtn {
width: root.btn-width;
height: root.btn-height;
icon: Icons.setting-fill;
icon: Icons.setting-light;
text: Logic.tr(Store.is-cn, "设置");
checked: Store.current-tab-index == TabIndex.Setting;

Expand Down
1 change: 1 addition & 0 deletions ui/store.slint
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ export global Store {
in-out property<MessageItem> message;
in-out property<OkCancelDialogSetting> ok-cancel-dialog-setting;

in-out property <bool> is-first-run: true;
in-out property <bool> rss-update-time-flag;
in-out property <bool> rss-unread-counts-flag;
in-out property <bool> find-entrys-counts-flag;
Expand Down
Loading

0 comments on commit 424b271

Please sign in to comment.