-
Notifications
You must be signed in to change notification settings - Fork 209
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
Showing
7 changed files
with
295 additions
and
7 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,67 @@ | ||
function parseData(data) { | ||
const lines = data.split('\n'); | ||
const result = []; | ||
|
||
lines.forEach((line) => { | ||
const parts = line.split('::'); | ||
if (parts.length === 2) { | ||
const title = parts[0]; | ||
const api = parts[1].replace(/{{String$new Date$$$.replace$'$GMT\+08:00$','$中国标准时间$'$}}/g, new Date().toString()); | ||
|
||
result.push({ | ||
title: title, | ||
api: { | ||
url: api, | ||
body: {}, | ||
header: {} | ||
} | ||
}); | ||
} | ||
}); | ||
|
||
return result; | ||
} | ||
function parseDataWithMethod(data) { | ||
const lines = data.split('\n'); | ||
const result = []; | ||
|
||
lines.forEach((line) => { | ||
const parts = line.split('::'); | ||
if (parts.length === 2) { | ||
const title = parts[0]; | ||
const apiData = parts[1].split(','); | ||
if (apiData.length === 2) { | ||
const url = apiData[0]; | ||
const apiInfo = apiData[1]; | ||
|
||
let parsedInfo = apiInfo.replace(/'/g, '"'); | ||
parsedInfo = JSON.parse(parsedInfo); | ||
const { method, body } = parsedInfo; | ||
|
||
result.push({ | ||
title: title, | ||
api: { | ||
url: url.trim(), | ||
method: method.trim(), | ||
body: body.trim(), | ||
header: {} | ||
} | ||
}); | ||
} | ||
} | ||
}); | ||
|
||
return result; | ||
} | ||
|
||
export const autoParseData = (data) => { | ||
if (data.includes('method')) { | ||
return parseDataWithMethod(data); | ||
} else { | ||
return parseData(data); | ||
} | ||
} | ||
|
||
export const AnalysisRules = (data) => { | ||
return autoParseData(data) | ||
} |
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,102 @@ | ||
/** | ||
* @author andy | ||
* @datetime 2024/7/27 01:02 | ||
* @className: BookSourceGroup | ||
* 通用分组选择弹窗 | ||
*/ | ||
import CommonConstants from '../../common/constants/CommonConstants' | ||
import PaddingConstants from '../../common/constants/PaddingConstants' | ||
|
||
@Component | ||
export default struct SourceGroup { | ||
@Prop groupList: string[] = [] | ||
@Prop currentName: string | ||
title: string = '移动至' | ||
confirm: (groupName: string) => void = (_groupName) => { | ||
} | ||
cancel: () => void = () => { | ||
} | ||
|
||
build() { | ||
Column() { | ||
Column() { | ||
Text(this.title) | ||
.fontSize(16) | ||
.fontWeight(700) | ||
.lineHeight(24) | ||
} | ||
.padding({ | ||
right: 20, | ||
left: 20, | ||
top: 12, | ||
bottom: 12 | ||
}) | ||
|
||
Divider() | ||
Scroll() { | ||
Grid() { | ||
ForEach(this.groupList, (item: string, index: number) => { | ||
GridItem() { | ||
this.titleBuilder(item) | ||
} | ||
.onClick(() => { | ||
this.confirm(item) | ||
}) | ||
}) | ||
} | ||
.columnsTemplate('1fr 1fr 1fr') | ||
.columnsGap(16) | ||
.rowsGap(16) | ||
} | ||
.padding(PaddingConstants.PADDING_20) | ||
.align(Alignment.Top) | ||
.layoutWeight(1) | ||
.scrollBar(BarState.Off) | ||
|
||
Column() { | ||
Divider().strokeWidth(0.5) | ||
|
||
Button('取消') | ||
.padding({ | ||
left: 32, | ||
right: 32, | ||
top: 8, | ||
bottom: 8 | ||
}) | ||
.width('100%') | ||
.height(56) | ||
.type(ButtonType.Normal) | ||
.stateEffect(false) | ||
.buttonStyle(ButtonStyleMode.TEXTUAL) | ||
.fontColor('#E0000000') | ||
.onClick(() => { | ||
this.cancel() | ||
}) | ||
} | ||
} | ||
.width(CommonConstants.FULL_WIDTH) | ||
.height(CommonConstants.FULL_HEIGHT) | ||
} | ||
|
||
@Builder | ||
titleBuilder(title: string) { | ||
Column() { | ||
Text(title) | ||
.fontSize(14) | ||
.textOverflow({ | ||
overflow: TextOverflow.Ellipsis | ||
}) | ||
.lineHeight(20) | ||
.maxLines(1) | ||
} | ||
.width(96) | ||
.borderRadius(4) | ||
.backgroundColor($r('app.string.color_black_6')) | ||
.padding({ | ||
left: 16, | ||
right: 16, | ||
top: 8, | ||
bottom: 8 | ||
}) | ||
} | ||
} |
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
Oops, something went wrong.