Skip to content

Commit

Permalink
style(sub): 修改代码样式与格式化
Browse files Browse the repository at this point in the history
  • Loading branch information
JxQg committed Jan 12, 2025
1 parent cf9e3d3 commit 74aa5b2
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 39 deletions.
2 changes: 1 addition & 1 deletion api/sub.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ func SubDel(c *gin.Context) {
func SubUpdateSort(c *gin.Context) {
var nodeSorts []models.SubscriptionNodes

subIDStr := c.PostForm("sub_id")
subIDStr := c.PostForm("subId")
if subIDStr == "" {
c.JSON(400, gin.H{
"msg": "订阅ID不能为空",
Expand Down
58 changes: 20 additions & 38 deletions webs/src/views/subcription/subs.vue
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ onMounted(async() => {
NodesList.value = data
})
const addSubs = async ()=>{
const config = JSON.stringify({
"clash": Clash.value.trim(),
Expand Down Expand Up @@ -177,7 +176,7 @@ const handleEdit = (row:any) => {
}
// 关闭对话框时清空数据
const closeDialog = () => {
const handleEditDialogClose = () => {
dialogVisible.value = false;
sortSubID.value = null; // 清空订阅 ID
sortValue.value = []; // 清空排序数据
Expand Down Expand Up @@ -319,32 +318,21 @@ const onDragEnd = () => {
const saveSortOrder = async () => {
try {
const nodesJson = JSON.stringify(sortValue.value.map((node) => ({
subscriptionID: sortSubID.value,
nodeID: node.ID,
sort: node.sort,
})));
await UpdateSubSort({
sub_id: sortSubID.value,
subId: sortSubID.value,
nodes: nodesJson,
});
ElMessage.success('排序更新成功');
getsubs()
} catch (error) {
console.error('Error updating nodes sort:', error);
ElMessage.error('排序更新失败');
}
getsubs()
};
onMounted(() => {
getsubs();
gettemps();
});
onMounted(async () => {
const { data } = await getNodes();
NodesList.value = data;
});
</script>

<template>
Expand Down Expand Up @@ -438,33 +426,27 @@ onMounted(async () => {
</el-select>
</div>
<!-- 添加节点排序 -->
<div class="m-4">
<p>节点排序</p>
<!-- 使用 vuedraggable 实现拖拽排序 -->
<draggable
v-model="sortValue"
tag="ul"
item-key="ID"
@end="onDragEnd"
>
<template #item="{ element, index }">
<li class="draggable-item">
<!-- 使用 el-tag 展示排序数字 -->
<el-tag type="info" class="sort-tag">
{{ index + 1 }}
</el-tag>
<!-- 节点名称 -->
<el-tag>{{ element.Name }}</el-tag>
</li>
</template>
</draggable>
</div>

<div class="m-4">
<p>节点排序</p>
<!-- 使用 vuedraggable 实现拖拽排序 -->
<draggable v-model="sortValue" tag="ul" item-key="ID" @end="onDragEnd">
<template #item="{ element, index }">
<li class="draggable-item">
<!-- 使用 el-tag 展示排序数字 -->
<el-tag type="info" class="sort-tag">
{{ index + 1 }}
</el-tag>
<!-- 节点名称 -->
<el-tag>{{ element.Name }}</el-tag>
</li>
</template>
</draggable>
</div>
<template #footer>
<div class="dialog-footer">
<!-- 根据 subId 是否为空动态禁用按钮 -->
<el-button type="primary" @click="saveSortOrder" :disabled="!sortSubID">保存排序</el-button>
<el-button @click="closeDialog">关闭</el-button>
<el-button @click="handleEditDialogClose">关闭</el-button>
<el-button type="primary" @click="addSubs">确定</el-button>
</div>
</template>
Expand Down

0 comments on commit 74aa5b2

Please sign in to comment.