This commit is contained in:
孟帅
2024-03-07 20:08:56 +08:00
parent 6dd8cbadad
commit 0fbc1ad47c
246 changed files with 9441 additions and 2293 deletions

View File

@@ -0,0 +1,70 @@
<template>
<div>
<n-space vertical>
<n-card
:segmented="{ content: true, footer: true }"
header-style="padding:10px"
footer-style="padding:10px"
>
<template #header> 渐变文字 </template>
<template #header-extra>
<n-gradient-text type="success"> 渐变文字成了 </n-gradient-text>
</template>
<n-space vertical>
<n-gradient-text style="white-space: normal" type="success">
<p
>苏轼1037年1月8日-1101年8月24日字子瞻和仲号铁冠道人东坡居士世称苏东坡苏仙汉族眉州眉山四川省眉山市祖籍河北栾城北宋著名文学家书法家画家历史治水名人苏轼是北宋中期文坛领袖在诗散文画等方面取得很高成就文纵横恣肆诗题材广阔清新豪健善用夸张比喻独具风格与黄庭坚并称苏黄词开豪放一派与辛弃疾同是豪放派代表并称苏辛散文著述宏富豪放自如与欧阳修并称欧苏唐宋八大家之一苏轼善书宋四家之一擅长文人画尤擅墨竹怪石枯木等与韩愈柳宗元和欧阳修合称千古文章四大家作品有东坡七集东坡易传东坡乐府潇湘竹石图卷古木怪石图卷</p
>
</n-gradient-text>
</n-space>
</n-card>
<n-card
:segmented="{ content: true, footer: true }"
header-style="padding:10px"
footer-style="padding:10px"
>
<template #header> 渐变文字 </template>
<template #header-extra>
<n-gradient-text type="warning"> 渐变文字成了 </n-gradient-text>
</template>
<n-space vertical>
<n-gradient-text style="white-space: normal" type="warning">
<p
>白居易772846字乐天号香山居士又号醉吟先生祖籍太原到其曾祖父时迁居下邽生于河南新郑是唐代伟大的现实主义诗人唐代三大诗人之一白居易与元稹共同倡导新乐府运动世称元白与刘禹锡并称刘白白居易的诗歌题材广泛形式多样语言平易通俗诗魔诗王之称官至翰林学士左赞善大夫公元846年白居易在洛阳逝世葬于香山白氏长庆集传世代表诗作有长恨歌卖炭翁琵琶行</p
>
</n-gradient-text>
</n-space>
</n-card>
<n-card
:segmented="{ content: true, footer: true }"
header-style="padding:10px"
footer-style="padding:10px"
>
<template #header> 自定义颜色 </template>
<template #header-extra>
<n-gradient-text gradient="linear-gradient(90deg, red 0%, green 50%, blue 100%)">
渐变文字成了
</n-gradient-text>
</template>
<n-space vertical>
<n-gradient-text
gradient="linear-gradient(90deg, red 0%, green 50%, blue 100%)"
style="white-space: normal"
>
<p
>杜甫712770字子美自号少陵野老世称杜工部杜少陵汉族河南府巩县今河南省巩义市唐代伟大的现实主义诗人杜甫被世人尊为诗圣其诗被称为诗史杜甫与李白合称李杜为了跟另外两位诗人李商隐与杜牧即小李杜区别开来杜甫与李白又合称大李杜他忧国忧民人格高尚他的约1400余首诗被保留了下来诗艺精湛在中国古典诗歌中备受推崇影响深远759-766年间曾居成都后世有杜甫草堂纪念</p
>
</n-gradient-text>
</n-space>
</n-card>
</n-space>
</div>
</template>
<script lang="ts" setup></script>
<style lang="less" scoped>
p {
font-size: 14px;
line-height: 2;
text-indent: 28px;
}
</style>

View File

@@ -0,0 +1,94 @@
<template>
<div>
<n-card title="高亮" style="margin-bottom: 10px">
<n-text>
<p style="line-height: 2" v-html="compData1.text"></p>
</n-text>
</n-card>
<n-card title="自定义颜色" style="margin-bottom: 10px">
<n-text>
<p style="line-height: 2" v-html="compData2.text"></p>
</n-text>
</n-card>
<n-card title="自定义样式">
<n-text>
<p style="line-height: 2" v-html="compData3.text"></p>
</n-text>
</n-card>
</div>
</template>
<script lang="ts" setup>
import highHtml from '@/utils/highHtml';
import { reactive, onMounted } from 'vue';
const text =
'先帝创业未半而中道崩殂,今天下三分,益州疲弊,此诚危急存亡之秋也。然侍卫之臣不懈于内,忠志之士忘身于外者,盖追先帝之殊遇,欲报之于陛下也。诚宜开张圣听,以光先帝遗德,恢弘志士之气,不宜妄自菲薄,引喻失义,以塞忠谏之路也。\n' +
'\n' +
'  宫中府中,俱为一体;陟罚臧否,不宜异同。若有作奸犯科及为忠善者,宜付有司论其刑赏,以昭陛下平明之理,不宜偏私,使内外异法也。\n' +
'\n' +
'  侍中、侍郎郭攸之、费祎、董允等,此皆良实,志虑忠纯,是以先帝简拔以遗陛下。愚以为宫中之事,事无大小,悉以咨之,然后施行,必能裨补阙漏,有所广益。\n' +
'\n' +
'  将军向宠,性行淑均,晓畅军事,试用于昔日,先帝称之曰能,是以众议举宠为督。愚以为营中之事,悉以咨之,必能使行阵和睦,优劣得所。\n' +
'\n' +
'  亲贤臣,远小人,此先汉所以兴隆也;亲小人,远贤臣,此后汉所以倾颓也。先帝在时,每与臣论此事,未尝不叹息痛恨于桓、灵也。侍中、尚书、长史、参军,此悉贞良死节之臣,愿陛下亲之信之,则汉室之隆,可计日而待也。\n' +
'\n' +
'  臣本布衣,躬耕于南阳,苟全性命于乱世,不求闻达于诸侯。先帝不以臣卑鄙,猥自枉屈,三顾臣于草庐之中,咨臣以当世之事,由是感激,遂许先帝以驱驰。后值倾覆,受任于败军之际,奉命于危难之间,尔来二十有一年矣。\n' +
'\n' +
'  先帝知臣谨慎,故临崩寄臣以大事也。受命以来,夙夜忧叹,恐托付不效,以伤先帝之明;故五月渡泸,深入不毛。今南方已定,兵甲已足,当奖率三军,北定中原,庶竭驽钝,攘除奸凶,兴复汉室,还于旧都。此臣所以报先帝而忠陛下之职分也。至于斟酌损益,进尽忠言,则攸之、祎、允之任也。\n' +
'\n' +
'  愿陛下托臣以讨贼兴复之效,不效,则治臣之罪,以告先帝之灵。若无兴德之言,则责攸之、祎、允等之慢,以彰其咎;陛下亦宜自谋,以咨诹善道,察纳雅言,深追先帝遗诏。臣不胜受恩感激。今当远离,临表涕零,不知所言';
const compData1 = reactive({
text: '',
keys: ['先帝', '先汉', '苟'],
});
const compData2 = reactive({
text: '',
keys: [
{
keyword: '先帝',
bgColor: 'red',
color: '#fff',
renderHighlightKeyword: (str) => {
return `<span class="high" style="padding:2px 5px;margin:0 5px;border-radius:3px;background-color: #3a5ccc;color: #ffffff">${str}</span>`;
},
},
{
keyword: '中',
bgColor: '#b4d5ff',
color: '#fff',
renderHighlightKeyword: (str) => {
return `<span class="high" style="padding:2px 5px;margin:0 5px;border-radius:3px;background-color: #e96656;color: #ffffff">${str}</span>`;
},
},
{ keyword: '苟', bgColor: '#b4d5ff', color: '#fff' },
],
});
const compData3 = reactive({
text: '',
keys: [
{
keyword: '之',
bgColor: 'red',
color: '#fff',
style: { padding: '2px 5px', margin: '0 5px', 'border-radius': '3px' },
},
{ keyword: '先帝', bgColor: '#b4d5ff', color: '#fff' },
{ keyword: '苟', bgColor: '#b4d5ff', color: '#fff' },
],
});
onMounted(() => {
compData1.text = highHtml(text, compData1.keys).highText;
compData2.text = highHtml(text, compData2.keys).highText;
compData3.text = highHtml(text, compData3.keys).highText;
});
</script>
<style lang="less">
.high {
&:hover {
background-color: seagreen !important;
cursor: pointer;
}
}
</style>

View File

@@ -0,0 +1,50 @@
<template>
<n-card
:segmented="{ content: true, footer: true }"
header-style="padding:10px"
footer-style="padding:10px"
>
<template #header> 敏感词汇验证 </template>
<n-space vertical>
<n-space>
<n-tag
:type="idx % 2 ? 'success' : 'warning'"
:key="idx"
v-for="(item, idx) in compData.keys"
>{{ item }}</n-tag
>
</n-space>
<n-input
placeholder="输入需要验证的词汇文本"
type="textarea"
size="small"
v-model:value="compData.text"
:autosize="{ minRows: 3, maxRows: 5 }"
@update:value="compData.handleUpdateText"
/>
<n-space>
<n-tag
:type="idx % 2 ? 'error' : 'info'"
:key="idx"
v-for="(item, idx) in compData.words"
>{{ item }}</n-tag
>
</n-space>
</n-space>
</n-card>
</template>
<script lang="ts" setup>
import { reactive } from 'vue';
import Mint from 'mint-filter';
const compData = reactive({
keys: ['敏感词', '胡萝卜', '香蕉', '苹果'],
text: '',
words: [],
});
const mint = new Mint(compData.keys);
compData.handleUpdateText = (value: string | [string, string]) => {
const test = mint.filter(value);
compData.words = test.words;
};
</script>

View File

@@ -0,0 +1,102 @@
<template>
<div>
<n-space vertical>
<n-card
:segmented="{ content: true, footer: true }"
header-style="padding:10px"
footer-style="padding:10px"
>
<template #header> 字符拼音 </template>
<template #header-extra> 陋室铭唐代刘禹锡 </template>
<div class="pinyin">
<template v-for="item in compData.items1">
<div class="pinyin-item" :key="idx" v-for="(todo, idx) in item">
<span class="py">{{ todo.py }}</span>
<span class="hz">{{ todo.hz }}</span> </div
><br />
</template>
</div>
</n-card>
<n-card
:segmented="{ content: true, footer: true }"
header-style="padding:10px"
footer-style="padding:10px"
>
<template #header> 字符拼音 </template>
<template #header-extra> 李贺小传李商隐唐代 </template>
<div class="pinyin">
<template v-for="item in compData.items2">
<div class="pinyin-item" :key="idx" v-for="(todo, idx) in item">
<span class="py">{{ todo.py }}</span>
<span class="hz">{{ todo.hz }}</span> </div
><br />
</template>
</div>
</n-card>
</n-space>
</div>
</template>
<script lang="ts" setup>
import { reactive } from 'vue';
import { pinyin } from 'pinyin-pro';
interface WordInfo {
hz: string;
py: string;
}
const text1 = [
' 山不在高,有仙则名。水不在深,有龙则灵。斯是陋室,惟吾德馨。苔痕上阶绿,草色入帘青。谈笑有鸿儒,往来无白丁。可以调素琴,阅金经。无丝竹之乱耳,无案牍之劳形。南阳诸葛庐,西蜀子云亭。孔子云:何陋之有?',
];
const text2 = [
' 京兆杜牧为李长吉集序,状长吉之奇甚尽,世传之。长吉姊嫁王氏者,语长吉之事尤备。',
' 长吉细瘦,通眉,长指爪,能苦吟疾书。最先为昌黎韩愈所知。所与游者,王参元、杨敬之、权璩、崔植辈为密,每旦日出与诸公游,未尝得题然后为诗,如他人思量牵合,以及程限为意。恒从小奚奴,骑距驉,背一古破锦囊,遇有所得,即书投囊中。及暮归.太夫人使婢受囊出之,见所书多.辄曰:“是儿要当呕出心乃已尔。”上灯,与食。长吉从婢取书,研墨叠纸足成之,投他囊中。非大醉及吊丧日率如此,过亦不复省。王、杨辈时复来探取写去。长吉往往独骑往还京、洛,所至或时有著,随弃之,故沈子明家所余四卷而已。',
' 长吉将死时,忽昼见一绯衣人,驾赤虬,持一板,书若太古篆或霹雳石文者,云当召长吉。长吉了不能读,欻下榻叩头,言:“阿㜷老且病,贺不愿去。”绯衣人笑曰:“帝成白玉楼,立召君为记。天上差乐,不苦也。”长吉独泣,边人尽见之。少之,长吉气绝。常所居窗中,勃勃有烟气,闻行车嘒管之声。太夫人急止人哭,待之如炊五斗黍许时,长吉竟死。王氏姊非能造作谓长吉者,实所见如此。',
' 呜呼,天苍苍而高也,上果有帝耶?帝果有苑囿、宫室、观阁之玩耶?苟信然,则天之高邈,帝之尊严,亦宜有人物文采愈此世者,何独眷眷于长吉而使其不寿耶?噫,又岂世所谓才而奇者,不独地上少,即天上亦不多耶?长吉生二十七年,位不过奉礼太常,时人亦多排摈毁斥之,又岂才而奇者,帝独重之,而人反不重耶?又岂人见会胜帝耶?',
];
const createHzPy = (text: string[]): WordInfo[][] => {
const items: WordInfo[][] = [];
text.forEach((item) => {
const todo: WordInfo[] = [];
for (let i = 0; i < item.length; i++) {
const tg = item.charAt(i);
todo.push({ hz: tg, py: pinyin(tg)[0] });
}
items.push(todo);
});
return items;
};
const compData = reactive({
items1: createHzPy(text1),
items2: createHzPy(text2),
});
</script>
<style lang="less" scoped>
.pinyin {
&-item {
line-height: 100%;
width: 42px;
text-align: center;
display: inline-block;
.py {
clear: both;
font-size: 12px;
font-weight: normal;
float: left;
width: 42px;
}
.hz {
clear: both;
margin-bottom: 10px;
text-align: center;
float: left;
font-size: 16px;
height: 36px;
width: 42px;
line-height: 36px;
}
}
}
</style>