diff --git a/README.md b/README.md index 709923a..82f9535 100644 --- a/README.md +++ b/README.md @@ -77,4 +77,11 @@ export const resetPassword = (params: resetPasswordRequest) => request$1: 请求名

$2: 请求类型

$3: 返回类型

-

$4: 接口地址

\ No newline at end of file +

$4: 接口地址

+ +## 开发 + +``` +pnpm i +pnpm tauri dev +``` diff --git a/src-tauri/src/services/category.rs b/src-tauri/src/services/category.rs index aee19d3..37f7e72 100644 --- a/src-tauri/src/services/category.rs +++ b/src-tauri/src/services/category.rs @@ -105,19 +105,12 @@ fn filter_new_interfaces( let config_json = config.read_config().unwrap(); let mut config_interfaces = vec![]; - let mut find_config_interfaces = false; - for project in config_json.project_list { - if find_config_interfaces == true { - break; - } + 'project: for project in config_json.project_list { for category in project.categories { - if find_config_interfaces == true { - break; - } if category.id == category_id { config_interfaces = category.interfaces; - find_config_interfaces = true; + break 'project; } } } diff --git a/src-tauri/src/services/project.rs b/src-tauri/src/services/project.rs index 44b0305..dcfd4e2 100644 --- a/src-tauri/src/services/project.rs +++ b/src-tauri/src/services/project.rs @@ -149,19 +149,10 @@ fn merge_projects(new_project: &ProjectShort, old_config: &mut ConfigJson) { fn merge_categories(new_project: &ProjectShort, old_project: &mut ProjectShort) { for category in &new_project.categories { - let mut find = false; - for old_category in &old_project.categories { - if find == true { - break; - } - if old_category.id == category.id { - find = true; - } - } - - if find == false { - old_project.categories.push(category.clone()); + if old_project.categories.iter().any(|oc| oc.id == category.id) { + continue; } + old_project.categories.push(category.clone()); } } diff --git a/src-tauri/src/structs/queue.rs b/src-tauri/src/structs/queue.rs index e013dad..5a6a1a2 100644 --- a/src-tauri/src/structs/queue.rs +++ b/src-tauri/src/structs/queue.rs @@ -224,38 +224,25 @@ impl Queue { Ok(mut config_json) => { for ri in result_queue { let insert_node_id = &ri.category_id; - let mut find = false; - - for project in &mut config_json.project_list { - if find { - break; - } + 'project: for project in &mut config_json.project_list { for category in &mut project.categories { - if find { - break; - } - if category.id.as_str() == insert_node_id.as_str() { for interface in &mut category.interfaces { if interface.id == ri.id { interface.name = Some(ri.title.clone()); interface.path = Some(ri.path.clone()); - - find = true; - break; + break 'project; } } - if !find { - category.interfaces.push(InterfaceShort { - id: ri.id.clone(), - name: Some(ri.title.clone()), - path: Some(ri.path.clone()) - }); - } + category.interfaces.push(InterfaceShort { + id: ri.id.clone(), + name: Some(ri.title.clone()), + path: Some(ri.path.clone()), + }); - find = true; + break 'project; } } } diff --git a/src/lib/modules/ServiceModule/components/TypesTree.svelte b/src/lib/modules/ServiceModule/components/TypesTree.svelte index 27289bf..a398175 100644 --- a/src/lib/modules/ServiceModule/components/TypesTree.svelte +++ b/src/lib/modules/ServiceModule/components/TypesTree.svelte @@ -8,6 +8,7 @@ import { Button, Search } from 'carbon-components-svelte'; import { confirm } from '@tauri-apps/api/dialog'; + let full_list: TypesTree[] = []; let list: TypesTree[] = []; let searchKey = ''; @@ -16,9 +17,10 @@ }); function get_data() { - request('get_request_list', { key: searchKey }) + request('get_request_list', { key: "" }) // @ts-expect-error .then((res: SuccessResponse) => { + full_list = sort(res.data); list = sort(res.data); toast.push(JSON.stringify(res.message), toastTheme.success); }) @@ -27,6 +29,33 @@ }); } + function filter_data() { + if (searchKey === '') { + list = full_list; + return; + } + + list = do_filter(full_list); + + function do_filter(list: TypesTree[]) { + return list.filter((item) => { + if (item.name.includes(searchKey)) { + return true; + } else { + if (item.children.length) { + item.children = do_filter(item.children); + + if (item.children.length) { + return true; + } + } + + return false; + } + }); + } + } + async function update_service() { const confirmed = await confirm('操作将重新生成ts文件,是否确定?'); @@ -61,14 +90,14 @@ } -
+
对应的接口树:
- +
{#each list as item}