Files
ZelWiki/TightWiki/Views/Admin/AddEmoji.cshtml
2025-02-08 16:40:55 +08:00

77 lines
3.0 KiB
Plaintext

@using TightWiki.Models
@model TightWiki.Models.ViewModels.Admin.AddEmojiViewModel
@{
Layout = "/Views/Shared/_Layout.cshtml";
var sessionState = ViewData["SessionState"] as TightWiki.SessionState ?? throw new Exception("Wiki State Context cannot be null.");
}
<script type="text/javascript">
window.addEventListener('DOMContentLoaded', (event) => {
const imageData = document.getElementById('ImageData');
const categories = document.getElementById('Categories');
const name = document.getElementById('Name');
imageData.addEventListener('change', (event) => {
const selectedFile = event.target.files[0];
name.value = selectedFile.name.substr(0, selectedFile.name.lastIndexOf('.')).replace(/ /g, '-').replace(/_/g, '-');
categories.value = name.value.replace(/-/g, ',');
});
});
</script>
<h3>
新增 Emoji
</h3>
<p><br /><br /></p>
@if (!string.IsNullOrEmpty(Model.ErrorMessage))
{
<div class="alert alert-danger">@Html.Raw(Model.ErrorMessage)</div>
}
@if (!string.IsNullOrEmpty(Model.SuccessMessage))
{
<div class="alert alert-success">@Html.Raw(Model.SuccessMessage)</div>
}
@using (Html.BeginForm(null, null, null, FormMethod.Post, true, new { action = $"{GlobalConfiguration.BasePath}{Context.Request.Path}", enctype = "multipart/form-data" }))
{
@Html.AntiForgeryToken()
@Html.HiddenFor(model => model.OriginalName)
@Html.HiddenFor(model => model.Id)
<div class="container">
<form>
<div class="form-group row mb-1">
<label for="ImageData" class="col-sm-2 col-form-label"><strong>图片</strong></label>
<div class="col-sm-10">
<input type="file" id="ImageData" name="ImageData" class="form-control-file" onchange="fileCheck(this);" accept="image/png, image/jpeg, image/gif" />
</div>
</div>
<div class="form-group row mb-1">
<label for="Name" class="col-sm-2 col-form-label"><strong>@Html.LabelFor(m => m.Name)</strong></label>
<div class="col-sm-10">
@Html.TextBoxFor(m => m.Name, new { @class = "form-control", placeholder = "必填项" })
<div class="text-danger">@Html.ValidationMessageFor(m => m.Name)</div>
</div>
</div>
<div class="form-group row mb-1">
<label for="Categories" class="col-sm-2 col-form-label"><strong>@Html.LabelFor(m => m.Categories)</strong> (以英文逗号分割)</label>
<div class="col-sm-10">
@Html.TextBoxFor(m => m.Categories, new { @class = "form-control" })
<div class="text-danger">@Html.ValidationMessageFor(m => m.Categories)</div>
</div>
</div>
<div class="form-group row mb-1">
<div class="col-sm-10 offset-sm-2">
<button type="submit" class="btn btn-success rounded-0">保存!</button>
</div>
</div>
</form>
</div>
}
<br />