memo() { # 获取传入的参数 updatedContent=$* # 转义特殊字符 # escapedContent=$(echo -n "$updatedContent" | jq -sRr @uri) # 构建请求体数据 # data="{\"content\": \"$escapedContent\"}" # 构建请求体数据 data="{\"content\": \"$updatedContent\"}" # 发送请求 response=$(curl -s -X POST -H "Content-Type: application/json" \ -H "Authorization: bearer eyJhbGciOiJIUzI1NiIsImtpZCI6InYxIiwidHlwIjoiSldUIn0.eyJuYW1lIjoidGlhbnl1bnBlcmZlY3QiLCJpc3MiOiJtZW1vcyIsInN1YiI6IjEiLCJhdWQiOlsidXNlci5hY2Nlc3MtdG9rZW4iXSwiaWF0IjoxNzA5MTc5NTUyfQ.LFxWB4efya1sL7VoJ42xpXxbAip-udT_Kx2OwZ8Y3-E" \ -d "$data" \ "https://memos.tianyunperfect.cn/api/v1/memo") # 判断是否存在name字段 if [[ $response == *"name"* ]]; then echo "记录成功 https://memos.tianyunperfect.cn" else echo "失败" $response fi } todo(){ memo "#todo $*" } function upload_file() { file_path=$1 if [ -z "$file_path" ]; then echo "Error: file_path is empty!" return 1 fi if [ ! -f "$file_path" ]; then echo "Error: file not exist!" return 1 fi oss_path=$2 # 如果没有传入oss路径,则 if [ -z "$oss_path" ]; then oss_path="file" fi curl -k -X POST -F "file=@$file_path" -F "oss_path=$oss_path" https://web_history.tianyunperfect.cn/oss/upload_file file_name=$(basename "$file_path") echo '' echo "https://alist.tianyunperfect.cn/oss_gang/$oss_path/$file_name" echo "https://tianyunperfect.oss-cn-hongkong.aliyuncs.com/$oss_path/$file_name" }