From 1b74ac506ecb88793f72da319c49e9e9b13a47cc Mon Sep 17 00:00:00 2001 From: kalinuxJS <382064030@qq.com> Date: Sun, 31 Aug 2025 22:24:49 +0800 Subject: [PATCH 1/2] chore: init --- members/kalinuxJS/readme.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 members/kalinuxJS/readme.md diff --git a/members/kalinuxJS/readme.md b/members/kalinuxJS/readme.md new file mode 100644 index 000000000..e76e13dc9 --- /dev/null +++ b/members/kalinuxJS/readme.md @@ -0,0 +1,12 @@ +# Web3 前端训练营报名 + +## 个人信息 + +* GitHub ID: kalinuxJS +* OpenBuild Username: +* ERC20 钱包地址: (首次如果没有,学习完毕钱包在填写) + +### 个人介绍 + +20年毕业、曾就职于中科院以及虎扑 +前端技术栈react\next\vue\微信小程序\node.js \ No newline at end of file From 07ba43b554321a3516cf9ecc66e40de444f8717d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=96=87=E9=9D=99?= Date: Mon, 1 Sep 2025 11:43:27 +0800 Subject: [PATCH 2/2] =?UTF-8?q?feat:=20=E6=96=B0=E5=A2=9E=E4=BB=BB?= =?UTF-8?q?=E5=8A=A11?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- members/kalinuxJS/task1/.gitignore | 24 +++++++ members/kalinuxJS/task1/README.md | 69 +++++++++++++++++++ members/kalinuxJS/task1/eslint.config.js | 23 +++++++ members/kalinuxJS/task1/index.html | 13 ++++ members/kalinuxJS/task1/package.json | 29 ++++++++ members/kalinuxJS/task1/public/vite.svg | 1 + members/kalinuxJS/task1/src/App.css | 42 +++++++++++ members/kalinuxJS/task1/src/App.tsx | 49 +++++++++++++ members/kalinuxJS/task1/src/assets/react.svg | 1 + .../task1/src/components/addToDo.tsx | 42 +++++++++++ .../kalinuxJS/task1/src/components/header.tsx | 13 ++++ .../task1/src/components/toDoList.tsx | 43 ++++++++++++ members/kalinuxJS/task1/src/index.css | 68 ++++++++++++++++++ members/kalinuxJS/task1/src/main.tsx | 10 +++ members/kalinuxJS/task1/src/vite-env.d.ts | 1 + members/kalinuxJS/task1/tsconfig.app.json | 27 ++++++++ members/kalinuxJS/task1/tsconfig.json | 7 ++ members/kalinuxJS/task1/tsconfig.node.json | 25 +++++++ members/kalinuxJS/task1/vite.config.ts | 7 ++ 19 files changed, 494 insertions(+) create mode 100644 members/kalinuxJS/task1/.gitignore create mode 100644 members/kalinuxJS/task1/README.md create mode 100644 members/kalinuxJS/task1/eslint.config.js create mode 100644 members/kalinuxJS/task1/index.html create mode 100644 members/kalinuxJS/task1/package.json create mode 100644 members/kalinuxJS/task1/public/vite.svg create mode 100644 members/kalinuxJS/task1/src/App.css create mode 100644 members/kalinuxJS/task1/src/App.tsx create mode 100644 members/kalinuxJS/task1/src/assets/react.svg create mode 100644 members/kalinuxJS/task1/src/components/addToDo.tsx create mode 100644 members/kalinuxJS/task1/src/components/header.tsx create mode 100644 members/kalinuxJS/task1/src/components/toDoList.tsx create mode 100644 members/kalinuxJS/task1/src/index.css create mode 100644 members/kalinuxJS/task1/src/main.tsx create mode 100644 members/kalinuxJS/task1/src/vite-env.d.ts create mode 100644 members/kalinuxJS/task1/tsconfig.app.json create mode 100644 members/kalinuxJS/task1/tsconfig.json create mode 100644 members/kalinuxJS/task1/tsconfig.node.json create mode 100644 members/kalinuxJS/task1/vite.config.ts diff --git a/members/kalinuxJS/task1/.gitignore b/members/kalinuxJS/task1/.gitignore new file mode 100644 index 000000000..a547bf36d --- /dev/null +++ b/members/kalinuxJS/task1/.gitignore @@ -0,0 +1,24 @@ +# Logs +logs +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* +pnpm-debug.log* +lerna-debug.log* + +node_modules +dist +dist-ssr +*.local + +# Editor directories and files +.vscode/* +!.vscode/extensions.json +.idea +.DS_Store +*.suo +*.ntvs* +*.njsproj +*.sln +*.sw? diff --git a/members/kalinuxJS/task1/README.md b/members/kalinuxJS/task1/README.md new file mode 100644 index 000000000..7959ce426 --- /dev/null +++ b/members/kalinuxJS/task1/README.md @@ -0,0 +1,69 @@ +# React + TypeScript + Vite + +This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules. + +Currently, two official plugins are available: + +- [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react) uses [Babel](https://babeljs.io/) for Fast Refresh +- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh + +## Expanding the ESLint configuration + +If you are developing a production application, we recommend updating the configuration to enable type-aware lint rules: + +```js +export default tseslint.config([ + globalIgnores(['dist']), + { + files: ['**/*.{ts,tsx}'], + extends: [ + // Other configs... + + // Remove tseslint.configs.recommended and replace with this + ...tseslint.configs.recommendedTypeChecked, + // Alternatively, use this for stricter rules + ...tseslint.configs.strictTypeChecked, + // Optionally, add this for stylistic rules + ...tseslint.configs.stylisticTypeChecked, + + // Other configs... + ], + languageOptions: { + parserOptions: { + project: ['./tsconfig.node.json', './tsconfig.app.json'], + tsconfigRootDir: import.meta.dirname, + }, + // other options... + }, + }, +]) +``` + +You can also install [eslint-plugin-react-x](https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin-react-x) and [eslint-plugin-react-dom](https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin-react-dom) for React-specific lint rules: + +```js +// eslint.config.js +import reactX from 'eslint-plugin-react-x' +import reactDom from 'eslint-plugin-react-dom' + +export default tseslint.config([ + globalIgnores(['dist']), + { + files: ['**/*.{ts,tsx}'], + extends: [ + // Other configs... + // Enable lint rules for React + reactX.configs['recommended-typescript'], + // Enable lint rules for React DOM + reactDom.configs.recommended, + ], + languageOptions: { + parserOptions: { + project: ['./tsconfig.node.json', './tsconfig.app.json'], + tsconfigRootDir: import.meta.dirname, + }, + // other options... + }, + }, +]) +``` diff --git a/members/kalinuxJS/task1/eslint.config.js b/members/kalinuxJS/task1/eslint.config.js new file mode 100644 index 000000000..d94e7deb7 --- /dev/null +++ b/members/kalinuxJS/task1/eslint.config.js @@ -0,0 +1,23 @@ +import js from '@eslint/js' +import globals from 'globals' +import reactHooks from 'eslint-plugin-react-hooks' +import reactRefresh from 'eslint-plugin-react-refresh' +import tseslint from 'typescript-eslint' +import { globalIgnores } from 'eslint/config' + +export default tseslint.config([ + globalIgnores(['dist']), + { + files: ['**/*.{ts,tsx}'], + extends: [ + js.configs.recommended, + tseslint.configs.recommended, + reactHooks.configs['recommended-latest'], + reactRefresh.configs.vite, + ], + languageOptions: { + ecmaVersion: 2020, + globals: globals.browser, + }, + }, +]) diff --git a/members/kalinuxJS/task1/index.html b/members/kalinuxJS/task1/index.html new file mode 100644 index 000000000..e4b78eae1 --- /dev/null +++ b/members/kalinuxJS/task1/index.html @@ -0,0 +1,13 @@ + + + + + + + Vite + React + TS + + +
+ + + diff --git a/members/kalinuxJS/task1/package.json b/members/kalinuxJS/task1/package.json new file mode 100644 index 000000000..db074917a --- /dev/null +++ b/members/kalinuxJS/task1/package.json @@ -0,0 +1,29 @@ +{ + "name": "task1", + "private": true, + "version": "0.0.0", + "type": "module", + "scripts": { + "dev": "vite", + "build": "tsc -b && vite build", + "lint": "eslint .", + "preview": "vite preview" + }, + "dependencies": { + "react": "^19.1.1", + "react-dom": "^19.1.1" + }, + "devDependencies": { + "@eslint/js": "^9.33.0", + "@types/react": "^19.1.10", + "@types/react-dom": "^19.1.7", + "@vitejs/plugin-react": "^5.0.0", + "eslint": "^9.33.0", + "eslint-plugin-react-hooks": "^5.2.0", + "eslint-plugin-react-refresh": "^0.4.20", + "globals": "^16.3.0", + "typescript": "~5.8.3", + "typescript-eslint": "^8.39.1", + "vite": "^7.1.2" + } +} diff --git a/members/kalinuxJS/task1/public/vite.svg b/members/kalinuxJS/task1/public/vite.svg new file mode 100644 index 000000000..e7b8dfb1b --- /dev/null +++ b/members/kalinuxJS/task1/public/vite.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/members/kalinuxJS/task1/src/App.css b/members/kalinuxJS/task1/src/App.css new file mode 100644 index 000000000..b9d355df2 --- /dev/null +++ b/members/kalinuxJS/task1/src/App.css @@ -0,0 +1,42 @@ +#root { + max-width: 1280px; + margin: 0 auto; + padding: 2rem; + text-align: center; +} + +.logo { + height: 6em; + padding: 1.5em; + will-change: filter; + transition: filter 300ms; +} +.logo:hover { + filter: drop-shadow(0 0 2em #646cffaa); +} +.logo.react:hover { + filter: drop-shadow(0 0 2em #61dafbaa); +} + +@keyframes logo-spin { + from { + transform: rotate(0deg); + } + to { + transform: rotate(360deg); + } +} + +@media (prefers-reduced-motion: no-preference) { + a:nth-of-type(2) .logo { + animation: logo-spin infinite 20s linear; + } +} + +.card { + padding: 2em; +} + +.read-the-docs { + color: #888; +} diff --git a/members/kalinuxJS/task1/src/App.tsx b/members/kalinuxJS/task1/src/App.tsx new file mode 100644 index 000000000..ae58c1339 --- /dev/null +++ b/members/kalinuxJS/task1/src/App.tsx @@ -0,0 +1,49 @@ +import { useState, useEffect } from 'react' +import reactLogo from './assets/react.svg' +import viteLogo from '/vite.svg' +import './App.css' +import Header from './components/header' +import ToDoList from './components/toDoList' +import AddToDo from './components/addToDo' + +// 定义待办事项的类型 +interface TodoItem { + content: string; + completed: boolean; +} + +function App() { + // 从本地存储初始化状态,如果没有则使用空数组 + const [list, setList] = useState(() => { + const savedTodos = localStorage.getItem('todos'); + return savedTodos ? JSON.parse(savedTodos) : []; + }); + + // 添加任务 + const addTask = (task: TodoItem) => { + setList([...list, task]); + } + + // 更新列表(用于完成和删除操作) + const changeList = (newList: TodoItem[]) => { + setList(newList); + } + + // 使用 useEffect 监听 list 变化,自动保存到本地存储 + useEffect(() => { + localStorage.setItem('todos', JSON.stringify(list)); + console.log('待办事项已保存到本地存储:', list); + }, [list]); + + return ( + <> +
+
+ + +
+ + ) +} + +export default App diff --git a/members/kalinuxJS/task1/src/assets/react.svg b/members/kalinuxJS/task1/src/assets/react.svg new file mode 100644 index 000000000..6c87de9bb --- /dev/null +++ b/members/kalinuxJS/task1/src/assets/react.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/members/kalinuxJS/task1/src/components/addToDo.tsx b/members/kalinuxJS/task1/src/components/addToDo.tsx new file mode 100644 index 000000000..0f55d8b52 --- /dev/null +++ b/members/kalinuxJS/task1/src/components/addToDo.tsx @@ -0,0 +1,42 @@ +import { useState } from 'react' + +interface TodoItem { + content: string; + completed: boolean; +} + +const AddToDo = ({ + addTask, +}: { + addTask: (task: TodoItem) => void +}) => { + const [content, setContent] = useState('') + + const handleAdd = () => { + if (content.trim()) { // 检查输入内容不为空 + addTask({content: content.trim(), completed: false}) + setContent('') // 清空输入框 + } + } + + const handleKeyPress = (e: React.KeyboardEvent) => { + if (e.key === 'Enter') { + handleAdd() + } + } + + return ( +
+ setContent(e.target.value)} + onKeyPress={handleKeyPress} + placeholder="请输入任务内容" + /> + +
+ ) +} + +export default AddToDo; \ No newline at end of file diff --git a/members/kalinuxJS/task1/src/components/header.tsx b/members/kalinuxJS/task1/src/components/header.tsx new file mode 100644 index 000000000..93c063efa --- /dev/null +++ b/members/kalinuxJS/task1/src/components/header.tsx @@ -0,0 +1,13 @@ +const Header = ({ + title, +}: { + title: string; +}) => { + return ( +
+

{title}

+
+ ) +} + +export default Header; \ No newline at end of file diff --git a/members/kalinuxJS/task1/src/components/toDoList.tsx b/members/kalinuxJS/task1/src/components/toDoList.tsx new file mode 100644 index 000000000..42266c9e8 --- /dev/null +++ b/members/kalinuxJS/task1/src/components/toDoList.tsx @@ -0,0 +1,43 @@ + +interface TodoItem { + content: string; + completed: boolean; +} + +interface TodoListProps { + list: TodoItem[]; + changeList: (list: TodoItem[]) => void; +} + +const ToDoList = ({list, changeList}: TodoListProps) => { + const handleComplete = (index: number) => { + const newList = [...list]; // 创建新数组,避免直接修改原数组 + newList[index].completed = !newList[index].completed; + changeList(newList); + } + + const handleDelete = (index: number) => { + const newList = [...list]; // 创建新数组,避免直接修改原数组 + newList.splice(index, 1); + changeList(newList); + } + + return ( +
+ {list.map((item, index) => ( +
+ {item.content} + {item.completed ? '已完成' : '未完成'} + + +
+ ))} +
+ ) +} + +export default ToDoList; \ No newline at end of file diff --git a/members/kalinuxJS/task1/src/index.css b/members/kalinuxJS/task1/src/index.css new file mode 100644 index 000000000..08a3ac9e1 --- /dev/null +++ b/members/kalinuxJS/task1/src/index.css @@ -0,0 +1,68 @@ +:root { + font-family: system-ui, Avenir, Helvetica, Arial, sans-serif; + line-height: 1.5; + font-weight: 400; + + color-scheme: light dark; + color: rgba(255, 255, 255, 0.87); + background-color: #242424; + + font-synthesis: none; + text-rendering: optimizeLegibility; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; +} + +a { + font-weight: 500; + color: #646cff; + text-decoration: inherit; +} +a:hover { + color: #535bf2; +} + +body { + margin: 0; + display: flex; + place-items: center; + min-width: 320px; + min-height: 100vh; +} + +h1 { + font-size: 3.2em; + line-height: 1.1; +} + +button { + border-radius: 8px; + border: 1px solid transparent; + padding: 0.6em 1.2em; + font-size: 1em; + font-weight: 500; + font-family: inherit; + background-color: #1a1a1a; + cursor: pointer; + transition: border-color 0.25s; +} +button:hover { + border-color: #646cff; +} +button:focus, +button:focus-visible { + outline: 4px auto -webkit-focus-ring-color; +} + +@media (prefers-color-scheme: light) { + :root { + color: #213547; + background-color: #ffffff; + } + a:hover { + color: #747bff; + } + button { + background-color: #f9f9f9; + } +} diff --git a/members/kalinuxJS/task1/src/main.tsx b/members/kalinuxJS/task1/src/main.tsx new file mode 100644 index 000000000..bef5202a3 --- /dev/null +++ b/members/kalinuxJS/task1/src/main.tsx @@ -0,0 +1,10 @@ +import { StrictMode } from 'react' +import { createRoot } from 'react-dom/client' +import './index.css' +import App from './App.tsx' + +createRoot(document.getElementById('root')!).render( + + + , +) diff --git a/members/kalinuxJS/task1/src/vite-env.d.ts b/members/kalinuxJS/task1/src/vite-env.d.ts new file mode 100644 index 000000000..11f02fe2a --- /dev/null +++ b/members/kalinuxJS/task1/src/vite-env.d.ts @@ -0,0 +1 @@ +/// diff --git a/members/kalinuxJS/task1/tsconfig.app.json b/members/kalinuxJS/task1/tsconfig.app.json new file mode 100644 index 000000000..227a6c672 --- /dev/null +++ b/members/kalinuxJS/task1/tsconfig.app.json @@ -0,0 +1,27 @@ +{ + "compilerOptions": { + "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo", + "target": "ES2022", + "useDefineForClassFields": true, + "lib": ["ES2022", "DOM", "DOM.Iterable"], + "module": "ESNext", + "skipLibCheck": true, + + /* Bundler mode */ + "moduleResolution": "bundler", + "allowImportingTsExtensions": true, + "verbatimModuleSyntax": true, + "moduleDetection": "force", + "noEmit": true, + "jsx": "react-jsx", + + /* Linting */ + "strict": true, + "noUnusedLocals": true, + "noUnusedParameters": true, + "erasableSyntaxOnly": true, + "noFallthroughCasesInSwitch": true, + "noUncheckedSideEffectImports": true + }, + "include": ["src"] +} diff --git a/members/kalinuxJS/task1/tsconfig.json b/members/kalinuxJS/task1/tsconfig.json new file mode 100644 index 000000000..1ffef600d --- /dev/null +++ b/members/kalinuxJS/task1/tsconfig.json @@ -0,0 +1,7 @@ +{ + "files": [], + "references": [ + { "path": "./tsconfig.app.json" }, + { "path": "./tsconfig.node.json" } + ] +} diff --git a/members/kalinuxJS/task1/tsconfig.node.json b/members/kalinuxJS/task1/tsconfig.node.json new file mode 100644 index 000000000..f85a39906 --- /dev/null +++ b/members/kalinuxJS/task1/tsconfig.node.json @@ -0,0 +1,25 @@ +{ + "compilerOptions": { + "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.node.tsbuildinfo", + "target": "ES2023", + "lib": ["ES2023"], + "module": "ESNext", + "skipLibCheck": true, + + /* Bundler mode */ + "moduleResolution": "bundler", + "allowImportingTsExtensions": true, + "verbatimModuleSyntax": true, + "moduleDetection": "force", + "noEmit": true, + + /* Linting */ + "strict": true, + "noUnusedLocals": true, + "noUnusedParameters": true, + "erasableSyntaxOnly": true, + "noFallthroughCasesInSwitch": true, + "noUncheckedSideEffectImports": true + }, + "include": ["vite.config.ts"] +} diff --git a/members/kalinuxJS/task1/vite.config.ts b/members/kalinuxJS/task1/vite.config.ts new file mode 100644 index 000000000..8b0f57b91 --- /dev/null +++ b/members/kalinuxJS/task1/vite.config.ts @@ -0,0 +1,7 @@ +import { defineConfig } from 'vite' +import react from '@vitejs/plugin-react' + +// https://vite.dev/config/ +export default defineConfig({ + plugins: [react()], +})