q-koa 13.3.9 → 13.4.0

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.
@@ -528,14 +528,8 @@ exports.urlToOss = async (ctx) => {
528
528
  const appConfig = getConfig(app)
529
529
  const { is_dev } = await appConfig.getObject('base')
530
530
  const { url } = ctx.request.body
531
- const {
532
- accessKeyId,
533
- accessKeySecret,
534
- bucket,
535
- region,
536
- cdn_host,
537
- oss_host,
538
- } = await appConfig.getObject('oss')
531
+ const { accessKeyId, accessKeySecret, bucket, region, cdn_host, oss_host } =
532
+ await appConfig.getObject('oss')
539
533
 
540
534
  if (
541
535
  !url ||
@@ -1,9 +1,12 @@
1
1
  const { getAppByCtx, getConfig, lodash, is_dev } = require('q-koa')
2
2
 
3
+ const fs = require('fs')
4
+ const path = require('path')
5
+
3
6
  exports.upsert = async (ctx) => {
4
7
  const { app } = getAppByCtx(ctx)
5
8
  const appConfig = getConfig(app)
6
- const { id } = ctx.request.body
9
+ const { id, value } = ctx.request.body
7
10
  if (!id) return
8
11
  const current_list = await app.model.setting.findAll({
9
12
  where: {
@@ -13,6 +16,46 @@ exports.upsert = async (ctx) => {
13
16
  if (current_list.some((o) => o.is_cache)) {
14
17
  appConfig.update()
15
18
  }
19
+ if (app.appConfig.UNI_APP_PROJECT && app.appConfig.UNI_APP_PROJECT.length) {
20
+ const target = await app.model.setting.findOne({
21
+ attributes: ['id'],
22
+ where: {
23
+ id,
24
+ code: 'version',
25
+ },
26
+ })
27
+ if (is_dev && target) {
28
+ const main = async (value) => {
29
+ const projectList = app.appConfig.UNI_APP_PROJECT.map((project) => {
30
+ return `../../uni-app/${project}/config.js`
31
+ })
32
+ for (const project of projectList) {
33
+ try {
34
+ const res = await fs.readFileSync(
35
+ path.resolve(process.cwd(), project),
36
+ 'utf-8'
37
+ )
38
+
39
+ if (res.includes('const version = ')) {
40
+ const newFileText = res.replace(
41
+ /const\s+version\s*=\s*'([^']+)'/,
42
+ `const version = '${value}'`
43
+ )
44
+ await fs.writeFileSync(
45
+ path.resolve(process.cwd(), project),
46
+ newFileText
47
+ )
48
+ }
49
+ } catch (e) {
50
+ console.log(e.message)
51
+ }
52
+ }
53
+ }
54
+ if (value) {
55
+ main(value)
56
+ }
57
+ }
58
+ }
16
59
  }
17
60
 
18
61
  exports.bulkUpdate = async (ctx) => {
@@ -302,6 +302,8 @@ exports.initData = async ({ includes, excludes, app, ctx }) => {
302
302
  if (
303
303
  target &&
304
304
  target.hasOwnProperty(i.code) &&
305
+ 'edit_list' in target &&
306
+ target.edit_list.includes(i.code) &&
305
307
  i.hasOwnProperty('value')
306
308
  ) {
307
309
  return {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "q-koa",
3
- "version": "13.3.9",
3
+ "version": "13.4.0",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {