commit 566d2223ac5a3b3b2019a9411b87bbc125405fbf Author: lichong <18518571399@163.com> Date: Tue Jul 2 11:50:39 2024 +0800 init 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 ` + + diff --git a/front/package.json b/front/package.json new file mode 100644 index 0000000..683778c --- /dev/null +++ b/front/package.json @@ -0,0 +1,30 @@ +{ + "name": "base", + "private": true, + "version": "0.0.0", + "type": "module", + "scripts": { + "dev": "vite", + "build": "vite build", + "preview": "vite preview" + }, + "dependencies": { + "@element-plus/icons-vue": "^2.3.1", + "axios": "^1.6.6", + "dayjs": "^1.11.10", + "element-plus": "^2.5.3", + "lodash": "^4.17.21", + "md5": "^2.3.0", + "nprogress": "^0.2.0", + "papaparse": "^5.4.1", + "qs": "^6.11.2", + "unplugin-auto-import": "^0.17.4", + "unplugin-vue-components": "^0.26.0", + "vue": "^3.3.11", + "vue-router": "^4.2.5" + }, + "devDependencies": { + "@vitejs/plugin-vue": "^4.6.2", + "vite": "^5.0.8" + } +} diff --git a/front/public/config.json b/front/public/config.json new file mode 100644 index 0000000..0f21a96 --- /dev/null +++ b/front/public/config.json @@ -0,0 +1,9 @@ +{ + "title": "可视化预警平台", + "jianceduixiang1path": "@/assets/img/jianceduixiang1.gif", + "jianceduixiang2path": "@/assets/img/jianceduixiang2.jpg", + "jianceduixiang3path": "@/assets/img/jianceduixiang3.png", + "jianceduixiang4path": "@/assets/img/jianceduixiang4.png", + "jianceduixiang5path": "@/assets/img/jianceduixiang5.gif", + "jianceduixiang6path": "@/assets/img/jianceduixiang6.gif" +} diff --git a/front/public/vite.svg b/front/public/vite.svg new file mode 100644 index 0000000..7048ee8 --- /dev/null +++ b/front/public/vite.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/front/src/App.vue b/front/src/App.vue new file mode 100644 index 0000000..018ec92 --- /dev/null +++ b/front/src/App.vue @@ -0,0 +1,20 @@ + + + + diff --git a/front/src/api/login.js b/front/src/api/login.js new file mode 100644 index 0000000..a3cc359 --- /dev/null +++ b/front/src/api/login.js @@ -0,0 +1,11 @@ +import _axios from "@/plugins/axios"; + +//登录、注册 +export function loginFun(data) { + return _axios({ + url: `/v1/login`, + method: "POST", + data, + }); +} + diff --git a/front/src/api/user.js b/front/src/api/user.js new file mode 100644 index 0000000..efaf90c --- /dev/null +++ b/front/src/api/user.js @@ -0,0 +1,36 @@ +import _axios from "@/plugins/axios"; + +//增加用户 +export function addUser(data) { + return _axios({ + url: `/v1/addUser`, + method: "POST", + data, + }); +} + +//删除用户 +export function delUser(data) { + return _axios({ + url: `/v1/delUser`, + method: "POST", + data, + }); +} +//修改用户 +export function getUser(data) { + return _axios({ + url: `/v1/updateUser`, + method: "POST", + data, + }); +} +//查找用户 +export function getUser(data) { + return _axios({ + url: `/v1/getUser`, + method: "POST", + data, + }); +} + diff --git a/front/src/assets/css/base.css b/front/src/assets/css/base.css new file mode 100644 index 0000000..d3c150d --- /dev/null +++ b/front/src/assets/css/base.css @@ -0,0 +1,3 @@ +body { + margin: 0; +} \ No newline at end of file diff --git a/front/src/assets/img/avatar.png b/front/src/assets/img/avatar.png new file mode 100644 index 0000000..4aa23de Binary files /dev/null and b/front/src/assets/img/avatar.png differ diff --git a/front/src/assets/img/login.jpg b/front/src/assets/img/login.jpg new file mode 100644 index 0000000..dec7236 Binary files /dev/null and b/front/src/assets/img/login.jpg differ diff --git a/front/src/assets/img/logo.jpg b/front/src/assets/img/logo.jpg new file mode 100644 index 0000000..88a682a Binary files /dev/null and b/front/src/assets/img/logo.jpg differ diff --git a/front/src/assets/img/student.png b/front/src/assets/img/student.png new file mode 100644 index 0000000..7fbf110 Binary files /dev/null and b/front/src/assets/img/student.png differ diff --git a/front/src/assets/img/teacher.png b/front/src/assets/img/teacher.png new file mode 100644 index 0000000..a0ea7c1 Binary files /dev/null and b/front/src/assets/img/teacher.png differ diff --git a/front/src/component/changeItem.vue b/front/src/component/changeItem.vue new file mode 100644 index 0000000..8193424 --- /dev/null +++ b/front/src/component/changeItem.vue @@ -0,0 +1,71 @@ + + + diff --git a/front/src/component/table.vue b/front/src/component/table.vue new file mode 100644 index 0000000..bc9a0b0 --- /dev/null +++ b/front/src/component/table.vue @@ -0,0 +1,114 @@ + + + diff --git a/front/src/main.js b/front/src/main.js new file mode 100644 index 0000000..5c591f7 --- /dev/null +++ b/front/src/main.js @@ -0,0 +1,22 @@ +import App from "./App.vue"; +import { createApp } from "vue"; +// 引入路由实例 +import router from "@/router/index.js"; +//全局引入lodash +import _ from "lodash"; +//全局引入lodash +import dayjs from "dayjs"; +// 引入css +import "@/assets/css/base.css"; +//全局引入element-plus所有图标 +import * as ElementPlusIconsVue from '@element-plus/icons-vue' + +const app = createApp(App); +for (const [key, component] of Object.entries(ElementPlusIconsVue)) { + app.component(key, component) +} +app.config.globalProperties.$_ = _; //挂载到app实例上 +app.config.globalProperties.$dayjs = dayjs; //挂载到app实例上 +app + .use(router) //路由 +app.mount("#app"); diff --git a/front/src/plugins/axios.js b/front/src/plugins/axios.js new file mode 100644 index 0000000..6274ce5 --- /dev/null +++ b/front/src/plugins/axios.js @@ -0,0 +1,40 @@ +import axios from "axios"; +import qs from "qs"; +import router from "@/router/index.js"; +let config = { + baseURL: "", + timeout: 600 * 1000, + withCredentials: true, // Check cross-site Access-Control + /* `paramsSerializer` 是一个负责 `params` 序列化的函数 + qs.stringify({ a: ['b', 'c'] }, { arrayFormat: 'indices' }) + // 'a[0]=b&a[1]=c' + qs.stringify({ a: ['b', 'c'] }, { arrayFormat: 'brackets' }) + // 'a[]=b&a[]=c' + qs.stringify({ a: ['b', 'c'] }, { arrayFormat: 'repeat' }) + // 'a=b&a=c' + */ + paramsSerializer: (params) => { + return qs.stringify(params, { arrayFormat: "indices" }); + }, +}; + +const _axios = axios.create(config); + +_axios.interceptors.request.use( + (config) => { + return config; + }, + (error) => { + return Promise.reject(error); + } +); +_axios.interceptors.response.use( + (response) => { + return Promise.resolve(response.data); + }, + (error) => { + ElMessage.error(error.response.data.message); + return Promise.reject(error); + } +); +export default _axios; diff --git a/front/src/router/index.js b/front/src/router/index.js new file mode 100644 index 0000000..a5368a3 --- /dev/null +++ b/front/src/router/index.js @@ -0,0 +1,44 @@ +import { createRouter, createWebHistory } from "vue-router"; +import { close, start } from "@/utils/nprogress"; +import home from "../views/home.vue" +const routes = [ + { + path: "/", + name: "home", + component: home, + redirect: "/bug", + children: [{ + path: "bug", + name: "bug", + component: () => import("../views/bug.vue"), + }, + { + path: "user", + name: "user", + component: () => import("../views/user.vue"), + },] + }, + { + path: "/login", + name: "login", + component: () => import("../views/login.vue"), + }, + { name: "重定向", path: "/:catchAll(.*)", redirect: "/bug" }, +]; + +// 创建路由实例 +const router = createRouter({ + history: createWebHistory(), + routes, //路由表 +}); +let witheRouter = ["login"]; +router.beforeEach((pre, next) => { + if (witheRouter.indexOf(pre.name) !== -1) { + } + start(); +}); + +router.afterEach(() => { + close(); +}); +export default router; diff --git a/front/src/style.css b/front/src/style.css new file mode 100644 index 0000000..bb131d6 --- /dev/null +++ b/front/src/style.css @@ -0,0 +1,79 @@ +:root { + font-family: Inter, 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; +} + +.card { + padding: 2em; +} + +#app { + max-width: 1280px; + margin: 0 auto; + padding: 2rem; + text-align: center; +} + +@media (prefers-color-scheme: light) { + :root { + color: #213547; + background-color: #ffffff; + } + a:hover { + color: #747bff; + } + button { + background-color: #f9f9f9; + } +} diff --git a/front/src/utils/nprogress.js b/front/src/utils/nprogress.js new file mode 100644 index 0000000..6b5f15a --- /dev/null +++ b/front/src/utils/nprogress.js @@ -0,0 +1,19 @@ +import NProgress from 'nprogress' +import 'nprogress/nprogress.css' +NProgress.configure({ + easing: 'ease', // 动画方式 + speed: 1000, // 递增进度条的速度 + showSpinner: false, // 是否显示加载ico + trickleSpeed: 200, // 自动递增间隔 + minimum: 0.3, // 更改启动时使用的最小百分比 + parent: 'body', //指定进度条的父容器 +}) +// 打开进度条 +export const start = () => { + NProgress.start() +} + +// 关闭进度条 +export const close = () => { + NProgress.done() +} \ No newline at end of file diff --git a/front/src/views/home.vue b/front/src/views/home.vue new file mode 100644 index 0000000..915d9d2 --- /dev/null +++ b/front/src/views/home.vue @@ -0,0 +1,85 @@ + + + + diff --git a/front/src/views/login.vue b/front/src/views/login.vue new file mode 100644 index 0000000..1895e80 --- /dev/null +++ b/front/src/views/login.vue @@ -0,0 +1,103 @@ + + + diff --git a/front/src/views/user.vue b/front/src/views/user.vue new file mode 100644 index 0000000..d4dbb07 --- /dev/null +++ b/front/src/views/user.vue @@ -0,0 +1,340 @@ + + + diff --git a/front/vite.config.js b/front/vite.config.js new file mode 100644 index 0000000..9b3758c --- /dev/null +++ b/front/vite.config.js @@ -0,0 +1,42 @@ +// Plugins +import vue from "@vitejs/plugin-vue"; + +// Utilities +import { defineConfig } from "vite"; +import { fileURLToPath, URL } from "node:url"; +import AutoImport from "unplugin-auto-import/vite"; +import Components from "unplugin-vue-components/vite"; +import { ElementPlusResolver } from "unplugin-vue-components/resolvers"; + +// https://vitejs.dev/config/ +export default defineConfig({ + plugins: [ + vue(), + AutoImport({ + resolvers: [ElementPlusResolver()], + }), + Components({ + resolvers: [ElementPlusResolver()], + }), + ], + define: { "process.env": {} }, + resolve: { + alias: { + "@": fileURLToPath(new URL("./src", import.meta.url)), + }, + extensions: [".js", ".json", ".jsx", ".mjs", ".ts", ".tsx", ".vue"], + }, + server: { + port: 3000, + proxy: { + "/v1": { + target: "http://127.0.0.1:7001/v1", + changeOrigin: true, + rewrite: (path) => path.replace(/^\/v1/, ""), + }, + }, + }, + build: { + sourcemap: true, + }, +});