pansoft-plrl/cli.sh

24 lines
708 B
Bash
Raw Normal View History

2024-09-26 20:53:54 +08:00
#!/bin/bash
# Send request and capture response data
response=$(curl -s http://192.168.147.164:8083/rl/dictData/page)
# Check if response is not empty
if [ -z "$response" ]; then
echo "请求失败,未收到响应"
echo "export const responseStatus = '请求失败,未收到响应';" > response.ts
exit 1
fi
# Extract status code and records using grep and sed
http_code=$(echo "$response" | grep -o '"code":[0-9]*' | sed 's/"code"://')
records=$(echo "$response" | grep -o '"records":\[[^]]*\]' | sed 's/"records"://')
# Define the TypeScript file path
ts_file="response.ts"
# Write to the TypeScript file
echo "请求成功"
echo "export const records = $records;" > $ts_file