q-koa 8.5.1 → 8.5.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -104,7 +104,9 @@ exports.showTables = async (ctx) => {
104
104
  const defaultConfigPath = path.resolve(__dirname, `../${_model}/config.js`)
105
105
  const defaultConfigExist = fs.existsSync(defaultConfigPath)
106
106
  const target =
107
- Object.keys(app.config[_model]).length === 0 && defaultConfigExist
107
+ app.config[_model] &&
108
+ Object.keys(app.config[_model]).length === 0 &&
109
+ defaultConfigExist
108
110
  ? require(defaultConfigPath)
109
111
  : app.config[_model]
110
112
  // const target = Object.keys(app.config[model])
@@ -112,6 +112,7 @@ exports.cash = async ({
112
112
  if (result.err_code_des) throw new Error(result.err_code_des)
113
113
  return result
114
114
  }
115
+
115
116
  exports.qr_code = async ({
116
117
  app,
117
118
  page,
@@ -168,18 +169,38 @@ exports.qr_code = async ({
168
169
  const fileName = `${
169
170
  String(new Date().getTime()).split('').reverse().join('') + Math.random()
170
171
  }.png`
171
- const result = await client.put(fileName, buffer)
172
- if (result.res && result.res.status === 200) {
173
- if (oss_host && cdn_host) {
174
- const url = result.url.replace(oss_host, cdn_host)
175
- return url
172
+
173
+ const handelResult = (result) => {
174
+ if (result && result.res && result.res.status === 200) {
175
+ if (oss_host && cdn_host) {
176
+ const url = result.url.replace(oss_host, cdn_host)
177
+ return url
178
+ } else {
179
+ return result.url
180
+ }
176
181
  } else {
177
- const url = result.url
178
- return url
182
+ return null
179
183
  }
180
- } else {
181
- throw new Error(result.res.statusMessage)
182
184
  }
185
+
186
+ return client
187
+ .put(fileName, buffer)
188
+
189
+ .then((result) => {
190
+ if (result && result.res && result.res.status === 200) {
191
+ if (oss_host && cdn_host) {
192
+ const url = result.url.replace(oss_host, cdn_host)
193
+ return Promise.resolve(url)
194
+ } else {
195
+ return Promise.resolve(result.url)
196
+ }
197
+ } else {
198
+ return Promise.reject(new Error('小程序码生成错误,请重试'))
199
+ }
200
+ })
201
+ .catch((e) => {
202
+ return Promise.reject(new Error(e.message))
203
+ })
183
204
  }
184
205
  }
185
206
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "q-koa",
3
- "version": "8.5.1",
3
+ "version": "8.5.4",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {