|
|
<!doctype html>
|
|
|
<html>
|
|
|
|
|
|
<head>
|
|
|
<meta charset="UTF-8" />
|
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
|
<title>创建新应用</title>
|
|
|
|
|
|
<style>
|
|
|
/* 引用原始样式 */
|
|
|
body {
|
|
|
--primary-color: #4a6cf7;
|
|
|
--secondary-color: #6c757d;
|
|
|
--background-color: #f8f9fa;
|
|
|
--card-background: #ffffff;
|
|
|
--text-color: #333333;
|
|
|
--success-color: #28a745;
|
|
|
--warning-color: #ffc107;
|
|
|
--danger-color: #dc3545;
|
|
|
--border-radius: 10px;
|
|
|
--box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
|
|
|
--transition: all 0.3s ease;
|
|
|
}
|
|
|
|
|
|
* {
|
|
|
margin: 0;
|
|
|
padding: 0;
|
|
|
box-sizing: border-box;
|
|
|
}
|
|
|
|
|
|
body {
|
|
|
width: 100%;
|
|
|
height: 100%;
|
|
|
font-family: 'Inter', sans-serif;
|
|
|
background-color: var(--background-color);
|
|
|
color: var(--text-color);
|
|
|
line-height: 1.6;
|
|
|
border-radius: var(--border-radius);
|
|
|
box-shadow: var(--box-shadow);
|
|
|
}
|
|
|
|
|
|
.container {
|
|
|
width: 100%;
|
|
|
margin: 50px auto;
|
|
|
background-color: var(--card-background);
|
|
|
padding: 30px;
|
|
|
border-radius: var(--border-radius);
|
|
|
box-shadow: var(--box-shadow);
|
|
|
}
|
|
|
|
|
|
h1 {
|
|
|
font-size: 2rem;
|
|
|
font-weight: 600;
|
|
|
color: var(--primary-color);
|
|
|
margin-bottom: 20px;
|
|
|
text-align: center;
|
|
|
}
|
|
|
|
|
|
.form-group {
|
|
|
margin-bottom: 20px;
|
|
|
}
|
|
|
|
|
|
.form-group label {
|
|
|
display: block;
|
|
|
font-weight: 500;
|
|
|
margin-bottom: 8px;
|
|
|
}
|
|
|
|
|
|
.form-group input,
|
|
|
.form-group textarea,
|
|
|
.form-group select {
|
|
|
width: 100%;
|
|
|
padding: 12px;
|
|
|
border: 1px solid #ddd;
|
|
|
border-radius: 6px;
|
|
|
font-size: 16px;
|
|
|
transition: var(--transition);
|
|
|
}
|
|
|
|
|
|
.form-group input:focus,
|
|
|
.form-group textarea:focus,
|
|
|
.form-group select:focus {
|
|
|
outline: none;
|
|
|
border-color: var(--primary-color);
|
|
|
box-shadow: 0 0 0 3px rgba(74, 108, 247, 0.2);
|
|
|
}
|
|
|
|
|
|
.form-group textarea {
|
|
|
resize: vertical;
|
|
|
min-height: 100px;
|
|
|
}
|
|
|
|
|
|
.btn {
|
|
|
display: inline-block;
|
|
|
width: 100%;
|
|
|
padding: 12px;
|
|
|
background-color: var(--primary-color);
|
|
|
color: white;
|
|
|
border: none;
|
|
|
border-radius: 6px;
|
|
|
font-size: 16px;
|
|
|
font-weight: 500;
|
|
|
cursor: pointer;
|
|
|
transition: var(--transition);
|
|
|
text-align: center;
|
|
|
}
|
|
|
|
|
|
.btn:hover {
|
|
|
background-color: #3955d1;
|
|
|
}
|
|
|
|
|
|
.error-message {
|
|
|
color: var(--danger-color);
|
|
|
font-size: 14px;
|
|
|
margin-top: 8px;
|
|
|
}
|
|
|
</style>
|
|
|
</head>
|
|
|
|
|
|
<body>
|
|
|
<div class="container">
|
|
|
<h1>创建新应用</h1>
|
|
|
<form @submit.prevent="handleSubmit">
|
|
|
<div class="form-group">
|
|
|
<label for="appName">应用名称</label>
|
|
|
<input type="text" id="appName" !value="name" placeholder="请输入应用名称" required
|
|
|
@input="name = $event.target.value" />
|
|
|
</div>
|
|
|
<div class="form-group">
|
|
|
<label for="appIcon">应用图标(URL)</label>
|
|
|
<input id="appIcon" !value="icon" placeholder="请输入应用图标的URL" required @input="icon = $event.target.value" />
|
|
|
</div>
|
|
|
<div class="form-group">
|
|
|
<label for="appDescription">应用描述</label>
|
|
|
<textarea id="appDescription" !value="des" placeholder="请输入应用描述" @input="des = $event.target.value"></textarea>
|
|
|
</div>
|
|
|
<div class="form-group">
|
|
|
<label for="appType">应用类型</label>
|
|
|
<select id="appType" !value="typ" @input="typ = $event.target.value">
|
|
|
<option value="">请选择类型</option>
|
|
|
<option value="public">公开制</option>
|
|
|
<option value="apply">申请制</option>
|
|
|
<option value="invite">邀请制</option>
|
|
|
</select>
|
|
|
</div>
|
|
|
<div class="form-group">
|
|
|
<label for="appName">应用地址</label>
|
|
|
<input type="text" !value="init_url" placeholder="请输入应用首页" required @input="init_url = $event.target.value" />
|
|
|
</div>
|
|
|
<button type="submit" class="btn">提交</button>
|
|
|
<p v-if="errorMessage" class="error-message">{{ errorMessage }}</p>
|
|
|
</form>
|
|
|
</div>
|
|
|
</body>
|
|
|
|
|
|
<script setup>
|
|
|
// 响应式数据
|
|
|
name = ''; // 应用名称
|
|
|
icon = `http://public.veypi.com/img/avatar/${String(Math.floor(Math.random() * 220)).padStart(4, '0')}.jpg`;
|
|
|
des = ''; // 应用描述
|
|
|
typ = 'public'; // 应用类型
|
|
|
init_url = ''
|
|
|
errorMessage = ''; // 错误提示信息
|
|
|
|
|
|
onsuccess = () => { }
|
|
|
// 提交表单
|
|
|
handleSubmit = () => {
|
|
|
console.log(name, icon, des, typ, init_url)
|
|
|
if (!name || !icon || !des || !typ || init_url) {
|
|
|
// errorMessage = '请填写所有必填字段';
|
|
|
// return;
|
|
|
}
|
|
|
const newApp = {
|
|
|
name: name,
|
|
|
icon: icon,
|
|
|
des: des || null, // 如果描述为空,则发送 null
|
|
|
typ: typ,
|
|
|
status: 'ok',
|
|
|
init_url: init_url,
|
|
|
};
|
|
|
|
|
|
$api.Post('/api/app', newApp)
|
|
|
.then(() => {
|
|
|
onsuccess()
|
|
|
name = '';
|
|
|
icon = `http://public.veypi.com/img/avatar/${String(Math.floor(Math.random() * 220)).padStart(4, '0')}.jpg`;
|
|
|
des = '';
|
|
|
typ = 'public';
|
|
|
status = '';
|
|
|
errorMessage = '';
|
|
|
})
|
|
|
.catch((err) => {
|
|
|
errorMessage = err.message || '创建应用失败,请稍后重试';
|
|
|
});
|
|
|
};
|
|
|
</script>
|
|
|
|
|
|
</html>
|