Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-native-template-qqm

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-native-template-qqm - npm Package Compare versions

Comparing version 0.1.1 to 0.1.2

.vscode/settings.json

67

app/apis/apiUtils.js
/*
* @Author: Lockie
* @Date: 2017-03-27 11:22:37
* @Date: 2017-03-27 11:24:40
* @Last Modified by: Lockie
* @Last Modified time: 2017-05-05 18:27:01
* @Last Modified time: 2017-06-02 17:34:57
*/

@@ -14,12 +14,12 @@ import { createAction } from 'redux-actions';

* @param {String} url
* @param {String} basePath
* @param {String} cat
* @param {Object} api
* @returns promise
*/
function makeMethod(url: String, basePath: String, api: Object) {
function makeMethod(url: String, cat: String, api: Object) {
return async (data) => {
let opts = {};
let uri = '';
if (basePath) {
uri = `${url}${basePath}/${api.path}`;
if (cat) {
uri = `${url}${cat}/${api.path}`;
} else {

@@ -97,2 +97,18 @@ uri = url + api.path;

//可以在这里对response做一些通用操作
if (response.status && response.status !== 0) {
if (response.status === -103) {
//重新登录
yield put(createAction('fetch/logout')());
} else if (ERR_STATUS.indexOf(response.status) < 0) {
//tip处理
yield put(createAction('TIP_ANIMATED')({ des: response.des }));
}
}
//用户信息刷新
if (response.version && response.version !== -1 && req.payload) {
const { token, userId } = req.payload;
if (token && userId) {
yield put(createAction('api/user/getUserInfo/request')({ token, userId, version: -1 }));
}
}
yield put(createAction(actionNames.success)({

@@ -128,29 +144,26 @@ req: req.payload || null,

* @param {String} url
* @param {String} basePath api的前缀,'api' or 'pubApi'
* @param {any} api Object or Array
* @param {String} actionPath api的前缀,'api' or 'pubApi'
* @param {Object} apiConfig
*/
function makeApi(url: String, basePath: String, api: any) {
function makeApi(url: String, actionPath: String, apiConfig: Object) {
const apiActions = {};
const sagas = [];
//判断api传进来的是Array还是Obejct
if (api instanceof Array) {
api.forEach((apiItem) => {
const path = apiItem.path;
const actionNames = makeActionNames(basePath || 'pubApi', path);
const request = makeMethod(url, null, apiItem);
const effect = makeEffect(request, actionNames);
apiActions[path] = createAction(actionNames.request);
sagas.push(effect);
});
} else {
for (let cat in api) {
for (let cat in apiConfig) {
if (apiConfig[cat].path === undefined) {
apiActions[cat] = {};
api[cat].forEach((apiItem) => {
const path = apiItem.path;
const actionNames = makeActionNames(basePath || 'api', `${cat}/${path}`);
const request = makeMethod(url, cat, apiItem);
for (let path in apiConfig[cat]) {
const api = apiConfig[cat][path];
const actionNames = makeActionNames(actionPath || 'api', `${cat}/${path}`);
const request = makeMethod(url, cat, api);
const effect = makeEffect(request, actionNames);
apiActions[cat][path] = createAction(actionNames.request);
sagas.push(effect);
});
}
} else {
const api = apiConfig[cat];
const actionNames = makeActionNames(actionPath || 'pubApi', cat);
const request = makeMethod(url, null, api);
const effect = makeEffect(request, actionNames);
apiActions[cat] = createAction(actionNames.request);
sagas.push(effect);
}

@@ -164,2 +177,2 @@ }

export default makeApi;
export default makeApi;

@@ -5,41 +5,36 @@ /*

* @Last Modified by: Lockie
* @Last Modified time: 2017-05-22 17:33:34
* @Last Modified time: 2017-06-02 17:35:44
*/
import { API_URL, PUB_API_URL } from '@app/config';
import config from '@app/config';
import makeApi from './apiUtils';
const API_PATH = {
user: [
{
user: {
register: {
path: 'register',
method: 'POST',
},
login: {
path: 'login',
method: 'POST',
},
]
};
const PUB_API_PATH = {
test: [
{
},
pub: {
ad: {
path: 'ad',
method: 'POST',
},
]
},
};
const OTHERS_PATH = [
{
const PUB_API_PATH = {
address: {
path: 'address',
method: 'GET',
}
];
},
};
const api = makeApi(API_URL, 'api', API_PATH);
const _pubApi = makeApi(PUB_API_URL, 'pubApi', PUB_API_PATH);
const _otherApi = makeApi(PUB_API_URL, 'pubApi', OTHERS_PATH);
const api = makeApi(config.API_URL, 'api', API_PATH);
const pubApi = makeApi(config.PUB_API_URL, 'pubApi', PUB_API_PATH);
//合并apiActions和sagas
const pubApi = {};
pubApi.apiActions = Object.assign({}, _pubApi.apiActions, _otherApi.apiActions);
pubApi.sagas = [].concat(_pubApi.sagas, _otherApi.sagas);
console.log('api', api);

@@ -46,0 +41,0 @@ console.log('pubApi', pubApi);

@@ -5,3 +5,3 @@ /*

* @Last Modified by: Lockie
* @Last Modified time: 2017-05-22 17:41:45
* @Last Modified time: 2017-06-02 17:36:38
*/

@@ -25,2 +25,8 @@ import React, { Component } from 'react';

<View style={{ flex: 1 }}>
<StatusBar
translucent
backgroundColor={'transparent'}
showHideTransition={'fade'}
barStyle={'light-content'}
/>
<AppWithNavigationState />

@@ -27,0 +33,0 @@ </View>

{
"name": "react-native-template-qqm",
"version": "0.1.1",
"version": "0.1.2",
"description": "react-native template for qqm",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -6,4 +6,4 @@ ## react-native template for QQM

```
$ react-native init projectName --template qqm
$ cd projectName
$ react-native init MyApp --template qqm
$ cd MyApp
$ react-native run-ios //run on ios

@@ -10,0 +10,0 @@ $ react-native run-anroid //run on android

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc