li.shaoyi 2 år sedan
förälder
incheckning
ac2e159a3d

+ 1 - 1
.gitignore

@@ -1,7 +1,7 @@
 .DS_Store
 node_modules
-electron_dist
 /dist
+/dist_electron
 
 
 # local env files

+ 34 - 25
electron.build.js

@@ -1,38 +1,47 @@
 const fs = require('fs')
-const path = require('path')
+const axios = require('axios')
 const { exec } = require('child_process')
 const { build } = require('electron-builder')
 
-const res = fs.readFileSync(path.resolve('dist/config/appconfig.json'), 'utf-8')
-const { appName } = JSON.parse(res)
+const fileContents = fs.readFileSync('dist/config/appconfig.json', 'utf-8')
+const appConfig = JSON.parse(fileContents)
 
 // 打包之前清空目录
-exec('rd/s/q electron_dist')
+exec('rd/s/q dist_electron')
 
-const config = {
-    productName: appName,
-    directories: {
-        output: 'electron_dist'
-    },
-    files: [
-        'dist',
-        'main.js',
-        '!node_modules'
-    ],
-    nsis: {
-        oneClick: false,
-        allowToChangeInstallationDirectory: true
-    },
-    win: {
-        icon: 'dist/favicon.ico',
-        target: [
+axios.get(appConfig.apiUrl).then((res) => {
+    const data = res.data.data
+    console.log(data)
+
+    const config = {
+        productName: appConfig.appName,
+        directories: {
+            output: 'dist_electron'
+        },
+        files: [
+            'dist',
+            'main.js',
+        ],
+        nsis: {
+            oneClick: false,
+            allowToChangeInstallationDirectory: true
+        },
+        win: {
+            icon: 'dist/favicon.ico',
+            target: [
+                'nsis'
+            ]
+        },
+        // 应用更新服务器地址,配置了 publish 才会生成 latest.yml 文件,和 .exe 文件一起放到该服务器地址下
+        publish: [
             {
-                target: 'nsis'
+                provider: 'generic',
+                url: data.pcUpdateUrl ?? ''
             }
         ]
     }
-}
 
-build({
-    config
+    build({
+        config
+    })
 })

+ 70 - 1
main.js

@@ -1,8 +1,74 @@
-const { app, BrowserWindow, Menu } = require('electron')
+const fs = require('fs')
+const yaml = require('js-yaml')
+const { app, BrowserWindow, Menu, dialog } = require('electron')
+const { autoUpdater } = require('electron-updater')
+
+const fileContents = fs.readFileSync('resources/app-update.yml', 'utf-8')
+const data = yaml.load(fileContents)
 
 const createWindow = () => {
     Menu.setApplicationMenu(null)
 
+    if (data.url) {
+        autoUpdater.autoDownload = false
+
+        autoUpdater.setFeedURL({
+            provider: data.provider,
+            url: data.url
+        })
+
+        // 检查更新出错
+        autoUpdater.on('error', (err) => {
+            dialog.showMessageBox({
+                type: 'error',
+                title: '错误',
+                noLink: true,
+                message: '更新发生错误',
+                detail: err.message
+            })
+        })
+
+        // 检测到有版本更新
+        autoUpdater.on('update-available', (e) => {
+            dialog.showMessageBox({
+                type: 'info',
+                title: '提示',
+                noLink: true,
+                message: e.version,
+                detail: '发现新版本,是否现在下载?',
+                buttons: ['取消', '下载']
+            }).then((res) => {
+                if (res.response === 1) {
+                    autoUpdater.downloadUpdate()
+                }
+            })
+        })
+
+        // 更新下载进度事件
+        autoUpdater.on('download-progress', (progress) => {
+            // https://www.electronjs.org/zh/docs/latest/tutorial/progress-bar
+            win.setProgressBar(progress.percent / 100)
+        })
+
+        // 下载完成,询问用户是否更新
+        autoUpdater.on('update-downloaded', (e) => {
+            dialog.showMessageBox({
+                type: 'info',
+                title: '提示',
+                noLink: true,
+                message: e.version,
+                detail: '已下载新版本,是否关闭应用更新?',
+                buttons: ['取消', '安装']
+            }).then((res) => {
+                if (res.response === 1) {
+                    autoUpdater.quitAndInstall()
+                } else {
+                    win.setProgressBar(-1)
+                }
+            })
+        })
+    }
+
     const win = new BrowserWindow({
         center: true,
         minWidth: 1280,
@@ -12,6 +78,9 @@ const createWindow = () => {
 
     win.maximize()
     win.loadFile('dist/index.html')
+    win.on('ready-to-show', () => {
+        autoUpdater.checkForUpdates()
+    })
 }
 
 app.whenReady().then(() => {

+ 52 - 101
package-lock.json

@@ -21,6 +21,7 @@
         "hqchart": "^1.1.12450",
         "html5-qrcode": "^2.2.5",
         "jquery": "^3.7.1",
+        "js-yaml": "^4.1.0",
         "long": "^5.2.0",
         "moment": "^2.29.3",
         "photoswipe": "^5.3.6",
@@ -2086,6 +2087,15 @@
         "node": "^10.12.0 || >=12.0.0"
       }
     },
+    "node_modules/@eslint/eslintrc/node_modules/argparse": {
+      "version": "1.0.10",
+      "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz",
+      "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==",
+      "dev": true,
+      "dependencies": {
+        "sprintf-js": "~1.0.2"
+      }
+    },
     "node_modules/@eslint/eslintrc/node_modules/globals": {
       "version": "13.22.0",
       "resolved": "https://registry.npmjs.org/globals/-/globals-13.22.0.tgz",
@@ -2110,6 +2120,19 @@
         "node": ">= 4"
       }
     },
+    "node_modules/@eslint/eslintrc/node_modules/js-yaml": {
+      "version": "3.14.1",
+      "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.14.1.tgz",
+      "integrity": "sha512-okMH7OXXJ7YrN9Ok3/SXrnu4iX9yOk+25nqX4imS2npuvTYDmo/QEZoqwZkYaIDk3jVvBOTOIEgEhaLOynBS9g==",
+      "dev": true,
+      "dependencies": {
+        "argparse": "^1.0.7",
+        "esprima": "^4.0.0"
+      },
+      "bin": {
+        "js-yaml": "bin/js-yaml.js"
+      }
+    },
     "node_modules/@eslint/eslintrc/node_modules/type-fest": {
       "version": "0.20.2",
       "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.20.2.tgz",
@@ -5140,12 +5163,6 @@
         "node": ">=14.0.0"
       }
     },
-    "node_modules/app-builder-lib/node_modules/argparse": {
-      "version": "2.0.1",
-      "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz",
-      "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==",
-      "dev": true
-    },
     "node_modules/app-builder-lib/node_modules/brace-expansion": {
       "version": "2.0.1",
       "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz",
@@ -5208,18 +5225,6 @@
         "is-ci": "bin.js"
       }
     },
-    "node_modules/app-builder-lib/node_modules/js-yaml": {
-      "version": "4.1.0",
-      "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz",
-      "integrity": "sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==",
-      "dev": true,
-      "dependencies": {
-        "argparse": "^2.0.1"
-      },
-      "bin": {
-        "js-yaml": "bin/js-yaml.js"
-      }
-    },
     "node_modules/app-builder-lib/node_modules/lru-cache": {
       "version": "6.0.0",
       "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz",
@@ -5271,13 +5276,9 @@
       ]
     },
     "node_modules/argparse": {
-      "version": "1.0.10",
-      "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz",
-      "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==",
-      "dev": true,
-      "dependencies": {
-        "sprintf-js": "~1.0.2"
-      }
+      "version": "2.0.1",
+      "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz",
+      "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q=="
     },
     "node_modules/arr-diff": {
       "version": "4.0.0",
@@ -6054,12 +6055,6 @@
         "url": "https://github.com/chalk/ansi-styles?sponsor=1"
       }
     },
-    "node_modules/builder-util/node_modules/argparse": {
-      "version": "2.0.1",
-      "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz",
-      "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==",
-      "dev": true
-    },
     "node_modules/builder-util/node_modules/chalk": {
       "version": "4.1.2",
       "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz",
@@ -6144,18 +6139,6 @@
         "is-ci": "bin.js"
       }
     },
-    "node_modules/builder-util/node_modules/js-yaml": {
-      "version": "4.1.0",
-      "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz",
-      "integrity": "sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==",
-      "dev": true,
-      "dependencies": {
-        "argparse": "^2.0.1"
-      },
-      "bin": {
-        "js-yaml": "bin/js-yaml.js"
-      }
-    },
     "node_modules/builder-util/node_modules/supports-color": {
       "version": "7.2.0",
       "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz",
@@ -8378,12 +8361,6 @@
         "dmg-license": "^1.0.11"
       }
     },
-    "node_modules/dmg-builder/node_modules/argparse": {
-      "version": "2.0.1",
-      "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz",
-      "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==",
-      "dev": true
-    },
     "node_modules/dmg-builder/node_modules/fs-extra": {
       "version": "10.1.0",
       "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-10.1.0.tgz",
@@ -8398,18 +8375,6 @@
         "node": ">=12"
       }
     },
-    "node_modules/dmg-builder/node_modules/js-yaml": {
-      "version": "4.1.0",
-      "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz",
-      "integrity": "sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==",
-      "dev": true,
-      "dependencies": {
-        "argparse": "^2.0.1"
-      },
-      "bin": {
-        "js-yaml": "bin/js-yaml.js"
-      }
-    },
     "node_modules/dmg-license": {
       "version": "1.0.11",
       "resolved": "https://registry.npmjs.org/dmg-license/-/dmg-license-1.0.11.tgz",
@@ -8919,11 +8884,6 @@
         "tiny-typed-emitter": "^2.1.0"
       }
     },
-    "node_modules/electron-updater/node_modules/argparse": {
-      "version": "2.0.1",
-      "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz",
-      "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q=="
-    },
     "node_modules/electron-updater/node_modules/fs-extra": {
       "version": "10.1.0",
       "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-10.1.0.tgz",
@@ -8937,17 +8897,6 @@
         "node": ">=12"
       }
     },
-    "node_modules/electron-updater/node_modules/js-yaml": {
-      "version": "4.1.0",
-      "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz",
-      "integrity": "sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==",
-      "dependencies": {
-        "argparse": "^2.0.1"
-      },
-      "bin": {
-        "js-yaml": "bin/js-yaml.js"
-      }
-    },
     "node_modules/element-plus": {
       "version": "2.3.14",
       "resolved": "https://registry.npmjs.org/element-plus/-/element-plus-2.3.14.tgz",
@@ -9510,6 +9459,15 @@
         "url": "https://github.com/chalk/ansi-styles?sponsor=1"
       }
     },
+    "node_modules/eslint/node_modules/argparse": {
+      "version": "1.0.10",
+      "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz",
+      "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==",
+      "dev": true,
+      "dependencies": {
+        "sprintf-js": "~1.0.2"
+      }
+    },
     "node_modules/eslint/node_modules/chalk": {
       "version": "4.1.2",
       "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz",
@@ -9610,6 +9568,19 @@
         "node": ">= 4"
       }
     },
+    "node_modules/eslint/node_modules/js-yaml": {
+      "version": "3.14.1",
+      "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.14.1.tgz",
+      "integrity": "sha512-okMH7OXXJ7YrN9Ok3/SXrnu4iX9yOk+25nqX4imS2npuvTYDmo/QEZoqwZkYaIDk3jVvBOTOIEgEhaLOynBS9g==",
+      "dev": true,
+      "dependencies": {
+        "argparse": "^1.0.7",
+        "esprima": "^4.0.0"
+      },
+      "bin": {
+        "js-yaml": "bin/js-yaml.js"
+      }
+    },
     "node_modules/eslint/node_modules/supports-color": {
       "version": "7.2.0",
       "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz",
@@ -12352,13 +12323,11 @@
       "dev": true
     },
     "node_modules/js-yaml": {
-      "version": "3.14.1",
-      "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.14.1.tgz",
-      "integrity": "sha512-okMH7OXXJ7YrN9Ok3/SXrnu4iX9yOk+25nqX4imS2npuvTYDmo/QEZoqwZkYaIDk3jVvBOTOIEgEhaLOynBS9g==",
-      "dev": true,
+      "version": "4.1.0",
+      "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz",
+      "integrity": "sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==",
       "dependencies": {
-        "argparse": "^1.0.7",
-        "esprima": "^4.0.0"
+        "argparse": "^2.0.1"
       },
       "bin": {
         "js-yaml": "bin/js-yaml.js"
@@ -15158,12 +15127,6 @@
         "node": ">=12.0.0"
       }
     },
-    "node_modules/read-config-file/node_modules/argparse": {
-      "version": "2.0.1",
-      "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz",
-      "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==",
-      "dev": true
-    },
     "node_modules/read-config-file/node_modules/dotenv": {
       "version": "9.0.2",
       "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-9.0.2.tgz",
@@ -15173,18 +15136,6 @@
         "node": ">=10"
       }
     },
-    "node_modules/read-config-file/node_modules/js-yaml": {
-      "version": "4.1.0",
-      "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz",
-      "integrity": "sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==",
-      "dev": true,
-      "dependencies": {
-        "argparse": "^2.0.1"
-      },
-      "bin": {
-        "js-yaml": "bin/js-yaml.js"
-      }
-    },
     "node_modules/read-pkg": {
       "version": "5.2.0",
       "resolved": "https://registry.npmjs.org/read-pkg/-/read-pkg-5.2.0.tgz",

+ 1 - 0
package.json

@@ -43,6 +43,7 @@
     "hqchart": "^1.1.12450",
     "html5-qrcode": "^2.2.5",
     "jquery": "^3.7.1",
+    "js-yaml": "^4.1.0",
     "long": "^5.2.0",
     "moment": "^2.29.3",
     "photoswipe": "^5.3.6",

+ 8 - 1
src/packages/mobile/views/goods/detail/Index.vue

@@ -5,7 +5,7 @@
         </template>
         <component :is="Price" v-bind="{ goodsCode }" />
         <component :is="Chart" v-bind="{ goodsCode }" />
-        <component :is="Forex" v-bind="{ goodsCode }" @more-click="onMoreClick" />
+        <component :is="Forex" v-bind="{ goodsCode }" :show-more="showMore" @more-click="onMoreClick" />
         <component :is="Tik" v-bind="{ goodsCode }" />
         <template #footer>
             <div class="g-form__footer">
@@ -26,6 +26,13 @@ import { useComponent } from '@/hooks/component'
 import { BuyOrSell } from '@/constants/order'
 import { useFuturesStore } from '@/stores'
 
+defineProps({
+    showMore: {
+        type: Boolean,
+        default: true
+    }
+})
+
 const Price = defineAsyncComponent(() => import('@mobile/components/modules/quote/price/index.vue'))
 const Chart = defineAsyncComponent(() => import('@mobile/components/modules/quote/chart/index.vue'))
 const Forex = defineAsyncComponent(() => import('@mobile/components/modules/quote/forex/index.vue'))

+ 3 - 0
src/packages/qxst/router/index.ts

@@ -144,6 +144,9 @@ const routes: Array<RouteRecordRaw> = [
         path: 'detail',
         name: 'goods-detail',
         component: () => import('@mobile/views/goods/detail/Index.vue'),
+        props: {
+          showMore: false
+        }
       },
       {
         path: 'trade',

+ 5 - 9
src/packages/qxst/views/account/certification/Index.vue

@@ -72,13 +72,10 @@ const { componentRef, componentId, openComponent, closeComponent } = useComponen
     router.back()
 })
 
-const isReadonly = computed(() => {
-    const [firstStep] = userESignRecords.value
-    return firstStep?.recordstatus === 3
-})
+const isReadonly = computed(() => userESignRecords.value.every((e) => e.templatetype === 1 && e.recordstatus === 3))
 
 /// 查询记录
-const { loading: buttonLoading, dataList: userESignRecords } = useRequest(queryUserESignRecord, {
+const { loading: buttonLoading, dataList: userESignRecords, run: getUserESignRecord } = useRequest(queryUserESignRecord, {
     onSuccess: (res) => {
         const [firstStep] = res.data
         if (firstStep?.recordstatus === 3) {
@@ -150,8 +147,8 @@ const onCheckCardNum = () => {
             }
         }).then(() => {
             formSubmit().then((res) => {
-                console.log(res)
                 hideLoading()
+                getUserESignRecord()
                 switch (res.data.code) {
                     case '0':
                         dialog('提交请求成功').then(() => {
@@ -172,7 +169,7 @@ const onCheckCardNum = () => {
                         showFailToast('实名认证类型和添加用户类型不匹配')
                         break;
                     default:
-                        showFailToast('请求失败,错误码:'+res.data.code)
+                        showFailToast('请求失败,错误码:' + res.data.code)
                         break;
                 }
             }).catch((err) => {
@@ -185,8 +182,7 @@ const onCheckCardNum = () => {
 }
 
 const onSubmit = () => {
-    const [firstStep] = userESignRecords.value
-    if (!firstStep || firstStep.recordstatus === 1) {
+    if (userESignRecords.value.every((e) => e.templatetype === 1 && e.recordstatus === 1)) {
         formRef.value?.submit()
     } else {
         openComponent('certification-next')