generated from emo-crab/rust-template
-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
478820b
commit 5929372
Showing
13 changed files
with
77 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
-- we don't know how to generate root <with-no-name> (class Root) :( | ||
|
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,15 @@ | ||
create table cve_product | ||
create table nvd.cve_product | ||
( | ||
cve_id varchar(16) not null comment 'CVE编号', | ||
product_id binary(16) not null comment '产品ID', | ||
primary key (cve_id, product_id), | ||
constraint cve_id | ||
foreign key (cve_id) references cves (id), | ||
foreign key (cve_id) references nvd.cves (id), | ||
constraint product_id | ||
foreign key (product_id) references products (id) | ||
foreign key (product_id) references nvd.products (id) | ||
) | ||
comment 'cve_match表'; | ||
|
||
create index product_id_idx | ||
on cve_product (product_id); | ||
on nvd.cve_product (product_id); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
create table cwes | ||
create table nvd.cwes | ||
( | ||
id int not null comment 'CWE ID' | ||
primary key, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
use std::collections::HashMap; | ||
use yew::{Html, Properties}; | ||
|
||
#[derive(Debug, Clone, PartialEq)] | ||
struct I18nTranslation { | ||
pub lang: Vec<String>, | ||
pub translations: HashMap<String, HashMap<String, String>>, | ||
} | ||
|
||
#[derive(Debug, Clone, PartialEq, Properties)] | ||
pub struct I18nTranslationProp { | ||
#[prop_or_else(|| vec ! ["en".to_string(), "zh".to_string()])] | ||
pub lang: Vec<String>, | ||
pub translations: HashMap<String, HashMap<String, String>>, | ||
pub children: Html, | ||
} | ||
|
||
#[derive(Clone, PartialEq)] | ||
pub struct I18n { | ||
pub config: I18nTranslation, | ||
current_lang: String, | ||
} | ||
|
||
impl I18n { | ||
pub fn new(config: I18nTranslation) -> Self { | ||
let current_lang = config.lang.get(0).unwrap_or(&"en".to_string()).to_string(); | ||
Self { config, current_lang } | ||
} | ||
pub fn set_lang(&mut self, lang: String) { | ||
if self.config.lang.contains(&lang) { | ||
self.current_lang = lang; | ||
} | ||
} | ||
pub fn t(&self, text: &str) -> String { | ||
if let Some(dict) = self.config.translations.get(&self.current_lang) { | ||
return dict.get(text).unwrap_or(&text.to_string()).to_string(); | ||
} | ||
return text.to_string(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,3 +28,4 @@ mod knowledge_base; | |
mod pagination; | ||
mod tooltip_popover; | ||
mod weaknesses; | ||
mod i18n; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters