From 011d9f980b615f42d687903ef6e7dfe53e52fec7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B6=85=E7=BA=A7=E6=97=A0=E6=95=8C=E6=95=B0=E7=A0=81?= =?UTF-8?q?=E6=9A=B4=E9=BE=99=E6=88=98=E5=A3=AB?= <67992313+konodioda727@users.noreply.github.com> Date: Fri, 18 Oct 2024 15:11:54 +0800 Subject: [PATCH] =?UTF-8?q?chore:=20=E6=9B=B4=E6=8D=A2=E5=9B=BE=E6=A0=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .eslintignore | 2 ++ .husky/pre-commit | 2 +- iconfont.json | 3 +- package.json | 2 +- src/app.config.ts | 7 ++--- src/common/components/Comment/index.tsx | 2 +- .../QuestionDetail/QuestionDetail.tsx | 10 ++---- src/common/components/iconfont/helper.d.ts | 2 ++ src/common/components/iconfont/helper.js | 9 ++++++ src/common/components/iconfont/index.d.ts | 13 ++++++++ src/common/components/iconfont/index.js | 7 +++++ src/common/components/iconfont/index.qq.js | 16 ++++++++++ src/common/components/iconfont/index.weapp.js | 16 ++++++++++ src/common/components/iconfont/qq/qq.js | 31 +++++++++++++++++++ src/common/components/iconfont/qq/qq.json | 4 +++ src/common/components/iconfont/qq/qq.qml | 23 ++++++++++++++ src/common/components/iconfont/qq/qq.qss | 3 ++ src/common/components/iconfont/weapp/weapp.js | 18 +++++------ .../components/iconfont/weapp/weapp.wxml | 10 ++++-- src/modules/login/components/Popper.tsx | 1 - .../notification/components/TabBar.tsx | 18 +++++------ src/pages/evaluateInfo/index.tsx | 1 - yarn.lock | 18 +++++------ 23 files changed, 171 insertions(+), 47 deletions(-) create mode 100644 src/common/components/iconfont/helper.d.ts create mode 100644 src/common/components/iconfont/helper.js create mode 100644 src/common/components/iconfont/index.d.ts create mode 100644 src/common/components/iconfont/index.js create mode 100644 src/common/components/iconfont/index.qq.js create mode 100644 src/common/components/iconfont/index.weapp.js create mode 100644 src/common/components/iconfont/qq/qq.js create mode 100644 src/common/components/iconfont/qq/qq.json create mode 100644 src/common/components/iconfont/qq/qq.qml create mode 100644 src/common/components/iconfont/qq/qq.qss diff --git a/.eslintignore b/.eslintignore index eb4b947..2577a9d 100644 --- a/.eslintignore +++ b/.eslintignore @@ -6,7 +6,9 @@ dist-ssr *.local weapp.js babel.config.js +app.config.ts ec-canvas *.js VirtualList.tsx +src/common/components/iconfont diff --git a/.husky/pre-commit b/.husky/pre-commit index 5a4e88c..84d8071 100644 --- a/.husky/pre-commit +++ b/.husky/pre-commit @@ -2,4 +2,4 @@ export GIT_TERMINAL_PROMPT=0 . "$(dirname -- "$0")/common.sh" -yarn lint +yarn lint --fix diff --git a/iconfont.json b/iconfont.json index 9b77538..85debed 100644 --- a/iconfont.json +++ b/iconfont.json @@ -3,5 +3,6 @@ "save_dir": "./src/common/components/iconfont", "use_rpx": false, "trim_icon_prefix": "icon", - "default_icon_size": 18 + "default_icon_size": 18, + "platforms": ["weapp", "qq"] } diff --git a/package.json b/package.json index 5fe14f8..1d1f4af 100644 --- a/package.json +++ b/package.json @@ -111,7 +111,7 @@ "taro-plugin-compiler-optimization": "^1.0.4", "thread-loader": "^4.0.4", "ts-node": "^10.9.2", - "typescript": "^5.6.2", + "typescript": "^5.6.3", "weapp-tailwindcss": "^3.5.2", "webpack": "^5.94.0" }, diff --git a/src/app.config.ts b/src/app.config.ts index 1ecaf9c..3691910 100644 --- a/src/app.config.ts +++ b/src/app.config.ts @@ -1,3 +1,5 @@ +import { useGlobalIconFont } from './common/components/iconfont/helper'; + export default defineAppConfig({ pages: [ 'pages/login/index', @@ -25,10 +27,7 @@ export default defineAppConfig({ pages: ['pages/history/index'], }, ], - // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment - usingComponents: Object.assign({ - iconfont: '/src/common/components/iconfont', - }), + usingComponents: Object.assign(useGlobalIconFont()), tabBar: { custom: true, list: [ diff --git a/src/common/components/Comment/index.tsx b/src/common/components/Comment/index.tsx index bac615c..9e01f7c 100644 --- a/src/common/components/Comment/index.tsx +++ b/src/common/components/Comment/index.tsx @@ -8,8 +8,8 @@ import './style.scss'; import { useCourseStore } from '@/pages/main/store/store'; +import IconFont from '@/common/components/iconfont'; import { CourseDetailsType, PublisherDetailsType } from '@/pages/main/store/types'; -import IconFont from '../iconfont'; import ShowStar from '../showStar/showStar'; interface CommentProps extends CommentInfo { diff --git a/src/common/components/QuestionDetail/QuestionDetail.tsx b/src/common/components/QuestionDetail/QuestionDetail.tsx index 092031b..70b45ec 100644 --- a/src/common/components/QuestionDetail/QuestionDetail.tsx +++ b/src/common/components/QuestionDetail/QuestionDetail.tsx @@ -1,19 +1,13 @@ +import '@/common/components/QuestionDetail/QuestionDetail'; import { Image, Text, View } from '@tarojs/components'; import React, { useEffect, useState } from 'react'; -import './index.scss'; - -// eslint-disable-next-line import/first import answericon from '@/common/assets/img/publishQuestion/answer.png'; -// eslint-disable-next-line import/first import askicon from '@/common/assets/img/publishQuestion/ask.png'; -// eslint-disable-next-line import/first +import IconFont from '@/common/components/iconfont'; import PublishHeader from '@/common/components/PublishHeader/PublishHeader'; -// eslint-disable-next-line import/first import { useCourseStore } from '@/pages/main/store/store'; -import IconFont from '../iconfont'; - interface IUser { avatar: string; id: number; diff --git a/src/common/components/iconfont/helper.d.ts b/src/common/components/iconfont/helper.d.ts new file mode 100644 index 0000000..24a9a53 --- /dev/null +++ b/src/common/components/iconfont/helper.d.ts @@ -0,0 +1,2 @@ +/* eslint-disable */ +export declare var useGlobalIconFont: () => { iconfont: string }; diff --git a/src/common/components/iconfont/helper.js b/src/common/components/iconfont/helper.js new file mode 100644 index 0000000..8e69747 --- /dev/null +++ b/src/common/components/iconfont/helper.js @@ -0,0 +1,9 @@ +/* eslint-disable */ +const useGlobalIconFont = () => { + return { + iconfont: `common/components/iconfont/${process.env.TARO_ENV}/${process.env.TARO_ENV}`, + }; +}; + +// es modules is unavaiable. +module.exports.useGlobalIconFont = useGlobalIconFont; diff --git a/src/common/components/iconfont/index.d.ts b/src/common/components/iconfont/index.d.ts new file mode 100644 index 0000000..7dd3121 --- /dev/null +++ b/src/common/components/iconfont/index.d.ts @@ -0,0 +1,13 @@ +/* eslint-disable */ +import React, { FunctionComponent } from 'react'; + +interface Props { + name: 'guanfangbanben' | 'tiwen' | 'comment' | 'like' | 'wechat' | 'yanjing' | 'yanjing1' | 'xiaxue'; + size?: number; + color?: string | string[]; + style?: React.CSSProperties; +} + +declare const IconFont: FunctionComponent; + +export default IconFont; diff --git a/src/common/components/iconfont/index.js b/src/common/components/iconfont/index.js new file mode 100644 index 0000000..9236f4b --- /dev/null +++ b/src/common/components/iconfont/index.js @@ -0,0 +1,7 @@ +/* eslint-disable */ + +const IconFont = () => { + return null; +}; + +export default IconFont; diff --git a/src/common/components/iconfont/index.qq.js b/src/common/components/iconfont/index.qq.js new file mode 100644 index 0000000..64976a0 --- /dev/null +++ b/src/common/components/iconfont/index.qq.js @@ -0,0 +1,16 @@ +/* eslint-disable */ + +import React from 'react'; + + +const IconFont = (props) => { + const { name, size, color, style } = props; + + return ; +}; + +IconFont.defaultProps = { + size: 18, +}; + +export default IconFont; diff --git a/src/common/components/iconfont/index.weapp.js b/src/common/components/iconfont/index.weapp.js new file mode 100644 index 0000000..64976a0 --- /dev/null +++ b/src/common/components/iconfont/index.weapp.js @@ -0,0 +1,16 @@ +/* eslint-disable */ + +import React from 'react'; + + +const IconFont = (props) => { + const { name, size, color, style } = props; + + return ; +}; + +IconFont.defaultProps = { + size: 18, +}; + +export default IconFont; diff --git a/src/common/components/iconfont/qq/qq.js b/src/common/components/iconfont/qq/qq.js new file mode 100644 index 0000000..3652c7b --- /dev/null +++ b/src/common/components/iconfont/qq/qq.js @@ -0,0 +1,31 @@ +Component({ + properties: { + // guanfangbanben | tiwen | comment | like | wechat | yanjing | yanjing1 | xiaxue + name: { + type: String, + }, + // string | string[] + color: { + type: null, + observer: function(color) { + this.setData({ + isStr: typeof color === 'string', + }); + } + }, + size: { + type: Number, + value: 18, + observer: function(size) { + this.setData({ + svgSize: size, + }); + }, + }, + }, + data: { + svgSize: 18, + quot: '"', + isStr: true, + }, +}); diff --git a/src/common/components/iconfont/qq/qq.json b/src/common/components/iconfont/qq/qq.json new file mode 100644 index 0000000..a89ef4d --- /dev/null +++ b/src/common/components/iconfont/qq/qq.json @@ -0,0 +1,4 @@ +{ + "component": true, + "usingComponents": {} +} diff --git a/src/common/components/iconfont/qq/qq.qml b/src/common/components/iconfont/qq/qq.qml new file mode 100644 index 0000000..ea3100a --- /dev/null +++ b/src/common/components/iconfont/qq/qq.qml @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/common/components/iconfont/qq/qq.qss b/src/common/components/iconfont/qq/qq.qss new file mode 100644 index 0000000..9f68d1a --- /dev/null +++ b/src/common/components/iconfont/qq/qq.qss @@ -0,0 +1,3 @@ +.icon { + background-repeat: no-repeat; +} diff --git a/src/common/components/iconfont/weapp/weapp.js b/src/common/components/iconfont/weapp/weapp.js index 6a95c67..1a24450 100644 --- a/src/common/components/iconfont/weapp/weapp.js +++ b/src/common/components/iconfont/weapp/weapp.js @@ -1,23 +1,23 @@ Component({ properties: { - // comment | like | wechat | yanjing | yanjing1 | xiaxue + // guanfangbanben | tiwen | comment | like | wechat | yanjing | yanjing1 | xiaxue name: { type: String, }, // string | string[] color: { type: null, - observer: function (color) { + observer: function(color) { this.setData({ colors: this.fixColor(), isStr: typeof color === 'string', }); - }, + } }, size: { type: Number, value: 18, - observer: function (size) { + observer: function(size) { this.setData({ svgSize: size, }); @@ -31,7 +31,7 @@ Component({ isStr: true, }, methods: { - fixColor: function () { + fixColor: function() { var color = this.data.color; var hex2rgb = this.hex2rgb; @@ -43,7 +43,7 @@ Component({ return item.indexOf('#') === 0 ? hex2rgb(item) : item; }); }, - hex2rgb: function (hex) { + hex2rgb: function(hex) { var rgb = []; hex = hex.substr(1); @@ -52,12 +52,12 @@ Component({ hex = hex.replace(/(.)/g, '$1$1'); } - hex.replace(/../g, function (color) { + hex.replace(/../g, function(color) { rgb.push(parseInt(color, 0x10)); return color; }); return 'rgb(' + rgb.join(',') + ')'; - }, - }, + } + } }); diff --git a/src/common/components/iconfont/weapp/weapp.wxml b/src/common/components/iconfont/weapp/weapp.wxml index 7df168e..ca879cb 100644 --- a/src/common/components/iconfont/weapp/weapp.wxml +++ b/src/common/components/iconfont/weapp/weapp.wxml @@ -1,8 +1,14 @@ + + + + + + - + - + diff --git a/src/modules/login/components/Popper.tsx b/src/modules/login/components/Popper.tsx index 78fb18d..4e5d97b 100644 --- a/src/modules/login/components/Popper.tsx +++ b/src/modules/login/components/Popper.tsx @@ -20,7 +20,6 @@ const Content: React.FC<{ onClose: () => void }> = memo(({ onClose }) => ( x diff --git a/src/modules/notification/components/TabBar.tsx b/src/modules/notification/components/TabBar.tsx index 4067198..7c71236 100644 --- a/src/modules/notification/components/TabBar.tsx +++ b/src/modules/notification/components/TabBar.tsx @@ -1,7 +1,7 @@ import { Text, View } from '@tarojs/components'; import { memo } from 'react'; -import { AtIcon } from 'taro-ui'; +import IconFont from '@/common/components/iconfont'; import { uniqueKey } from '@/common/utils'; interface TabBarProps { @@ -12,15 +12,15 @@ interface TabBarProps { const Tabs: { name: string; icon: string }[] = [ { name: '提问', - icon: 'icon-tiwen', + icon: 'tiwen', }, { name: '点赞', - icon: 'icon-like', + icon: 'like', }, { name: '官方', - icon: 'icon-guanfangbanben', + icon: 'guanfangbanben', }, ]; @@ -29,14 +29,14 @@ const TabBar: React.FC = memo(({ tab, setTab }) => ( {Tabs.map((item) => ( - { setTab(item.name); }} - > + > {item.name} diff --git a/src/pages/evaluateInfo/index.tsx b/src/pages/evaluateInfo/index.tsx index 89bb0ba..f3dd8a5 100644 --- a/src/pages/evaluateInfo/index.tsx +++ b/src/pages/evaluateInfo/index.tsx @@ -1,4 +1,3 @@ -/* eslint-disable simple-import-sort/imports */ /* eslint-disable @typescript-eslint/no-misused-promises */ /* eslint-disable @typescript-eslint/no-explicit-any */ diff --git a/yarn.lock b/yarn.lock index b98aba6..cd5f0f7 100644 --- a/yarn.lock +++ b/yarn.lock @@ -11348,7 +11348,7 @@ __metadata: taro-ui: "npm:^3.3.0" thread-loader: "npm:^4.0.4" ts-node: "npm:^10.9.2" - typescript: "npm:^5.6.2" + typescript: "npm:^5.6.3" weapp-tailwindcss: "npm:^3.5.2" webpack: "npm:^5.94.0" zustand: "npm:^4.5.5" @@ -15654,23 +15654,23 @@ __metadata: languageName: node linkType: hard -"typescript@npm:^5.6.2": - version: 5.6.2 - resolution: "typescript@npm:5.6.2" +"typescript@npm:^5.6.3": + version: 5.6.3 + resolution: "typescript@npm:5.6.3" bin: tsc: bin/tsc tsserver: bin/tsserver - checksum: 10c0/3ed8297a8c7c56b7fec282532503d1ac795239d06e7c4966b42d4330c6cf433a170b53bcf93a130a7f14ccc5235de5560df4f1045eb7f3550b46ebed16d3c5e5 + checksum: 10c0/44f61d3fb15c35359bc60399cb8127c30bae554cd555b8e2b46d68fa79d680354b83320ad419ff1b81a0bdf324197b29affe6cc28988cd6a74d4ac60c94f9799 languageName: node linkType: hard -"typescript@patch:typescript@npm%3A^5.6.2#optional!builtin": - version: 5.6.2 - resolution: "typescript@patch:typescript@npm%3A5.6.2#optional!builtin::version=5.6.2&hash=379a07" +"typescript@patch:typescript@npm%3A^5.6.3#optional!builtin": + version: 5.6.3 + resolution: "typescript@patch:typescript@npm%3A5.6.3#optional!builtin::version=5.6.3&hash=379a07" bin: tsc: bin/tsc tsserver: bin/tsserver - checksum: 10c0/e6c1662e4852e22fe4bbdca471dca3e3edc74f6f1df043135c44a18a7902037023ccb0abdfb754595ca9028df8920f2f8492c00fc3cbb4309079aae8b7de71cd + checksum: 10c0/ac8307bb06bbfd08ae7137da740769b7d8c3ee5943188743bb622c621f8ad61d244767480f90fbd840277fbf152d8932aa20c33f867dea1bb5e79b187ca1a92f languageName: node linkType: hard