写配置的纯逻辑在 shared/providers.ts。删除前 subscriptionReferences 同时查 直接 use 和经订阅副本(共用缓存文件 path)的间接引用,有被引用的就拦下并列出 策略组。订阅不允许改名:名字被 use: 和副本引用,同步所有引用不如删了重建。 页面还没挂进 App.vue 的导航,由集成者统一加。
112 lines
2.6 KiB
Vue
112 lines
2.6 KiB
Vue
<script setup lang="ts">
|
|
/**
|
|
* 订阅列表。每行一个订阅:名字、当前线路数、上次更新时间、健康检查开没开。
|
|
*
|
|
* 只管显示和选中,不碰任何数据。
|
|
*/
|
|
|
|
defineProps<{
|
|
/** 一行要显示的东西,由页面按配置和运行时数据拼好 */
|
|
rows: Array<{
|
|
name: string
|
|
/** 当前有多少条线路。null 表示内核没给数据(没连接,或这个订阅还没拉取过) */
|
|
lines: number | null
|
|
/** 上次拉取成功的时刻。null 表示不知道或从没拉取过 */
|
|
updated: Date | null
|
|
/** 健康检查开没开 */
|
|
healthCheck: boolean
|
|
}>
|
|
}>()
|
|
const selected = defineModel<string | null>('selected', { required: true })
|
|
|
|
const pad = (n: number) => String(n).padStart(2, '0')
|
|
|
|
function formatUpdated(at: Date): string {
|
|
return `${pad(at.getMonth() + 1)}-${pad(at.getDate())} ${pad(at.getHours())}:${pad(at.getMinutes())}`
|
|
}
|
|
</script>
|
|
|
|
<template>
|
|
<ol class="rows">
|
|
<li v-for="row in rows" :key="row.name">
|
|
<button
|
|
type="button"
|
|
:class="['line', selected === row.name && 'is-on']"
|
|
@click="selected = row.name"
|
|
>
|
|
<span class="name">{{ row.name }}</span>
|
|
<span class="lines mono">
|
|
<template v-if="row.lines !== null">{{ row.lines }} 条</template>
|
|
<template v-else>—</template>
|
|
</span>
|
|
<span class="updated mono">{{ row.updated ? formatUpdated(row.updated) : '—' }}</span>
|
|
<span :class="['hc', !row.healthCheck && 'is-off']">
|
|
{{ row.healthCheck ? '健康检查' : '—' }}
|
|
</span>
|
|
</button>
|
|
</li>
|
|
</ol>
|
|
</template>
|
|
|
|
<style scoped>
|
|
.rows {
|
|
list-style: none;
|
|
margin: 0;
|
|
padding: 0;
|
|
border: 1px solid var(--c-border);
|
|
border-radius: var(--r-md);
|
|
background: var(--c-surface);
|
|
overflow: hidden;
|
|
}
|
|
|
|
.rows li + li {
|
|
border-top: 1px solid var(--c-border);
|
|
}
|
|
|
|
.line {
|
|
width: 100%;
|
|
display: grid;
|
|
grid-template-columns: minmax(0, 1fr) 4rem 6.5rem 4.5rem;
|
|
align-items: center;
|
|
gap: var(--s-3);
|
|
padding: var(--s-3) var(--s-4);
|
|
border: none;
|
|
background: none;
|
|
cursor: pointer;
|
|
text-align: left;
|
|
}
|
|
|
|
.line:hover {
|
|
background: var(--c-surface-sunken);
|
|
}
|
|
|
|
.line.is-on {
|
|
background: var(--c-accent-soft);
|
|
}
|
|
|
|
.name {
|
|
min-width: 0;
|
|
overflow: hidden;
|
|
text-overflow: ellipsis;
|
|
white-space: nowrap;
|
|
}
|
|
|
|
.lines,
|
|
.updated {
|
|
text-align: right;
|
|
font-size: var(--t-sm);
|
|
font-variant-numeric: tabular-nums;
|
|
color: var(--c-text-soft);
|
|
}
|
|
|
|
.hc {
|
|
text-align: right;
|
|
font-size: var(--t-xs);
|
|
color: var(--c-text-soft);
|
|
}
|
|
|
|
.hc.is-off {
|
|
color: var(--c-text-faint);
|
|
}
|
|
</style>
|