feat: 菜单图标 icon 支持使用在线图标

This commit is contained in:
xiaoxian521 2022-11-08 12:05:07 +08:00
parent b2081b3481
commit d11398274a
9 changed files with 15 additions and 22 deletions

View File

@ -3,7 +3,7 @@ import iconifyIconOnline from "./src/iconifyIconOnline";
import iconSelect from "./src/Select.vue";
import fontIcon from "./src/iconfont";
/** 离线图标组件 */
/** 本地图标组件 */
const IconifyIconOffline = iconifyIconOffline;
/** 在线图标组件 */
const IconifyIconOnline = iconifyIconOnline;

View File

@ -3,7 +3,8 @@ import { h, defineComponent, Component } from "vue";
import { IconifyIconOnline, IconifyIconOffline, FontIcon } from "../index";
/**
* fontawesome45+iconfontremixiconelement-plus的iconssvg
* `iconfont` `svg` `iconify`
* @see {@link https://yiming_chang.gitee.io/pure-admin-doc/pages/icon/}
* @param icon
* @param attrs iconType
* @returns Component
@ -34,11 +35,12 @@ export function useRenderIcon(icon: any, attrs?: iconType): Component {
// svg
return icon;
} else {
// 通过是否存在 : 符号来判断是在线还是本地图标,存在即是在线图标,反之
return defineComponent({
name: "Icon",
render() {
const IconifyIcon =
attrs && attrs["online"] ? IconifyIconOnline : IconifyIconOffline;
icon && icon.includes(":") ? IconifyIconOnline : IconifyIconOffline;
return h(IconifyIcon, {
icon: icon,
...attrs

View File

@ -161,7 +161,7 @@ addIcon("unExpand", UnExpand);
import LocationCompany from "@iconify-icons/carbon/location-company";
addIcon("location-company", LocationCompany);
// Iconify Icon在Vue里离线使用用于内网环境https://docs.iconify.design/icon-components/vue/offline.html
// Iconify Icon在Vue里本地使用用于内网环境https://docs.iconify.design/icon-components/vue/offline.html
export default defineComponent({
name: "IconifyIconOffline",
components: { IconifyIcon },

View File

@ -11,7 +11,6 @@ export interface iconType {
horizontalAlign?: boolean;
verticalAlign?: boolean;
align?: string;
online?: boolean;
onLoad?: Function;
includes?: Function;

View File

@ -62,9 +62,7 @@ function onBack() {
clearable
v-model="ruleForm.verifyCode"
:placeholder="t('login.smsVerifyCode')"
:prefix-icon="
useRenderIcon('ri:shield-keyhole-line', { online: true })
"
:prefix-icon="useRenderIcon('ri:shield-keyhole-line')"
/>
<el-button
:disabled="isDisabled"

View File

@ -110,9 +110,7 @@ function onBack() {
clearable
v-model="ruleForm.verifyCode"
:placeholder="t('login.smsVerifyCode')"
:prefix-icon="
useRenderIcon('ri:shield-keyhole-line', { online: true })
"
:prefix-icon="useRenderIcon('ri:shield-keyhole-line')"
/>
<el-button
:disabled="isDisabled"

View File

@ -83,9 +83,7 @@ function onBack() {
clearable
v-model="ruleForm.verifyCode"
:placeholder="t('login.smsVerifyCode')"
:prefix-icon="
useRenderIcon('ri:shield-keyhole-line', { online: true })
"
:prefix-icon="useRenderIcon('ri:shield-keyhole-line')"
/>
<el-button
:disabled="isDisabled"

View File

@ -207,9 +207,7 @@ watch(imgCode, value => {
clearable
v-model="ruleForm.verifyCode"
:placeholder="t('login.verifyCode')"
:prefix-icon="
useRenderIcon('ri:shield-keyhole-line', { online: true })
"
:prefix-icon="useRenderIcon('ri:shield-keyhole-line')"
>
<template v-slot:append>
<ReImageVerify v-model:code="imgCode" />

View File

@ -240,21 +240,21 @@ function onHide() {
<el-button-group>
<el-button
type="primary"
:icon="useRenderIcon('fa:plus-square-o', { online: true })"
:icon="useRenderIcon('fa:plus-square-o')"
@click="onAdd"
>
{{ t("buttons.hsadd") }}
</el-button>
<el-button
type="primary"
:icon="useRenderIcon('fa:folder-open-o', { online: true })"
:icon="useRenderIcon('fa:folder-open-o')"
@click="onExpand"
>
{{ t("buttons.hsexpendAll") }}
</el-button>
<el-button
type="primary"
:icon="useRenderIcon('fa:folder-o', { online: true })"
:icon="useRenderIcon('fa:folder-o')"
@click="onUnExpand"
>
{{ t("buttons.hscollapseAll") }}
@ -301,7 +301,7 @@ function onHide() {
<el-button
link
type="primary"
:icon="useRenderIcon('fa:plus-square-o', { online: true })"
:icon="useRenderIcon('fa:plus-square-o')"
@click="onAddChild(row)"
>
新增子类型
@ -310,7 +310,7 @@ function onHide() {
v-show="row.model"
link
type="primary"
:icon="useRenderIcon('fa:cog', { online: true })"
:icon="useRenderIcon('fa:cog')"
@click="onDeploy(row)"
>
字典配置