diff --git a/WeChatTweak.RaycastExtension/.eslintrc.json b/WeChatTweak.RaycastExtension/.eslintrc.json new file mode 100644 index 0000000..31608d8 --- /dev/null +++ b/WeChatTweak.RaycastExtension/.eslintrc.json @@ -0,0 +1,10 @@ +{ + "root": true, + "env": { + "es2020": true, + "node": true + }, + "parser": "@typescript-eslint/parser", + "plugins": ["@typescript-eslint"], + "extends": ["eslint:recommended", "plugin:@typescript-eslint/recommended", "prettier"] +} diff --git a/WeChatTweak.RaycastExtension/.gitignore b/WeChatTweak.RaycastExtension/.gitignore new file mode 100644 index 0000000..1ce5671 --- /dev/null +++ b/WeChatTweak.RaycastExtension/.gitignore @@ -0,0 +1,8 @@ +# See https://help.github.com/articles/ignoring-files/ for more about ignoring files. + +# dependencies +node_modules +package-lock.json + +# misc +.DS_Store diff --git a/WeChatTweak.RaycastExtension/.prettierrc b/WeChatTweak.RaycastExtension/.prettierrc new file mode 100644 index 0000000..b7d51e0 --- /dev/null +++ b/WeChatTweak.RaycastExtension/.prettierrc @@ -0,0 +1,4 @@ +{ + "printWidth": 120, + "singleQuote": false +} \ No newline at end of file diff --git a/WeChatTweak.RaycastExtension/README.md b/WeChatTweak.RaycastExtension/README.md new file mode 100644 index 0000000..c981383 --- /dev/null +++ b/WeChatTweak.RaycastExtension/README.md @@ -0,0 +1,3 @@ +# WeChatTweak + +A Raycast extension for WeChatTweak. \ No newline at end of file diff --git a/WeChatTweak.RaycastExtension/assets/icon.png b/WeChatTweak.RaycastExtension/assets/icon.png new file mode 100644 index 0000000..5e457bd Binary files /dev/null and b/WeChatTweak.RaycastExtension/assets/icon.png differ diff --git a/WeChatTweak.RaycastExtension/package.json b/WeChatTweak.RaycastExtension/package.json new file mode 100644 index 0000000..695c5a6 --- /dev/null +++ b/WeChatTweak.RaycastExtension/package.json @@ -0,0 +1,39 @@ +{ + "$schema": "https://www.raycast.com/schemas/extension.json", + "name": "wechattweak", + "title": "WeChatTweak", + "description": "A Raycast extension for WeChatTweak.", + "icon": "icon.png", + "author": "viko16", + "categories": [ + "Productivity" + ], + "license": "MIT", + "commands": [ + { + "name": "index", + "title": "Search your friends...", + "description": "快速搜索好友", + "mode": "view" + } + ], + "dependencies": { + "@raycast/api": "^1.39.3", + "@raycast/utils": "^1.4.1" + }, + "devDependencies": { + "@typescript-eslint/eslint-plugin": "^5.0.0", + "@typescript-eslint/parser": "^5.0.0", + "eslint": "^7.32.0", + "eslint-config-prettier": "^8.3.0", + "prettier": "^2.5.1", + "typescript": "^4.4.3" + }, + "scripts": { + "build": "ray build -e dist", + "dev": "ray develop", + "fix-lint": "ray lint --fix", + "lint": "ray lint", + "publish": "ray publish" + } +} diff --git a/WeChatTweak.RaycastExtension/src/index.tsx b/WeChatTweak.RaycastExtension/src/index.tsx new file mode 100644 index 0000000..e52d879 --- /dev/null +++ b/WeChatTweak.RaycastExtension/src/index.tsx @@ -0,0 +1,57 @@ +import { Action, ActionPanel, List, showToast, Toast } from "@raycast/api"; +import { getAvatarIcon, useFetch } from "@raycast/utils"; +import { useState } from "react"; + +interface SearchResult { + m_nsRemark: string; + m_nsNickName: string; + wt_avatarPath: string; + m_nsUsrName: string; +} + +export default function Command() { + const [searchText, setSearchText] = useState(""); + const { isLoading, data = [] } = useFetch( + `http://localhost:48065/wechat/search?keyword=${encodeURIComponent(searchText.trim())}`, + { + keepPreviousData: true, + onError(error) { + console.error(error); + showToast(Toast.Style.Failure, "Could not perform search", String(error)); + }, + } + ); + + return ( + + + {data.map((resultItem) => { + const title = resultItem.m_nsRemark || resultItem.m_nsNickName; + return ( + + + + + + } + /> + ); + })} + + + ); +} diff --git a/WeChatTweak.RaycastExtension/tsconfig.json b/WeChatTweak.RaycastExtension/tsconfig.json new file mode 100644 index 0000000..3546500 --- /dev/null +++ b/WeChatTweak.RaycastExtension/tsconfig.json @@ -0,0 +1,17 @@ +{ + "$schema": "https://json.schemastore.org/tsconfig", + "display": "Node 16", + "include": ["src/**/*"], + "compilerOptions": { + "lib": ["es2021"], + "module": "commonjs", + "target": "es2021", + "strict": true, + "isolatedModules": true, + "esModuleInterop": true, + "skipLibCheck": true, + "forceConsistentCasingInFileNames": true, + "jsx": "react-jsx", + "resolveJsonModule": true + } +}