增加了fetch的声明和增加了login页面
This commit is contained in:
parent
40c8a4f069
commit
16e36290ef
|
|
@ -19,6 +19,9 @@ module.exports = function (content) {
|
|||
// const callback = this.async();
|
||||
|
||||
// console.log(content, options);
|
||||
/**
|
||||
* domparser会自动给没有value的attribute赋上值,目前改不动
|
||||
*/
|
||||
const doc = new DOMParser().parseFromString(content, 'text/xml');
|
||||
traverse(doc, (node) => {
|
||||
if (node.nodeType === node.ELEMENT_NODE) {
|
||||
|
|
|
|||
|
|
@ -206,6 +206,7 @@ export function projectConfigContentWithWeChatMp(
|
|||
export function appJsonContentWithWeChatMp(isDev: boolean) {
|
||||
const pages = [];
|
||||
if (isDev) {
|
||||
pages.push("@oak-general-business/token/login/index");
|
||||
pages.push('@oak-general-business/address/list/index');
|
||||
pages.push('@oak-general-business/address/upsert/index');
|
||||
pages.push('@oak-general-business/pickers/area/index');
|
||||
|
|
@ -219,7 +220,8 @@ export function appJsonContentWithWeChatMp(isDev: boolean) {
|
|||
"backgroundTextStyle":"light",
|
||||
"navigationBarBackgroundColor": "#fff",
|
||||
"navigationBarTitleText": "Weixin",
|
||||
"navigationBarTextStyle":"black"
|
||||
"navigationBarTextStyle":"black",
|
||||
"enablePullDownRefresh": true
|
||||
},
|
||||
"style": "v2",
|
||||
"sitemapLocation": "sitemap.json"
|
||||
|
|
|
|||
|
|
@ -1,9 +1,11 @@
|
|||
import { MakeOakComponent, MakeOakPage } from 'oak-frontend-base';
|
||||
import { EntityDict } from 'oak-app-domain/EntityDict';
|
||||
import { GeneralRuntimeContext, aspectDict } from 'oak-general-business';
|
||||
import { RuntimeContext } from '../../../src/RuntimeContext';
|
||||
import { aspectDict } from '../../../src/aspects';
|
||||
import { createFeatures } from '../init';
|
||||
|
||||
declare global {
|
||||
const OakPage: MakeOakPage<EntityDict, GeneralRuntimeContext<EntityDict>, typeof aspectDict, {}>;
|
||||
const OakComponent: MakeOakComponent<EntityDict, GeneralRuntimeContext<EntityDict>, typeof aspectDict, {}>;
|
||||
const OakPage: MakeOakPage<EntityDict, RuntimeContext, typeof aspectDict, ReturnType<typeof createFeatures>>;
|
||||
const OakComponent: MakeOakComponent<EntityDict, RuntimeContext, typeof aspectDict, ReturnType<typeof createFeatures>>;
|
||||
}
|
||||
export {}
|
||||
|
|
@ -0,0 +1,65 @@
|
|||
|
||||
/**
|
||||
* 封装wx环境下的fetch,注意有部分属性并非完全吻合,请谨慎使用
|
||||
* @param url
|
||||
* @param options
|
||||
* @returns
|
||||
*/
|
||||
const fetch2 = async (url: string, options?: Parameters<typeof fetch>[1]) => {
|
||||
const params = Object.assign({
|
||||
method: 'GET',
|
||||
dataType: '其他',
|
||||
responseType: 'text',
|
||||
headers: {
|
||||
'Content-type': 'application/json',
|
||||
},
|
||||
}, options);
|
||||
const { method, headers, dataType, responseType, body } = params;
|
||||
|
||||
let responseType2 = responseType;
|
||||
if ((headers as Record<string, string>)['Accept'] === 'application/octet-stream') {
|
||||
responseType2 = 'arraybuffer';
|
||||
}
|
||||
|
||||
if (!['text', 'arraybuffer'].includes(responseType2)) {
|
||||
throw new Error(`传入不支持的responseType: ${responseType2}`);
|
||||
}
|
||||
|
||||
let dataType2 = dataType === 'json' ? dataType : '其他';
|
||||
if (responseType2 === 'arraybuffer') {
|
||||
dataType2 = '其他';
|
||||
}
|
||||
|
||||
return new Promise(
|
||||
(resolve, reject) => {
|
||||
wx.request({
|
||||
url,
|
||||
data: body || {},
|
||||
method: method as any,
|
||||
header: headers,
|
||||
dataType: dataType2 as any,
|
||||
responseType: responseType2 as any,
|
||||
success: (res) => {
|
||||
const { statusCode, data, header } = res;
|
||||
const result = Object.assign({}, res, {
|
||||
status: statusCode,
|
||||
ok: statusCode === 200,
|
||||
headers: header,
|
||||
arrayBuffer: async () => data as ArrayBuffer,
|
||||
json: async () => JSON.parse(data as string),
|
||||
text: async () => data as string,
|
||||
clone: () => result!,
|
||||
url,
|
||||
statusText: statusCode === 200 ? 'ok' : 'error',
|
||||
});
|
||||
return resolve(result);
|
||||
},
|
||||
fail: reject,
|
||||
});
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
Object.assign(global, {
|
||||
fetch: fetch2,
|
||||
});
|
||||
Loading…
Reference in New Issue