diff --git a/2024-10-31.md b/2024-10-31.md new file mode 100644 index 0000000..2b36d96 --- /dev/null +++ b/2024-10-31.md @@ -0,0 +1 @@ +# 2024-10-31 diff --git a/dist.nu b/dist.nu new file mode 100644 index 0000000..5f298e8 --- /dev/null +++ b/dist.nu @@ -0,0 +1,5 @@ +cd ./src/images/ +svn add . --no-ignore --force +svn ci -m "版本更新" +cd .. +cd .. diff --git a/package.json b/package.json index b50c6a5..01fd7f5 100644 --- a/package.json +++ b/package.json @@ -18,7 +18,7 @@ "@antfu/eslint-config": "^3.7.3", "eslint": "^9.12.0", "eslint-config-prettier": "^9.1.0", - "miniprogram-api-typings": "^2.8.3-1", + "miniprogram-api-typings": "^4.0.1", "prettier": "^3.3.3" } } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index d19c53c..07f148d 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -31,8 +31,8 @@ importers: specifier: ^9.1.0 version: 9.1.0(eslint@9.12.0) miniprogram-api-typings: - specifier: ^2.8.3-1 - version: 2.12.0 + specifier: ^4.0.1 + version: 4.0.1 prettier: specifier: ^3.3.3 version: 3.3.3 @@ -95,25 +95,29 @@ packages: resolution: {integrity: sha512-0xZJFNE5XMpENsgfHYTw8FbX4kv53mFLn2i3XPoq69LyhYSCBJtitaHx9QnsVTrsogI4Z3+HtEfZ2/GFPOtf5g==} engines: {node: '>=6.9.0'} - '@babel/helper-string-parser@7.25.7': - resolution: {integrity: sha512-CbkjYdsJNHFk8uqpEkpCvRs3YRp9tY6FmFY7wLMSYuGYkrdUi7r2lc4/wqsvlHoMznX3WJ9IP8giGPq68T/Y6g==} + '@babel/helper-string-parser@7.25.9': + resolution: {integrity: sha512-4A/SCr/2KLd5jrtOMFzaKjVtAei3+2r/NChoBNoZ3EyP/+GlhoaEGoWOZUmFmoITP7zOJyHIMm+DYRd8o3PvHA==} engines: {node: '>=6.9.0'} '@babel/helper-validator-identifier@7.25.7': resolution: {integrity: sha512-AM6TzwYqGChO45oiuPqwL2t20/HdMC1rTPAesnBCgPCSF1x3oN9MVUwQV2iyz4xqWrctwK5RNC8LV22kaQCNYg==} engines: {node: '>=6.9.0'} + '@babel/helper-validator-identifier@7.25.9': + resolution: {integrity: sha512-Ed61U6XJc3CVRfkERJWDz4dJwKe7iLmmJsbOGu9wSloNSFttHV0I8g6UAgb7qnK5ly5bGLPd4oXZlxCdANBOWQ==} + engines: {node: '>=6.9.0'} + '@babel/highlight@7.25.7': resolution: {integrity: sha512-iYyACpW3iW8Fw+ZybQK+drQre+ns/tKpXbNESfrhNnPLIklLbXr7MYJ6gPEd0iETGLOK+SxMjVvKb/ffmk+FEw==} engines: {node: '>=6.9.0'} - '@babel/parser@7.25.8': - resolution: {integrity: sha512-HcttkxzdPucv3nNFmfOOMfFf64KgdJVqm1KaCm25dPGMLElo9nsLvXeJECQg8UzPuBGLyTSA0ZzqCtDSzKTEoQ==} + '@babel/parser@7.26.2': + resolution: {integrity: sha512-DWMCZH9WA4Maitz2q21SRKHo9QXZxkDsbNZoVD62gusNtNBBqDg9i7uOhASfTfIGNzW+O+r7+jAlM8dwphcJKQ==} engines: {node: '>=6.0.0'} hasBin: true - '@babel/types@7.25.8': - resolution: {integrity: sha512-JWtuCu8VQsMladxVz/P4HzHUGCAwpuqacmowgXFs5XjxIgKuNjnLokQzuVjlTvIzODaDmpjT3oxcC48vyk9EWg==} + '@babel/types@7.26.0': + resolution: {integrity: sha512-Z/yiTPj+lDVnF7lWeKCIJzaIkI0vYO87dMpZ4bg4TDrFe4XXLFWL1TbXU27gBP3QccxV9mZICCrnjnYlJjXHOA==} engines: {node: '>=6.9.0'} '@clack/core@0.3.4': @@ -1071,8 +1075,8 @@ packages: resolution: {integrity: sha512-G6T0ZX48xgozx7587koeX9Ys2NYy6Gmv//P89sEte9V9whIapMNF4idKxnW2QtCcLiTWlb/wfCabAtAFWhhBow==} engines: {node: '>=16 || 14 >=14.17'} - miniprogram-api-typings@2.12.0: - resolution: {integrity: sha512-ibvbqeslVFur0IAvTxLMvsbtvVcMo6gwvOnj0YZHV7aeDLu091VQRrETT2QuiG9P6aZWRcxeNGJChRKVPCp9VQ==} + miniprogram-api-typings@4.0.1: + resolution: {integrity: sha512-Ok4SSNCYnNLgbAhHCpIeqx6XICZ3aUxZ2iQDExmwKEinWaQQFzzxobK5JP9skrEOWn9PoKodjw4iUdF8Um0i/A==} miniprogram-licia@1.43.0: resolution: {integrity: sha512-NTQxO0LaoIv66I7civEqyUwtF36My7S0TwGyvMAFUpUqGXcQZsM9Ng2OWwHaBvlqdjjPHSacTMH3XqGpnieEow==} @@ -1163,6 +1167,9 @@ packages: picocolors@1.1.0: resolution: {integrity: sha512-TQ92mBOW0l3LeMeyLV6mzy/kWr8lkd/hp3mTg7wYK7zJhuBStmGMBG0BdeDZS/dZx1IukaX6Bk11zcln25o1Aw==} + picocolors@1.1.1: + resolution: {integrity: sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==} + picomatch@2.3.1: resolution: {integrity: sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==} engines: {node: '>=8.6'} @@ -1343,10 +1350,6 @@ packages: tinyexec@0.3.0: resolution: {integrity: sha512-tVGE0mVJPGb0chKhqmsoosjsS+qUnJVGJpZgsHYQcGoPlG3B51R3PouqTgEGH2Dc9jjFyOqOpix6ZHNMXp1FZg==} - to-fast-properties@2.0.0: - resolution: {integrity: sha512-/OaKK0xYrs3DmxRYqL/yDc+FxFUVYhDlXMhRmv3z915w2HF1tnN1omB354j8VUGO/hbRzyD6Y3sA7v7GS/ceog==} - engines: {node: '>=4'} - to-regex-range@5.0.1: resolution: {integrity: sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==} engines: {node: '>=8.0'} @@ -1526,10 +1529,12 @@ snapshots: '@babel/highlight': 7.25.7 picocolors: 1.1.0 - '@babel/helper-string-parser@7.25.7': {} + '@babel/helper-string-parser@7.25.9': {} '@babel/helper-validator-identifier@7.25.7': {} + '@babel/helper-validator-identifier@7.25.9': {} + '@babel/highlight@7.25.7': dependencies: '@babel/helper-validator-identifier': 7.25.7 @@ -1537,15 +1542,14 @@ snapshots: js-tokens: 4.0.0 picocolors: 1.1.0 - '@babel/parser@7.25.8': + '@babel/parser@7.26.2': dependencies: - '@babel/types': 7.25.8 + '@babel/types': 7.26.0 - '@babel/types@7.25.8': + '@babel/types@7.26.0': dependencies: - '@babel/helper-string-parser': 7.25.7 - '@babel/helper-validator-identifier': 7.25.7 - to-fast-properties: 2.0.0 + '@babel/helper-string-parser': 7.25.9 + '@babel/helper-validator-identifier': 7.25.9 '@clack/core@0.3.4': dependencies: @@ -1777,7 +1781,7 @@ snapshots: '@vue/compiler-core@3.5.12': dependencies: - '@babel/parser': 7.25.8 + '@babel/parser': 7.26.2 '@vue/shared': 3.5.12 entities: 4.5.0 estree-walker: 2.0.2 @@ -1790,7 +1794,7 @@ snapshots: '@vue/compiler-sfc@3.5.12': dependencies: - '@babel/parser': 7.25.8 + '@babel/parser': 7.26.2 '@vue/compiler-core': 3.5.12 '@vue/compiler-dom': 3.5.12 '@vue/compiler-ssr': 3.5.12 @@ -2737,7 +2741,7 @@ snapshots: dependencies: brace-expansion: 2.0.1 - miniprogram-api-typings@2.12.0: {} + miniprogram-api-typings@4.0.1: {} miniprogram-licia@1.43.0: {} @@ -2826,6 +2830,8 @@ snapshots: picocolors@1.1.0: {} + picocolors@1.1.1: {} + picomatch@2.3.1: {} picomatch@4.0.2: {} @@ -2846,7 +2852,7 @@ snapshots: postcss@8.4.47: dependencies: nanoid: 3.3.7 - picocolors: 1.1.0 + picocolors: 1.1.1 source-map-js: 1.2.1 prelude-ls@1.2.1: {} @@ -2987,8 +2993,6 @@ snapshots: tinyexec@0.3.0: {} - to-fast-properties@2.0.0: {} - to-regex-range@5.0.1: dependencies: is-number: 7.0.0 diff --git a/project.private.config.json b/project.private.config.json index 1f743b7..7853185 100644 --- a/project.private.config.json +++ b/project.private.config.json @@ -199,5 +199,6 @@ } ] } - } + }, + "libVersion": "3.6.3" } \ No newline at end of file diff --git a/src/components/customAudioBar/index.wxml b/src/components/customAudioBar/index.wxml index 2b0e6da..313110f 100644 --- a/src/components/customAudioBar/index.wxml +++ b/src/components/customAudioBar/index.wxml @@ -9,5 +9,5 @@ - 45” + {{time}}” diff --git a/src/components/customRecord/index.ts b/src/components/customRecord/index.ts index ad0248b..b105846 100644 --- a/src/components/customRecord/index.ts +++ b/src/components/customRecord/index.ts @@ -1,6 +1,4 @@ -import { isQualifiedName } from 'typescript' - -const _app = getApp() +const app = getApp(); // pages/story/a.ts Component({ @@ -21,11 +19,11 @@ Component({ lifetimes: { attached() { - const recorderManager = wx.getRecorderManager() + const recorderManager = wx.getRecorderManager(); this.setData({ recorderManager, - }) - this.recorderManagerListen(recorderManager) + }); + this.recorderManagerListen(recorderManager); }, }, /** @@ -36,90 +34,154 @@ Component({ this.checkRecordPermission(() => { this.setData({ startShow: true, - }) - }) + }); + }); }, handleShow() { - const { recorderManager } = this.data + const { recorderManager } = this.data; this.setData({ show: true, - }) + }); recorderManager?.start({ - format: 'mp3', - }) + format: "mp3", + }); }, handleHide() { - const { recorderManager } = this.data - recorderManager?.stop() + const { recorderManager } = this.data; + recorderManager?.stop(); this.setData({ startShow: false, show: false, - }) + }); }, recorderManagerListen(recorderManager: WechatMiniprogram.RecorderManager) { recorderManager.onError(() => { wx.showToast({ - title: '录音失败', - icon: 'none', - }) - }) + title: "录音失败", + icon: "none", + }); + }); recorderManager.onStart(() => { - this.handleTiem() - }) + this.handleTiem(); + }); recorderManager.onStop((res) => { - this.handleHide() - console.log(res) - }) + this.handleHide(); + this.uploadFile({ + fileType: "audio", + tempFilePath: res.tempFilePath, + size: res.fileSize, + duration: res.duration, + }).then((res) => { + this.triggerEvent("file", res as object); + }); + }); }, checkRecordPermission(callback: () => void) { wx.getSetting({ success(res) { - if (!res.authSetting['scope.record']) { + if (!res.authSetting["scope.record"]) { wx.authorize({ - scope: 'scope.record', + scope: "scope.record", success() { // 用户已同意授权 }, fail() { // 用户拒绝了授权 wx.showModal({ - title: '提示', - content: '需要获取录音权限,请点击确定进入设置页面进行授权。', + title: "提示", + content: "需要获取录音权限,请点击确定进入设置页面进行授权。", showCancel: false, success(res) { if (res.confirm) { wx.openSetting({ success(res) { // 用户在设置页面设置了录音权限 - if (res.authSetting['scope.record']) { + if (res.authSetting["scope.record"]) { // 用户在设置页面设置了录音权限 } else { // 用户在设置页面未设置录音权限 } }, - }) + }); } }, - }) + }); }, - }) + }); } else { // 已经有录音权限 - callback() + callback(); } }, - }) + }); }, handleTiem() { const time = setTimeout(() => { - clearInterval(time) - if (!this.data.show) return + clearInterval(time); + if (!this.data.show) return; this.setData({ time: this.data.time + 1, - }) - console.log(this.data.time) - this.handleTiem() - }, 1000) + }); + this.handleTiem(); + }, 1000); + }, + uploadFile(item) { + wx.showLoading({ + title: "正在上传", + }); + return new Promise((resolve, reject) => { + let url = `${app.globalData.upFileUrl}?r=file-service/upload-`; + if (item.fileType === "image") { + url += "img"; + } else if (item.fileType === "video") { + url += "video"; + } else if (item.fileType === "audio") { + url += "audio"; + } else { + url += "doc"; + } + wx.uploadFile({ + filePath: item.tempFilePath, + name: "file", + url, + success: (res) => { + wx.hideLoading(); + const data = JSON.parse(res.data); + const expandJson = { + fileId: "", + name: data.data.Url, + size: (item.size / 1024).toFixed(2), + fileUrl: data.data.Url, + suffix: this.GetExtensionFileName(data.data.Url), + type: item.fileType, + imgUrl: "", + duration: "", + }; + if (item.fileType === "image") { + expandJson.imgUrl = data.data.Url; + } + if (item.fileType === "video") { + expandJson.imgUrl = data.data.SnapshotUrl; + } + if (item.fileType === "audio") { + expandJson.duration = item.duration; + } + resolve(expandJson); + }, + fail() { + wx.hideLoading(); + reject(new Error("上传失败")); + }, + }); + }); + }, + GetExtensionFileName(pathfilename) { + const reg = /(\\+)/g; + const pString = pathfilename.replace(reg, "#"); //用正则表达式来将\或\\替换成# + const arr = pString.split("#"); // 以“#”为分隔符,将字符分解为数组 例如 D Program Files bg.png + const lastString = arr[arr.length - 1]; //取最后一个字符 + const arr2 = lastString.split("."); // 再以"."作为分隔符 + return arr2[arr2.length - 1]; //将后缀名返回出来 }, }, -}) +}); diff --git a/src/components/uploadFile/index.ts b/src/components/uploadFile/index.ts index 0a23185..befd2b3 100644 --- a/src/components/uploadFile/index.ts +++ b/src/components/uploadFile/index.ts @@ -10,6 +10,14 @@ Component({ type: Boolean, value: false, }, + accept: { + type: String, + value: "image", + }, + obscure: { + type: Boolean, + value: false, + }, }, /** @@ -30,9 +38,20 @@ Component({ return arr2[arr2.length - 1]; //将后缀名返回出来 }, handleAfterRead(e) { - this.uploadFile(e.detail.file).then((res) => { - this.triggerEvent("file", res as object); - }); + if (this.data.obscure) { + wx.editImage({ + src: e.detail.file.url || e.detail.file.tempFilePath, + success: (res:any) => { + this.uploadFile(res.detail.file).then((res) => { + this.triggerEvent("file", res as object); + }); + }, + }); + } else { + this.uploadFile(e.detail.file).then((res) => { + this.triggerEvent("file", res as object); + }); + } }, handleChooseAvatar(e) { this.uploadFile({ diff --git a/src/components/uploadFile/index.wxml b/src/components/uploadFile/index.wxml index 01e6525..f3ac8b0 100644 --- a/src/components/uploadFile/index.wxml +++ b/src/components/uploadFile/index.wxml @@ -1,6 +1,6 @@ - + diff --git a/src/images/empty-3.png b/src/images/empty-3.png deleted file mode 100644 index fcfabff..0000000 Binary files a/src/images/empty-3.png and /dev/null differ diff --git a/src/images/empty-4.png b/src/images/empty-4.png deleted file mode 100644 index 5314d3f..0000000 Binary files a/src/images/empty-4.png and /dev/null differ diff --git a/src/images/empty-5.png b/src/images/empty-5.png deleted file mode 100644 index 54301b7..0000000 Binary files a/src/images/empty-5.png and /dev/null differ diff --git a/src/images/new.png b/src/images/new.png deleted file mode 100644 index 850916a..0000000 Binary files a/src/images/new.png and /dev/null differ diff --git a/src/images/none_1.png b/src/images/none_1.png deleted file mode 100644 index e0c650f..0000000 Binary files a/src/images/none_1.png and /dev/null differ diff --git a/src/images/user.png b/src/images/user.png index 35955fc..4ec6bcb 100644 Binary files a/src/images/user.png and b/src/images/user.png differ diff --git a/src/module1/pages/entryCases/index.ts b/src/module1/pages/entryCases/index.ts index ec09116..28df187 100644 --- a/src/module1/pages/entryCases/index.ts +++ b/src/module1/pages/entryCases/index.ts @@ -1,29 +1,66 @@ -const _app = getApp() +const _app = getApp(); Page({ data: { show1: false, show2: false, show3: false, + + images: [] as any, + description: "", + audios: [] as any, }, onLoad() {}, handleChooseFile() { wx.chooseMessageFile({ count: 1, success(res) { - console.log(res) + console.log(res); }, fail() { wx.showToast({ - icon: 'none', - title: '取消选择', - }) + icon: "none", + title: "取消选择", + }); }, - }) + }); }, handleSubmit() { wx.navigateTo({ - url: '/module1/pages/entryCasesResult/index', - }) + url: "/module1/pages/entryCasesResult/index", + }); + }, + handlePhoto(e) { + const detail = e.detail; + const images = this.data.images; + this.setData({ + images: [ + ...images, + { + name: detail.name, + url: detail.fileUrl, + isRepeat: 2, + }, + ], + }); + }, + handleDelPhoto(e) { + const { index } = e.currentTarget.dataset; + this.setData({ + images: this.data.images.filter((_, i) => i !== Number(index)), + }); + }, + handleAudio(e) { + this.setData({ + audios: [ + ...this.data.audios, + { + name: e.detail.name, + url: e.detail.fileUrl, + duration: e.detail.duration, + isRepeat: 2, + }, + ], + }); }, -}) +}); diff --git a/src/module1/pages/entryCases/index.wxml b/src/module1/pages/entryCases/index.wxml index 62efb6c..481935e 100644 --- a/src/module1/pages/entryCases/index.wxml +++ b/src/module1/pages/entryCases/index.wxml @@ -5,21 +5,17 @@ (0/9) - - - + + + - + - + @@ -31,6 +27,7 @@