12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- import { stringify } from 'qs';
- import request from '../utils/request';
- import { resources, resource, signature } from '../utils/api';
- import { saveLocalSignature, getLocalSignature } from '../utils/helper';
- export async function getSignature (params) {
- /*
- const localSignature = getLocalSignature();
- const expireTime = Math.floor((new Date()).getTime() / 1000 + 5).toString(); // 5s缓冲时间
- // oss签名不存在或者已经过了有效期则请求新的签名
- let newSignature;
- if (!localSignature || localSignature.expire <= expireTime) {
- return request(`${signature}?${stringify(params)}`);
- } else {
- return { data: localSignature };
- }
- */
- // 每次都重新请求签名 TODO: 保存签名到本地减少请求次数
- // return request(`${signature}?${stringify(params)}`);
- return request(`http://127.0.0.1:8700`);
- }
- export async function query (params) {
- return request(`${resources}?${stringify(params)}`);
- }
- export async function create(params) {
- const options = {
- method: 'POST',
- body: JSON.stringify(params),
- };
- return request(`${resource}`, options);
- }
- export async function remove ({ id }) {
- const options = { method: 'DELETE' };
- return request(`${resource}/${id}`, options);
- }
- export async function update(params) {
- const options = {
- method: 'PUT',
- body: JSON.stringify(params),
- };
- return request(`${resource}`, options);
- }
|