Skip to content

Commit 4fcc93b

Browse files
committed
style: optimize refresh and installation animations
1 parent 56b7832 commit 4fcc93b

File tree

1 file changed

+48
-4
lines changed

1 file changed

+48
-4
lines changed

src/page/npm-registry/index.vue

Lines changed: 48 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,26 @@
77
</TDLink>
88
</template>
99
<template #action>
10-
<RefreshIcon class="action" @click="getRegistry" :style="{ color: getTheme(refreshIconType) }" />
10+
<RefreshIcon :class="[refreshIconType === 'warning' ? 'action_refresh' : 'action']" @click="getRegistry"
11+
:style="{ color: getTheme(refreshIconType) }" />
1112
</template>
1213
</TDTable>
14+
1315
<TDDivider>
1416
<DogeIcon />
1517
</TDDivider>
18+
1619
<TDTable :columns="registryColumns" :data="registryData" rowKey="key" bordered>
1720
<template #registry="{ row }">
18-
<TDLink target="_blank" :href="row.registry" theme="success" underline>{{ row.registry }}</TDLink>
21+
<TDLink target="_blank" :href="row.registry"
22+
:theme="installDesktopIconType.key === row.key ? installDesktopIconType.type : 'success'" underline>
23+
{{ row.registry }}
24+
</TDLink>
1925
</template>
2026
<template #action="{ row }">
21-
<InstallDesktopIcon class="action" @click="installNpmRegistry(row)"
27+
<InstallDesktopIcon class="action" @click="installNpmRegistry(row)" :class="[installDesktopIconType.type === 'warning' &&
28+
installDesktopIconType.key === row.key
29+
? 'action_install' : 'action']"
2230
:style="{ color: installDesktopIconType.key === row.key ? getTheme(installDesktopIconType.type) : '' }" />
2331
</template>
2432
</TDTable>
@@ -44,7 +52,7 @@ enum RefreshIconType {
4452
}
4553
4654
const refreshIconType = ref<RefreshIconType>(RefreshIconType.WAITING);
47-
const installDesktopIconType = ref<{ key: number; type: RefreshIconType }>({ key: 0, type: RefreshIconType.WAITING });
55+
const installDesktopIconType = ref<{ key: number; type: RefreshIconType }>({ key: -1, type: RefreshIconType.WAITING });
4856
4957
const currentColumns: TableProps['columns'] = [
5058
{ colKey: 'registry', title: '当前源', align: 'center' },
@@ -87,6 +95,8 @@ const executeCmdCommand = async (cmdCommand: string): Promise<string> => await i
8795
* @description get npm registry
8896
*/
8997
const getRegistry = async () => {
98+
if (refreshIconType.value === RefreshIconType.LOADING) return;
99+
90100
refreshIconType.value = RefreshIconType.LOADING;
91101
const registry = await executeCmdCommand('npm config get registry');
92102
if (registry === 'failed') {
@@ -104,6 +114,8 @@ const getRegistry = async () => {
104114
* @description npm registry install
105115
*/
106116
const installNpmRegistry = async (row: TableData) => {
117+
if (installDesktopIconType.value.type === RefreshIconType.LOADING) return;
118+
107119
installDesktopIconType.value = { key: row.key, type: RefreshIconType.LOADING };
108120
const installNpmRegistryType = await executeCmdCommand(`npm config set registry ${row.registry}`);
109121
@@ -129,4 +141,36 @@ onMounted(() => getRegistry());
129141
.action {
130142
cursor: pointer;
131143
}
144+
145+
@keyframes spin {
146+
from {
147+
transform: rotate(0deg);
148+
}
149+
150+
to {
151+
transform: rotate(360deg);
152+
}
153+
}
154+
155+
.action_refresh {
156+
animation: spin 1s linear infinite;
157+
}
158+
159+
@keyframes moveDown {
160+
0% {
161+
transform: translateY(0);
162+
}
163+
164+
50% {
165+
transform: translateY(4px);
166+
}
167+
168+
100% {
169+
transform: translateY(0);
170+
}
171+
}
172+
173+
.action_install {
174+
animation: moveDown 1s linear infinite;
175+
}
132176
</style>

0 commit comments

Comments
 (0)