Skip to content

Commit

Permalink
Merge pull request #10 from Lemonnnnnnnnnnn/master
Browse files Browse the repository at this point in the history
fix UI problem
  • Loading branch information
Lemonnnnnnnnnnn authored Feb 27, 2024
2 parents 2141312 + 3cf5b86 commit 4a6d8e5
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 46 deletions.
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,4 +77,11 @@ export const resetPassword = (params: resetPasswordRequest) => request<resetPass
<p>$1: 请求名</p>
<p>$2: 请求类型</p>
<p>$3: 返回类型</p>
<p>$4: 接口地址</p>
<p>$4: 接口地址</p>

## 开发

```
pnpm i
pnpm tauri dev
```
11 changes: 2 additions & 9 deletions src-tauri/src/services/category.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
}
Expand Down
15 changes: 3 additions & 12 deletions src-tauri/src/services/project.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
}

29 changes: 8 additions & 21 deletions src-tauri/src/structs/queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
}
Expand Down
35 changes: 32 additions & 3 deletions src/lib/modules/ServiceModule/components/TypesTree.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -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 = '';
Expand All @@ -16,9 +17,10 @@
});
function get_data() {
request('get_request_list', { key: searchKey })
request('get_request_list', { key: "" })
// @ts-expect-error
.then((res: SuccessResponse<TypesTree[]>) => {
full_list = sort(res.data);
list = sort(res.data);
toast.push(JSON.stringify(res.message), toastTheme.success);
})
Expand All @@ -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文件,是否确定?');
Expand Down Expand Up @@ -61,14 +90,14 @@
}
</script>

<main>
<main style="overflow:auto">
<div class="flex justify-between items-center">
<div class="header">对应的接口树:</div>
<Button kind="tertiary" on:click={update_service}>更新所有请求</Button>
</div>
<div class="flex items-center" style="margin-top:10px;margin-bottom:10px">
<Search bind:value={searchKey} />
<Button kind="secondary" on:click={get_data}>搜索</Button>
<Button kind="secondary" on:click={filter_data}>搜索</Button>
</div>

{#each list as item}
Expand Down

0 comments on commit 4a6d8e5

Please sign in to comment.