mirror of
https://github.com/pure-admin/vue-pure-admin.git
synced 2025-11-21 14:13:36 +08:00
Merge branch 'main' of github.com:pure-admin/vue-pure-admin into gitee
This commit is contained in:
@@ -1,11 +1,13 @@
|
||||
<script setup lang="ts">
|
||||
import { match } from "pinyin-pro";
|
||||
import { useI18n } from "vue-i18n";
|
||||
import { useRouter } from "vue-router";
|
||||
import { cloneDeep } from "@pureadmin/utils";
|
||||
import SearchResult from "./SearchResult.vue";
|
||||
import SearchFooter from "./SearchFooter.vue";
|
||||
import { useNav } from "@/layout/hooks/useNav";
|
||||
import { transformI18n } from "@/plugins/i18n";
|
||||
import { ref, computed, shallowRef } from "vue";
|
||||
import { cloneDeep, isAllEmpty } from "@pureadmin/utils";
|
||||
import { useDebounceFn, onKeyStroke } from "@vueuse/core";
|
||||
import { usePermissionStoreHook } from "@/store/modules/permission";
|
||||
import Search from "@iconify-icons/ri/search-line";
|
||||
@@ -23,6 +25,7 @@ const { device } = useNav();
|
||||
const emit = defineEmits<Emits>();
|
||||
const props = withDefaults(defineProps<Props>(), {});
|
||||
const router = useRouter();
|
||||
const { locale } = useI18n();
|
||||
|
||||
const keyword = ref("");
|
||||
const scrollbarRef = ref();
|
||||
@@ -62,12 +65,19 @@ function flatTree(arr) {
|
||||
/** 查询 */
|
||||
function search() {
|
||||
const flatMenusData = flatTree(menusData.value);
|
||||
resultOptions.value = flatMenusData.filter(
|
||||
menu =>
|
||||
keyword.value &&
|
||||
transformI18n(menu.meta?.title)
|
||||
.toLocaleLowerCase()
|
||||
.includes(keyword.value.toLocaleLowerCase().trim())
|
||||
resultOptions.value = flatMenusData.filter(menu =>
|
||||
keyword.value
|
||||
? transformI18n(menu.meta?.title)
|
||||
.toLocaleLowerCase()
|
||||
.includes(keyword.value.toLocaleLowerCase().trim()) ||
|
||||
(locale.value === "zh" &&
|
||||
!isAllEmpty(
|
||||
match(
|
||||
transformI18n(menu.meta?.title).toLocaleLowerCase(),
|
||||
keyword.value.toLocaleLowerCase().trim()
|
||||
)
|
||||
))
|
||||
: false
|
||||
);
|
||||
if (resultOptions.value?.length > 0) {
|
||||
activePath.value = resultOptions.value[0].path;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<script setup lang="ts">
|
||||
import { useI18n } from "vue-i18n";
|
||||
import { transformI18n } from "@/plugins/i18n";
|
||||
import { useResizeObserver } from "@vueuse/core";
|
||||
import { useEpThemeStoreHook } from "@/store/modules/epTheme";
|
||||
import { useRenderIcon } from "@/components/ReIcon/src/hooks";
|
||||
@@ -7,8 +7,6 @@ import { ref, computed, getCurrentInstance, onMounted } from "vue";
|
||||
import enterOutlined from "@/assets/svg/enter_outlined.svg?component";
|
||||
import Bookmark2Line from "@iconify-icons/ri/bookmark-2-line";
|
||||
|
||||
const { t } = useI18n();
|
||||
|
||||
interface optionsItem {
|
||||
path: string;
|
||||
meta?: {
|
||||
@@ -98,7 +96,9 @@ defineExpose({ handleScroll });
|
||||
@mouseenter="handleMouse(item)"
|
||||
>
|
||||
<component :is="useRenderIcon(item.meta?.icon ?? Bookmark2Line)" />
|
||||
<span class="result-item-title">{{ t(item.meta?.title) }}</span>
|
||||
<span class="result-item-title">
|
||||
{{ transformI18n(item.meta?.title) }}
|
||||
</span>
|
||||
<enterOutlined />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -146,6 +146,24 @@ export default {
|
||||
meta: {
|
||||
title: $t("menus.hsInfiniteScroll")
|
||||
}
|
||||
},
|
||||
{
|
||||
path: "/able/sensitive",
|
||||
name: "Sensitive",
|
||||
component: () => import("@/views/able/sensitive.vue"),
|
||||
meta: {
|
||||
title: $t("menus.hsSensitive"),
|
||||
extraIcon: "IF-pure-iconfont-new svg"
|
||||
}
|
||||
},
|
||||
{
|
||||
path: "/able/pinyin",
|
||||
name: "Pinyin",
|
||||
component: () => import("@/views/able/pinyin.vue"),
|
||||
meta: {
|
||||
title: $t("menus.hsPinyin"),
|
||||
extraIcon: "IF-pure-iconfont-new svg"
|
||||
}
|
||||
}
|
||||
]
|
||||
} as RouteConfigsTable;
|
||||
|
||||
34
src/views/able/pinyin.vue
Normal file
34
src/views/able/pinyin.vue
Normal file
@@ -0,0 +1,34 @@
|
||||
<script setup lang="ts">
|
||||
import { html } from "pinyin-pro";
|
||||
|
||||
defineOptions({
|
||||
name: "Pinyin"
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<el-card shadow="never">
|
||||
<template #header>
|
||||
<div class="card-header">
|
||||
<span class="font-medium">汉语拼音</span>
|
||||
</div>
|
||||
</template>
|
||||
<p v-html="html('带 音 调')" />
|
||||
<p class="mt-2" v-html="html('不 带 音 调', { toneType: 'none' })" />
|
||||
<p class="mt-2 custom" v-html="html('自 定 义 样 式')" />
|
||||
</el-card>
|
||||
</template>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.custom {
|
||||
/* 汉字的样式 */
|
||||
:deep(.py-chinese-item) {
|
||||
color: #409eff;
|
||||
}
|
||||
|
||||
/* 拼音的样式 */
|
||||
:deep(.py-pinyin-item) {
|
||||
color: #f56c6c;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
43
src/views/able/sensitive.vue
Normal file
43
src/views/able/sensitive.vue
Normal file
@@ -0,0 +1,43 @@
|
||||
<script setup lang="ts">
|
||||
import { ref } from "vue";
|
||||
import Mint from "mint-filter";
|
||||
|
||||
defineOptions({
|
||||
name: "Sensitive"
|
||||
});
|
||||
|
||||
// 自定义敏感词字典
|
||||
const words = ["脑残", "废物", "白痴", "三八", "智障"];
|
||||
|
||||
const modelValue = ref();
|
||||
const mint = new Mint(words);
|
||||
|
||||
function onInput() {
|
||||
modelValue.value = mint.filter(modelValue.value).text;
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<el-card shadow="never">
|
||||
<template #header>
|
||||
<div class="card-header">
|
||||
<span class="font-medium">敏感词过滤</span>
|
||||
</div>
|
||||
</template>
|
||||
<div class="flex flex-wrap gap-2 my-2">
|
||||
<span>自定义敏感词</span>
|
||||
<el-tag
|
||||
v-for="(word, index) in words"
|
||||
:key="index"
|
||||
type="danger"
|
||||
class="mx-1"
|
||||
effect="dark"
|
||||
round
|
||||
>
|
||||
{{ word }}
|
||||
</el-tag>
|
||||
</div>
|
||||
<el-input v-model="modelValue" @input="onInput" />
|
||||
<p class="mt-2">{{ modelValue }}</p>
|
||||
</el-card>
|
||||
</template>
|
||||
Reference in New Issue
Block a user