refactor: 整理代码,使用 Less

This commit is contained in:
2026-07-21 21:17:43 +08:00
parent 7ec0ad36ba
commit e491dd78bf
7 changed files with 355 additions and 307 deletions
+45 -11
View File
@@ -172,7 +172,38 @@ function handleSwitchTab(tab) {
</n-config-provider>
</template>
<style>
<style lang="less">
:root {
--frost-primary-color: #0ea5a0;
--frost-primary-color-hover: #0b8c87;
--frost-primary-color-pressed: #0b8c87;
--frost-primary-color-suppl: #0ea5a0;
--frost-success-color: #22c55e;
--frost-success-color-hover: #16a34a;
--frost-success-color-pressed: #15803d;
--frost-success-color-suppl: #22c55e;
--frost-warning-color: #f59e0b;
--frost-warning-color-hover: #d97706;
--frost-warning-color-pressed: #b45309;
--frost-warning-color-suppl: #f59e0b;
--frost-error-color: #ef4444;
--frost-error-color-hover: #dc2626;
--frost-error-color-pressed: #b91c1c;
--frost-error-color-suppl: #ef4444;
--frost-info-color: #3b82f6;
--frost-info-color-hover: #2563eb;
--frost-info-color-pressed: #1d4ed8;
--frost-info-color-suppl: #3b82f6;
--frost-color-text-tertiary: #999;
--frost-color-topic: #d25a00;
--frost-color-bg-light: #f5f7fa;
--frost-color-bg-item: #fafafa;
--frost-shadow-black-4: rgba(0, 0, 0, 0.04);
--frost-shadow-black-6: rgba(0, 0, 0, 0.06);
--frost-shadow-black-8: rgba(0, 0, 0, 0.08);
--frost-shadow-black-12: rgba(0, 0, 0, 0.12);
}
html, body, #app {
margin: 0;
padding: 0;
@@ -189,13 +220,13 @@ html, body, #app {
padding: 0 0 16px 0;
height: calc(100vh - 50px);
overflow: hidden;
}
.dashboard-content {
&.dashboard-content {
display: flex;
flex-direction: column;
overflow: hidden;
}
}
.dashboard-scroll-wrapper {
flex: 1;
@@ -210,7 +241,6 @@ html, body, #app {
gap: 12px;
height: 100%;
min-width: 0;
}
.publish-panel,
.messages-panel {
@@ -232,7 +262,6 @@ html, body, #app {
}
@media (max-width: 900px) {
.message-center-layout {
grid-template-columns: 1fr;
}
}
@@ -242,22 +271,27 @@ html, body, #app {
scrollbar-width: thin;
scrollbar-color: rgba(144, 147, 153, 0.5) transparent;
}
::-webkit-scrollbar {
width: 8px;
height: 8px;
}
::-webkit-scrollbar-track {
&-track {
background-color: transparent;
}
::-webkit-scrollbar-thumb {
&-thumb {
background-color: rgba(144, 147, 153, 0.5);
border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
&:hover {
background-color: rgba(144, 147, 153, 0.8);
}
::-webkit-scrollbar-corner {
}
&-corner {
display: none;
background-color: transparent;
}
}
</style>
+23 -23
View File
@@ -216,7 +216,7 @@ async function handleImportFile(event) {
</n-layout-sider>
</template>
<style scoped>
<style scoped lang="less">
:deep(.sidebar-scroll-container) {
height: 100%;
overflow: hidden !important;
@@ -242,7 +242,7 @@ async function handleImportFile(event) {
.sidebar-logo {
width: 32px;
height: 32px;
background: #0ea5a0;
background: var(--frost-primary-color);
border-radius: 6px;
display: flex;
align-items: center;
@@ -278,15 +278,19 @@ async function handleImportFile(event) {
margin-bottom: 4px;
border: 1px solid transparent;
transition: all 0.15s;
}
.server-item:hover {
&:hover {
background: var(--n-color-hover);
.server-actions {
opacity: 1;
}
}
.server-item.active {
&.active {
background: var(--n-color-pressed);
border-color: #0ea5a0;
border-color: var(--frost-primary-color);
}
}
.server-item-top {
@@ -310,24 +314,20 @@ async function handleImportFile(event) {
transition: opacity 0.15s;
}
.server-item:hover .server-actions {
opacity: 1;
}
.server-url {
margin-top: 4px;
overflow: hidden;
}
.server-url :deep(.n-tag) {
:deep(.n-tag) {
max-width: 100%;
}
.server-url :deep(.n-tag__content) {
:deep(.n-tag__content) {
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
}
.server-bottom {
display: flex;
@@ -347,23 +347,23 @@ async function handleImportFile(event) {
height: 6px;
border-radius: 50%;
margin-right: 2px;
&.connected {
background: var(--frost-success-color);
}
.status-dot.connected {
background: #22c55e;
}
.status-dot.connecting {
background: #f59e0b;
&.connecting {
background: var(--frost-warning-color);
animation: pulse 1s infinite;
}
.status-dot.disconnected {
background: #999;
&.disconnected {
background: var(--frost-color-text-tertiary);
}
.status-dot.error {
background: #ef4444;
&.error {
background: var(--frost-error-color);
}
}
@keyframes pulse {
+17 -15
View File
@@ -189,49 +189,51 @@ async function handleToggleConnection(srv) {
</div>
</template>
<style scoped>
<style scoped lang="less">
.dashboard {
max-width: 900px;
}
.server-descriptions :deep(.n-descriptions-table) {
.server-descriptions {
:deep(.n-descriptions-table) {
table-layout: fixed;
width: 100%;
}
.server-descriptions :deep(.n-descriptions-table-header),
.server-descriptions :deep(.n-descriptions-table-content) {
:deep(.n-descriptions-table-header),
:deep(.n-descriptions-table-content) {
width: 25%;
}
.server-descriptions :deep(.n-descriptions-table-content) {
:deep(.n-descriptions-table-content) {
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
}
.status-dot {
display: inline-block;
width: 8px;
height: 8px;
border-radius: 50%;
&.connected {
background: var(--frost-success-color);
}
.status-dot.connected {
background: #22c55e;
}
.status-dot.connecting {
background: #f59e0b;
&.connecting {
background: var(--frost-warning-color);
animation: pulse 1s infinite;
}
.status-dot.disconnected {
background: #999;
&.disconnected {
background: var(--frost-color-text-tertiary);
}
.status-dot.error {
background: #ef4444;
&.error {
background: var(--frost-error-color);
}
}
@keyframes pulse {
+22 -16
View File
@@ -154,29 +154,29 @@ function formatPayload(payload) {
</template>
<style scoped>
<style scoped lang="less">
.messages-view {
width: 100%;
height: 100%;
min-width: 0;
min-height: 0;
}
.messages-view :deep(.n-card) {
:deep(.n-card) {
display: flex;
flex-direction: column;
height: 100%;
min-height: 0;
}
.messages-view :deep(.n-card__content) {
:deep(.n-card__content) {
flex: 1 1 auto;
min-height: 0;
overflow: hidden;
}
}
.msg-log {
background: #f5f7fa;
background: var(--frost-color-bg-light);
border-radius: 6px;
padding: 12px;
height: 100%;
@@ -192,7 +192,7 @@ function formatPayload(payload) {
.msg-entry {
padding: 8px 0;
border-bottom: 1px solid rgba(0, 0, 0, 0.06);
border-bottom: 1px solid var(--frost-shadow-black-6);
}
.msg-header {
@@ -203,45 +203,51 @@ function formatPayload(payload) {
}
.msg-time {
color: #999;
color: var(--frost-color-text-tertiary);
flex-shrink: 0;
}
.msg-dir {
flex-shrink: 0;
font-weight: 700;
width: 28px;
&.pub {
color: var(--frost-info-color);
}
.msg-dir.pub {
color: #3b82f6;
&.sub {
color: var(--frost-success-color);
}
.msg-dir.sub {
color: #22c55e;
}
.msg-topic {
color: #d25a00;
color: var(--frost-color-topic);
min-width: 0;
flex: 1;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
cursor: pointer;
}
.msg-topic:hover {
&:hover {
text-decoration: underline;
}
}
.msg-payload {
margin: 6px 0 0;
padding: 8px 10px;
border-radius: 4px;
background: rgba(0, 0, 0, 0.04);
background: var(--frost-shadow-black-4);
color: #333;
font: inherit;
white-space: pre-wrap;
overflow-wrap: anywhere;
}
.msg-meta {
color: #999;
color: var(--frost-color-text-tertiary);
font-size: 11px;
flex-shrink: 0;
}
+32 -32
View File
@@ -299,7 +299,7 @@ async function copyTopic(topic) {
</template>
<style scoped>
<style scoped lang="less">
.publish-view {
display: flex;
flex-direction: column;
@@ -307,96 +307,96 @@ async function copyTopic(topic) {
height: 100%;
min-width: 0;
min-height: 0;
}
.publish-view :deep(.n-tabs) {
:deep(.n-tabs) {
display: flex;
flex-direction: column;
height: 100%;
min-height: 0;
}
.publish-view :deep(.n-tabs-nav) {
:deep(.n-tabs-nav) {
flex-shrink: 0;
}
.publish-view :deep(.n-tabs-pane-wrapper) {
:deep(.n-tabs-pane-wrapper) {
flex: 1 1 auto;
min-height: 0;
overflow: hidden;
}
.publish-view :deep(.n-tabs-tab-panels),
.publish-view :deep(.n-tabs-pane-wrapper) {
:deep(.n-tabs-tab-panels),
:deep(.n-tabs-pane-wrapper) {
height: 100%;
min-height: 0;
}
.publish-view :deep(.n-tab-pane) {
:deep(.n-tab-pane) {
box-sizing: border-box;
height: 100%;
min-height: 0;
}
.publish-view :deep(.n-tab-pane > .n-card) {
:deep(.n-tab-pane > .n-card) {
display: flex;
flex-direction: column;
height: 100%;
min-height: 0;
}
.publish-view :deep(.n-card__content) {
:deep(.n-card__content) {
flex: 1 1 auto;
min-height: 0;
overflow: hidden;
}
.publish-view :deep(.n-card__content > div) {
> div {
height: 100%;
min-height: 0;
}
}
}
.topic-field {
width: 100%;
}
.topic-field :deep(.n-form-item-blank) {
:deep(.n-form-item-blank) {
width: 100%;
}
}
.publish-form {
display: flex;
flex-direction: column;
height: 100%;
min-height: 0;
}
.publish-form .payload-field {
.payload-field {
flex: 1;
min-height: 0;
display: flex;
flex-direction: column;
}
.publish-form .payload-field :deep(.n-form-item-blank) {
:deep(.n-form-item-blank) {
flex: 1;
min-height: 0;
}
.publish-form .payload-field :deep(.n-input) {
:deep(.n-input) {
height: 100%;
}
.publish-form .payload-field :deep(.n-input__textarea-el),
.publish-form .payload-field :deep(textarea) {
:deep(.n-input__textarea-el),
:deep(textarea) {
resize: none !important;
height: 100% !important;
min-height: 0 !important;
font-family: monospace;
}
}
}
.msg-log {
background: #f5f7fa;
background: var(--frost-color-bg-light);
border-radius: 6px;
padding: 12px;
height: 100%;
@@ -411,7 +411,7 @@ async function copyTopic(topic) {
.msg-entry {
padding: 8px 0;
border-bottom: 1px solid rgba(0, 0, 0, 0.06);
border-bottom: 1px solid var(--frost-shadow-black-6);
}
.msg-header {
@@ -422,7 +422,7 @@ async function copyTopic(topic) {
}
.msg-time {
color: #999;
color: var(--frost-color-text-tertiary);
flex-shrink: 0;
}
@@ -430,31 +430,31 @@ async function copyTopic(topic) {
flex-shrink: 0;
font-weight: 700;
width: 28px;
}
.msg-dir.pub {
color: #3b82f6;
&.pub {
color: var(--frost-info-color);
}
}
.msg-topic {
color: #d25a00;
color: var(--frost-color-topic);
min-width: 0;
flex: 1;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
cursor: pointer;
}
.msg-topic:hover {
&:hover {
text-decoration: underline;
}
}
.msg-payload {
margin: 6px 0 0;
padding: 8px 10px;
border-radius: 4px;
background: rgba(0, 0, 0, 0.04);
background: var(--frost-shadow-black-4);
color: #333;
font: inherit;
white-space: pre-wrap;
@@ -462,7 +462,7 @@ async function copyTopic(topic) {
}
.msg-meta {
color: #999;
color: var(--frost-color-text-tertiary);
font-size: 11px;
flex-shrink: 0;
}
+37 -33
View File
@@ -664,7 +664,7 @@ onUnmounted(() => {
</template>
<style scoped>
<style scoped lang="less">
.quick-send-view {
display: flex;
flex-direction: column;
@@ -672,20 +672,20 @@ onUnmounted(() => {
height: 100%;
min-width: 0;
min-height: 0;
}
.quick-send-view :deep(.n-card) {
:deep(.n-card) {
display: flex;
flex-direction: column;
height: 100%;
min-height: 0;
}
.quick-send-view :deep(.n-card__content) {
:deep(.n-card__content) {
flex: 1 1 auto;
min-height: 0;
overflow: hidden;
}
}
.quick-list {
flex: 1;
@@ -696,49 +696,49 @@ onUnmounted(() => {
gap: 12px;
padding-right: 4px;
align-content: start;
}
.quick-list.columns-1 {
&.columns-1 {
grid-template-columns: 1fr;
}
.quick-list.columns-2 {
&.columns-2 {
grid-template-columns: repeat(2, 1fr);
}
.quick-list.columns-3 {
&.columns-3 {
grid-template-columns: repeat(3, 1fr);
}
}
.payload-field {
display: flex;
flex-direction: column;
gap: 8px;
width: 100%;
}
.payload-field :deep(.n-input) {
:deep(.n-input) {
width: 100%;
}
.payload-field .n-button {
.n-button {
align-self: flex-end;
}
}
.quick-item {
border: 1px solid rgba(0, 0, 0, 0.08);
border: 1px solid var(--frost-shadow-black-8);
border-radius: 6px;
padding: 12px;
background: #fafafa;
background: var(--frost-color-bg-item);
cursor: grab;
transition: box-shadow 0.2s, opacity 0.2s;
}
.quick-item.dragging {
&.dragging {
opacity: 0.6;
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
box-shadow: 0 4px 12px var(--frost-shadow-black-12);
cursor: grabbing;
}
}
.quick-header {
display: flex;
@@ -751,12 +751,12 @@ onUnmounted(() => {
.quick-checkbox {
flex-shrink: 0;
margin-top: 2px;
}
.quick-checkbox :deep(.n-checkbox-box) {
:deep(.n-checkbox-box) {
width: 16px;
height: 16px;
}
}
.quick-topic-wrap {
display: flex;
@@ -772,14 +772,14 @@ onUnmounted(() => {
font-weight: 700;
width: 28px;
font-size: 12px;
}
.quick-dir.pub {
color: #3b82f6;
&.pub {
color: var(--frost-info-color);
}
}
.quick-topic {
color: #d25a00;
color: var(--frost-color-topic);
min-width: 0;
flex: 1;
overflow: hidden;
@@ -788,14 +788,14 @@ onUnmounted(() => {
cursor: pointer;
font-family: monospace;
font-size: 13px;
}
.quick-topic:hover {
&:hover {
text-decoration: underline;
}
}
.quick-meta {
color: #999;
color: var(--frost-color-text-tertiary);
font-size: 11px;
flex-shrink: 0;
font-family: monospace;
@@ -805,7 +805,7 @@ onUnmounted(() => {
margin: 10px 0 0;
padding: 8px 10px;
border-radius: 4px;
background: rgba(0, 0, 0, 0.04);
background: var(--frost-shadow-black-4);
color: #333;
font: inherit;
white-space: pre-wrap;
@@ -817,23 +817,27 @@ onUnmounted(() => {
overflow-y: auto;
}
.quick-send-modal .n-form-item {
.quick-send-modal {
.n-form-item {
margin-bottom: 20px;
}
.quick-send-modal .n-form-item__label {
&__label {
margin-bottom: 8px;
}
.quick-send-modal .n-form-item:last-child {
&:last-child {
margin-bottom: 0;
}
}
.quick-send-modal .n-grid {
.n-grid {
margin-bottom: 20px;
}
}
.quick-send-dialog .n-dialog__icon {
color: #0ea5a0;
.quick-send-dialog {
:deep(.n-dialog__icon) {
color: var(--frost-primary-color);
}
}
</style>
+20 -18
View File
@@ -426,7 +426,7 @@ async function handleEditSave(t) {
</template>
<style scoped>
<style scoped lang="less">
.subscribe-view {
display: flex;
flex-direction: column;
@@ -479,11 +479,13 @@ async function handleEditSave(t) {
flex: 0 0 auto;
}
.topic-field :deep(.n-form-item-blank),
.qos-field :deep(.n-form-item-blank),
.comment-field :deep(.n-form-item-blank) {
.topic-field,
.qos-field,
.comment-field {
:deep(.n-form-item-blank) {
width: 100%;
}
}
.topic-item {
box-sizing: border-box;
@@ -491,15 +493,15 @@ async function handleEditSave(t) {
min-height: 56px;
padding-top: 0 !important;
padding-bottom: 0 !important;
}
.topic-item :deep(.n-list-item__main) {
:deep(.n-list-item__main) {
display: flex;
align-items: center;
height: 100%;
min-width: 0;
gap: 12px;
}
}
.topic-content {
position: relative;
@@ -526,11 +528,11 @@ async function handleEditSave(t) {
font-size: 13px;
overflow: hidden;
visibility: visible;
}
.topic-name.is-hidden {
&.is-hidden {
visibility: hidden;
}
}
.topic-label {
min-width: 0;
@@ -554,20 +556,20 @@ async function handleEditSave(t) {
color: var(--n-text-color-3);
font-size: 11px;
line-height: 16px;
}
.topic-comment-prefix {
&-prefix {
flex-shrink: 0;
color: #0f766e;
}
.topic-comment-text {
&-text {
flex: 1;
min-width: 0;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
}
.topic-qos-tag {
min-width: 56px;
@@ -577,24 +579,24 @@ async function handleEditSave(t) {
.topic-actions {
flex-shrink: 0;
visibility: visible;
}
.topic-actions.is-hidden {
&.is-hidden {
visibility: hidden;
pointer-events: none;
}
.topic-actions .n-button {
.n-button {
min-width: 40px;
}
.topic-actions .topic-action-sub {
.topic-action-sub {
min-width: auto;
}
.topic-actions .topic-action-remove {
.topic-action-remove {
min-width: 24px;
}
}
.topic-edit-row {
position: absolute;
@@ -609,12 +611,12 @@ async function handleEditSave(t) {
overflow: hidden;
visibility: hidden;
pointer-events: none;
}
.topic-edit-row.is-visible {
&.is-visible {
visibility: visible;
pointer-events: auto;
}
}
.topic-edit-topic {
flex: 1 1 auto;