From 032d83ce661e37ccd504fc9e2a900b5c4c8ed60b Mon Sep 17 00:00:00 2001 From: song Date: Fri, 3 Sep 2021 18:16:35 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=88=86=E4=BA=AB=E9=A1=B9=E7=9B=AE?= =?UTF-8?q?=E5=92=8C=E7=82=B9=E5=87=BB=E5=88=86=E4=BA=AB=E7=9A=84=E9=A1=B9?= =?UTF-8?q?=E7=9B=AE=E9=93=BE=E6=8E=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 1 + src/App.vue | 14 ++++--- src/components/ShareProject/ShareProject.vue | 2 +- src/pages/project/project.vue | 42 +++++++++++++++++++- 4 files changed, 51 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cd212a3..984b83f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -60,6 +60,7 @@ - | 面变化首页变化 | [5e860f1](https://dd.tall.wiki/gitea/wally/tall-mui-3-project/commits/5e860f1) - | 项目api url设置 | [6cd5245](https://dd.tall.wiki/gitea/wally/tall-mui-3-project/commits/6cd5245) - | 项目列表, 项目url | [32e005b](https://dd.tall.wiki/gitea/wally/tall-mui-3-project/commits/32e005b) + - | 项目创建分享链接 | [eb2c4ba](https://dd.tall.wiki/gitea/wally/tall-mui-3-project/commits/eb2c4ba) - | 首页项目样式改变 | [8514c85](https://dd.tall.wiki/gitea/wally/tall-mui-3-project/commits/8514c85) diff --git a/src/App.vue b/src/App.vue index e36ab95..ccee2d3 100644 --- a/src/App.vue +++ b/src/App.vue @@ -16,12 +16,14 @@ export default { if (!this.token) { // 不论有没有token都直接从userId获取token // token有过期时间 从本地获取可能是过期 干脆直接从userId获取 - if (!options.query || !options.query.u) { - // 参数里没有u (userId)提示 - this.$t.ui.showToast('缺少用户信息参数'); - } else { - const data = await this.getToken(options.query.u); - this.noPhone(data.phone); + if (!options.query.share) { + if (!options.query || !options.query.u) { + // 参数里没有u (userId)提示 + this.$t.ui.showToast('缺少用户信息参数'); + } else { + const data = await this.getToken(options.query.u); + this.noPhone(data.phone); + } } } // FIXME: 这里重复书写的 diff --git a/src/components/ShareProject/ShareProject.vue b/src/components/ShareProject/ShareProject.vue index 6a0c939..d8608a5 100644 --- a/src/components/ShareProject/ShareProject.vue +++ b/src/components/ShareProject/ShareProject.vue @@ -119,7 +119,7 @@ export default { async created() { this.path = window.location.href.split('?')[0]; const { path, projectId } = this; - const params = { path, projectId, roleId: '0' }; + const params = { path: `${path}share=1`, projectId, roleId: '0' }; await this.creatShare(params); }, diff --git a/src/pages/project/project.vue b/src/pages/project/project.vue index 4a532e6..a24fd91 100644 --- a/src/pages/project/project.vue +++ b/src/pages/project/project.vue @@ -36,7 +36,13 @@ export default { }, onLoad(options) { - this.init(options); + if (options.share && options.share === '1') { + console.log('是分享来的'); + this.shareInit(options); + } else { + console.log('不是分享来的'); + this.init(options); + } }, watch: { @@ -126,6 +132,40 @@ export default { } }, + // 分享链接来的初始化 + async shareInit(options) { + const user = JSON.parse(this.$t.storage.getStorageSync('user')); + if (user && user.id) { + await this.getToken(user.id); + const res = await this.clickShare({ code: options.shareId }); + if (res && res.projectId) { + let query = { ...this.$route.query }; + query = { + u: user.id, + p: res.projectId, + }; + this.$router.push({ path: this.$route.path, query }); + this.init(query); + } + } else { + this.$t.ui.showToast('缺少用户信息参数,请登录'); + } + }, + + /** + * 点击分享连接 + * @param {any} commit + * @param {object} param 请求参数 + */ + async clickShare(param) { + try { + const data = await this.$u.api.clickShare(param); + return data; + } catch (error) { + this.$t.ui.showToast(error.msg || '获取失败'); + } + }, + /** * 通过项目id获取项目信息 * @param {string} projectId