Skip to content

Commit ae4846b

Browse files
committed
docs: 修改商店页面
1 parent 76c779a commit ae4846b

File tree

5 files changed

+128
-136
lines changed

5 files changed

+128
-136
lines changed

docs/.vitepress/theme/custom.css

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -18,22 +18,3 @@
1818
--vp-c-brand-3: var(--vp-c-blue-3);
1919
--vp-c-brand-soft: var(--vp-c-blue-soft);
2020
}
21-
22-
:root {
23-
--button-background: #9ca3af0d;
24-
--button-background-hover: #9ca3af1a;
25-
--button-background-active: #0099ff0d;
26-
--button-color-active: #0099ff;
27-
--divider: rgba(60, 60, 67, 0.12);
28-
--card-border: rgba(82, 82, 89, 0.32);
29-
--card-hover: #09f;
30-
--card-icon: #000;
31-
--card-des: #3c3c43;
32-
--card-tag: #9ca3af2b;
33-
--card-button: #f6f6f7;
34-
}
35-
html.dark {
36-
--card-icon: #fff;
37-
--card-button: #9ca3af0d;
38-
--card-des: #9ca3af;
39-
}

docs/store/components/Card.vue

Lines changed: 39 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<script setup lang="ts">
22
import { ref, onMounted } from "vue";
3+
import type { DataItem } from "./StoreList.vue";
34
import IconVerify from "./icons/IconVerify.vue";
45
import IconGithub from "./icons/IconGithub.vue";
56
import IconAuthor from "./icons/IconAuthor.vue";
@@ -8,41 +9,42 @@ import IconModule from "./icons/IconModules.vue";
89
import IconVersion from "./icons/IconVersion.vue";
910
import IconLicense from "./icons/IconLicense.vue";
1011
import IconCopy from "./icons/IconCopy.vue";
11-
const props = defineProps(["item"]);
12-
const version = ref("0.0.0");
13-
const openGithub = (url: string) => {
14-
window.open(url);
12+
13+
const props = defineProps<{ item: DataItem }>();
14+
15+
const version = ref("unknown");
16+
17+
const openHomepageLink = () => {
18+
window.open(props.item.homepage);
1519
};
16-
const copyText = () => {
17-
let input = document.createElement("textarea");
18-
input.style.cssText =
19-
"position: absolute; top: 0; left: 0; opacity: 0; z-index: -10;";
20-
input.value = "pip install " + props.item.pypi_name;
21-
document.body.appendChild(input);
22-
input.select();
23-
document.execCommand("copy");
24-
document.body.removeChild(input);
20+
21+
const copyInstallLink = async () => {
22+
await navigator.clipboard.writeText("pip install " + props.item.pypi_name);
2523
};
24+
2625
onMounted(async () => {
27-
const _ = (
26+
const v = (
2827
await (
2928
await fetch("https://pypi.org/pypi/" + props.item.pypi_name + "/json")
3029
).json()
3130
)["info"]["version"];
32-
!!_ && (version.value = _);
31+
if (!!v) {
32+
version.value = v;
33+
}
3334
});
3435
</script>
36+
3537
<template>
3638
<div class="card">
3739
<div class="card-top">
3840
<div class="card-head">
3941
<div class="card-title">
40-
{{ item.name
41-
}}<IconVerify v-if="item.is_official" style="margin-left: 0.1rem" />
42+
{{ item.name }}
43+
<IconVerify v-if="item.is_official" style="margin-left: 0.1rem" />
4244
</div>
4345
<div
4446
class="card-github"
45-
@click="openGithub(item.homepage)"
47+
@click="openHomepageLink"
4648
v-if="!!item.homepage"
4749
>
4850
<IconGithub />
@@ -87,31 +89,30 @@ onMounted(async () => {
8789
</div>
8890
</div>
8991
</div>
90-
<div class="card-button" @click="copyText()">
92+
<div class="card-button" @click="copyInstallLink">
9193
点击复制安装命令
92-
<div style="margin-left: 0.3rem">
93-
<IconCopy />
94-
</div>
94+
<IconCopy style="margin-left: 0.3rem" />
9595
</div>
9696
</div>
9797
</template>
98+
9899
<style scoped>
99100
.card {
100-
border: 1px solid var(--card-border);
101-
border-radius: 0.5rem;
101+
border: 1px solid var(--vp-c-bg-soft);
102+
border-radius: 12px;
103+
background-color: var(--vp-c-bg-soft);
102104
padding: 1.5rem;
103105
width: 100%;
104106
height: 100%;
105107
transition: border-color 0.25s;
106-
cursor: pointer;
107108
display: flex;
108109
flex-direction: column;
109110
justify-content: space-between;
110111
max-width: 332px;
111112
}
112113
113114
.card:hover {
114-
border: 1px solid var(--card-hover);
115+
border: 1px solid var(--vp-c-bg-elv);
115116
}
116117
117118
.card-head {
@@ -129,15 +130,15 @@ onMounted(async () => {
129130
130131
.card-github {
131132
cursor: pointer;
132-
fill: var(--card-icon);
133+
fill: var(--vp-c-neutral);
133134
}
134135
135136
.card-github:hover {
136-
fill: var(--card-hover);
137+
fill: var(--vp-c-brand-1);
137138
}
138139
139140
.card-des {
140-
color: var(--card-des);
141+
color: var(--vp-c-text-2);
141142
opacity: 0.7;
142143
font-size: 0.875rem;
143144
line-height: 1.25rem;
@@ -156,7 +157,7 @@ onMounted(async () => {
156157
.card-tag {
157158
margin: 0.5rem 0.5rem 0 0;
158159
padding: 0 0.5rem;
159-
background-color: var(--card-tag);
160+
background-color: var(--vp-c-default-soft);
160161
border-radius: 0.1875rem;
161162
}
162163
@@ -179,22 +180,24 @@ onMounted(async () => {
179180
align-items: center;
180181
}
181182
183+
.card-icon {
184+
width: 16px;
185+
height: 16px;
186+
}
187+
182188
.card-button {
183189
display: flex;
184190
justify-content: center;
185191
align-items: center;
186192
width: 100%;
187193
padding: 0.4rem 1rem;
188-
background-color: var(--card-button);
194+
background-color: var(--vp-c-default-soft);
189195
border-radius: 0.5rem;
190196
cursor: pointer;
191197
}
192198
193199
.card-button:hover {
194-
color: var(--card-hover);
195-
}
196-
197-
.card-button:hover {
198-
fill: var(--card-hover);
200+
color: var(--vp-c-brand-1);
201+
fill: var(--vp-c-brand-1);
199202
}
200203
</style>

docs/store/components/Pagination.vue

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,30 @@
11
<script setup lang="ts">
22
import { computed } from "vue";
3-
const props = defineProps(["modelValue", "pageTotal"]);
4-
const emit = defineEmits(["update:modelValue"]);
3+
4+
const props = defineProps<{ modelValue: number; pageTotal: number }>();
5+
const emit = defineEmits<{
6+
"update:modelValue": [v: number];
7+
}>();
8+
59
const onPrev = () => {
6-
if (props.modelValue <= 1) return; // 限制上一页翻页按钮的边界
10+
if (props.modelValue <= 1) return;
711
emit("update:modelValue", props.modelValue - 1);
812
};
913
const onNext = () => {
10-
if (props.modelValue >= props.pageTotal) return; // 限制下一页翻页按钮的边界
14+
if (props.modelValue >= props.pageTotal) return;
1115
emit("update:modelValue", props.modelValue + 1);
1216
};
1317
const setPageNum = (pageNum: number | string) => {
14-
if (typeof pageNum !== "number") return; //如果pageNum不是数值类型则返回
15-
if (pageNum < 1) return; // 限制上一页翻页按钮的边界
16-
if (pageNum > props.pageTotal) return; // 限制下一页翻页按钮的边界
18+
if (typeof pageNum !== "number") return;
19+
if (pageNum < 1) return;
20+
if (pageNum > props.pageTotal) return;
1721
emit("update:modelValue", pageNum);
1822
};
23+
1924
const genPageArray = (current: number, total: number, size: number) => {
20-
let arr: Array<string | number> = [];
25+
let arr: (string | number)[] = [];
2126
if (total < size + 2) {
22-
arr = Array.from({ length: total }, (v, k) => k + 1);
27+
arr = Array.from({ length: total }, (_, k) => k + 1);
2328
} else if (current < size - 2) {
2429
arr = Array.from(
2530
(function* gen(i, l) {
@@ -56,17 +61,18 @@ const genPageArray = (current: number, total: number, size: number) => {
5661
}
5762
return arr;
5863
};
59-
const pageArrayLg = computed(() => {
64+
65+
const pageArrayLg = computed<(number | string)[]>(() => {
6066
const current = props.modelValue;
6167
const total = props.pageTotal;
6268
return genPageArray(current, total, 17);
6369
});
64-
const pageArrayMd = computed(() => {
70+
const pageArrayMd = computed<(number | string)[]>(() => {
6571
const current = props.modelValue;
6672
const total = props.pageTotal;
6773
return genPageArray(current, total, 10);
6874
});
69-
const pageArraySm = computed(() => {
75+
const pageArraySm = computed<(number | string)[]>(() => {
7076
const current = props.modelValue;
7177
const total = props.pageTotal;
7278
return genPageArray(current, total, 6);
@@ -157,15 +163,15 @@ const pageArraySm = computed(() => {
157163
padding: 0rem 0.25rem;
158164
align-items: center;
159165
justify-content: center;
160-
background-color: var(--card-button);
166+
background-color: var(--vp-c-bg-soft);
161167
border-radius: 0.25rem;
162168
cursor: pointer;
163169
}
164170
165171
.paper-item:hover,
166172
.paper-item.active {
167-
background-color: var(--button-background-active);
173+
background-color: var(--vp-c-brand-soft);
168174
--un-text-opacity: 1;
169-
color: var(--button-color-active);
175+
color: var(--vp-c-brand-1);
170176
}
171177
</style>

0 commit comments

Comments
 (0)