diff --git a/.drone.yml b/.drone.yml deleted file mode 100644 index 02f8349..0000000 --- a/.drone.yml +++ /dev/null @@ -1,219 +0,0 @@ ---- -kind: pipeline -type: docker -name: development - -# 常量值 -constants: - - &DEVELOPMENT_HOST test.tall.wiki - - &DEVELOPMENT_CMD - - npm config set registry http://registry.npm.taobao.org - - npm i - - npm run build - - &DEVELOPMENT_SCP_TARGET /home/experiment - - &DEVELOPMENT_URL https://test.tall.wiki/experiment/ - - &DEVELOPMENT_PORT 22 - - &DEVELOPMENT_NODE_VERSION node:16 - - &DEVELOPMENT_BRANCH develop - - &DEVELOPMENT_SCP_SOURCE dist/* - - &SCP_STRIP_DIR_LEVEL 1 - - &NOTIFY_WECHATROBOT_WEBHOOK https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=428e5c5d-f992-4349-939d-9c99556e50b8 - - -# 挂载的主机卷,可以映射到docker容器中 -volumes: - # maven构建缓存(宿主机目录) - - name: ssh_key - host: - path: /root/.ssh/ - - name: cache - host: - path: /var/lib/cache - - name: data - host: - path: /var/lib/data - -steps: - - name: restore-cache - image: drillster/drone-volume-cache - volumes: - - name: cache - path: /cache - settings: - restore: true - mount: - - ./node_modules - - - name: build - image: *DEVELOPMENT_NODE_VERSION - pull: if-not-exists # default always - # volumes: - # - name: cache - # path: /root/.m2 - commands: *DEVELOPMENT_CMD - - - name: rebuild-cache - image: drillster/drone-volume-cache - volumes: - - name: cache - path: /cache - settings: - rebuild: true - mount: - - ./node_modules - - - name: deploy-scp - image: appleboy/drone-scp - pull: if-not-exists - volumes: - - name: ssh_key - path: /root/.ssh/ - settings: - host: *DEVELOPMENT_HOST - port: *DEVELOPMENT_PORT - username: root - key_path: /root/.ssh/id_rsa - rm: true # true则会删除目标目录重建 - target: *DEVELOPMENT_SCP_TARGET - source: *DEVELOPMENT_SCP_SOURCE - strip_components: 1 # 去除的目录层数,如果没有该选项,则拷贝过去是 target/xxx.jar,1代表去除target - - - name: notify-wechatwork - image: fifsky/drone-wechat-work - pull: if-not-exists - settings: - url: *NOTIFY_WECHATROBOT_WEBHOOK - msgtype: markdown - content: | - {{if eq .Status "success" }} - #### 🎉 ${DRONE_REPO} 测试环境构建成功 - > Branch: ${DRONE_BRANCH} - > Commit: [${DRONE_COMMIT_MESSAGE} ](${DRONE_COMMIT_LINK}) - > Author: ${DRONE_COMMIT_AUTHOR} - > PATH: https://test.tall.wiki/experiment/ - > [点击查看](https://test.tall.wiki/experiment/) - {{else}} - #### ❌ ${DRONE_REPO} 测试环境构建失败 - > Branch: ${DRONE_BRANCH} - > Commit: [${DRONE_COMMIT_MESSAGE} ](${DRONE_COMMIT_LINK}) - > Author: ${DRONE_COMMIT_AUTHOR} - > 请立即修复!!! - > [点击查看](https://test.tall.wiki/experiment/) - {{end}} - when: - status: - - failure - - success - -trigger: - branch: - - *DEVELOPMENT_BRANCH - ---- -kind: pipeline -type: docker -name: production - -# 常量值 -constants: - - &PRODUCTION_HOST www.tall.wiki - - &PRODUCTION_CMD - - npm config set registry http://registry.npm.taobao.org - - npm i - - npm run build:prod - - &PRODUCTION_SCP_TARGET /home/experiment - - &PRODUCTION_BRANCH master - - &PRODUCTION_PORT 22 - - &PRODUCTION_NODE_VERSION node:16 - - &PRODUCTION_SCP_SOURCE dist/* - - &SCP_STRIP_DIR_LEVEL 1 - - &NOTIFY_WECHATROBOT_WEBHOOK https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=428e5c5d-f992-4349-939d-9c99556e50b8 - -# 挂载的主机卷,可以映射到docker容器中 -volumes: - # maven构建缓存(宿主机目录) - - name: ssh_key - host: - path: /root/.ssh/ - - name: cache - host: - path: /var/lib/cache - - name: data - host: - path: /var/lib/data - -steps: - - name: restore-cache - image: drillster/drone-volume-cache - volumes: - - name: cache - path: /cache - settings: - restore: true - mount: - - ./node_modules - - - name: build - image: *PRODUCTION_NODE_VERSION - pull: if-not-exists # default always - # volumes: - # - name: cache - # path: /root/.m2 - commands: *PRODUCTION_CMD - - - name: rebuild-cache - image: drillster/drone-volume-cache - volumes: - - name: cache - path: /cache - settings: - rebuild: true - mount: - - ./node_modules - - - name: deploy-scp - image: appleboy/drone-scp - pull: if-not-exists - volumes: - - name: ssh_key - path: /root/.ssh/ - settings: - host: *PRODUCTION_HOST - port: *PRODUCTION_PORT - username: root - key_path: /root/.ssh/id_rsa - rm: true # true则会删除目标目录重建 - target: *PRODUCTION_SCP_TARGET - source: *PRODUCTION_SCP_SOURCE - strip_components: 1 # 去除的目录层数,如果没有该选项,则拷贝过去是 target/xxx.jar,1代表去除target - - - name: notify-wechatwork - image: fifsky/drone-wechat-work - pull: if-not-exists - settings: - url: *NOTIFY_WECHATROBOT_WEBHOOK - msgtype: markdown - content: | - {{if eq .Status "success" }} - #### 🎉 ${DRONE_REPO} 生产环境构建成功 - > Branch: ${DRONE_BRANCH} - > Commit: [${DRONE_COMMIT_MESSAGE}](${DRONE_COMMIT_LINK}) - > Author: ${DRONE_COMMIT_AUTHOR} - > PATH: https://www.tall.wiki/experiment/ - > [点击查看](https://www.tall.wiki/experiment/) - {{else}} - #### ❌ ${DRONE_REPO} 生产环境构建失败 - > Branch: ${DRONE_BRANCH} - > Commit: [${DRONE_COMMIT_MESSAGE}](${DRONE_COMMIT_LINK}) - > Author: ${DRONE_COMMIT_AUTHOR} - > 请立即修复!!! - > [点击查看](https://www.tall.wiki/experiment/) - {{end}} - when: - status: - - failure - - success - -trigger: - branch: - - *PRODUCTION_BRANCH diff --git a/.env.development b/.env.development index 5317fce..9da8b22 100644 --- a/.env.development +++ b/.env.development @@ -1 +1,5 @@ -VITE_API_URL=http://localhost:3000 +VITE_BASE_URL=http://101.201.226.163 +VITE_API_URL=http://101.201.226.163/gateway +VITE_MSG_URL=ws://101.201.226.163:8196/message/v4.0/ws +VITE_SERVICELIST=['ZERO', 'CONTEST', 'PT'] +VITE_VERSION=v4.0.0 diff --git a/.env.production b/.env.production index ab22b6a..9da8b22 100644 --- a/.env.production +++ b/.env.production @@ -1 +1,5 @@ -VITE_API_URL=https://www.tall.wiki +VITE_BASE_URL=http://101.201.226.163 +VITE_API_URL=http://101.201.226.163/gateway +VITE_MSG_URL=ws://101.201.226.163:8196/message/v4.0/ws +VITE_SERVICELIST=['ZERO', 'CONTEST', 'PT'] +VITE_VERSION=v4.0.0 diff --git a/.env.test b/.env.test index 9bcb052..9da8b22 100644 --- a/.env.test +++ b/.env.test @@ -1 +1,5 @@ -VITE_API_URL=https://test.tall.wiki +VITE_BASE_URL=http://101.201.226.163 +VITE_API_URL=http://101.201.226.163/gateway +VITE_MSG_URL=ws://101.201.226.163:8196/message/v4.0/ws +VITE_SERVICELIST=['ZERO', 'CONTEST', 'PT'] +VITE_VERSION=v4.0.0 diff --git a/index.html b/index.html index 6264214..23b952e 100644 --- a/index.html +++ b/index.html @@ -4,7 +4,7 @@ - 山大实验室管理平台 + PT
diff --git a/package-lock.json b/package-lock.json index 30ba9d5..4d22bea 100644 --- a/package-lock.json +++ b/package-lock.json @@ -14,6 +14,7 @@ "dayjs": "^1.10.7", "echarts": "^5.2.2", "lodash": "^4.17.21", + "uuid": "^8.3.2", "vite": "^2.6.4", "vite-plugin-compression": "^0.3.5", "vite-plugin-windicss": "^1.4.11", @@ -8487,6 +8488,14 @@ "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=", "dev": true }, + "node_modules/uuid": { + "version": "8.3.2", + "resolved": "https://registry.npmmirror.com/uuid/-/uuid-8.3.2.tgz", + "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==", + "bin": { + "uuid": "dist/bin/uuid" + } + }, "node_modules/v8-compile-cache": { "version": "2.3.0", "resolved": "https://registry.nlark.com/v8-compile-cache/download/v8-compile-cache-2.3.0.tgz", @@ -15694,6 +15703,11 @@ "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=", "dev": true }, + "uuid": { + "version": "8.3.2", + "resolved": "https://registry.npmmirror.com/uuid/-/uuid-8.3.2.tgz", + "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==" + }, "v8-compile-cache": { "version": "2.3.0", "resolved": "https://registry.nlark.com/v8-compile-cache/download/v8-compile-cache-2.3.0.tgz", diff --git a/package.json b/package.json index 0dbd4a9..1e8103d 100644 --- a/package.json +++ b/package.json @@ -20,6 +20,7 @@ "dayjs": "^1.10.7", "echarts": "^5.2.2", "lodash": "^4.17.21", + "uuid": "^8.3.2", "vite": "^2.6.4", "vite-plugin-compression": "^0.3.5", "vite-plugin-windicss": "^1.4.11", diff --git a/src/App.vue b/src/App.vue index 91881b0..d614def 100644 --- a/src/App.vue +++ b/src/App.vue @@ -2,74 +2,24 @@
- - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/components/tall/center/Index.vue b/src/components/tall/center/Index.vue index 1faf9c1..9ecec0f 100644 --- a/src/components/tall/center/Index.vue +++ b/src/components/tall/center/Index.vue @@ -10,17 +10,17 @@ - -
+ + - -
+ + - -
+ + {{ val.name }}
-
- + --> diff --git a/src/components/tall/task/AssignmentSubject.vue b/src/components/tall/task/AssignmentSubject.vue deleted file mode 100644 index 5d41738..0000000 --- a/src/components/tall/task/AssignmentSubject.vue +++ /dev/null @@ -1,453 +0,0 @@ - - - - - diff --git a/src/components/tall/task/CheckSubjectProgress.vue b/src/components/tall/task/CheckSubjectProgress.vue deleted file mode 100644 index e3b2691..0000000 --- a/src/components/tall/task/CheckSubjectProgress.vue +++ /dev/null @@ -1,192 +0,0 @@ - - - - - diff --git a/src/components/tall/task/Conclusion.vue b/src/components/tall/task/Conclusion.vue deleted file mode 100644 index 4697d8b..0000000 --- a/src/components/tall/task/Conclusion.vue +++ /dev/null @@ -1,246 +0,0 @@ - - - - - diff --git a/src/components/tall/task/ContractManagement.vue b/src/components/tall/task/ContractManagement.vue deleted file mode 100644 index a1ba322..0000000 --- a/src/components/tall/task/ContractManagement.vue +++ /dev/null @@ -1,235 +0,0 @@ - - - - - diff --git a/src/components/tall/task/DataUnlock.vue b/src/components/tall/task/DataUnlock.vue deleted file mode 100644 index 69a2ea1..0000000 --- a/src/components/tall/task/DataUnlock.vue +++ /dev/null @@ -1,172 +0,0 @@ - - - - - diff --git a/src/components/tall/task/ExperimentalCode.vue b/src/components/tall/task/ExperimentalCode.vue deleted file mode 100644 index 2c203aa..0000000 --- a/src/components/tall/task/ExperimentalCode.vue +++ /dev/null @@ -1,287 +0,0 @@ - - - - - diff --git a/src/components/tall/task/ExperimentalData.vue b/src/components/tall/task/ExperimentalData.vue deleted file mode 100644 index 2c203aa..0000000 --- a/src/components/tall/task/ExperimentalData.vue +++ /dev/null @@ -1,287 +0,0 @@ - - - - - diff --git a/src/components/tall/task/ExperimentalResult.vue b/src/components/tall/task/ExperimentalResult.vue deleted file mode 100644 index cbe1ca6..0000000 --- a/src/components/tall/task/ExperimentalResult.vue +++ /dev/null @@ -1,277 +0,0 @@ - - - - - diff --git a/src/components/tall/task/InterimInspection.vue b/src/components/tall/task/InterimInspection.vue deleted file mode 100644 index 72c4e23..0000000 --- a/src/components/tall/task/InterimInspection.vue +++ /dev/null @@ -1,246 +0,0 @@ - - - - - diff --git a/src/components/tall/task/LabReport.vue b/src/components/tall/task/LabReport.vue deleted file mode 100644 index 18d1ef1..0000000 --- a/src/components/tall/task/LabReport.vue +++ /dev/null @@ -1,274 +0,0 @@ - - - - - diff --git a/src/components/tall/task/MeetingManagement.vue b/src/components/tall/task/MeetingManagement.vue deleted file mode 100644 index b41a28f..0000000 --- a/src/components/tall/task/MeetingManagement.vue +++ /dev/null @@ -1,292 +0,0 @@ - - - - - diff --git a/src/components/tall/task/MemberManagement.vue b/src/components/tall/task/MemberManagement.vue deleted file mode 100644 index e5da8ab..0000000 --- a/src/components/tall/task/MemberManagement.vue +++ /dev/null @@ -1,258 +0,0 @@ - - - - - diff --git a/src/components/tall/task/PlanAssignment.vue b/src/components/tall/task/PlanAssignment.vue deleted file mode 100644 index 54b68bf..0000000 --- a/src/components/tall/task/PlanAssignment.vue +++ /dev/null @@ -1,389 +0,0 @@ - - - - - diff --git a/src/components/tall/task/Procedure.vue b/src/components/tall/task/Procedure.vue deleted file mode 100644 index 1186ef3..0000000 --- a/src/components/tall/task/Procedure.vue +++ /dev/null @@ -1,271 +0,0 @@ - - - - - diff --git a/src/components/tall/task/PublishPatent.vue b/src/components/tall/task/PublishPatent.vue deleted file mode 100644 index 559376a..0000000 --- a/src/components/tall/task/PublishPatent.vue +++ /dev/null @@ -1,308 +0,0 @@ - - - - - diff --git a/src/components/tall/task/PublishThesis.vue b/src/components/tall/task/PublishThesis.vue deleted file mode 100644 index 807eb46..0000000 --- a/src/components/tall/task/PublishThesis.vue +++ /dev/null @@ -1,251 +0,0 @@ - - - - - diff --git a/src/components/tall/task/PublishWork.vue b/src/components/tall/task/PublishWork.vue deleted file mode 100644 index 807eb46..0000000 --- a/src/components/tall/task/PublishWork.vue +++ /dev/null @@ -1,251 +0,0 @@ - - - - - diff --git a/src/components/tall/task/Result.vue b/src/components/tall/task/Result.vue deleted file mode 100644 index bbe3091..0000000 --- a/src/components/tall/task/Result.vue +++ /dev/null @@ -1,236 +0,0 @@ - - - - - diff --git a/src/components/tall/task/ScientificPayoffs.vue b/src/components/tall/task/ScientificPayoffs.vue deleted file mode 100644 index 75d6b32..0000000 --- a/src/components/tall/task/ScientificPayoffs.vue +++ /dev/null @@ -1,284 +0,0 @@ - - - - - diff --git a/src/components/tall/task/SubConclusion.vue b/src/components/tall/task/SubConclusion.vue deleted file mode 100644 index 9b25873..0000000 --- a/src/components/tall/task/SubConclusion.vue +++ /dev/null @@ -1,246 +0,0 @@ - - - - - diff --git a/src/components/tall/task/SubInterimInspection.vue b/src/components/tall/task/SubInterimInspection.vue deleted file mode 100644 index bdab7b9..0000000 --- a/src/components/tall/task/SubInterimInspection.vue +++ /dev/null @@ -1,246 +0,0 @@ - - - - - diff --git a/src/components/tall/task/SubMeetingManagement.vue b/src/components/tall/task/SubMeetingManagement.vue deleted file mode 100644 index 5acd1de..0000000 --- a/src/components/tall/task/SubMeetingManagement.vue +++ /dev/null @@ -1,244 +0,0 @@ - - - - - diff --git a/src/components/tall/task/SubMemberManagement.vue b/src/components/tall/task/SubMemberManagement.vue deleted file mode 100644 index e69de29..0000000 diff --git a/src/components/tall/task/SubResult.vue b/src/components/tall/task/SubResult.vue deleted file mode 100644 index 1e2615c..0000000 --- a/src/components/tall/task/SubResult.vue +++ /dev/null @@ -1,246 +0,0 @@ - - - - - diff --git a/src/components/tall/task/SubSubjectProgress.vue b/src/components/tall/task/SubSubjectProgress.vue deleted file mode 100644 index 38086a3..0000000 --- a/src/components/tall/task/SubSubjectProgress.vue +++ /dev/null @@ -1,195 +0,0 @@ - - - - - diff --git a/src/components/tall/task/TaskConList.vue b/src/components/tall/task/TaskConList.vue deleted file mode 100644 index 5dbbf69..0000000 --- a/src/components/tall/task/TaskConList.vue +++ /dev/null @@ -1,144 +0,0 @@ - - - - - diff --git a/src/components/tall/top/Navbar.vue b/src/components/tall/top/Navbar.vue index cf8b16f..ad3aab8 100644 --- a/src/components/tall/top/Navbar.vue +++ b/src/components/tall/top/Navbar.vue @@ -27,7 +27,8 @@ const isShowList = computed(() => store.state.layout.isShowListStatus); // 是 if (sessionTaskDetail) { const obj = JSON.parse(sessionTaskDetail); - store.commit('task/setTaskDetail', obj); + console.log(obj); + // store.commit('task/setTaskDetail', obj); } if (sessionLabel) { diff --git a/src/components/tall/top/TopNavbar.vue b/src/components/tall/top/TopNavbar.vue index 9c436c4..bd2c752 100644 --- a/src/components/tall/top/TopNavbar.vue +++ b/src/components/tall/top/TopNavbar.vue @@ -11,7 +11,8 @@
-
退出登录
+
登录
+
退出登录
@@ -28,18 +29,23 @@ const store = useStore(); const router = useRouter(); const collapsed = computed(() => store.state.layout.display.left); // 是否显示左栏 const account = computed(() => store.getters['user/account']); +const userId = computed(() => store.getters['user/userId']); // toggle left window display function toggleCollapse() { store.commit('layout/setDisplay', { prop: 'left', show: !collapsed.value }); } +function signUp() { + router.push({ path: '/user/signin' }); +} + // 退出登录 function signOut() { store.commit('user/setUser', null); store.commit('projects/setProject', null); - store.commit('task/setTaskDetail', null); - router.push({ path: '/experiment/user/signin' }); + // store.commit('task/setTaskDetail', null); + // router.push({ path: '/experiment/user/signin' }); } diff --git a/src/plugins/p-task-title.vue b/src/plugins/p-task-title.vue new file mode 100644 index 0000000..25468b7 --- /dev/null +++ b/src/plugins/p-task-title.vue @@ -0,0 +1,12 @@ + + + diff --git a/src/routers/index.js b/src/routers/index.js index 2fbc78d..e6043f7 100644 --- a/src/routers/index.js +++ b/src/routers/index.js @@ -1,14 +1,14 @@ import { createRouter, createWebHistory } from 'vue-router'; // 还有 createWebHashHistory 和 createMemoryHistory -export const user = [{ path: '/experiment/user/signIn', name: 'signIn', component: () => import('views/user/SignIn.vue') }]; +export const user = [{ path: '/user/signIn', name: 'signIn', component: () => import('views/user/SignIn.vue') }]; export const routes = [ { - path: '/experiment/home', + path: '/home', name: 'home', - redirect: '/experiment/home/test', + redirect: '/home/test', component: () => import('views/home/Index.vue'), - children: [{ path: '/experiment/home/test', name: 'test', component: () => import('views/detail/Test.vue') }], + children: [{ path: '/home/test', name: 'test', component: () => import('views/detail/Test.vue') }], }, ]; @@ -16,8 +16,8 @@ const router = createRouter({ history: createWebHistory(), routes: [ { - path: '/experiment', - redirect: '/experiment/home', + path: '/', + redirect: '/home', }, ...user, ...routes, diff --git a/src/store/tall/layout/mutations.js b/src/store/tall/layout/mutations.js index b2aa1cf..4f74371 100644 --- a/src/store/tall/layout/mutations.js +++ b/src/store/tall/layout/mutations.js @@ -48,6 +48,11 @@ const mutations = { sessionStorage.setItem('expreStartTime', data.startTime); sessionStorage.setItem('expreEndTime', data.endTime); }, + + // 设置唯一标识 + setDeviceId(state, data) { + state.deviceId = data; + }, }; export default mutations; diff --git a/src/store/tall/layout/state.js b/src/store/tall/layout/state.js index 813c502..d8f99cd 100644 --- a/src/store/tall/layout/state.js +++ b/src/store/tall/layout/state.js @@ -13,6 +13,7 @@ const state = { subEndTime: '', // 子课题结束时间 expreStartTime: '', // 实验开始时间 expreEndTime: '', // 实验结束时间 + deviceId: '', // 唯一标识 }; export default state; diff --git a/src/store/tall/role/getters.js b/src/store/tall/role/getters.js index efbfa27..7f43f7c 100644 --- a/src/store/tall/role/getters.js +++ b/src/store/tall/role/getters.js @@ -1,12 +1,11 @@ const getters = { // 是不是负责人 isMine({ roleId, invisibleRoles, visibleRoles }) { - console.log(roleId, invisibleRoles, visibleRoles); - // if (!visibleRoles || !visibleRoles.length) return false; - // const visible = visibleRoles.find(visible => visible.id === roleId); - // if (visible) return visible.mine; - // const invisible = invisibleRoles.find(invisible => invisible.id === roleId); - // if (invisible) return visible.mine; + if (!visibleRoles || !visibleRoles.length) return false; + const visibleData = visibleRoles.find(visible => visible.id === roleId); + if (visibleData) return visibleData.mine; + const invisibleData = invisibleRoles.find(invisible => invisible.id === roleId); + if (invisibleData) return invisibleData.mine; return false; }, }; diff --git a/src/store/tall/role/mutations.js b/src/store/tall/role/mutations.js index 52641c5..a9f4e1f 100644 --- a/src/store/tall/role/mutations.js +++ b/src/store/tall/role/mutations.js @@ -15,7 +15,16 @@ const mutations = { */ setVisibleRoles(state, data) { state.visibleRoles = data || []; - sessionStorage.setItem('roles', JSON.stringify(data)); + // sessionStorage.setItem('roles', JSON.stringify(data)); + }, + + /** + * 设置当前角色信息 + * @param {Object} state + * @param {string} roleId 当前正在展示的角色的id + */ + setRoleInfo(state, data) { + state.roleInfo = data; }, /** diff --git a/src/store/tall/role/state.js b/src/store/tall/role/state.js index 1117de7..5622853 100644 --- a/src/store/tall/role/state.js +++ b/src/store/tall/role/state.js @@ -2,6 +2,7 @@ const state = { invisibleRoles: [], // 不展示的角色信息 visibleRoles: [], // 展示的角色信息 roleId: '', // 当前展示查看的角色id + roleInfo: null, // 当前展示查看的角色 members: [], // 项目下所有成员 }; diff --git a/src/store/tall/task/index.js b/src/store/tall/task/index.js index 3c8f997..76eee2b 100644 --- a/src/store/tall/task/index.js +++ b/src/store/tall/task/index.js @@ -1,5 +1,4 @@ -import { getByCode, submitAnswer, getIntellectual, getIntellectualList, submitIntellectual } from 'apis'; -import { message } from 'ant-design-vue'; +// import { message } from 'ant-design-vue'; export default { namespaced: true, @@ -26,19 +25,10 @@ export default { showSkeleton: false, // 定期任务骨架屏 newProjectInfo: {}, showScrollTo: false, // 是否可以设置时间轴自动滚动的位置 - taskDetail: {}, // 当前点击任务信息 - label: '', // 任务code - members: [], // 成员列表 - globalHeight: 0, // 日常任务面板高度 - detailId: '', // 子课题Id - subProjectInfo: null, // 当前子课题信息 - experimentationId: '', // 实验ID - experimentationInfo: null, // 当前实验信息 + regularTasks: [], // 定期任务 - intellectualId: '', // 当前选择的知识产权ID - meetId: '', // 当前选择的会议ID - subMeetId: '', // 当前选择的子课题会议ID - question: null, + currLocationTaskId: '', // 前需要定位到的任务id + businessCode: '', // 当前打开的项目的所属服务 }, getters: { @@ -231,17 +221,7 @@ export default { */ setPermanents(state, tasks) { state.permanents = tasks || []; - sessionStorage.setItem('permanents', JSON.stringify(tasks)); - }, - - /** - * 定期任务 - * @param {object} state - * @param {array} tasks 服务端查询到的定期任务书籍 - */ - setRegularTasks(state, tasks) { - state.regularTasks = tasks || []; - sessionStorage.setItem('regularTasks', JSON.stringify(tasks)); + // sessionStorage.setItem('permanents', JSON.stringify(tasks)); }, /** @@ -311,187 +291,33 @@ export default { }, /** - * 设置当前点击的任务信息 - */ - setTaskDetail(state, data) { - state.taskDetail = data; - if (data) { - sessionStorage.setItem('taskId', data.id); - sessionStorage.setItem('taskDetail', JSON.stringify(data)); - } else { - sessionStorage.removeItem('taskId'); - sessionStorage.removeItem('taskDetail'); - } - }, - - /** - * 设置当前任务的code - */ - setLabel(state, data) { - state.label = data; - if (data) { - sessionStorage.setItem('label', data); - } else { - sessionStorage.removeItem('label'); - } - }, - - /** - * 设置成员列表 - */ - setMembers(state, data) { - state.members = data || []; - }, - - /** - * 设置日常任务面板高度 - */ - setGlobalHeight(state, data) { - state.globalHeight = data; - sessionStorage.setItem('globalHeight', data); - }, - - /** - * 子课题Id - */ - sonDetailId(state, data) { - state.detailId = data; - }, - - /** - * 设置当前子课题信息 - */ - setSubProjectInfo(state, data) { - state.subProjectInfo = data; - }, - - /** - * 实验Id - */ - sonExperimentationId(state, data) { - state.experimentationId = data; - }, - - /** - * 设置当前实验信息 - */ - setExperimentationInfo(state, data) { - state.experimentationInfo = data; - }, - - /** - * 知识产权ID + * 定期任务 + * @param {object} state + * @param {array} tasks 服务端查询到的定期任务书籍 */ - setIntellectualId(state, data) { - state.intellectualId = data; + setRegularTasks(state, tasks) { + state.regularTasks = tasks || []; + // sessionStorage.setItem('regularTasks', JSON.stringify(tasks)); }, /** - * 会议ID + * 当前需要定位到的任务id + * @param {Object} state + * @param {Object} data */ - setMeetId(state, data) { - state.meetId = data; + setCurrLocationTaskId(state, data) { + state.currLocationTaskId = data; }, /** - * 子课题会议ID + * 当前打开的项目的所属服务 + * @param {Object} state + * @param {Object} data */ - setSubMeetId(state, data) { - state.subMeetId = data; - }, - - setQuestion(state, data) { - state.question = data; + setBusinessCode(state, data) { + state.businessCode = data; }, }, - actions: { - /** - * 根据code查询所有试题 - * @param {string} param.code - * @param {integer} param.projectId - * @param {integer} param.intellectualId - */ - async getByCode({ commit }, param) { - try { - const data = await getByCode(param); - commit('setQuestion', data || null); - return data; - } catch (error) { - message.info(error); - throw new Error(error); - } - }, - - /** - * 答案 - * @param {string} param.code - * @param {integer} param.projectId - * @param {array} param.questionAndAnswerList - */ - async submitAnswer({ commit }, param) { - try { - const data = await submitAnswer(param); - commit('setQuestion', data || null); - message.info('保存成功'); - return data; - } catch (error) { - message.info(error); - throw new Error(error); - } - }, - - /** - * 查询知识产权题目(论文、专利、软著) - * @param {string} param.code - * @param {integer} param.projectId - * @param {integer} param.intellectualId - */ - async getIntellectual({ commit }, param) { - try { - const data = await getIntellectual(param); - commit('setQuestion', data || null); - return data; - } catch (error) { - message.info(error); - throw new Error(error); - } - }, - - /** - * 查询知识产权列表 (论文、专利、软著) - * @param {string} param.code - * @param {integer} param.projectId - * @param {integer} param.intellectualId - */ - async getIntellectualList({ commit }, param) { - try { - const data = await getIntellectualList(param); - commit('setQuestion', data || null); - return data; - } catch (error) { - message.info(error); - throw new Error(error); - } - }, - - /** - * 提交知识产权信息(论文、专利、软著) - * @param {string} param.code - * @param {integer} param.projectId - * @param {integer} param.intellectualId - * @param {array} param.questionAndAnswerList - */ - async submitIntellectual({ commit }, param) { - try { - const data = await submitIntellectual(param); - commit('setQuestion', data || null); - message.info('保存成功'); - return data; - } catch (error) { - message.info(error); - throw new Error(error); - } - }, - }, + actions: {}, }; diff --git a/src/store/tall/user/index.js b/src/store/tall/user/index.js index 5516004..738a067 100644 --- a/src/store/tall/user/index.js +++ b/src/store/tall/user/index.js @@ -1,10 +1,11 @@ -import { getToken } from 'apis'; +import { getNewToken, getToken } from 'apis'; + import { message } from 'ant-design-vue'; export default { namespaced: true, - state: { user: null }, + state: { user: null, count: 3 }, getters: { token({ user }) { @@ -37,6 +38,13 @@ export default { sessionStorage.removeItem('user'); } }, + + /** + * 设置token过期重新请求次数 + */ + setCount(state, data) { + state.count = data; + }, }, actions: { @@ -55,5 +63,19 @@ export default { throw new Error(error); } }, + + /** + * 根据refreshToken重新获取token + * @param {string} refreshToken + */ + async getTokenByRefreshToken(refreshToken) { + try { + const data = await getNewToken(refreshToken); + return data; + } catch (error) { + message.error(error); + throw new Error(error); + } + }, }, }; diff --git a/src/utils/axios.js b/src/utils/axios.js index 1081013..9856922 100644 --- a/src/utils/axios.js +++ b/src/utils/axios.js @@ -1,6 +1,7 @@ import Axios from 'axios'; import { message } from 'ant-design-vue'; import store from 'store'; +import router from './routers/index'; const baseUrl = '/gateway'; @@ -12,10 +13,12 @@ const instance = Axios.create({ // request instance.interceptors.request.use( config => { - const token = store.getters['user/token'] || localStorage.getItem('token'); + const token = store.getters['user/token'] || sessionStorage.getItem('token'); if (token) { config.headers.Authorization = `Bearer ${token}`; } + config.headers.appType = 0; + config.headers.deviceId = store.state.layout.deviceId; return config; }, error => { @@ -25,17 +28,52 @@ instance.interceptors.request.use( // response instance.interceptors.response.use( - response => { + async response => { if (response.status !== 200 || !response.data) { return Promise.reject(response.statusText); } - const { code, data, msg } = response.data; + const { code, msg, tokenObj } = response.data; + const resData = response.data.data; if (code === 200) { - return data; + if (tokenObj.token) { + sessionStorage.setItem('token', tokenObj.token); + sessionStorage.setItem('refreshToken', tokenObj.refreshToken); + } + return resData; + } + if (code === 49) { + // token过期 + store.commit('user/setCount', store.state.user.count - 1); + + // 2、刷新token + const refreshToken = sessionStorage.getItem('refreshToken'); + const data = await store.dispatch('user/getTokenByRefreshToken', refreshToken); + + // 3、重新请求当前api + const { config } = response; + config.headers.Authorization = `Bearer ${data.token}`; + const res = await Axios.request(config); + if (res.data.code === 200) { + store.commit('user/setCount', 3); + } + + return res; + } + if (code === 401) { + // refreshToken过期 + sessionStorage.removeItem('token'); + sessionStorage.removeItem('refreshToken'); + store.commit('user/setUser', null); + message.error(msg); + setTimeout(() => { + router.push({ path: '/user/signin' }); + }, 1500); + return Promise.reject(msg); } return Promise.reject(msg); }, error => { + console.log('error', error); if (error.response && error.response.data) { const msg = error.response.data.message; message.error(msg); diff --git a/src/views/detail/Test.vue b/src/views/detail/Test.vue index b391947..6562d4d 100644 --- a/src/views/detail/Test.vue +++ b/src/views/detail/Test.vue @@ -4,162 +4,52 @@
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
+
diff --git a/vite.config.js b/vite.config.js index 1b2bd62..ab7aa7e 100644 --- a/vite.config.js +++ b/vite.config.js @@ -1,17 +1,17 @@ -import Components from 'unplugin-vue-components/vite'; import { AntDesignVueResolver } from 'unplugin-vue-components/resolvers'; +import Components from 'unplugin-vue-components/vite'; +import { VitePWA } from 'vite-plugin-pwa'; import WindiCSS from 'vite-plugin-windicss'; import { defineConfig } from 'vite'; import path from 'path'; -import vue from '@vitejs/plugin-vue'; import viteCompression from 'vite-plugin-compression'; -import { VitePWA } from 'vite-plugin-pwa'; +import vue from '@vitejs/plugin-vue'; const resolve = dir => path.join(__dirname, dir); // https://vitejs.dev/config/ export default defineConfig({ - base: '/experiment', + base: '/', plugins: [vue(), VitePWA(), WindiCSS(), Components({ resolvers: [AntDesignVueResolver()] }), viteCompression()], resolve: { alias: { diff --git a/yarn.lock b/yarn.lock index b73a2c7..0f83650 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4800,6 +4800,11 @@ "resolved" "https://registry.npm.taobao.org/util-deprecate/download/util-deprecate-1.0.2.tgz?cache=0&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Futil-deprecate%2Fdownload%2Futil-deprecate-1.0.2.tgz" "version" "1.0.2" +"uuid@^8.3.2": + "integrity" "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==" + "resolved" "https://registry.npmmirror.com/uuid/-/uuid-8.3.2.tgz" + "version" "8.3.2" + "v8-compile-cache@^2.0.3": "integrity" "sha1-LeGWGMZtwkfc+2+ZM4A12CRaLO4=" "resolved" "https://registry.nlark.com/v8-compile-cache/download/v8-compile-cache-2.3.0.tgz"