@@ -108,7 +111,7 @@ import siteIcon from '@/icon/plink/site.svg';
import tagIcon from '@/icon/plink/tag.svg';
import urlIcon from '@/icon/plink/uri.svg';
import userIcon from '@/icon/plink/user.svg';
-
+import { getDictValue } from '@/util';
definePage({
name: 'plink',
@@ -137,18 +140,32 @@ const rules: any = {
}
const pList = ref
([])
const formRef = ref(null)
+const tagColorList: any = ref([])
async function getPlinkList() {
const res = await $http.plink.getPlinkList()
+
+ const list: Array = []
+ // 对res.data.tags进行去重
+ res.data.forEach((i: any) => {
+ const t = getTags(i.tagname)
+ t.forEach((ii: string) => {
+ if (!list.includes(ii)) list.push(ii)
+ })
+ });
+
+ tagColorList.value = list.map((i: string) => {
+ return {
+ tag: i,
+ color: getRandomFromPalette()
+ }
+ })
pList.value = res.data
- // for (let i = 0; i < 20; i++) {
- // pList.value.push(res.data[0])
- // }
}
function getTags(str: any) {
str = str.replaceAll(',', ',')
let tags = str.split(',').slice(0, 3)
tags.forEach((tag: any, idx: number) => {
- tags[idx] = tag.trim().slice(0, 3)
+ tags[idx] = tag.trim().slice(0, 4)
});
return tags
}
@@ -178,7 +195,23 @@ function submitPut() {
})
}
+// 生成一个随机的鲜艳颜色,和白色能对比
+function getRandomFromPalette(): string {
+ const hue = Math.floor(Math.random() * 360);
+ return hslToHex(hue, 80, 50);
+}
+
+function hslToHex(h: number, s: number, l: number): any {
+ l /= 100;
+ const a = s * Math.min(l, 1 - l) / 100;
+ const f = (n: number) => {
+ const k = (n + h / 30) % 12;
+ const color = l - a * Math.max(Math.min(k - 3, 9 - k, 1), -1);
+ return Math.round(255 * color).toString(16).padStart(2, '0');
+ }
+ return `#${f(0)}${f(8)}${f(4)}`;
+}
onMounted(() => {
boxStyle.value = {
height: window.innerHeight - nav.navH - 1 + 'px',
@@ -197,11 +230,8 @@ onMounted(() => {
100% {
transform: rotate(360deg);
}
-
}
-
-
.zhuan {
animation: spin 1.5s linear infinite;
}
diff --git a/src/views/blog/index.vue b/src/views/blog/index.vue
index 2bcc6b2..e5e39ab 100644
--- a/src/views/blog/index.vue
+++ b/src/views/blog/index.vue
@@ -4,11 +4,13 @@
- {{ i.name }}
-
-
- {{ i.total || 0 }}篇文章
+ class="relative cate flex my-6 py-6 px-8 justify-between text-xl font-bold bg-white shadow rounded cursor-pointer">
+
+
+ {{ i.name }}
+
+
+ {{ i.total || 0 }}
@@ -36,12 +38,14 @@
{{ item.title }}
{{ item.pro }}
-
@@ -49,13 +53,14 @@
diff --git a/yarn.lock b/yarn.lock
index 6ce263f..4fb31e5 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -3609,6 +3609,11 @@ npm-run-all2@^8.0.4:
shell-quote "^1.7.3"
which "^5.0.0"
+nprogress@^0.2.0:
+ version "0.2.0"
+ resolved "https://registry.npmmirror.com/nprogress/-/nprogress-0.2.0.tgz#cb8f34c53213d895723fcbab907e9422adbcafb1"
+ integrity sha512-I19aIingLgR1fmhftnbWWO3dXc0hSxqHQHQb3H8m+K3TnEn/iSeTZZOyvKXWqQESMwuUVnatlCnZdLBZZt2VSA==
+
nth-check@^2.0.1:
version "2.1.1"
resolved "https://registry.npmmirror.com/nth-check/-/nth-check-2.1.1.tgz#c9eab428effce36cd6b92c924bdb000ef1f1ed1d"