Browse Source

feat: 设置项目域名

test2
xuesinan 4 years ago
parent
commit
1a835f1c6d
  1. 3
      CHANGELOG.md
  2. 11
      apis/project.js
  3. 9
      apis/role.js
  4. 2
      apis/tall.js
  5. 19
      apis/task.js
  6. 4
      components/Projects/ProjectItem.vue
  7. 11
      store/index.js
  8. 108
      utils/cache.js
  9. 8
      utils/upload.js

3
CHANGELOG.md

@ -1,4 +1,4 @@
# 1.0.0 (2022-01-20)
# 1.0.0 (2022-01-25)
### 🌟 新功能
范围|描述|commitId
@ -33,6 +33,7 @@
- | 注册、用户协议 | [68e9189](https://101.201.226.163:50022/TALL/TALL-MUI-4/commits/68e9189)
- | app.vue | [970cf9a](https://101.201.226.163:50022/TALL/TALL-MUI-4/commits/970cf9a)
- | first commit | [8dc26de](https://101.201.226.163:50022/TALL/TALL-MUI-4/commits/8dc26de)
- | get请求 | [3a61439](https://101.201.226.163:50022/TALL/TALL-MUI-4/commits/3a61439)
project | 日常任务面板添加 | [b3f16ff](https://101.201.226.163:50022/TALL/TALL-MUI-4/commits/b3f16ff)
theme | theme demo | [9175758](https://101.201.226.163:50022/TALL/TALL-MUI-4/commits/9175758)
- | token过期策略 | [8f16ae1](https://101.201.226.163:50022/TALL/TALL-MUI-4/commits/8f16ae1)

11
apis/project.js

@ -1,17 +1,16 @@
import Config from '@/common/js/config.js'
import store from '@/store/index.js';
const apiUrl = Config.apiUrl;
const defaultwbs = `${apiUrl}/defaultwbs`;
const domain = store.state.domain;
export function setupProject(app) {
uni.$u.api = { ...uni.$u.api } || {};
//根据id获取项目信息
uni.$u.api.findProjectById = param => uni.$u.post(`${defaultwbs}/project/findProjectById`, param);
uni.$u.api.findProjectById = param => uni.$u.post(`${domain}/project/findProjectById`, param);
//创建分享连接
uni.$u.api.createShare = param => uni.$u.post(`${defaultwbs}/share/create`, param);
uni.$u.api.createShare = param => uni.$u.post(`${domain}/share/create`, param);
//点击分享连接
uni.$u.api.clickShare = param => uni.$u.post(`${defaultwbs}/share/click`, param);
uni.$u.api.clickShare = param => uni.$u.post(`${domain}/share/click`, param);
};

9
apis/role.js

@ -1,12 +1,11 @@
import Config from '@/common/js/config.js'
import store from '@/store/index.js';
const apiUrl = Config.apiUrl;
const defaultwbs = `${apiUrl}/defaultwbs`;
const domain = store.state.domain;
export function setupRole(app) {
uni.$u.api = { ...uni.$u.api } || {};
//根据项目id查找角色
uni.$u.api.findShowRole = param => uni.$u.post(`${defaultwbs}/role/show`, param);
uni.$u.api.findShowRole = param => uni.$u.post(`${domain}/role/show`, param);
//根据项目id查找所有成员
uni.$u.api.queryChecker = param => uni.$u.post(`${defaultwbs}/deliver/queryChecker`, param);
uni.$u.api.queryChecker = param => uni.$u.post(`${domain}/deliver/queryChecker`, param);
};

2
apis/tall.js

@ -18,7 +18,7 @@ export function setupTall(app) {
// 根据refreshToken重新获取token
uni.$u.api.getNewToken = refreshToken => uni.$u.http.get(`${tall}/users/refreshToken`, { refreshToken });
// 根据userId获取token
uni.$u.api.getToken = userId => uni.$u.get(`${tall}/users/userId`, { userId });
uni.$u.api.getToken = userId => uni.$u.http.get(`${tall}/users/userId`, { userId });
// 绑定手机号
uni.$u.api.phoneBind = (phone, smsCode) => uni.$u.http.post(`${tall}/users/binding`, { phone, smsCode });
// 是否合并账号

19
apis/task.js

@ -1,20 +1,19 @@
import Config from '@/common/js/config.js'
import store from '@/store/index.js';
const apiUrl = Config.apiUrl;
const defaultwbs = `${apiUrl}/defaultwbs`;
const domain = store.state.domain;
export function setupTask(app) {
uni.$u.api = { ...uni.$u.api } || {};
uni.$u.api.getGlobal = param => uni.$u.post(`${defaultwbs}/task/global`, param);
uni.$u.api.getPermanent = param => uni.$u.post(`${defaultwbs}/task/permanent`, param);
uni.$u.api.getGlobal = param => uni.$u.post(`${domain}/task/global`, param);
uni.$u.api.getPermanent = param => uni.$u.post(`${domain}/task/permanent`, param);
//根据时间基准点和角色查找定期任务
uni.$u.api.getRegularTask = param => uni.$u.post(`${defaultwbs}/task/regular`, param);
uni.$u.api.getRegularTask = param => uni.$u.post(`${domain}/task/regular`, param);
//修改任务状态
uni.$u.api.updateTaskType = param => uni.$u.post(`${defaultwbs}/task/type`, param);
uni.$u.api.updateTaskType = param => uni.$u.post(`${domain}/task/type`, param);
//新建任务
uni.$u.api.saveTask = param => uni.$u.post(`${defaultwbs}/task/save`, param);
uni.$u.api.saveTask = param => uni.$u.post(`${domain}/task/save`, param);
//克隆任务
uni.$u.api.cloneTask = param => uni.$u.post(`${defaultwbs}/task/clone`, param);
uni.$u.api.cloneTask = param => uni.$u.post(`${domain}/task/clone`, param);
//模糊查询 查找项目下的任务
uni.$u.api.queryTaskOfProject = param => uni.$u.post(`${defaultwbs}/task/queryTaskOfProject`, param);
uni.$u.api.queryTaskOfProject = param => uni.$u.post(`${domain}/task/queryTaskOfProject`, param);
};

4
components/Projects/ProjectItem.vue

@ -102,9 +102,7 @@ const data = reactive({
//
function openProject(project) {
const gateway = config.apiUrlNew;
const url = `${gateway}/defaultwbs`;
const { name, id } = project;
const { name, id, url } = project;
uni.navigateTo({ url: `/pages/project/project?u=${userId.value}&p=${id}&pname=${name}&url=${encodeURIComponent(url)}` });
}

11
store/index.js

@ -4,6 +4,7 @@ import role from './role/index.js';
import socket from './socket/index.js';
import task from './task/index.js';
import user from './user/index.js';
import Config from '@/common/js/config.js';
// 不属于具体模块的 应用级的 store内容
const state = {
@ -12,6 +13,7 @@ const state = {
forceUseStorage: true, // 强制启用storage
systemInfo: null, // 系统设备信息
count: 3, // 后台出错,多次返回错误的token信息导致的死循环,用count来阻止死循环
domain: `${Config.apiUrl}/defaultwbs`, // 项目跳转域名
};
const getters = {
@ -59,6 +61,15 @@ const mutations = {
setCount(state, data) {
state.count = data;
},
/**
* 设置域名
* @param {Object} state
* @param {Object} data
*/
setDomain(state, data) {
state.domain = data;
}
};
export default createStore({

108
utils/cache.js

@ -9,7 +9,113 @@ export const filter = {
projects(data, start, end) {
if (!data || !data.length) return [];
return data.filter(item => start <= +item.endTime && end >= +item.startTime);
},
},
/**
* 角色 过滤获取到的数据 根据开始截止时间
* @param {object} data 缓存拿到的数据
* @returns
*/
// roles(data) {
// if (!data) return [];
// return data;
// },
/**
* 日常任务 过滤获取到的数据 根据开始截止时间
* @param {object} data 缓存拿到的数据
* @param {number} timeNode 时间基准点 ms
* @returns
*/
dailyTask(data, timeNode) {
if (!data || !data.length) return [];
// TODO: 缺少通过时间颗粒度筛选数据 任务没有返回时间颗粒度标签
return data.filter(item => timeNode <= +item.endTime && timeNode >= +item.startTime);
},
/**
* 永久日常任务 过滤获取到的数据 根据开始截止时间
* @param {object} data 缓存拿到的数据
* @returns
*/
fixedTasks(data) {
if (!data || !data.length) return [];
return data;
},
/**
* 定期任务 过滤获取到的数据 根据开始截止时间
* @param {object} data 缓存拿到的数据
* @param {number} timeNode 时间基准点 ms
* @param {number} queryNum 颗粒度数量
* @param {number} timeUnit 时间颗粒度
* @param {number} queryType 0向上查找 1向下查找(默认) 下查包含自己上查不包含
* @returns
*/
planTask(data, timeNode, queryNum, timeUnit, queryType) {
if (!data || !data.length) return [];
if (queryType === 0) {
// 计算颗粒度 对应的 dayjs add 的单位
let target = uni.$t.timeConfig.timeUnits.find(item => item.id === timeUnit);
// TODO: 缺少通过时间颗粒度筛选数据 任务没有返回时间颗粒度标签
let start = uni.$t.time.add(+timeNode, -queryNum, target.granularity).valueOf();
let arr = [];
arr = data.filter(item => start <= +item.planStart && +timeNode > +item.planEnd);
if (!arr || !arr.length) {
// 开始时间往前推
let resultS = [];
let againStart = uni.$t.time.add(start, -1, target.granularity).valueOf();
let againArr = data.filter(item => againStart >= +item.planStart);
if (againArr && againArr.length) {
let sTime = uni.$t.time.setTimestampToStr(+againArr[0].planStart);
data.forEach(item => {
if (uni.$t.time.isSame(uni.$moment(sTime.date).valueOf(), +item.planStart, target.granularity)) {
resultS.push(item);
}
});
}
return resultS;
} else {
return arr;
}
} else {
// 计算颗粒度 对应的 dayjs add 的单位
let target = uni.$t.timeConfig.timeUnits.find(item => item.id === timeUnit);
// TODO: 缺少通过时间颗粒度筛选数据 任务没有返回时间颗粒度标签
let end = uni.$t.time.add(timeNode, +queryNum - 1, target.granularity).valueOf();
let arr = [];
arr = data.filter(item => end >= +item.planEnd && +timeNode <= +item.planStart);
if (!arr || !arr.length) {
// 结束时间往后推
let resultE = [];
let againEnd = uni.$t.time.add(end, 1, target.granularity).valueOf();
let againEndArr = data.filter(item => againEnd <= +item.planStart);
if (againEndArr) {
let eTime = uni.$t.time.setTimestampToStr(+againEndArr[againEndArr.length - 1].planStart);
data.forEach(item => {
if (uni.$t.time.isSame(uni.$moment(eTime.date).valueOf(), +item.planEnd, target.granularity)) {
resultE.push(item);
}
});
}
return resultE;
} else {
return arr;
}
}
},
/**
* 插件 过滤获取到的数据 根据插件id
* @param {object} data 缓存拿到的数据
* @returns
*/
plugin(data) {
if (!data || !data.id) return null;
return data;
},
};
export default {

8
utils/upload.js

@ -54,7 +54,7 @@ export default {
* @returns
*/
chooseAndUpload(url, formData = {}, extension = ['.xls', '.xlsx'], name = 'param') {
uni.hideLoading();
uni.$ui.hideLoading();
let timer = null;
clearTimeout(timer);
return new Promise((resolve, reject) => {
@ -85,7 +85,7 @@ export default {
statusCode
}) => {
clearTimeout(timer);
uni.hideLoading();
uni.$ui.hideLoading();
if (statusCode === 200 && data) {
const {
@ -103,14 +103,14 @@ export default {
},
fail: error => {
clearTimeout(timer);
uni.hideLoading();
uni.$ui.hideLoading();
reject(error);
},
});
})
.catch(error => {
clearTimeout(timer);
uni.hideLoading();
uni.$ui.hideLoading();
reject(error);
});
});

Loading…
Cancel
Save