Browse Source

feat: 分享项目和点击分享的项目链接

project
song 4 years ago
parent
commit
032d83ce66
  1. 1
      CHANGELOG.md
  2. 14
      src/App.vue
  3. 2
      src/components/ShareProject/ShareProject.vue
  4. 42
      src/pages/project/project.vue

1
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)

14
src/App.vue

@ -16,12 +16,14 @@ export default {
if (!this.token) {
// tokenuserIdtoken
// 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:

2
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);
},

42
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

Loading…
Cancel
Save