From f26f29d84e0a68831a6af14dab3eec5500496d2e Mon Sep 17 00:00:00 2001 From: spring <2396852758@qq.com> Date: 星期三, 28 五月 2025 16:48:52 +0800 Subject: [PATCH] 初始化项目 --- uni_modules/uni-icons/components/uni-icons/uni-icons.uvue | 91 +++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 91 insertions(+), 0 deletions(-) diff --git a/uni_modules/uni-icons/components/uni-icons/uni-icons.uvue b/uni_modules/uni-icons/components/uni-icons/uni-icons.uvue new file mode 100644 index 0000000..398678e --- /dev/null +++ b/uni_modules/uni-icons/components/uni-icons/uni-icons.uvue @@ -0,0 +1,91 @@ +<template> + <text class="uni-icons" :style="styleObj"> + <slot>{{unicode}}</slot> + </text> +</template> + +<script> + import { fontData, IconsDataItem } from './uniicons_file' + + /** + * Icons 鍥炬爣 + * @description 鐢ㄤ簬灞曠ず icon 鍥炬爣 + * @tutorial https://ext.dcloud.net.cn/plugin?id=28 + * @property {Number} size 鍥炬爣澶у皬 + * @property {String} type 鍥炬爣鍥炬锛屽弬鑰冪ず渚� + * @property {String} color 鍥炬爣棰滆壊 + * @property {String} customPrefix 鑷畾涔夊浘鏍� + * @event {Function} click 鐐瑰嚮 Icon 瑙﹀彂浜嬩欢 + */ + export default { + name: "uni-icons", + props: { + type: { + type: String, + default: '' + }, + color: { + type: String, + default: '#333333' + }, + size: { + type: Object, + default: 16 + }, + fontFamily: { + type: String, + default: '' + } + }, + data() { + return {}; + }, + computed: { + unicode() : string { + let codes = fontData.find((item : IconsDataItem) : boolean => { return item.font_class == this.type }) + if (codes !== null) { + return codes.unicode + } + return '' + }, + iconSize() : string { + const size = this.size + if (typeof size == 'string') { + const reg = /^[0-9]*$/g + return reg.test(size as string) ? '' + size + 'px' : '' + size; + // return '' + this.size + } + return this.getFontSize(size as number) + }, + styleObj() : UTSJSONObject { + if (this.fontFamily !== '') { + return { color: this.color, fontSize: this.iconSize, fontFamily: this.fontFamily } + } + return { color: this.color, fontSize: this.iconSize } + } + }, + created() { }, + methods: { + /** + * 瀛椾綋澶у皬 + */ + getFontSize(size : number) : string { + return size + 'px'; + }, + }, + } +</script> + +<style scoped> + @font-face { + font-family: UniIconsFontFamily; + src: url('./uniicons.ttf'); + } + + .uni-icons { + font-family: UniIconsFontFamily; + font-size: 18px; + font-style: normal; + color: #333; + } +</style> -- Gitblit v1.9.3