From f62d475c36359eec48e259d57761e93cca96a13c Mon Sep 17 00:00:00 2001 From: lichong <18518571399@163.com> Date: Tue, 10 Dec 2024 11:52:56 +0800 Subject: [PATCH] init --- .gitignore | 25 +++++++++++++++ .gitmodules | 3 ++ README.md | 35 +++++++++++++++++++++ index.html | 16 ++++++++++ package.json | 36 +++++++++++++++++++++ public/vite.svg | 10 ++++++ src/App.vue | 30 ++++++++++++++++++ src/api/common.js | 11 +++++++ src/assets/css/base.scss | 5 +++ src/assets/i18n/en.js | 11 +++++++ src/assets/i18n/zh.js | 11 +++++++ src/layouts/basic/index.vue | 47 +++++++++++++++++++++++++++ src/main.js | 42 +++++++++++++++++++++++++ src/plugins/axios.js | 30 ++++++++++++++++++ src/plugins/vuetify.js | 13 ++++++++ src/router/index.js | 35 +++++++++++++++++++++ src/utils/nprogress.js | 20 ++++++++++++ src/utils/utils.js | 0 src/views/home/index.vue | 21 +++++++++++++ vite.config.js | 63 +++++++++++++++++++++++++++++++++++++ 20 files changed, 464 insertions(+) create mode 100644 .gitignore create mode 100644 .gitmodules create mode 100644 README.md create mode 100644 index.html create mode 100644 package.json create mode 100644 public/vite.svg create mode 100644 src/App.vue create mode 100644 src/api/common.js create mode 100644 src/assets/css/base.scss create mode 100644 src/assets/i18n/en.js create mode 100644 src/assets/i18n/zh.js create mode 100644 src/layouts/basic/index.vue create mode 100644 src/main.js create mode 100644 src/plugins/axios.js create mode 100644 src/plugins/vuetify.js create mode 100644 src/router/index.js create mode 100644 src/utils/nprogress.js create mode 100644 src/utils/utils.js create mode 100644 src/views/home/index.vue create mode 100644 vite.config.js diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..f84fdca --- /dev/null +++ b/.gitignore @@ -0,0 +1,25 @@ +# Logs +logs +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* +pnpm-debug.log* +lerna-debug.log* +src/assets/mapdata/* +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/.gitmodules b/.gitmodules new file mode 100644 index 0000000..1c4ed42 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "pathogen_api"] + path = pathogen_api + url = http://gitlab.app.bio-it.tech/root/pathogen_api.git diff --git a/README.md b/README.md new file mode 100644 index 0000000..54ed584 --- /dev/null +++ b/README.md @@ -0,0 +1,35 @@ +# 病原数据项目简介 + +## 设计图 +https://nv3dpiclr7.feishu.cn/docx/Y3c0dj64TowO8KxhxbvcCniCnhd + +## 需求讨论 +https://nv3dpiclr7.feishu.cn/docx/Y3c0dj64TowO8KxhxbvcCniCnhd + +## 环境 +`node>16` + +## 基础包列表 +`axios` `dayjs` `echarts` `element-plus` `lodash``nprogress` `pinia` `vue3` `vue-i18n` `vite5` + +## 项目启动 + +- //安装依赖包 +``` +npm install +``` + +- //开发环境 +``` +npm run dev +``` + +- //开发前准备 +``` +需要将src/assets下的mapdata解压下方可使用,解压后目录层级示例为src/assets/mapdata/provinces +``` + +- //打包 +``` +npm run build +``` diff --git a/index.html b/index.html new file mode 100644 index 0000000..f268fa3 --- /dev/null +++ b/index.html @@ -0,0 +1,16 @@ + + + + + + + + + + pathogenData + + +
+ + + diff --git a/package.json b/package.json new file mode 100644 index 0000000..cfd6ab7 --- /dev/null +++ b/package.json @@ -0,0 +1,36 @@ +{ + "name": "pathogendata", + "private": true, + "version": "0.0.0", + "type": "module", + "scripts": { + "dev": "vite", + "build": "node --max_old_space_size=16384 ./node_modules/vite/bin/vite.js build", + "npm:i": "npm i -d --registry=https://registry.npmmirror.com", + "updateapi": "git submodule update --init --recursive" + }, + "dependencies": { + "@element-plus/icons-vue": "^2.3.1", + "@jamescoyle/vue-icon": "^0.1.2", + "@mdi/font": "^7.4.47", + "@mdi/js": "^7.4.47", + "axios": "^1.7.9", + "dayjs": "^1.11.13", + "element-plus": "^2.9.0", + "lodash": "^4.17.21", + "nprogress": "^0.2.0", + "vue": "^3.5.13", + "vue-i18n": "^10.0.5", + "vue-router": "^4.5.0", + "vuetify": "^3.7.5" + }, + "devDependencies": { + "@vitejs/plugin-vue": "^4.6.2", + "sass": "~1.32.0", + "sass-loader": "^10.5.2", + "unplugin-fonts": "^1.3.1", + "unplugin-vue-components": "^0.27.5", + "vite": "^5.4.11", + "vite-plugin-vuetify": "^2.0.4" + } +} diff --git a/public/vite.svg b/public/vite.svg new file mode 100644 index 0000000..4c34530 --- /dev/null +++ b/public/vite.svg @@ -0,0 +1,10 @@ + + + + + Artboard 46 + + + + + \ No newline at end of file diff --git a/src/App.vue b/src/App.vue new file mode 100644 index 0000000..3426869 --- /dev/null +++ b/src/App.vue @@ -0,0 +1,30 @@ + + + + diff --git a/src/api/common.js b/src/api/common.js new file mode 100644 index 0000000..a4caa8a --- /dev/null +++ b/src/api/common.js @@ -0,0 +1,11 @@ +import _axios from "@/plugins/axios"; +import _ from "lodash"; +let personalToken = `6LEduRKgkheVUBeQ6uvGrZ`//广实代谢 +//获取分析 +export function mathedAnalyzedParams(data = {}) { + return _axios({ + url: `/biobank/v1/workflowlaunchs?token=${personalToken}`, + method: "POST", + data: data, + }); +} \ No newline at end of file diff --git a/src/assets/css/base.scss b/src/assets/css/base.scss new file mode 100644 index 0000000..f31f35e --- /dev/null +++ b/src/assets/css/base.scss @@ -0,0 +1,5 @@ +html, +body { + margin: 0; + padding: 0; +} \ No newline at end of file diff --git a/src/assets/i18n/en.js b/src/assets/i18n/en.js new file mode 100644 index 0000000..09ac286 --- /dev/null +++ b/src/assets/i18n/en.js @@ -0,0 +1,11 @@ +const en = { + "menus": { + "home": 'Home', + "customStatistics": 'Data Statistics', + "spatiotemporalDistribution": 'Spatiotemporal Distribution', + "hostComparison": 'Host Comparison', + 'pathogenSpatiotemporalDistribution': 'Pathogen Spatiotemporal Distribution', + 'monitoringWarningSystem': 'Monitoring Warning System', + }, +} +export default en \ No newline at end of file diff --git a/src/assets/i18n/zh.js b/src/assets/i18n/zh.js new file mode 100644 index 0000000..843f75d --- /dev/null +++ b/src/assets/i18n/zh.js @@ -0,0 +1,11 @@ +const zh = { + "menus": { + "home": '首 页', + "customStatistics": '数据统计', + "spatiotemporalDistribution": '时空分布', + "hostComparison": '宿主物种', + 'pathogenSpatiotemporalDistribution': '病原时空分布', + 'monitoringWarningSystem': '监测预警系统', + }, +} +export default zh \ No newline at end of file diff --git a/src/layouts/basic/index.vue b/src/layouts/basic/index.vue new file mode 100644 index 0000000..a0efeb0 --- /dev/null +++ b/src/layouts/basic/index.vue @@ -0,0 +1,47 @@ + + + + \ No newline at end of file diff --git a/src/main.js b/src/main.js new file mode 100644 index 0000000..b405a0b --- /dev/null +++ b/src/main.js @@ -0,0 +1,42 @@ +import App from "./App.vue"; +import { createApp } from "vue"; +import { createI18n } from 'vue-i18n' +// 引入路由实例 +import router from "@/router/index.js"; +//全局引入lodash +import _ from "lodash"; +//全局引入lodash +import dayjs from "dayjs"; +// 引入css +import "@/assets/css/base.scss"; +//全局引入element-plus组件库,方便修改配置,也可以在vite.config.js中动态引入 +import ElementPlus from 'element-plus' +//全局引入element-plus所有图标 +import * as ElementPlusIconsVue from '@element-plus/icons-vue' +import 'element-plus/dist/index.css' +//引入中英文的数据 +import en from './assets/i18n/en.js' +import zh from './assets/i18n/zh.js' + +const i18n = createI18n({ + // something vue-i18n options here ... + locale: 'zh', // 设置默认的语音版本语言 + messages: { + zh: { ...zh }, + en: { ...en }, + } +}) +// Plugins +import vuetify from '@/plugins/vuetify.js' + +const app = createApp(App); +i18n.install(app) // use不生效,install生效 +for (const [key, component] of Object.entries(ElementPlusIconsVue)) { + app.component(key, component) +} +app.config.globalProperties.$_ = _; //挂载到app实例上 +app.config.globalProperties.$dayjs = dayjs; //挂载到app实例上 +app.use(ElementPlus, { zIndex: 3000 }) + .use(vuetify) //vuetify + .use(router) //路由 + .mount("#app"); diff --git a/src/plugins/axios.js b/src/plugins/axios.js new file mode 100644 index 0000000..f74d1d0 --- /dev/null +++ b/src/plugins/axios.js @@ -0,0 +1,30 @@ +import axios from "axios"; +import {ElMessage} from 'element-plus' + +let config = { + baseURL: "", + timeout: 600 * 1000, + withCredentials: true, + +}; + +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/src/plugins/vuetify.js b/src/plugins/vuetify.js new file mode 100644 index 0000000..529f4f0 --- /dev/null +++ b/src/plugins/vuetify.js @@ -0,0 +1,13 @@ +// Styles +import '@mdi/font/css/materialdesignicons.css' +import 'vuetify/styles' + +// Composables +import {createVuetify} from 'vuetify' + +// https://vuetifyjs.com/en/introduction/why-vuetify/#feature-guides +export default createVuetify({ + theme: { + defaultTheme: 'light', + }, +}) diff --git a/src/router/index.js b/src/router/index.js new file mode 100644 index 0000000..760b13f --- /dev/null +++ b/src/router/index.js @@ -0,0 +1,35 @@ +import { createRouter, createWebHistory } from "vue-router"; +import { close, start } from "@/utils/nprogress"; +import layout from "@/layouts/basic/index" + +const routes = [ + { + path: "/", + name: "", + component: layout, + redirect: "/home", + children: [ + { + path: "home", + name: "home", + component: () => import("@/views/home/index.vue"), + }, + ] + }, + { name: "重定向", path: "/:catchAll(.*)", redirect: "/home" }, +]; + +// 创建路由实例 +const router = createRouter({ + history: createWebHistory(), + routes, //路由表 +}); +router.beforeEach((to, from, next) => { + next() + start(); +}); + +router.afterEach((pre, next) => { + close(); +}); +export default router; diff --git a/src/utils/nprogress.js b/src/utils/nprogress.js new file mode 100644 index 0000000..55b9f30 --- /dev/null +++ b/src/utils/nprogress.js @@ -0,0 +1,20 @@ +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/src/utils/utils.js b/src/utils/utils.js new file mode 100644 index 0000000..e69de29 diff --git a/src/views/home/index.vue b/src/views/home/index.vue new file mode 100644 index 0000000..28aefd6 --- /dev/null +++ b/src/views/home/index.vue @@ -0,0 +1,21 @@ + + + + diff --git a/vite.config.js b/vite.config.js new file mode 100644 index 0000000..1177b84 --- /dev/null +++ b/vite.config.js @@ -0,0 +1,63 @@ +// Plugins +import vue from "@vitejs/plugin-vue"; +import Vuetify, {transformAssetUrls} from 'vite-plugin-vuetify' +import Components from 'unplugin-vue-components/vite' +// Utilities +import {defineConfig} from "vite"; +import {fileURLToPath, URL} from "node:url"; + +// https://vitejs.dev/config/ +export default defineConfig({ + // publicDir: "src/assets", + // assetsDir:"src/assets", + plugins: [ + vue({ + template: {transformAssetUrls} + }), + Vuetify(), + Components(), + ], + define: {"process.env": {}}, + resolve: { + alias: { + "@": fileURLToPath(new URL("./src", import.meta.url)), + }, + extensions: [".js", ".json", ".jsx", ".mjs", ".ts", ".tsx", ".vue"], + }, + server: { + host: "0.0.0.0", + port: 3000, + proxy: { + // "/biobank": { + // target: "http://127.0.0.1:7001", + // changeOrigin: true, + // // rewrite: (path) => path.replace(/^\/biobank/, "") + // }, + "/biobank": { + target: "http://10.20.16.11:8000", + changeOrigin: true, + // rewrite: (path) => path.replace(/^\/biobank/, "") + }, + // "/pathogen_api": { + // target: "http://10.20.16.11:7727", + // changeOrigin: true, + // // rewrite: (path) => path.replace(/^\/pathogen_api/, "") + // }, + "/pathogen_api": { + target: "http://127.0.0.1:7002", + // target: "http://192.168.31.138:7002", + changeOrigin: true, + // rewrite: (path) => path.replace(/^\/pathogen_api/, "") + }, + // "/biobank": { + // target: "http://192.168.31.89:7002", + // changeOrigin: true, + // // rewrite: (path) => path.replace(/^\/biobank/, "") + // }, + }, + }, + // 构建的时候添加源代码映射,调试可以快速定位,上线的时候最好注掉 + build: { + sourcemap: true, + }, +});