From 19e702254e0de67511886e6af7fcff6dfd7bcafd Mon Sep 17 00:00:00 2001 From: haha Date: Fri, 1 Aug 2025 23:39:18 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BE=AE=E4=BF=A1=E5=B0=8F=E7=A8=8B=E5=BA=8F?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0svg-icon?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- yanzhu-ui-app/miniprogram/.DS_Store | Bin 0 -> 6148 bytes .../miniprogram/components/svg-icon/base64.js | 7 ++ .../miniprogram/components/svg-icon/index.js | 114 ++++++++++++++++++ .../components/svg-icon/index.json | 4 + .../components/svg-icon/index.wxml | 10 ++ .../components/svg-icon/index.wxss | 7 ++ yanzhu-ui-app/miniprogram/config.js | 16 ++- yanzhu-ui-app/miniprogram/images/svg/add.svg | 1 + yanzhu-ui-app/miniprogram/images/svg/add2.svg | 1 + .../pageage/project_checked/list/index.json | 4 +- .../pageage/project_checked/list/index.wxml | 2 + .../miniprogram/project.private.config.json | 21 +--- 12 files changed, 161 insertions(+), 26 deletions(-) create mode 100644 yanzhu-ui-app/miniprogram/.DS_Store create mode 100644 yanzhu-ui-app/miniprogram/components/svg-icon/base64.js create mode 100644 yanzhu-ui-app/miniprogram/components/svg-icon/index.js create mode 100644 yanzhu-ui-app/miniprogram/components/svg-icon/index.json create mode 100644 yanzhu-ui-app/miniprogram/components/svg-icon/index.wxml create mode 100644 yanzhu-ui-app/miniprogram/components/svg-icon/index.wxss create mode 100644 yanzhu-ui-app/miniprogram/images/svg/add.svg create mode 100644 yanzhu-ui-app/miniprogram/images/svg/add2.svg diff --git a/yanzhu-ui-app/miniprogram/.DS_Store b/yanzhu-ui-app/miniprogram/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..74ca77fbf918009fc9caee7c66002ff40899e5e9 GIT binary patch literal 6148 zcmeHK%}&BV5S|4TkeG1LgySY&NkoJY;-x`+0c-T22B{EjEL}p2JrI(f^@V&ApU0Wq zg@k|yFUH7BGV|@uPdD?m+3f;==u8JE0A&Cupb}<^Xf_DNN!KJ}J%mC(LqP~b)EJ_* zYj2j?n``+hi_=mLK*#FV=mKOCr}qo&~?(zUJ$6j6HR%52tZ zwyLsu+L%}6tX;2FWusl6&x?h_qvNy7-b*kF)tezy;J2q`-{Jz^aj>zsS9cNyDtyBD zqIOZk$P6$8%)mA+0W-$#n)2uW~EcL_pi z(Xp5s#0ZKorHH0f*eixG<>;3-&#{;qH02=l%J>|+vamN4p;t%0)af7`gKU`rW?+?p zteKYS{J;4A{=ZtpGiHDp_*V>wT-WV(uqAu8t~Ezztweo5C8503;Iae<`Y6U+I*Kc( aTF@_Pfaq9E4Wb8ye*`oQY?y&xW#9|Re@-O; literal 0 HcmV?d00001 diff --git a/yanzhu-ui-app/miniprogram/components/svg-icon/base64.js b/yanzhu-ui-app/miniprogram/components/svg-icon/base64.js new file mode 100644 index 00000000..7e6fa06d --- /dev/null +++ b/yanzhu-ui-app/miniprogram/components/svg-icon/base64.js @@ -0,0 +1,7 @@ +/** + * Minified by jsDelivr using Terser v5.15.1. + * Original file: /npm/js-base64@3.7.5/base64.js + * + * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files + */ +!function(t,n){var r,e;"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(r=t.Base64,(e=n()).noConflict=function(){return t.Base64=r,e},t.Meteor&&(Base64=e),t.Base64=e)}("undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:this,(function(){"use strict";var t,n="3.7.5",r="function"==typeof atob,e="function"==typeof btoa,o="function"==typeof Buffer,u="function"==typeof TextDecoder?new TextDecoder:void 0,i="function"==typeof TextEncoder?new TextEncoder:void 0,f=Array.prototype.slice.call("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="),c=(t={},f.forEach((function(n,r){return t[n]=r})),t),a=/^(?:[A-Za-z\d+\/]{4})*?(?:[A-Za-z\d+\/]{2}(?:==)?|[A-Za-z\d+\/]{3}=?)?$/,d=String.fromCharCode.bind(String),s="function"==typeof Uint8Array.from?Uint8Array.from.bind(Uint8Array):function(t){return new Uint8Array(Array.prototype.slice.call(t,0))},l=function(t){return t.replace(/=/g,"").replace(/[+\/]/g,(function(t){return"+"==t?"-":"_"}))},h=function(t){return t.replace(/[^A-Za-z0-9\+\/]/g,"")},p=function(t){for(var n,r,e,o,u="",i=t.length%3,c=0;c255||(e=t.charCodeAt(c++))>255||(o=t.charCodeAt(c++))>255)throw new TypeError("invalid character found");u+=f[(n=r<<16|e<<8|o)>>18&63]+f[n>>12&63]+f[n>>6&63]+f[63&n]}return i?u.slice(0,i-3)+"===".substring(i):u},y=e?function(t){return btoa(t)}:o?function(t){return Buffer.from(t,"binary").toString("base64")}:p,A=o?function(t){return Buffer.from(t).toString("base64")}:function(t){for(var n=[],r=0,e=t.length;r>>6)+d(128|63&n):d(224|n>>>12&15)+d(128|n>>>6&63)+d(128|63&n);var n=65536+1024*(t.charCodeAt(0)-55296)+(t.charCodeAt(1)-56320);return d(240|n>>>18&7)+d(128|n>>>12&63)+d(128|n>>>6&63)+d(128|63&n)},B=/[\uD800-\uDBFF][\uDC00-\uDFFFF]|[^\x00-\x7F]/g,x=function(t){return t.replace(B,g)},C=o?function(t){return Buffer.from(t,"utf8").toString("base64")}:i?function(t){return A(i.encode(t))}:function(t){return y(x(t))},m=function(t,n){return void 0===n&&(n=!1),n?l(C(t)):C(t)},v=function(t){return m(t,!0)},U=/[\xC0-\xDF][\x80-\xBF]|[\xE0-\xEF][\x80-\xBF]{2}|[\xF0-\xF7][\x80-\xBF]{3}/g,F=function(t){switch(t.length){case 4:var n=((7&t.charCodeAt(0))<<18|(63&t.charCodeAt(1))<<12|(63&t.charCodeAt(2))<<6|63&t.charCodeAt(3))-65536;return d(55296+(n>>>10))+d(56320+(1023&n));case 3:return d((15&t.charCodeAt(0))<<12|(63&t.charCodeAt(1))<<6|63&t.charCodeAt(2));default:return d((31&t.charCodeAt(0))<<6|63&t.charCodeAt(1))}},w=function(t){return t.replace(U,F)},S=function(t){if(t=t.replace(/\s+/g,""),!a.test(t))throw new TypeError("malformed base64.");t+="==".slice(2-(3&t.length));for(var n,r,e,o="",u=0;u>16&255):64===e?d(n>>16&255,n>>8&255):d(n>>16&255,n>>8&255,255&n);return o},E=r?function(t){return atob(h(t))}:o?function(t){return Buffer.from(t,"base64").toString("binary")}:S,D=o?function(t){return s(Buffer.from(t,"base64"))}:function(t){return s(E(t).split("").map((function(t){return t.charCodeAt(0)})))},R=function(t){return D(T(t))},z=o?function(t){return Buffer.from(t,"base64").toString("utf8")}:u?function(t){return u.decode(D(t))}:function(t){return w(E(t))},T=function(t){return h(t.replace(/[-_]/g,(function(t){return"-"==t?"+":"/"})))},Z=function(t){return z(T(t))},j=function(t){return{value:t,enumerable:!1,writable:!0,configurable:!0}},I=function(){var t=function(t,n){return Object.defineProperty(String.prototype,t,j(n))};t("fromBase64",(function(){return Z(this)})),t("toBase64",(function(t){return m(this,t)})),t("toBase64URI",(function(){return m(this,!0)})),t("toBase64URL",(function(){return m(this,!0)})),t("toUint8Array",(function(){return R(this)}))},O=function(){var t=function(t,n){return Object.defineProperty(Uint8Array.prototype,t,j(n))};t("toBase64",(function(t){return b(this,t)})),t("toBase64URI",(function(){return b(this,!0)})),t("toBase64URL",(function(){return b(this,!0)}))},P={version:n,VERSION:"3.7.5",atob:E,atobPolyfill:S,btoa:y,btoaPolyfill:p,fromBase64:Z,toBase64:m,encode:m,encodeURI:v,encodeURL:v,utob:x,btou:w,decode:Z,isValid:function(t){if("string"!=typeof t)return!1;var n=t.replace(/\s+/g,"").replace(/={0,2}$/,"");return!/[^\s0-9a-zA-Z\+/]/.test(n)||!/[^\s0-9a-zA-Z\-_]/.test(n)},fromUint8Array:b,toUint8Array:R,extendString:I,extendUint8Array:O,extendBuiltins:function(){I(),O()},Base64:{}};return Object.keys(P).forEach((function(t){return P.Base64[t]=P[t]})),P})); diff --git a/yanzhu-ui-app/miniprogram/components/svg-icon/index.js b/yanzhu-ui-app/miniprogram/components/svg-icon/index.js new file mode 100644 index 00000000..af3e52b6 --- /dev/null +++ b/yanzhu-ui-app/miniprogram/components/svg-icon/index.js @@ -0,0 +1,114 @@ +import { encode } from "./base64"; + +const fs = wx.getFileSystemManager(); + +// 临时文件缓存 +const tempFileMap = new Map(); + +// 同步 wx.downloadFile +const downloadFileSync = (url) => + new Promise((resolve, reject) => { + wx.downloadFile({ + url, + success: resolve, + fail: reject, + }); + }); + +Component({ + externalClasses: ["image-class"], + properties: { + src: String, // svg 资源地址,暂仅支持本地路径 + color: String, // svg 颜色 + colors: null, // svg 颜色配置,支持数组或对象 + mode: String, // svg 裁剪、缩放的模式 + size: { + type: Number, + value: 48, // 默认宽度为24 + }, + }, + observers: { + async "src, color, colors"(src, color, colors) { + try { + if ( + color || + (colors && (colors.length > 0 || Object.keys(colors).length > 0)) + ) { + let data; + if (src.indexOf(".") == -1 && src.indexOf("/") == -1) { + src = `/images/svg/${src}.svg`; + } + // 网络资源下载,排除开发工具临时路径格式: http://tmp/ + if (/^http(s)?:\/\//.test(src) && !/^http:\/\/tmp\//.test(src)) { + let tempFilePath = tempFileMap.get(src); + try { + if (!tempFilePath) throw tempFilePath; + // 检查临时文件是否存在 + fs.accessSync(tempFilePath); + } catch (err) { + tempFilePath = (await downloadFileSync(src)).tempFilePath; + // 缓存临时文件 + tempFileMap.set(src, tempFilePath); + } + data = fs.readFileSync(tempFilePath, "utf8"); + } else { + data = fs.readFileSync(src, "utf8"); + } + // eslint-disable-next-line no-param-reassign + if (!colors) colors = {}; // 默认值 + if (/(fill|stroke)=".*?"/.test(data)) { + let index = 0; + data = data.replace(/(fill|stroke)=".*?"/g, (matched) => { + // 获取原本颜色 + const matchedColor = matched.slice(matched.indexOf('"') + 1, -1); + // 设置替换颜色 + const replaceColor = + colors[index++] || + colors[matchedColor] || + color || + matchedColor; + + if (/fill/.test(matched)) return `fill="${replaceColor}"`; + if (/stroke/.test(matched)) return `stroke="${replaceColor}"`; + return `fill="${replaceColor}"`; + }); + } + // 设置默认底色 + const defaultColor = + colors["#000"] || colors["#000000"] || colors.black || color; + // svg 标签是否包含底色 + if ( + defaultColor && + !/fill=".*?"/.test(data.slice(0, data.indexOf(">"))) + ) { + data = data.replace(/ \ No newline at end of file diff --git a/yanzhu-ui-app/miniprogram/components/svg-icon/index.wxss b/yanzhu-ui-app/miniprogram/components/svg-icon/index.wxss new file mode 100644 index 00000000..313a54da --- /dev/null +++ b/yanzhu-ui-app/miniprogram/components/svg-icon/index.wxss @@ -0,0 +1,7 @@ +.svg-icon { + display: block; +} + +.image-hover { + opacity: 0.7; +} \ No newline at end of file diff --git a/yanzhu-ui-app/miniprogram/config.js b/yanzhu-ui-app/miniprogram/config.js index 00ff1138..49db8652 100644 --- a/yanzhu-ui-app/miniprogram/config.js +++ b/yanzhu-ui-app/miniprogram/config.js @@ -2,9 +2,15 @@ module.exports = { timeout: 60000, appId: "wx46466c7828eede2b", - //baseUrl: 'https://xiangguan.sxyanzhu.com/wechat', - baseUrl: 'http://127.0.0.1:8080', - baseImgUrl: 'https://xiangguan.sxyanzhu.com', + baseUrl: "https://xiangguan.sxyanzhu.com/wechat", + //baseUrl: 'http://127.0.0.1:8080', + baseImgUrl: "https://xiangguan.sxyanzhu.com", //baseImgUrl: 'http://127.0.0.1:9300', - noSecuritys: ['/code', '/auth/wxLogin', '/auth/getMaOpenId', '/auth/getMaPhoneNumber', '/auth/maLogin'] -}; \ No newline at end of file + noSecuritys: [ + "/code", + "/auth/wxLogin", + "/auth/getMaOpenId", + "/auth/getMaPhoneNumber", + "/auth/maLogin", + ], +}; diff --git a/yanzhu-ui-app/miniprogram/images/svg/add.svg b/yanzhu-ui-app/miniprogram/images/svg/add.svg new file mode 100644 index 00000000..aee93118 --- /dev/null +++ b/yanzhu-ui-app/miniprogram/images/svg/add.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/yanzhu-ui-app/miniprogram/images/svg/add2.svg b/yanzhu-ui-app/miniprogram/images/svg/add2.svg new file mode 100644 index 00000000..ca26a0c6 --- /dev/null +++ b/yanzhu-ui-app/miniprogram/images/svg/add2.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/yanzhu-ui-app/miniprogram/pageage/project_checked/list/index.json b/yanzhu-ui-app/miniprogram/pageage/project_checked/list/index.json index 965b8e80..e1c274e2 100644 --- a/yanzhu-ui-app/miniprogram/pageage/project_checked/list/index.json +++ b/yanzhu-ui-app/miniprogram/pageage/project_checked/list/index.json @@ -1,4 +1,6 @@ { - "usingComponents": {}, + "usingComponents": { + "svg-icon": "/components/svg-icon/index" + }, "navigationStyle": "custom" } \ No newline at end of file diff --git a/yanzhu-ui-app/miniprogram/pageage/project_checked/list/index.wxml b/yanzhu-ui-app/miniprogram/pageage/project_checked/list/index.wxml index dab400d2..204f7590 100644 --- a/yanzhu-ui-app/miniprogram/pageage/project_checked/list/index.wxml +++ b/yanzhu-ui-app/miniprogram/pageage/project_checked/list/index.wxml @@ -59,6 +59,8 @@ 暂无数据 + + diff --git a/yanzhu-ui-app/miniprogram/project.private.config.json b/yanzhu-ui-app/miniprogram/project.private.config.json index 0f0f0e7e..25b6fca5 100644 --- a/yanzhu-ui-app/miniprogram/project.private.config.json +++ b/yanzhu-ui-app/miniprogram/project.private.config.json @@ -19,25 +19,6 @@ "ignoreDevUnusedFiles": true, "bigPackageSizeSupport": false }, - "condition": { - "miniprogram": { - "list": [ - { - "name": "pages/project_qr/index", - "pathName": "pages/project_qr/index", - "query": "QRPID=133&SIGID=3&PARID=109", - "launchMode": "default", - "scene": null - }, - { - "name": "", - "pathName": "pages/login/login", - "query": "proId=1", - "launchMode": "default", - "scene": null - } - ] - } - }, + "condition": {}, "libVersion": "3.8.9" } \ No newline at end of file