|
20 | 20 | </p> |
21 | 21 | </div> |
22 | 22 |
|
23 | | - <form method="POST" action="<%= isEdit ? `/book/${ book.username }/${ book.slug }/edit` : '/book/create' %>" enctype="multipart/form-data" class="p-6 space-y-6"> |
| 23 | + <form method="POST" action="<%= isEdit ? `/book/${ book.username }/${ book.slug }/edit` : '/book/create' %>" enctype="multipart/form-data" class="<%= isEdit ? 'p-6 pt-0' : 'p-6' %> space-y-6"> |
24 | 24 | <%- include('../../components/alert', { type: 'error', message: error }) %> |
25 | 25 | <%- include('../../components/alert', { type: 'success', message: success }) %> |
26 | 26 | <% if (isEdit) { %> |
27 | | - <input type="hidden" name="_method" value="PUT"> |
| 27 | + <input type="hidden" class="hidden" name="_method" value="PUT"> |
28 | 28 | <% } %> |
29 | 29 |
|
30 | | - <!-- 书籍标题 --> |
31 | | - <div> |
32 | | - <label for="title" class="block text-sm font-medium text-gray-700 mb-2"> |
33 | | - 书籍标题 <span class="text-red-500">*</span> |
34 | | - </label> |
35 | | - <%- include('../../components/input', { type: 'text', name: 'title', id: 'title', value: isEdit ? book.title : '', required: true, placeholder: '请输入书籍标题' }) %> |
36 | | - </div> |
37 | | - |
38 | | - <!-- URL路径 --> |
39 | | - <div> |
40 | | - <label for="slug" class="block text-sm font-medium text-gray-700 mb-2"> |
41 | | - URL路径 <span class="text-red-500">*</span> |
42 | | - </label> |
43 | | - <div class="flex items-center"> |
44 | | - <%- include('../../components/input', { type: 'text', name: 'slug', prefix: `/book/${ isEdit ? book.username : user.username }/`, id: 'slug', value: isEdit ? book.slug : '', required: true, placeholder: '请输入URL路径' }) %> |
45 | | - </div> |
46 | | - <p class="mt-1 text-xs text-gray-500"> |
47 | | - 只能包含小写字母、数字和连字符,将用于书籍的访问地址 |
48 | | - </p> |
49 | | - </div> |
50 | | - |
51 | | - <!-- 书籍描述 --> |
52 | | - <div> |
53 | | - <label for="description" class="block text-sm font-medium text-gray-700 mb-2"> |
54 | | - 书籍描述 |
55 | | - </label> |
56 | | - <%- include('../../components/textarea', { name: 'description', id: 'description', value: isEdit ? book.description : '', placeholder: '请输入书籍描述' }) %> |
57 | | - </div> |
58 | | - |
59 | 30 | <!-- 封面图片 --> |
60 | 31 | <div> |
61 | 32 | <label for="cover_image" class="block text-sm font-medium text-gray-700 mb-2"> |
62 | | - 封面图片 |
| 33 | + 封面图片 <span class="text-red-500">*</span> |
63 | 34 | </label> |
64 | 35 |
|
65 | 36 | <% if (isEdit && book.cover_image) { %> |
|
90 | 61 | </p> |
91 | 62 | </div> |
92 | 63 |
|
| 64 | + <div class="grid grid-cols-1 md:grid-cols-2 gap-6"> |
| 65 | + <!-- 书籍标题 --> |
| 66 | + <div> |
| 67 | + <label for="title" class="block text-sm font-medium text-gray-700 mb-2"> |
| 68 | + 书籍标题 <span class="text-red-500">*</span> |
| 69 | + </label> |
| 70 | + <%- include('../../components/input', { type: 'text', name: 'title', id: 'title', value: isEdit ? book.title : '', required: true, placeholder: '请输入书籍标题' }) %> |
| 71 | + </div> |
| 72 | + |
| 73 | + <!-- URL路径 --> |
| 74 | + <div> |
| 75 | + <label for="slug" class="block text-sm font-medium text-gray-700 mb-2"> |
| 76 | + URL路径 <span class="text-red-500">*</span> |
| 77 | + </label> |
| 78 | + <div class="flex items-center"> |
| 79 | + <%- include('../../components/input', { type: 'text', name: 'slug', prefix: `/book/${ isEdit ? book.username : user.username }/`, id: 'slug', value: isEdit ? book.slug : '', required: true, placeholder: '请输入URL路径' }) %> |
| 80 | + </div> |
| 81 | + <p class="mt-1 text-xs text-gray-500"> |
| 82 | + 只能包含小写字母、数字和连字符,将用于书籍的访问地址 |
| 83 | + </p> |
| 84 | + </div> |
| 85 | + </div> |
| 86 | + |
| 87 | + <!-- 书籍描述 --> |
| 88 | + <div> |
| 89 | + <label for="description" class="block text-sm font-medium text-gray-700 mb-2"> |
| 90 | + 书籍描述 |
| 91 | + </label> |
| 92 | + <%- include('../../components/textarea', { name: 'description', id: 'description', value: isEdit ? book.description : '', placeholder: '请输入书籍描述' }) %> |
| 93 | + </div> |
| 94 | + |
93 | 95 | <!-- 状态设置 --> |
94 | 96 | <div class="grid grid-cols-1 md:grid-cols-2 gap-6"> |
95 | 97 | <!-- 发布状态 --> |
|
112 | 114 | </div> |
113 | 115 | </div> |
114 | 116 |
|
| 117 | + <!-- 排序 --> |
| 118 | + <div class="grid grid-cols-1 md:grid-cols-2 gap-6"> |
| 119 | + <!-- 排序字段 --> |
| 120 | + <div> |
| 121 | + <label for="order_col" class="block text-sm font-medium text-gray-700 mb-2"> |
| 122 | + 排序字段 |
| 123 | + </label> |
| 124 | + <%- include('../../components/select', { id: 'order_col', name: 'order_col', value: isEdit ? book.order_col : 'created_at', required: true, options: [ { value: 'created_at', label: '创建时间' }, { value: 'updated_at', label: '更新时间' }, { value: 'view_count', label: '浏览量' } ] }) %> |
| 125 | + <p class="mt-1 text-xs text-gray-500"> |
| 126 | + 用于标记书籍的排序字段,只有在书籍目录和阅读时生效。 |
| 127 | + </p> |
| 128 | + </div> |
| 129 | + |
| 130 | + <!-- 排序方式 --> |
| 131 | + <div> |
| 132 | + <label for="order_dir" class="block text-sm font-medium text-gray-700 mb-2"> |
| 133 | + 排序方式 |
| 134 | + </label> |
| 135 | + <%- include('../../components/select', { id: 'order_dir', name: 'order_dir', value: isEdit ? book.order_dir : 'asc', required: true, options: [ { value: 'asc', label: '升序' }, { value: 'desc', label: '降序' } ] }) %> |
| 136 | + </div> |
| 137 | + </div> |
| 138 | + |
115 | 139 | <!-- 操作按钮 --> |
116 | 140 | <div class="flex items-center justify-between pt-6 border-t border-gray-200"> |
117 | 141 | <div class="flex space-x-3"> |
118 | 142 | <%- include('../../components/button', { type: 'submit', icon: 'fas fa-save', text: isEdit ? '保存修改' : '创建书籍' }) %> |
119 | | - <%- include('../../components/button', { href: isEdit ? `/books/${ book.slug }` : '/books', icon: 'fas fa-times', text: '取消', variant: 'outline' }) %> |
| 143 | + <%- include('../../components/button', { href: isEdit ? `/book/${authUser.username}/${ book.slug }` : '/book/${authUser.username}', icon: 'fas fa-times', text: '取消', variant: 'outline' }) %> |
120 | 144 | </div> |
121 | 145 | </div> |
122 | 146 | </form> |
|
0 commit comments