From 566d2223ac5a3b3b2019a9411b87bbc125405fbf Mon Sep 17 00:00:00 2001
From: lichong <18518571399@163.com>
Date: Tue, 2 Jul 2024 11:50:39 +0800
Subject: [PATCH] init
---
api/main.py | 52 +++++
front/.gitignore | 25 +++
front/README.md | 7 +
front/index.html | 12 +
front/package.json | 30 +++
front/public/config.json | 9 +
front/public/vite.svg | 1 +
front/src/App.vue | 20 ++
front/src/api/login.js | 11 +
front/src/api/user.js | 36 +++
front/src/assets/css/base.css | 3 +
front/src/assets/img/avatar.png | Bin 0 -> 15926 bytes
front/src/assets/img/login.jpg | Bin 0 -> 25276 bytes
front/src/assets/img/logo.jpg | Bin 0 -> 6512 bytes
front/src/assets/img/student.png | Bin 0 -> 41974 bytes
front/src/assets/img/teacher.png | Bin 0 -> 43354 bytes
front/src/component/changeItem.vue | 71 ++++++
front/src/component/table.vue | 114 ++++++++++
front/src/main.js | 22 ++
front/src/plugins/axios.js | 40 ++++
front/src/router/index.js | 44 ++++
front/src/style.css | 79 +++++++
front/src/utils/nprogress.js | 19 ++
front/src/views/home.vue | 85 ++++++++
front/src/views/login.vue | 103 +++++++++
front/src/views/user.vue | 340 +++++++++++++++++++++++++++++
front/vite.config.js | 42 ++++
27 files changed, 1165 insertions(+)
create mode 100644 api/main.py
create mode 100644 front/.gitignore
create mode 100644 front/README.md
create mode 100644 front/index.html
create mode 100644 front/package.json
create mode 100644 front/public/config.json
create mode 100644 front/public/vite.svg
create mode 100644 front/src/App.vue
create mode 100644 front/src/api/login.js
create mode 100644 front/src/api/user.js
create mode 100644 front/src/assets/css/base.css
create mode 100644 front/src/assets/img/avatar.png
create mode 100644 front/src/assets/img/login.jpg
create mode 100644 front/src/assets/img/logo.jpg
create mode 100644 front/src/assets/img/student.png
create mode 100644 front/src/assets/img/teacher.png
create mode 100644 front/src/component/changeItem.vue
create mode 100644 front/src/component/table.vue
create mode 100644 front/src/main.js
create mode 100644 front/src/plugins/axios.js
create mode 100644 front/src/router/index.js
create mode 100644 front/src/style.css
create mode 100644 front/src/utils/nprogress.js
create mode 100644 front/src/views/home.vue
create mode 100644 front/src/views/login.vue
create mode 100644 front/src/views/user.vue
create mode 100644 front/vite.config.js
diff --git a/api/main.py b/api/main.py
new file mode 100644
index 0000000..0b11773
--- /dev/null
+++ b/api/main.py
@@ -0,0 +1,52 @@
+from flask import Flask
+from pymongo import MongoClient
+
+app = Flask(__name__)
+client = MongoClient("mongodb://localhost:27019/")
+db = client["back"]
+collection = db["users"]
+
+
+# 测试
+@app.route("/")
+def hello():
+ return "Hello World!"
+
+
+# 新增用户
+@app.route("/insert")
+def insert_data():
+ user = {"name": "John Doe", "age": 25, "city": "New York"}
+ collection.insert_one(user)
+ return "Data inserted successfully!"
+
+
+# 查询用户
+@app.route("/query")
+def query_data():
+ users = collection.find()
+ result = ""
+ for user in users:
+ result += f"Name: {user['name']}, Age: {user['age']}, City: {user['city']}
"
+ return result
+
+
+# 更新用户
+@app.route("/update")
+def update_data():
+ query = {"name": "John Doe"}
+ new_data = {"$set": {"age": 30, "city": "San Francisco"}}
+ collection.update_one(query, new_data)
+ return "Data updated successfully!"
+
+
+# 删除用户
+@app.route("/delete")
+def delete_data():
+ query = {"name": "John Doe"}
+ collection.delete_one(query)
+ return "Data deleted successfully!"
+
+
+if __name__ == "__main__":
+ app.run()
diff --git a/front/.gitignore b/front/.gitignore
new file mode 100644
index 0000000..782636d
--- /dev/null
+++ b/front/.gitignore
@@ -0,0 +1,25 @@
+# Logs
+logs
+*.log
+npm-debug.log*
+yarn-debug.log*
+yarn-error.log*
+pnpm-debug.log*
+lerna-debug.log*
+
+node_modules
+dist
+package-lock.json
+dist-ssr
+*.local
+
+# Editor directories and files
+.vscode/*
+!.vscode/extensions.json
+.idea
+.DS_Store
+*.suo
+*.ntvs*
+*.njsproj
+*.sln
+*.sw?
diff --git a/front/README.md b/front/README.md
new file mode 100644
index 0000000..f529bc8
--- /dev/null
+++ b/front/README.md
@@ -0,0 +1,7 @@
+# base
+
+This template should help get you started developing with Vue 3 in Vite. The template uses Vue 3 `
+