Skip to content

Commit ebd20b0

Browse files
committed
feat: 优化文件管理Mihomo配置中订阅名称选取交互
1 parent 4840343 commit ebd20b0

File tree

4 files changed

+108
-21
lines changed

4 files changed

+108
-21
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "sub-store-front-end",
3-
"version": "2.14.321",
3+
"version": "2.14.322",
44
"private": true,
55
"scripts": {
66
"dev": "vite --host",

src/locales/en.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -533,6 +533,12 @@ export default {
533533
tipsDes: "Use a JavaScript script to filter nodes",
534534
},
535535
},
536+
sourceNamePicker: {
537+
title: 'Select Subscription Name',
538+
cancel: 'Cancel',
539+
confirm: 'Confirm',
540+
emptyTips: 'Subscription not found? Click to add a subscription',
541+
},
536542
},
537543
},
538544
myPage: {

src/locales/zh.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -528,6 +528,12 @@ export default {
528528
tipsDes: '使用一段 JavaScript 脚本来过滤节点',
529529
},
530530
},
531+
sourceNamePicker: {
532+
title: '选择订阅名称',
533+
cancel: '取消',
534+
confirm: '确定',
535+
emptyTips: '未找到订阅?点击去添加订阅',
536+
},
531537
},
532538
},
533539
myPage: {

src/views/FileEditor.vue

Lines changed: 95 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -90,30 +90,30 @@
9090
@click-left-icon="showIconPopup"
9191
/>
9292
</nut-form-item>
93-
<nut-form-item
94-
required
95-
:label="$t(`specificWord.type`)"
96-
prop="type"
97-
>
98-
<div class="radio-wrapper">
99-
<nut-radiogroup direction="horizontal" v-model="form.type">
100-
<nut-radio shape="button" label="mihomoProfile">
101-
{{ $t(`filePage.type.mihomoProfile`) }}
102-
</nut-radio>
103-
<nut-radio shape="button" label="file">
104-
{{ $t(`specificWord.file`) }}
105-
</nut-radio>
106-
</nut-radiogroup>
107-
</div>
108-
</nut-form-item>
93+
<nut-form-item required :label="$t(`specificWord.type`)" prop="type">
94+
<div class="radio-wrapper">
95+
<nut-radiogroup v-model="form.type" direction="horizontal">
96+
<nut-radio shape="button" label="mihomoProfile">
97+
{{ $t(`filePage.type.mihomoProfile`) }}
98+
</nut-radio>
99+
<nut-radio shape="button" label="file">
100+
{{ $t(`specificWord.file`) }}
101+
</nut-radio>
102+
</nut-radiogroup>
103+
</div>
104+
</nut-form-item>
109105
<template v-if="form.type === 'mihomoProfile'">
110106
<nut-form-item
111107
required
112108
:label="$t(`editorPage.subConfig.basic.source.label`)"
113109
prop="source"
114110
>
115111
<div class="radio-wrapper">
116-
<nut-radiogroup direction="horizontal" v-model="form.sourceType">
112+
<nut-radiogroup
113+
v-model="form.sourceType"
114+
direction="horizontal"
115+
@change="handleTypeChange"
116+
>
117117
<nut-radio shape="button" label="subscription">
118118
{{ $t(`specificWord.singleSub`) }}
119119
</nut-radio>
@@ -134,13 +134,17 @@
134134
},
135135
]"
136136
>
137-
<input
137+
<nut-input
138138
class="nut-input-text"
139+
:border="false"
139140
data-1p-ignore
140141
@blur="customerBlurValidate('name')"
142+
input-align="right"
141143
v-model.trim="form.sourceName"
142144
:placeholder="(form.sourceType === 'subscription' ? $t(`specificWord.singleSub`) : $t(`specificWord.collectionSub`))+$t(`editorPage.subConfig.basic.name.label`)"
143145
type="text"
146+
right-icon="rect-right"
147+
@click-right-icon="showSourceName"
144148
/>
145149
</nut-form-item>
146150
</template>
@@ -353,6 +357,21 @@
353357
/>
354358
<icon-popup v-model:visible="iconPopupVisible" ref="iconPopupRef" @setIcon="setIcon">
355359
</icon-popup>
360+
<!-- 订阅名称 -->
361+
<nut-picker
362+
:key="sourceNameColumns.length"
363+
v-model="selectSourceName"
364+
v-model:visible="showSourceNamePicker"
365+
:columns="sourceNameColumns"
366+
:title="$t(`editorPage.subConfig.sourceNamePicker.title`)"
367+
:cancel-text="$t(`editorPage.subConfig.sourceNamePicker.cancel`)"
368+
:ok-text="$t(`editorPage.subConfig.sourceNamePicker.confirm`)"
369+
@confirm="handleSourceNameConfirm"
370+
>
371+
<div v-if="!sourceNameColumns.length" class="empty-tips" @click="goAddSub">
372+
<p>{{ t(`editorPage.subConfig.sourceNamePicker.emptyTips`) }}</p>
373+
</div>
374+
</nut-picker>
356375
</template>
357376

358377
<script lang="ts" setup>
@@ -404,6 +423,7 @@ const { showNotify } = useAppNotifyStore();
404423
const globalStore = useGlobalStore();
405424
const settingsStore = useSettingsStore();
406425
const { bottomSafeArea } = storeToRefs(globalStore);
426+
const { subs, collections } = storeToRefs(subsStore);
407427
const { appearanceSetting } = storeToRefs(settingsStore);
408428
const padding = bottomSafeArea.value + "px";
409429
@@ -426,13 +446,44 @@ const form = reactive<any>({
426446
icon: "",
427447
source: "local",
428448
sourceType: "collection",
449+
sourceName: "",
429450
process: [],
430451
type: configName === 'UNTITLED-mihomoProfile' ? 'mihomoProfile' : 'file',
431452
});
432453
provide("form", form);
433454
// 排除非动作卡片
434455
const ignoreList = ["Quick Setting Operator"];
435-
456+
// 订阅名称
457+
const showSourceNamePicker = ref(false);
458+
const selectSourceName = computed(() => [form.sourceName]);
459+
const sourceNameColumns = computed(() => {
460+
const list =
461+
form.sourceType === "collection" ? subsStore.collections : subsStore.subs;
462+
if (!list || list.length === 0) {
463+
return [];
464+
}
465+
return list.map((item) => {
466+
return {
467+
text: item.displayName ? `${item.displayName}` : item.name,
468+
value: item.name,
469+
};
470+
});
471+
});
472+
const handleTypeChange = (val) => {
473+
form.sourceName = "";
474+
};
475+
const showSourceName = () => {
476+
showSourceNamePicker.value = true;
477+
};
478+
const handleSourceNameConfirm = ({ selectedValue, selectedOptions }) => {
479+
if (selectedValue[0]) {
480+
form.sourceName = selectedValue[0];
481+
}
482+
showSourceNamePicker.value = false;
483+
};
484+
const goAddSub = () => {
485+
router.push("/subs");
486+
};
436487
watch(
437488
() => cmStore.EditCode["FileEditer"],
438489
(newCode) => {
@@ -499,6 +550,7 @@ watchEffect(() => {
499550
}
500551
// 标记 加载完成
501552
isInit.value = true;
553+
console.log('form', form);
502554
return;
503555
}
504556
});
@@ -810,6 +862,16 @@ const handleEditGlobalClick = () => {
810862
}
811863
}
812864
}
865+
:deep(.nut-form-item__label) {
866+
width: auto;
867+
}
868+
:deep(.nut-input-text){
869+
.nut-input-inner {
870+
.nut-input-right-icon {
871+
margin-left: 10px;
872+
}
873+
}
874+
}
813875
}
814876
.actions-title-wrapper {
815877
display: flex;
@@ -818,7 +880,6 @@ const handleEditGlobalClick = () => {
818880
color: var(--comment-text-color);
819881
.doc {
820882
margin-left: 4px;
821-
822883
color: var(--primary-text-color);
823884
}
824885
}
@@ -924,4 +985,18 @@ const handleEditGlobalClick = () => {
924985
}
925986
}
926987
}
988+
989+
.empty-tips {
990+
padding: 40px 20px;
991+
display: flex;
992+
align-items: center;
993+
justify-content: center;
994+
background: var(--background-color);
995+
p {
996+
// color: var(--primary-text-color);
997+
color: var(--comment-text-color);
998+
font-size: 14px;
999+
text-align: center;
1000+
}
1001+
}
9271002
</style>

0 commit comments

Comments
 (0)