mirror of
https://github.com/Sunnyyoung/WeChatTweak-macOS.git
synced 2025-07-08 00:26:06 +08:00
Add Raycast Extension
This commit is contained in:
parent
0b8de8dc63
commit
791b7feedc
10
WeChatTweak.RaycastExtension/.eslintrc.json
Normal file
10
WeChatTweak.RaycastExtension/.eslintrc.json
Normal file
|
@ -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"]
|
||||||
|
}
|
8
WeChatTweak.RaycastExtension/.gitignore
vendored
Normal file
8
WeChatTweak.RaycastExtension/.gitignore
vendored
Normal file
|
@ -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
|
4
WeChatTweak.RaycastExtension/.prettierrc
Normal file
4
WeChatTweak.RaycastExtension/.prettierrc
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
{
|
||||||
|
"printWidth": 120,
|
||||||
|
"singleQuote": false
|
||||||
|
}
|
3
WeChatTweak.RaycastExtension/README.md
Normal file
3
WeChatTweak.RaycastExtension/README.md
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
# WeChatTweak
|
||||||
|
|
||||||
|
A Raycast extension for WeChatTweak.
|
BIN
WeChatTweak.RaycastExtension/assets/icon.png
Normal file
BIN
WeChatTweak.RaycastExtension/assets/icon.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 62 KiB |
39
WeChatTweak.RaycastExtension/package.json
Normal file
39
WeChatTweak.RaycastExtension/package.json
Normal file
|
@ -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"
|
||||||
|
}
|
||||||
|
}
|
57
WeChatTweak.RaycastExtension/src/index.tsx
Normal file
57
WeChatTweak.RaycastExtension/src/index.tsx
Normal file
|
@ -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<SearchResult[]>(
|
||||||
|
`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 (
|
||||||
|
<List
|
||||||
|
isLoading={isLoading}
|
||||||
|
searchText={searchText}
|
||||||
|
onSearchTextChange={setSearchText}
|
||||||
|
searchBarPlaceholder="Search by name..."
|
||||||
|
throttle
|
||||||
|
>
|
||||||
|
<List.Section title="Results" subtitle={data.length + ""}>
|
||||||
|
{data.map((resultItem) => {
|
||||||
|
const title = resultItem.m_nsRemark || resultItem.m_nsNickName;
|
||||||
|
return (
|
||||||
|
<List.Item
|
||||||
|
key={resultItem.m_nsUsrName}
|
||||||
|
title={title}
|
||||||
|
icon={resultItem.wt_avatarPath || getAvatarIcon(title)}
|
||||||
|
actions={
|
||||||
|
<ActionPanel>
|
||||||
|
<ActionPanel.Section>
|
||||||
|
<Action.OpenInBrowser
|
||||||
|
title={title}
|
||||||
|
url={`http://localhost:48065/wechat/start?session=${resultItem.m_nsUsrName}`}
|
||||||
|
/>
|
||||||
|
</ActionPanel.Section>
|
||||||
|
</ActionPanel>
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</List.Section>
|
||||||
|
</List>
|
||||||
|
);
|
||||||
|
}
|
17
WeChatTweak.RaycastExtension/tsconfig.json
Normal file
17
WeChatTweak.RaycastExtension/tsconfig.json
Normal file
|
@ -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
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user