🦄 refactor: 重写前端
路由守护尚未写完
1
.gitignore
vendored
|
|
@ -141,3 +141,4 @@ model.pt
|
|||
tmp
|
||||
.DS_Store
|
||||
/data
|
||||
/web/node_modules
|
||||
|
|
|
|||
|
|
@ -1,30 +0,0 @@
|
|||
import uuid
|
||||
from manager.api.response import response_success, response_error
|
||||
|
||||
|
||||
async def verify_token(config, request):
|
||||
if 'token' not in config['manager']:
|
||||
return True
|
||||
expected_token = config['manager']['token']
|
||||
token = request.headers.get('Authorization', '').replace('Bearer ', '')
|
||||
|
||||
if not token or token != expected_token:
|
||||
return False
|
||||
return True
|
||||
|
||||
|
||||
class AuthApi:
|
||||
def __init__(self, config):
|
||||
self.config = config
|
||||
|
||||
async def login(self, request):
|
||||
try:
|
||||
data = await request.json()
|
||||
if 'password' not in data:
|
||||
return response_error("密码不能为空")
|
||||
# 通过config参数回传修改能力
|
||||
if self.config['manager']['token'] == data['password']:
|
||||
return response_success(data=str(uuid.uuid4()))
|
||||
return response_error("密码不正确")
|
||||
except Exception as e:
|
||||
return response_error(str(e))
|
||||
|
|
@ -1,227 +0,0 @@
|
|||
import os
|
||||
import yaml
|
||||
from config.logger import setup_logging
|
||||
from aiohttp import web
|
||||
from core.utils.util import get_project_dir
|
||||
from config.private_config import PrivateConfig
|
||||
from manager.api.user_manager import UserManager # 添加导入
|
||||
from core.utils.auth_code_gen import AuthCodeGenerator # 添加导入
|
||||
|
||||
TAG = __name__
|
||||
logger = setup_logging()
|
||||
|
||||
class ConfigHandler:
|
||||
def __init__(self, session_manager):
|
||||
self.session_manager = session_manager
|
||||
self.user_manager = UserManager() # 添加 user_manager 实例
|
||||
self.private_config_path = get_project_dir() + 'data/.private_config.yaml'
|
||||
self.config_path = get_project_dir() + 'config.yaml'
|
||||
# 如果存在.config.yaml文件,则使用该文件
|
||||
if os.path.exists(get_project_dir() + "data/.config.yaml"):
|
||||
self.config_path = get_project_dir() + "data/.config.yaml"
|
||||
with open(self.config_path, 'r', encoding='utf-8') as f:
|
||||
self.config = yaml.safe_load(f)
|
||||
|
||||
async def get_module_options(self, request):
|
||||
"""Get all available module options from config.yaml"""
|
||||
try:
|
||||
with open(self.config_path, 'r', encoding='utf-8') as f:
|
||||
config = yaml.safe_load(f)
|
||||
|
||||
# Extract available modules
|
||||
modules = {
|
||||
'LLM': list(config.get('LLM', {}).keys()),
|
||||
'TTS': list(config.get('TTS', {}).keys()),
|
||||
'VAD': list(config.get('VAD', {}).keys()),
|
||||
'ASR': list(config.get('ASR', {}).keys())
|
||||
}
|
||||
|
||||
return web.json_response({
|
||||
'success': True,
|
||||
'data': modules,
|
||||
'message': '获取成功'
|
||||
})
|
||||
|
||||
except Exception as e:
|
||||
logger.bind(tag=TAG).error(f"Error getting module options: {str(e)}", exc_info=True)
|
||||
return web.json_response({
|
||||
'success': False,
|
||||
'message': '获取配置选项失败'
|
||||
})
|
||||
|
||||
async def get_private_configs(self, request):
|
||||
"""只返回用户绑定的设备配置"""
|
||||
try:
|
||||
username = request['username']
|
||||
logger.bind(tag=TAG).info(f"Getting devices for user: {username}")
|
||||
|
||||
# 从用户管理器获取用户的设备列表
|
||||
user_devices = await self.user_manager.get_user_devices(username)
|
||||
logger.bind(tag=TAG).info(f"User {username} has devices: {user_devices}")
|
||||
|
||||
# 读取所有配置
|
||||
all_configs = {}
|
||||
if os.path.exists(self.private_config_path):
|
||||
with open(self.private_config_path, 'r', encoding='utf-8') as f:
|
||||
all_configs = yaml.safe_load(f) or {}
|
||||
|
||||
# 只返回用户有权限的设备配置
|
||||
user_configs = {
|
||||
device_id: config
|
||||
for device_id, config in all_configs.items()
|
||||
if device_id in user_devices
|
||||
}
|
||||
|
||||
logger.bind(tag=TAG).info(f"Returning {len(user_configs)} device configs for user {username}")
|
||||
return web.json_response({
|
||||
'success': True,
|
||||
'data': user_configs,
|
||||
'message': '获取成功'
|
||||
})
|
||||
|
||||
except Exception as e:
|
||||
logger.bind(tag=TAG).error(f"Error getting devices for user {request.get('username')}: {str(e)}", exc_info=True)
|
||||
return web.json_response({
|
||||
'success': False,
|
||||
'message': f'获取设备列表失败: {str(e)}'
|
||||
}, status=400)
|
||||
|
||||
async def save_device_config(self, request):
|
||||
"""保存单个设备的配置"""
|
||||
try:
|
||||
data = await request.json()
|
||||
device_id = data.get('id')
|
||||
config = data.get('config')
|
||||
username = request['username'] # 从请求中获取用户名
|
||||
|
||||
# 检查设备所有权
|
||||
user_devices = await self.user_manager.get_user_devices(username)
|
||||
if device_id not in user_devices:
|
||||
return web.json_response({
|
||||
'success': False,
|
||||
'message': '无权操作此设备'
|
||||
}, status=403)
|
||||
|
||||
logger.bind(tag=TAG).info(f"Device config updated: {device_id} :\n{config}")
|
||||
if not device_id or not config:
|
||||
return web.json_response({
|
||||
'success': False,
|
||||
'message': '设备ID和配置不能为空'
|
||||
})
|
||||
|
||||
# 使用PrivateConfig处理配置保存
|
||||
private_config = PrivateConfig(device_id, self.config)
|
||||
await private_config.load_or_create()
|
||||
|
||||
success = await private_config.update_config(
|
||||
config.get('selected_module'),
|
||||
config.get('prompt'),
|
||||
config.get('nickname', '小智')
|
||||
)
|
||||
|
||||
|
||||
if not success:
|
||||
raise Exception("Failed to update device config")
|
||||
|
||||
return web.json_response({
|
||||
'success': True,
|
||||
'message': '保存成功'
|
||||
})
|
||||
|
||||
except Exception as e:
|
||||
logger.bind(tag=TAG).error(f"Error saving device config: {str(e)}", exc_info=True)
|
||||
return web.json_response({
|
||||
'success': False,
|
||||
'message': f'保存配置失败: {str(e)}'
|
||||
})
|
||||
|
||||
async def delete_device_config(self, request):
|
||||
"""删除设备配置"""
|
||||
try:
|
||||
data = await request.json()
|
||||
device_id = data.get('device_id')
|
||||
username = request['username']
|
||||
|
||||
# 检查设备所有权
|
||||
user_devices = await self.user_manager.get_user_devices(username)
|
||||
if device_id not in user_devices:
|
||||
return web.json_response({
|
||||
'success': False,
|
||||
'message': '无权删除此设备'
|
||||
}, status=403)
|
||||
|
||||
# 使用PrivateConfig处理配置删除
|
||||
private_config = PrivateConfig(device_id, self.config)
|
||||
success = await private_config.delete_config()
|
||||
await self.user_manager.remove_device(username, device_id)
|
||||
|
||||
if not success:
|
||||
raise Exception("Failed to delete device config")
|
||||
|
||||
return web.json_response({
|
||||
'success': True,
|
||||
'message': '删除成功'
|
||||
})
|
||||
|
||||
except Exception as e:
|
||||
logger.bind(tag=TAG).error(f"Error deleting device config: {str(e)}", exc_info=True)
|
||||
return web.json_response({
|
||||
'success': False,
|
||||
'message': f'删除配置失败: {str(e)}'
|
||||
})
|
||||
|
||||
async def bind_device(self, request):
|
||||
"""绑定设备到用户"""
|
||||
try:
|
||||
data = await request.json()
|
||||
auth_code = data.get('auth_code')
|
||||
username = request['username']
|
||||
|
||||
if not auth_code or len(auth_code) != 6:
|
||||
return web.json_response({
|
||||
'success': False,
|
||||
'message': '请输入6位认证码'
|
||||
}, status=400)
|
||||
|
||||
# 读取所有设备配置
|
||||
with open(self.private_config_path, 'r', encoding='utf-8') as f:
|
||||
all_configs = yaml.safe_load(f) or {}
|
||||
|
||||
# 查找匹配认证码的设备
|
||||
device_found = None
|
||||
for device_id, config in all_configs.items():
|
||||
if config.get('auth_code') == auth_code and not config.get('owner'):
|
||||
device_found = device_id
|
||||
break
|
||||
|
||||
if not device_found:
|
||||
return web.json_response({
|
||||
'success': False,
|
||||
'message': '认证码无效或设备已被绑定'
|
||||
}, status=400)
|
||||
|
||||
# 使用 PrivateConfig 进行绑定
|
||||
private_config = PrivateConfig(device_found, self.config, AuthCodeGenerator())
|
||||
await private_config.load_or_create()
|
||||
|
||||
# 绑定设备到用户 - 修改为异步调用
|
||||
success = await private_config.bind_user(username)
|
||||
if success:
|
||||
# 同时更新用户的设备列表 - 修改为异步调用
|
||||
await self.user_manager.add_device(username, device_found)
|
||||
return web.json_response({
|
||||
'success': True,
|
||||
'message': '设备绑定成功'
|
||||
})
|
||||
else:
|
||||
return web.json_response({
|
||||
'success': False,
|
||||
'message': '设备绑定失败'
|
||||
}, status=500)
|
||||
|
||||
except Exception as e:
|
||||
logger.bind(tag=TAG).error(f"Error binding device: {str(e)}", exc_info=True)
|
||||
return web.json_response({
|
||||
'success': False,
|
||||
'message': f'绑定设备失败: {str(e)}'
|
||||
}, status=500)
|
||||
|
|
@ -1,53 +0,0 @@
|
|||
from config.logger import setup_logging
|
||||
from aiohttp import web
|
||||
import datetime
|
||||
|
||||
TAG = __name__
|
||||
logger = setup_logging()
|
||||
|
||||
class LoginHandler:
|
||||
def __init__(self, user_manager, session_manager):
|
||||
self.user_manager = user_manager
|
||||
self.session_manager = session_manager
|
||||
|
||||
async def handle_login(self, request):
|
||||
"""处理登录请求"""
|
||||
try:
|
||||
data = await request.json()
|
||||
username = data.get('username')
|
||||
password = data.get('password')
|
||||
|
||||
if not username or not password:
|
||||
logger.bind(tag=TAG).warning(f"Login attempt with empty credentials from {request.remote}")
|
||||
return web.json_response({
|
||||
'success': False,
|
||||
'message': '用户名和密码不能为空'
|
||||
})
|
||||
|
||||
stored_user = await self.user_manager.get_user(username)
|
||||
if not stored_user or stored_user['password'] != self.user_manager.hash_password(password):
|
||||
logger.bind(tag=TAG).warning(f"Failed login attempt for user {username} from {request.remote}")
|
||||
return web.json_response({
|
||||
'success': False,
|
||||
'message': '用户名或密码错误'
|
||||
})
|
||||
|
||||
# 更新最后登录时间
|
||||
await self.user_manager.update_user(username, {
|
||||
'last_login': datetime.datetime.now().isoformat()
|
||||
})
|
||||
|
||||
# 创建会话并返回session_id
|
||||
session_id = self.session_manager.create_session(username)
|
||||
return web.json_response({
|
||||
'success': True,
|
||||
'message': '登录成功',
|
||||
'session_id': session_id
|
||||
})
|
||||
|
||||
except Exception as e:
|
||||
logger.bind(tag=TAG).error(f"Login error: {str(e)}", exc_info=True)
|
||||
return web.json_response({
|
||||
'success': False,
|
||||
'message': '登录失败,请稍后重试'
|
||||
})
|
||||
|
|
@ -1,42 +0,0 @@
|
|||
from config.logger import setup_logging
|
||||
from aiohttp import web
|
||||
from config.settings import update_config
|
||||
from ruamel.yaml.scalarstring import PreservedScalarString
|
||||
from manager.api.auth import verify_token
|
||||
from manager.api.response import response_unauthorized, response_success, response_error
|
||||
|
||||
TAG = __name__
|
||||
logger = setup_logging()
|
||||
|
||||
class PromptApi:
|
||||
def __init__(self, config):
|
||||
self.config = config
|
||||
|
||||
async def get_prompt(self, request):
|
||||
if not await verify_token(self.config, request):
|
||||
return response_unauthorized()
|
||||
|
||||
return web.json_response({
|
||||
'prompt': self.config['prompt'],
|
||||
'Access-Control-Allow-Origin': '*'
|
||||
})
|
||||
|
||||
async def update_prompt(self, request):
|
||||
if not await verify_token(self.config, request):
|
||||
return response_unauthorized()
|
||||
|
||||
try:
|
||||
data = await request.json()
|
||||
if 'prompt' not in data:
|
||||
return response_success()
|
||||
|
||||
# 使用PreservedScalarString保留多行文本格式
|
||||
self.config['prompt'] = PreservedScalarString(data['prompt'])
|
||||
|
||||
# 保存到配置文件
|
||||
update_config(self.config)
|
||||
|
||||
return response_success()
|
||||
except Exception as e:
|
||||
logger.bind(tag=TAG).error(f"Failed to update prompt: {e}")
|
||||
return response_error(str(e))
|
||||
|
|
@ -1,55 +0,0 @@
|
|||
from config.logger import setup_logging
|
||||
from aiohttp import web
|
||||
import datetime
|
||||
|
||||
TAG = __name__
|
||||
logger = setup_logging()
|
||||
|
||||
class RegisterHandler:
|
||||
def __init__(self, user_manager):
|
||||
self.user_manager = user_manager
|
||||
|
||||
async def handle_register(self, request):
|
||||
"""处理注册请求"""
|
||||
try:
|
||||
data = await request.json()
|
||||
username = data.get('username')
|
||||
password = data.get('password')
|
||||
|
||||
if not username or not password:
|
||||
logger.bind(tag=TAG).warning(f"Registration attempt with empty credentials from {request.remote}")
|
||||
return web.json_response({
|
||||
'success': False,
|
||||
'message': '用户名和密码不能为空'
|
||||
})
|
||||
|
||||
# 检查用户是否已存在
|
||||
if await self.user_manager.get_user(username):
|
||||
logger.bind(tag=TAG).warning(f"Registration attempt with existing username {username} from {request.remote}")
|
||||
return web.json_response({
|
||||
'success': False,
|
||||
'message': '用户名已存在'
|
||||
})
|
||||
|
||||
# 创建用户
|
||||
user_data = {
|
||||
'username': username,
|
||||
'password': self.user_manager.hash_password(password),
|
||||
'devices': [],
|
||||
'created_at': datetime.datetime.now().isoformat(),
|
||||
'last_login': ''
|
||||
}
|
||||
await self.user_manager.add_user(username, user_data)
|
||||
|
||||
logger.bind(tag=TAG).info(f"Successfully registered new user {username} from {request.remote}")
|
||||
return web.json_response({
|
||||
'success': True,
|
||||
'message': '注册成功'
|
||||
})
|
||||
|
||||
except Exception as e:
|
||||
logger.bind(tag=TAG).error(f"Register error: {str(e)}", exc_info=True)
|
||||
return web.json_response({
|
||||
'success': False,
|
||||
'message': '注册失败,请稍后重试'
|
||||
})
|
||||
|
|
@ -1,16 +0,0 @@
|
|||
from aiohttp import web
|
||||
from typing import Optional, Dict, Any # 导入Optional用于表示可选类型
|
||||
|
||||
|
||||
def response_error(msg):
|
||||
return web.json_response({"code": -1, 'msg': msg}, status=200)
|
||||
|
||||
|
||||
def response_success(msg: str = '', data: Optional[Any] = None):
|
||||
if data is None:
|
||||
data = {}
|
||||
return web.json_response({"code": 0, 'msg': msg, 'data': data}, status=200)
|
||||
|
||||
|
||||
def response_unauthorized():
|
||||
return web.json_response({"code": 401}, status=200)
|
||||
|
|
@ -1,175 +0,0 @@
|
|||
import os
|
||||
import yaml
|
||||
import hashlib
|
||||
from config.logger import setup_logging
|
||||
from core.utils.util import get_project_dir
|
||||
from core.utils.lock_manager import FileLockManager
|
||||
|
||||
TAG = __name__
|
||||
logger = setup_logging()
|
||||
|
||||
class UserManager:
|
||||
def __init__(self):
|
||||
self.secrets_path = get_project_dir() + 'data/.secrets.yaml'
|
||||
self.lock_manager = FileLockManager()
|
||||
self.ensure_secrets_file()
|
||||
|
||||
def ensure_secrets_file(self):
|
||||
"""确保 .secrets.yaml 文件存在"""
|
||||
if not os.path.exists(self.secrets_path):
|
||||
default_config = {
|
||||
'users': {}
|
||||
}
|
||||
try:
|
||||
with open(self.secrets_path, 'w', encoding='utf-8') as f:
|
||||
yaml.dump(default_config, f)
|
||||
os.chmod(self.secrets_path, 0o600)
|
||||
logger.bind(tag=TAG).info("Created new .secrets.yaml file")
|
||||
except Exception as e:
|
||||
logger.bind(tag=TAG).error(f"Failed to create .secrets.yaml: {e}")
|
||||
raise
|
||||
|
||||
async def _load_user_data_internal(self):
|
||||
"""内部加载用户数据方法 - 不获取锁"""
|
||||
try:
|
||||
with open(self.secrets_path, 'r', encoding='utf-8') as f:
|
||||
data = yaml.safe_load(f) or {'users': {}}
|
||||
users = data['users']
|
||||
logger.bind(tag=TAG).debug("Successfully loaded user data")
|
||||
except Exception as e:
|
||||
logger.bind(tag=TAG).error(f"Failed to load user data: {e}")
|
||||
users = {}
|
||||
return users
|
||||
|
||||
async def load_user_data(self):
|
||||
"""加载用户数据"""
|
||||
try:
|
||||
await self.lock_manager.acquire_lock(self.secrets_path)
|
||||
try:
|
||||
users = await self._load_user_data_internal()
|
||||
finally:
|
||||
self.lock_manager.release_lock(self.secrets_path)
|
||||
|
||||
except Exception as e:
|
||||
logger.bind(tag=TAG).error(f"Failed to load user data: {e}")
|
||||
users = {}
|
||||
return users
|
||||
|
||||
async def _save_user_data_internal(self, users):
|
||||
"""内部保存用户数据方法 - 不获取锁"""
|
||||
try:
|
||||
with open(self.secrets_path, 'w', encoding='utf-8') as f:
|
||||
yaml.dump({'users': users}, f)
|
||||
logger.bind(tag=TAG).debug("Successfully saved user data")
|
||||
except Exception as e:
|
||||
logger.bind(tag=TAG).error(f"Failed to save user data: {e}")
|
||||
raise
|
||||
|
||||
async def save_user_data(self, users):
|
||||
"""外部保存用户数据方法 - 获取锁"""
|
||||
try:
|
||||
await self.lock_manager.acquire_lock(self.secrets_path)
|
||||
try:
|
||||
await self._save_user_data_internal(users)
|
||||
finally:
|
||||
self.lock_manager.release_lock(self.secrets_path)
|
||||
except Exception as e:
|
||||
logger.bind(tag=TAG).error(f"Failed to save user data: {e}")
|
||||
raise
|
||||
|
||||
def hash_password(self, password):
|
||||
"""密码哈希"""
|
||||
return hashlib.sha256(password.encode()).hexdigest()
|
||||
|
||||
async def get_users(self):
|
||||
"""异步获取所有用户"""
|
||||
users = await self.load_user_data() # 确保获取最新数据
|
||||
return users
|
||||
|
||||
async def get_user(self, username):
|
||||
"""异步获取指定用户"""
|
||||
users = await self.load_user_data() # 确保获取最新数据
|
||||
return users.get(username)
|
||||
|
||||
async def add_user(self, username: str, user_data: dict):
|
||||
"""异步添加新用户"""
|
||||
try:
|
||||
await self.lock_manager.acquire_lock(self.secrets_path)
|
||||
try:
|
||||
users = await self._load_user_data_internal() # 确保获取最新数据
|
||||
if username in users:
|
||||
raise ValueError("User already exists")
|
||||
users[username] = user_data
|
||||
await self._save_user_data_internal(users)
|
||||
finally:
|
||||
self.lock_manager.release_lock(self.secrets_path)
|
||||
except Exception as e:
|
||||
logger.bind(tag=TAG).error(f"Error adding user: {e}")
|
||||
raise
|
||||
|
||||
async def update_user(self, username, data):
|
||||
"""更新用户数据"""
|
||||
try:
|
||||
await self.lock_manager.acquire_lock(self.secrets_path)
|
||||
try:
|
||||
users = await self._load_user_data_internal() # 确保获取最新数据
|
||||
if username in users:
|
||||
users[username].update(data)
|
||||
await self._save_user_data_internal(users)
|
||||
return True
|
||||
return False
|
||||
finally:
|
||||
self.lock_manager.release_lock(self.secrets_path)
|
||||
except Exception as e:
|
||||
logger.bind(tag=TAG).error(f"Error updating user: {e}")
|
||||
return False
|
||||
|
||||
async def get_user_devices(self, username: str) -> list:
|
||||
"""获取用户的设备列表"""
|
||||
user = await self.get_user(username)
|
||||
print(user)
|
||||
if user and user.get('devices'):
|
||||
return user['devices']
|
||||
return []
|
||||
|
||||
async def add_device(self, username: str, device_id: str) -> bool:
|
||||
"""添加设备到用户的设备列表"""
|
||||
try:
|
||||
await self.lock_manager.acquire_lock(self.secrets_path)
|
||||
try:
|
||||
users = await self._load_user_data_internal() # 确保获取最新数据
|
||||
user = users.get(username) # 直接从内存获取,因为已经有锁
|
||||
if not user:
|
||||
return False
|
||||
|
||||
if 'devices' not in user:
|
||||
user['devices'] = []
|
||||
|
||||
if device_id not in user['devices']:
|
||||
user['devices'].append(device_id)
|
||||
await self._save_user_data_internal(users)
|
||||
return True
|
||||
finally:
|
||||
self.lock_manager.release_lock(self.secrets_path)
|
||||
except Exception as e:
|
||||
logger.bind(tag=TAG).error(f"Error adding device: {e}")
|
||||
return False
|
||||
|
||||
async def remove_device(self, username: str, device_id: str) -> bool:
|
||||
"""从用户的设备列表中移除设备"""
|
||||
try:
|
||||
await self.lock_manager.acquire_lock(self.secrets_path)
|
||||
try:
|
||||
users = await self._load_user_data_internal() # 确保获取最新数据
|
||||
user = users.get(username) # 直接从内存获取,因为已经有锁
|
||||
if user and 'devices' in user:
|
||||
if device_id in user['devices']:
|
||||
user['devices'].remove(device_id)
|
||||
await self._save_user_data_internal(users)
|
||||
return True
|
||||
return False
|
||||
finally:
|
||||
self.lock_manager.release_lock(self.secrets_path)
|
||||
except Exception as e:
|
||||
logger.bind(tag=TAG).error(f"Error removing device: {e}")
|
||||
return False
|
||||
|
|
@ -1,116 +0,0 @@
|
|||
# 添加项目根目录到Python路径
|
||||
import os
|
||||
import sys
|
||||
current_dir = os.path.dirname(os.path.abspath(__file__))
|
||||
root_dir = os.path.dirname(current_dir)
|
||||
sys.path.append(root_dir)
|
||||
|
||||
from config.logger import setup_logging
|
||||
from aiohttp import web
|
||||
from aiohttp_cors import setup as cors_setup, ResourceOptions
|
||||
from manager.api.login import LoginHandler
|
||||
from manager.api.register import RegisterHandler
|
||||
from manager.api.user_manager import UserManager
|
||||
from manager.api.config import ConfigHandler
|
||||
from manager.session import SessionManager
|
||||
from functools import wraps
|
||||
|
||||
TAG = __name__
|
||||
logger = setup_logging()
|
||||
|
||||
def auth_required(handler):
|
||||
"""鉴权装饰器"""
|
||||
@wraps(handler)
|
||||
async def wrapper(self, request):
|
||||
session_id = request.cookies.get('session_id')
|
||||
username = self.session_manager.validate_session(session_id)
|
||||
if not username:
|
||||
return web.json_response({'error': 'Unauthorized'}, status=401)
|
||||
# 将用户名添加到请求对象
|
||||
request['username'] = username
|
||||
return await handler(self, request)
|
||||
return wrapper
|
||||
|
||||
class WebUI:
|
||||
def __init__(self):
|
||||
self.app = web.Application()
|
||||
self.user_manager = UserManager()
|
||||
self.session_manager = SessionManager()
|
||||
|
||||
# 添加静态文件路径
|
||||
self.static_path = os.path.join(root_dir, 'web', 'dist')
|
||||
|
||||
self.setup_routes()
|
||||
self.setup_cors()
|
||||
|
||||
def setup_cors(self):
|
||||
"""设置CORS"""
|
||||
cors = cors_setup(self.app, defaults={
|
||||
"*": ResourceOptions(
|
||||
allow_credentials=True,
|
||||
expose_headers="*",
|
||||
allow_headers="*",
|
||||
allow_methods="*"
|
||||
)
|
||||
})
|
||||
|
||||
for route in list(self.app.router.routes()):
|
||||
cors.add(route)
|
||||
|
||||
def setup_routes(self):
|
||||
"""设置路由"""
|
||||
login_handler = LoginHandler(self.user_manager, self.session_manager)
|
||||
register_handler = RegisterHandler(self.user_manager)
|
||||
config_handler = ConfigHandler(self.session_manager)
|
||||
|
||||
# Public APIs
|
||||
self.app.router.add_post('/api/login', login_handler.handle_login)
|
||||
self.app.router.add_post('/api/register', register_handler.handle_register)
|
||||
|
||||
# Protected APIs
|
||||
self.app.router.add_get('/api/config/devices', self.auth_wrapper(config_handler.get_private_configs))
|
||||
|
||||
self.app.router.add_get('/api/config/module-options', self.auth_wrapper(config_handler.get_module_options))
|
||||
self.app.router.add_post('/api/config/save_device_config', self.auth_wrapper(config_handler.save_device_config))
|
||||
self.app.router.add_post('/api/config/delete_device', self.auth_wrapper(config_handler.delete_device_config))
|
||||
self.app.router.add_post('/api/config/bind_device', self.auth_wrapper(config_handler.bind_device))
|
||||
|
||||
# 添加静态文件服务
|
||||
self.app.router.add_static('/assets/', path=os.path.join(self.static_path, 'assets'))
|
||||
# 所有未匹配的路由都返回 index.html
|
||||
self.app.router.add_get('/{tail:.*}', self.handle_static_files)
|
||||
|
||||
async def handle_static_files(self, request):
|
||||
"""处理静态文件请求,支持SPA前端路由"""
|
||||
index_file = os.path.join(self.static_path, 'index.html')
|
||||
if os.path.exists(index_file):
|
||||
return web.FileResponse(index_file)
|
||||
return web.Response(status=404, text='Not found')
|
||||
|
||||
def auth_wrapper(self, handler):
|
||||
"""包装处理器添加鉴权"""
|
||||
@wraps(handler)
|
||||
async def wrapper(request):
|
||||
# 从请求头获取session_id
|
||||
session_id = request.headers.get('Authorization')
|
||||
if not session_id:
|
||||
logger.bind(tag=TAG).warning("No session_id in Authorization header")
|
||||
return web.json_response({'error': 'Unauthorized'}, status=401)
|
||||
|
||||
username = self.session_manager.validate_session(session_id)
|
||||
if not username:
|
||||
logger.bind(tag=TAG).warning(f"Invalid session_id: {session_id}")
|
||||
return web.json_response({'error': 'Unauthorized'}, status=401)
|
||||
|
||||
request['username'] = username
|
||||
logger.bind(tag=TAG).debug(f"Auth success for user: {username}")
|
||||
return await handler(request)
|
||||
return wrapper
|
||||
|
||||
def run(self, host='0.0.0.0', port=8002):
|
||||
"""运行服务器"""
|
||||
web.run_app(self.app, host=host, port=port)
|
||||
|
||||
if __name__ == '__main__':
|
||||
webui = WebUI()
|
||||
webui.run()
|
||||
|
|
@ -1,33 +0,0 @@
|
|||
import time
|
||||
from typing import Dict, Optional
|
||||
|
||||
class SessionManager:
|
||||
def __init__(self):
|
||||
self.sessions: Dict[str, Dict] = {}
|
||||
self.session_timeout = 24 * 60 * 60 # 24小时过期
|
||||
|
||||
def create_session(self, username: str) -> str:
|
||||
"""创建新会话"""
|
||||
session_id = str(hash(f"{username}:{time.time()}"))
|
||||
self.sessions[session_id] = {
|
||||
'username': username,
|
||||
'created_at': time.time()
|
||||
}
|
||||
return session_id
|
||||
|
||||
def validate_session(self, session_id: str) -> Optional[str]:
|
||||
"""验证会话是否有效,返回用户名"""
|
||||
if session_id not in self.sessions:
|
||||
return None
|
||||
|
||||
session = self.sessions[session_id]
|
||||
if time.time() - session['created_at'] > self.session_timeout:
|
||||
del self.sessions[session_id]
|
||||
return None
|
||||
|
||||
return session['username']
|
||||
|
||||
def remove_session(self, session_id: str):
|
||||
"""删除会话"""
|
||||
if session_id in self.sessions:
|
||||
del self.sessions[session_id]
|
||||
|
|
@ -1,77 +0,0 @@
|
|||
/* common.css */
|
||||
/* 基础样式 */
|
||||
body {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
background: linear-gradient(135deg, #1a1f25 0%, #0d1117 100%);
|
||||
min-height: 100vh;
|
||||
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
|
||||
}
|
||||
|
||||
/* 头部组件 */
|
||||
.app-header {
|
||||
background: rgba(13, 17, 23, 0.8);
|
||||
backdrop-filter: blur(10px);
|
||||
color: #fff;
|
||||
padding: 1.5rem 2rem;
|
||||
font-size: 1.4rem;
|
||||
border-bottom: 1px solid rgba(255, 255, 255, 0.1);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 1rem;
|
||||
position: relative;
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
.header-logo {
|
||||
width: 32px;
|
||||
height: 32px;
|
||||
background: linear-gradient(45deg, #00c6fb 0%, #005bea 100%);
|
||||
border-radius: 8px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
/* 页脚组件 */
|
||||
.app-footer {
|
||||
text-align: center;
|
||||
color: rgba(255, 255, 255, 0.6);
|
||||
font-size: 13px;
|
||||
padding: 20px;
|
||||
position: fixed;
|
||||
bottom: 0;
|
||||
width: 100%;
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
/* 背景动画 */
|
||||
.animated-bg {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
z-index: -1;
|
||||
background: linear-gradient(-45deg, #1a1f25, #0d1117, #162030, #1c1c1c);
|
||||
background-size: 400% 400%;
|
||||
}
|
||||
|
||||
|
||||
.user-menu {
|
||||
position: fixed;
|
||||
top: 23px;
|
||||
right: 32px;
|
||||
z-index: 1000;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.user-info {
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.user-name {
|
||||
font-size: 14px;
|
||||
color: #606266;
|
||||
}
|
||||
|
Before Width: | Height: | Size: 1.1 KiB |
|
|
@ -1,156 +0,0 @@
|
|||
<!doctype html>
|
||||
<html lang="zh">
|
||||
<head>
|
||||
<meta charset="UTF-8"/>
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1.0"/>
|
||||
<script src="js/vue3.5.13.js"></script>
|
||||
<link rel="stylesheet" href="css/element-plus2.9.4.css">
|
||||
<script src="js/element-plus2.9.4.js"></script>
|
||||
<script src="js/icons-vue2.3.1.js"></script>
|
||||
<script src="js/common.js"></script>
|
||||
<link rel="icon" href="images/favicon.ico" />
|
||||
<link rel="stylesheet" href="css/common.css">
|
||||
<title>小智-server</title>
|
||||
<style>
|
||||
/* 页面特有样式 */
|
||||
.content-container {
|
||||
max-width: 1200px;
|
||||
margin: 20px auto;
|
||||
padding: 2rem;
|
||||
background: #fff;
|
||||
border-radius: 8px;
|
||||
box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
|
||||
.role-title {
|
||||
font-size: 16px;
|
||||
font-weight: bold;
|
||||
margin-bottom: 1rem;
|
||||
}
|
||||
|
||||
.character-count {
|
||||
text-align: right;
|
||||
color: #999;
|
||||
font-size: 12px;
|
||||
margin-top: 4px;
|
||||
}
|
||||
|
||||
.button-group {
|
||||
margin-top: 1rem;
|
||||
}
|
||||
|
||||
.note {
|
||||
color: #909399;
|
||||
font-size: 12px;
|
||||
margin-top: 1rem;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div id="app">
|
||||
<div class="animated-bg"></div>
|
||||
<app-header>xiaozhi-esp32-server</app-header>
|
||||
|
||||
<div class="user-menu">
|
||||
<el-dropdown @command="handleCommand">
|
||||
<div class="user-info">
|
||||
<el-avatar :size="32" src="https://cube.elemecdn.com/3/7c/3ea6beec64369c2642b92c6726f1epng.png"/>
|
||||
<span class="user-name">管理员</span>
|
||||
</div>
|
||||
<template #dropdown>
|
||||
<el-dropdown-menu>
|
||||
<el-dropdown-item command="logout">退出</el-dropdown-item>
|
||||
</el-dropdown-menu>
|
||||
</template>
|
||||
</el-dropdown>
|
||||
</div>
|
||||
|
||||
<div class="content-container">
|
||||
<div class="role-description">角色介绍</div>
|
||||
<el-input
|
||||
type="textarea"
|
||||
v-model="form.prompt"
|
||||
:rows="10"
|
||||
resize="vertical"
|
||||
@input="updateCharCount"
|
||||
></el-input>
|
||||
<div class="character-count">{{ charCount }} / 2000</div>
|
||||
|
||||
<div class="button-group">
|
||||
<el-button type="primary" @click="savePrompt">保存配置</el-button>
|
||||
<el-button @click="loadPrompt">重置</el-button>
|
||||
</div>
|
||||
|
||||
<div class="note">注意:保存配置后,需要重启设备,新的配置才会生效。</div>
|
||||
</div>
|
||||
|
||||
<app-footer></app-footer>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
const {ElMessage} = ElementPlus;
|
||||
const App = {
|
||||
data() {
|
||||
return {
|
||||
form: {
|
||||
prompt: ''
|
||||
},
|
||||
charCount: 0
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
loadPrompt() {
|
||||
let that = this;
|
||||
that.form.prompt = '';
|
||||
get('/api/prompt', function (data) {
|
||||
if (data.code === -1) {
|
||||
ElMessage({
|
||||
message: data.msg,
|
||||
type: 'error'
|
||||
});
|
||||
} else {
|
||||
that.form.prompt = data.prompt;
|
||||
that.updateCharCount();
|
||||
}
|
||||
})
|
||||
},
|
||||
updateCharCount() {
|
||||
this.charCount = this.form.prompt.length;
|
||||
},
|
||||
savePrompt() {
|
||||
post('/api/prompt', {prompt: this.form.prompt}, (data) => {
|
||||
if (data.code === 0) {
|
||||
ElMessage({
|
||||
message: '保存成功',
|
||||
type: 'success'
|
||||
});
|
||||
this.loadPrompt();
|
||||
} else {
|
||||
ElMessage({
|
||||
message: data.msg || '保存失败',
|
||||
type: 'error'
|
||||
});
|
||||
}
|
||||
});
|
||||
},
|
||||
// 新增退出处理方法
|
||||
handleCommand(command) {
|
||||
if (command === 'logout') {
|
||||
this.handleLogout();
|
||||
}
|
||||
},
|
||||
handleLogout() {
|
||||
localStorage.removeItem('token');
|
||||
location.href = 'login.html';
|
||||
},
|
||||
},
|
||||
mounted() {
|
||||
this.loadPrompt();
|
||||
}
|
||||
};
|
||||
|
||||
const app = createVueApp(App);
|
||||
app.mount("#app");
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -1,68 +0,0 @@
|
|||
function post(api, bodyData, fn) {
|
||||
let basePath = '';
|
||||
let token = localStorage.getItem('token');
|
||||
fetch(basePath + api, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'Authorization': token,
|
||||
},
|
||||
body: bodyData==null ? null : JSON.stringify(bodyData)
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
if(data.code === 401){
|
||||
window.location = 'login.html';
|
||||
return
|
||||
}
|
||||
fn(data);
|
||||
});
|
||||
}
|
||||
|
||||
function get(api, fn) {
|
||||
let basePath = 'http://localhost:8001';
|
||||
let token = localStorage.getItem('token');
|
||||
fetch(basePath + api, {
|
||||
method: "GET",
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'Authorization': token,
|
||||
},
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
if(data.code === 401){
|
||||
window.location = 'login.html';
|
||||
return
|
||||
}
|
||||
fn(data);
|
||||
});
|
||||
}
|
||||
|
||||
// 注册全局组件
|
||||
const AppHeader = {
|
||||
template: `
|
||||
<header class="app-header">
|
||||
<div class="header-logo">AI</div>
|
||||
<slot>xiaozhi-esp32-server</slot>
|
||||
</header>
|
||||
`
|
||||
};
|
||||
|
||||
const AppFooter = {
|
||||
template: `
|
||||
<footer class="app-footer">
|
||||
<slot>© 2025 xiaozhi-esp32-server</slot>
|
||||
</footer>
|
||||
`
|
||||
};
|
||||
|
||||
// 初始化Vue应用的通用配置
|
||||
function createVueApp(options) {
|
||||
const app = Vue.createApp({
|
||||
...options,
|
||||
components: { AppHeader, AppFooter }
|
||||
});
|
||||
app.use(ElementPlus);
|
||||
return app;
|
||||
}
|
||||
|
|
@ -1,138 +0,0 @@
|
|||
<!doctype html>
|
||||
<html lang="zh">
|
||||
<head>
|
||||
<meta charset="UTF-8"/>
|
||||
<link rel="icon" href="images/favicon.ico" />
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1.0"/>
|
||||
<script src="js/vue3.5.13.js"></script>
|
||||
<link rel="stylesheet" href="css/element-plus2.9.4.css">
|
||||
<script src="js/element-plus2.9.4.js"></script>
|
||||
<script src="js/icons-vue2.3.1.js"></script>
|
||||
<script src="js/common.js"></script>
|
||||
<link rel="stylesheet" href="css/common.css">
|
||||
<title>小智-server</title>
|
||||
<style>
|
||||
/* 页面特有样式 */
|
||||
.login-container {
|
||||
max-width: 440px;
|
||||
margin: 60px auto;
|
||||
padding: 2.5rem;
|
||||
background: rgba(255, 255, 255, 0.05);
|
||||
border-radius: 16px;
|
||||
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
|
||||
backdrop-filter: blur(8px);
|
||||
border: 1px solid rgba(255, 255, 255, 0.1);
|
||||
}
|
||||
|
||||
.login-title {
|
||||
font-size: 28px;
|
||||
color: #fff;
|
||||
margin-bottom: 40px;
|
||||
font-weight: 600;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.custom-input :deep(.el-input__wrapper) {
|
||||
background: rgba(255, 255, 255, 0.05) !important;
|
||||
border: 1px solid rgba(255, 255, 255, 0.1) !important;
|
||||
box-shadow: none !important;
|
||||
}
|
||||
|
||||
.custom-input :deep(.el-input__inner) {
|
||||
color: #fff !important;
|
||||
}
|
||||
|
||||
.custom-button {
|
||||
background: linear-gradient(45deg, #00c6fb 0%, #005bea 100%) !important;
|
||||
border: none !important;
|
||||
height: 44px !important;
|
||||
font-size: 16px !important;
|
||||
font-weight: 500 !important;
|
||||
letter-spacing: 1px;
|
||||
transition: all 0.3s ease !important;
|
||||
}
|
||||
|
||||
.custom-button:hover {
|
||||
transform: translateY(-2px);
|
||||
box-shadow: 0 4px 15px rgba(0, 198, 251, 0.3) !important;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div id="app">
|
||||
<div class="animated-bg"></div>
|
||||
<app-header>xiaozhi-esp32-server</app-header>
|
||||
|
||||
<div class="login-container">
|
||||
<h2 class="login-title">安全验证</h2>
|
||||
<div class="login-form">
|
||||
<el-form :model="form" size="large">
|
||||
<el-form-item>
|
||||
<el-input
|
||||
class="custom-input"
|
||||
v-model="form.password"
|
||||
type="password"
|
||||
placeholder="请输入访问密码"
|
||||
show-password>
|
||||
</el-input>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button class="custom-button" type="primary" style="width: 100%" @click="handleLogin">
|
||||
验证并进入系统
|
||||
</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<app-footer></app-footer>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
const {ElMessage} = ElementPlus;
|
||||
const App = {
|
||||
data() {
|
||||
return {
|
||||
form: {
|
||||
password: ''
|
||||
}
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
handleLogin() {
|
||||
let that = this;
|
||||
post('/api/login', that.form, function (data) {
|
||||
if (data.code === -1) {
|
||||
// 弹出错误提示
|
||||
ElMessage({
|
||||
message: '登录失败,请检查您的密码',
|
||||
type: 'error'
|
||||
});
|
||||
localStorage.removeItem('token');
|
||||
} else {
|
||||
// 登录成功时的处理逻辑
|
||||
ElMessage({
|
||||
message: '登录成功',
|
||||
type: 'success'
|
||||
});
|
||||
localStorage.setItem('token', that.form.password); // 设置登录状态为已登录
|
||||
location.href = 'index.html'; // 跳转到主页
|
||||
}
|
||||
})
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
// 在页面加载时自动调用 handleLogin 方法
|
||||
let token = localStorage.getItem('token')
|
||||
if (token) {
|
||||
this.form.password = token;
|
||||
this.handleLogin();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const app = createVueApp(App);
|
||||
app.mount("#app");
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
Before Width: | Height: | Size: 1.1 KiB |
|
|
@ -1,28 +0,0 @@
|
|||
<!doctype html>
|
||||
<html lang="en" style="height: 100%;">
|
||||
<head>
|
||||
<meta charset="UTF-8"/>
|
||||
<link rel="icon" href="/favicon.ico"/>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
|
||||
<title>智控台</title>
|
||||
<style>
|
||||
html, body {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
#app {
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
}
|
||||
</style>
|
||||
<script type="module" crossorigin src="/assets/index-DF7ROAy9.js"></script>
|
||||
<link rel="stylesheet" crossorigin href="/assets/index-D_oCZVZF.css">
|
||||
</head>
|
||||
<body>
|
||||
<div id="app"></div>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -1 +0,0 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="31.88" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 257"><defs><linearGradient id="IconifyId1813088fe1fbc01fb466" x1="-.828%" x2="57.636%" y1="7.652%" y2="78.411%"><stop offset="0%" stop-color="#41D1FF"></stop><stop offset="100%" stop-color="#BD34FE"></stop></linearGradient><linearGradient id="IconifyId1813088fe1fbc01fb467" x1="43.376%" x2="50.316%" y1="2.242%" y2="89.03%"><stop offset="0%" stop-color="#FFEA83"></stop><stop offset="8.333%" stop-color="#FFDD35"></stop><stop offset="100%" stop-color="#FFA800"></stop></linearGradient></defs><path fill="url(#IconifyId1813088fe1fbc01fb466)" d="M255.153 37.938L134.897 252.976c-2.483 4.44-8.862 4.466-11.382.048L.875 37.958c-2.746-4.814 1.371-10.646 6.827-9.67l120.385 21.517a6.537 6.537 0 0 0 2.322-.004l117.867-21.483c5.438-.991 9.574 4.796 6.877 9.62Z"></path><path fill="url(#IconifyId1813088fe1fbc01fb467)" d="M185.432.063L96.44 17.501a3.268 3.268 0 0 0-2.634 3.014l-5.474 92.456a3.268 3.268 0 0 0 3.997 3.378l24.777-5.718c2.318-.535 4.413 1.507 3.936 3.838l-7.361 36.047c-.495 2.426 1.782 4.5 4.151 3.78l15.304-4.649c2.372-.72 4.652 1.36 4.15 3.788l-11.698 56.621c-.732 3.542 3.979 5.473 5.943 2.437l1.313-2.028l72.516-144.72c1.215-2.423-.88-5.186-3.54-4.672l-25.505 4.922c-2.396.462-4.435-1.77-3.759-4.114l16.646-57.705c.677-2.35-1.37-4.583-3.769-4.113Z"></path></svg>
|
||||
|
Before Width: | Height: | Size: 1.5 KiB |
|
|
@ -1 +0,0 @@
|
|||
VITE_API_BASE_URL='http://127.0.0.1:8002'
|
||||
1
web/.env.example
Normal file
|
|
@ -0,0 +1 @@
|
|||
VITE_BASE_URL=http://0.0.0.0:8888
|
||||
|
|
@ -1 +0,0 @@
|
|||
VITE_API_BASE_URL='' # 空字符串表示使用当前域名和端口
|
||||
29
web/.gitignore
vendored
|
|
@ -1,24 +1,7 @@
|
|||
# Logs
|
||||
logs
|
||||
*.log
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
pnpm-debug.log*
|
||||
lerna-debug.log*
|
||||
|
||||
node_modules
|
||||
dist
|
||||
dist-ssr
|
||||
*.local
|
||||
|
||||
# Editor directories and files
|
||||
.vscode/*
|
||||
!.vscode/extensions.json
|
||||
.idea
|
||||
.DS_Store
|
||||
*.suo
|
||||
*.ntvs*
|
||||
*.njsproj
|
||||
*.sln
|
||||
*.sw?
|
||||
/node_modules
|
||||
yarn.lock
|
||||
poetry.lock
|
||||
/dist
|
||||
*.pyc
|
||||
sql_app.db
|
||||
|
|
|
|||
21
web/LICENSE.md
Executable file
|
|
@ -0,0 +1,21 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) 2025 Kalicyh
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
97
web/README.md
Normal file → Executable file
|
|
@ -1,88 +1,25 @@
|
|||
# Vue 3 + Vite 项目配置文档
|
||||
## admin
|
||||
|
||||
## 开发环境配置
|
||||
常用命令
|
||||
见 `package.json`
|
||||
|
||||
### 使用 Poetry 配置开发环境
|
||||
`yarn lib`安装依赖
|
||||
|
||||
在项目根目录中执行以下命令安装 Python 依赖:
|
||||
`yarn dev`运行fastapi+react
|
||||
|
||||
```sh
|
||||
poetry install
|
||||
|
||||
### 接口文档
|
||||
|
||||
```
|
||||
Swagger UI:服务于 /docs
|
||||
ReDoc:服务于 /redoc
|
||||
OpenAPI 模式服务于 /openapi.json
|
||||
```
|
||||
|
||||
---
|
||||

|
||||
|
||||
## 安装项目依赖
|
||||
## 技术栈
|
||||
|
||||
你可以选择以下任意一个包管理工具(`npm`、`yarn` 或 `pnpm`)来管理项目依赖。
|
||||
|
||||
### 通用命令
|
||||
|
||||
- `install`:安装项目依赖
|
||||
- `dev`:同时启动前后端
|
||||
- `dev:ui`:启动前端
|
||||
- `dev:api`:启动后端
|
||||
- `dev:d`:在 Docker 环境下同时启动前后端
|
||||
- `build`:打包项目
|
||||
|
||||
---
|
||||
|
||||
### 使用 npm
|
||||
|
||||
1. 安装依赖:
|
||||
|
||||
```sh
|
||||
npm install
|
||||
```
|
||||
|
||||
2. 启动开发模式:
|
||||
|
||||
```sh
|
||||
npm run dev
|
||||
```
|
||||
|
||||
3. 打包项目:
|
||||
|
||||
```sh
|
||||
npm run build
|
||||
```
|
||||
|
||||
### 使用 yarn
|
||||
|
||||
1. 安装依赖:
|
||||
|
||||
```sh
|
||||
yarn install
|
||||
```
|
||||
|
||||
2. 启动开发模式:
|
||||
|
||||
```sh
|
||||
yarn dev
|
||||
```
|
||||
|
||||
3. 打包项目:
|
||||
|
||||
```sh
|
||||
yarn build
|
||||
```
|
||||
|
||||
### 使用 pnpm
|
||||
|
||||
1. 安装依赖:
|
||||
|
||||
```sh
|
||||
pnpm install
|
||||
```
|
||||
|
||||
2. 启动开发模式:
|
||||
|
||||
```sh
|
||||
pnpm run dev
|
||||
```
|
||||
|
||||
3. 打包项目:
|
||||
|
||||
```sh
|
||||
pnpm run build
|
||||
```
|
||||
Minimal UI ([Free version](https://free.minimals.cc/))
|
||||
[Material Icons](https://mui.com/material-ui/material-icons/)
|
||||
[sonner](https://sonner.emilkowal.ski/)
|
||||
0
web/api/__init__.py
Normal file
122
web/api/admin/admin.py
Normal file
|
|
@ -0,0 +1,122 @@
|
|||
# api/admin/admin.py
|
||||
from fastapi import APIRouter, Depends, HTTPException, status
|
||||
from sqlalchemy.orm import Session
|
||||
from typing import List
|
||||
|
||||
from api.auth import models, security
|
||||
from api.db.database import get_db
|
||||
from api.db import models as db_models
|
||||
|
||||
router = APIRouter()
|
||||
|
||||
def get_current_admin_user(db: Session = Depends(get_db), token: str = Depends(security.oauth2_scheme)):
|
||||
"""
|
||||
获取当前登录的管理员用户
|
||||
"""
|
||||
credentials_exception = HTTPException(
|
||||
status_code=status.HTTP_401_UNAUTHORIZED,
|
||||
detail="Could not validate credentials",
|
||||
headers={"WWW-Authenticate": "Bearer"},
|
||||
)
|
||||
try:
|
||||
payload = security.decode_access_token(token)
|
||||
username: str = payload.get("sub")
|
||||
if username is None:
|
||||
raise credentials_exception
|
||||
except Exception:
|
||||
raise credentials_exception
|
||||
|
||||
user = db.query(db_models.User).filter(db_models.User.username == username).first()
|
||||
if user is None or user.id != 1: # 默认第一个注册的是管理员
|
||||
raise HTTPException(status_code=status.HTTP_403_FORBIDDEN, detail="Not enough permissions")
|
||||
|
||||
return user
|
||||
|
||||
@router.get("/admin/check", response_model=dict)
|
||||
def check_admin(db: Session = Depends(get_db), current_user: db_models.User = Depends(get_current_admin_user)):
|
||||
"""
|
||||
检查当前用户是否为管理员
|
||||
"""
|
||||
if current_user.id == 1: # 默认第一个注册的是管理员
|
||||
return {"isAdmin": True}
|
||||
else:
|
||||
return {"isAdmin": False}
|
||||
|
||||
@router.get("/users", response_model=List[models.UserResponse])
|
||||
def list_users(db: Session = Depends(get_db), current_user: db_models.User = Depends(get_current_admin_user)):
|
||||
"""
|
||||
获取所有用户信息
|
||||
"""
|
||||
users = db.query(db_models.User).all()
|
||||
return users
|
||||
|
||||
@router.post("/users", response_model=models.UserResponse)
|
||||
def create_user(user: models.UserCreate, db: Session = Depends(get_db), current_user: db_models.User = Depends(get_current_admin_user)):
|
||||
"""
|
||||
创建新用户
|
||||
"""
|
||||
existing_user = db.query(db_models.User).filter(db_models.User.username == user.username).first()
|
||||
if existing_user:
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_400_BAD_REQUEST,
|
||||
detail="Username already registered"
|
||||
)
|
||||
hashed_password = security.get_password_hash(user.password)
|
||||
new_user = db_models.User(
|
||||
username=user.username,
|
||||
email=user.email,
|
||||
full_name=user.full_name,
|
||||
hashed_password=hashed_password,
|
||||
disabled=False
|
||||
)
|
||||
db.add(new_user)
|
||||
db.commit()
|
||||
db.refresh(new_user)
|
||||
return new_user
|
||||
|
||||
@router.delete("/users/{user_id}", response_model=models.UserResponse)
|
||||
def delete_user(user_id: int, db: Session = Depends(get_db), current_user: db_models.User = Depends(get_current_admin_user)):
|
||||
"""
|
||||
删除用户
|
||||
"""
|
||||
user = db.query(db_models.User).filter(db_models.User.id == user_id).first()
|
||||
if not user:
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_404_NOT_FOUND,
|
||||
detail="User not found"
|
||||
)
|
||||
db.delete(user)
|
||||
db.commit()
|
||||
return user
|
||||
|
||||
@router.put("/users/{user_id}/disable", response_model=models.UserResponse)
|
||||
def disable_user(user_id: int, db: Session = Depends(get_db), current_user: db_models.User = Depends(get_current_admin_user)):
|
||||
"""
|
||||
禁用用户
|
||||
"""
|
||||
user = db.query(db_models.User).filter(db_models.User.id == user_id).first()
|
||||
if not user:
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_404_NOT_FOUND,
|
||||
detail="User not found"
|
||||
)
|
||||
user.disabled = True
|
||||
db.commit()
|
||||
db.refresh(user)
|
||||
return user
|
||||
|
||||
@router.put("/users/{user_id}/enable", response_model=models.UserResponse)
|
||||
def enable_user(user_id: int, db: Session = Depends(get_db), current_user: db_models.User = Depends(get_current_admin_user)):
|
||||
"""
|
||||
启用用户
|
||||
"""
|
||||
user = db.query(db_models.User).filter(db_models.User.id == user_id).first()
|
||||
if not user:
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_404_NOT_FOUND,
|
||||
detail="User not found"
|
||||
)
|
||||
user.disabled = False
|
||||
db.commit()
|
||||
db.refresh(user)
|
||||
return user
|
||||
57
web/api/app.py
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
# api/main.py
|
||||
from fastapi import FastAPI, Depends
|
||||
from fastapi.middleware.cors import CORSMiddleware
|
||||
from fastapi.staticfiles import StaticFiles
|
||||
|
||||
from api.admin import admin
|
||||
from api.auth import auth as auth_router
|
||||
from api.auth.dependencies import get_current_active_user
|
||||
|
||||
description = """
|
||||
`VScode`启动! 🚀
|
||||
"""
|
||||
|
||||
app = FastAPI(
|
||||
title="App",
|
||||
description=description,
|
||||
summary="我们生来,就是为了,在宇宙中,留下印记。",
|
||||
version="0.0.1",
|
||||
terms_of_service="https://blog.kalicyh.love/",
|
||||
contact={
|
||||
"name": "kalicyh",
|
||||
"url": "https://blog.kalicyh.love/",
|
||||
"email": "kalicyh@qq.com",
|
||||
},
|
||||
license_info={
|
||||
"name": "MIT",
|
||||
"url": "https://mit-license.org/",
|
||||
},
|
||||
)
|
||||
|
||||
# 允许所有域名跨域
|
||||
app.add_middleware(
|
||||
CORSMiddleware,
|
||||
allow_origins=["*"], # 允许所有域名
|
||||
allow_credentials=True, # 允许携带 Cookies
|
||||
allow_methods=["*"], # 允许所有 HTTP 方法
|
||||
allow_headers=["*"], # 允许所有请求头
|
||||
)
|
||||
|
||||
# 注册认证路由
|
||||
app.include_router(auth_router.router, prefix="/auth", tags=["auth"])
|
||||
app.include_router(admin.router, prefix="/admin", tags=["admin"])
|
||||
|
||||
# 示例:受保护接口,需要 Bearer Token 验证
|
||||
@app.get("/users/me")
|
||||
async def read_users_me(current_user = Depends(get_current_active_user)):
|
||||
return current_user
|
||||
|
||||
# 挂载 React 静态文件
|
||||
app.mount("/", StaticFiles(directory="dist", html=True), name="dist")
|
||||
|
||||
# 应用启动时检查并创建数据库表
|
||||
@app.on_event("startup")
|
||||
def on_startup():
|
||||
from api.db import database, models
|
||||
models.Base.metadata.create_all(bind=database.engine)
|
||||
print("数据库表检查完成,如果不存在则已创建!")
|
||||
0
web/api/auth/__init__.py
Normal file
66
web/api/auth/auth.py
Normal file
|
|
@ -0,0 +1,66 @@
|
|||
# api/auth/auth.py
|
||||
from fastapi import APIRouter, Depends, HTTPException, status
|
||||
from fastapi.security import OAuth2PasswordRequestForm
|
||||
from sqlalchemy.orm import Session
|
||||
from datetime import timedelta
|
||||
|
||||
from api.auth import models, security
|
||||
from api.db.database import get_db
|
||||
from api.db import models as db_models
|
||||
|
||||
router = APIRouter()
|
||||
|
||||
@router.post("/register", response_model=models.UserResponse)
|
||||
def register(user: models.UserCreate, db: Session = Depends(get_db)):
|
||||
"""
|
||||
用户注册接口
|
||||
检查用户名是否存在,若不存在则对密码进行 bcrypt 哈希处理后保存到数据库
|
||||
"""
|
||||
# 检查用户名是否已存在
|
||||
existing_user = db.query(db_models.User).filter(db_models.User.username == user.username).first()
|
||||
if existing_user:
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_400_BAD_REQUEST,
|
||||
detail="Username already registered"
|
||||
)
|
||||
# 对密码进行 bcrypt 哈希处理
|
||||
hashed_password = security.get_password_hash(user.password)
|
||||
# 创建新用户记录
|
||||
new_user = db_models.User(
|
||||
username=user.username,
|
||||
email=user.email,
|
||||
full_name=user.full_name,
|
||||
hashed_password=hashed_password,
|
||||
disabled=False
|
||||
)
|
||||
db.add(new_user)
|
||||
db.commit()
|
||||
db.refresh(new_user)
|
||||
return new_user
|
||||
|
||||
@router.post("/login", response_model=models.Token)
|
||||
def login_for_access_token(form_data: OAuth2PasswordRequestForm = Depends(), db: Session = Depends(get_db)):
|
||||
"""
|
||||
用户登录接口
|
||||
通过 OAuth2PasswordRequestForm 获取表单中的 username 和 password,
|
||||
查询数据库,验证密码后生成 JWT 令牌返回
|
||||
"""
|
||||
# 从数据库中查询用户
|
||||
user = db.query(db_models.User).filter(db_models.User.username == form_data.username).first()
|
||||
if not user:
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_401_UNAUTHORIZED,
|
||||
detail="Incorrect username or password",
|
||||
headers={"WWW-Authenticate": "Bearer"}
|
||||
)
|
||||
if not security.verify_password(form_data.password, user.hashed_password):
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_401_UNAUTHORIZED,
|
||||
detail="Incorrect username or password",
|
||||
headers={"WWW-Authenticate": "Bearer"}
|
||||
)
|
||||
access_token_expires = timedelta(minutes=security.ACCESS_TOKEN_EXPIRE_MINUTES)
|
||||
access_token = security.create_access_token(
|
||||
data={"sub": user.username}, expires_delta=access_token_expires
|
||||
)
|
||||
return {"access_token": access_token, "token_type": "bearer"}
|
||||
59
web/api/auth/dependencies.py
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
# api/auth/dependencies.py
|
||||
from fastapi import Depends, HTTPException, status
|
||||
from fastapi.security import OAuth2PasswordBearer
|
||||
from jose import JWTError, jwt
|
||||
from sqlalchemy.orm import Session
|
||||
|
||||
from api.auth import models, security
|
||||
from api.db.database import get_db
|
||||
from api.db import models as db_models
|
||||
|
||||
oauth2_scheme = OAuth2PasswordBearer(tokenUrl="/auth/login")
|
||||
|
||||
def get_user(db: Session, username: str):
|
||||
"""
|
||||
获取用户(从数据库中查询)
|
||||
"""
|
||||
return db.query(db_models.User).filter(db_models.User.username == username).first()
|
||||
|
||||
def authenticate_user(db: Session, username: str, password: str):
|
||||
"""
|
||||
验证用户凭证
|
||||
使用数据库中的用户数据进行验证
|
||||
"""
|
||||
user = get_user(db, username)
|
||||
if not user:
|
||||
return None
|
||||
if not security.verify_password(password, user.hashed_password):
|
||||
return None
|
||||
return user
|
||||
|
||||
async def get_current_user(token: str = Depends(oauth2_scheme), db: Session = Depends(get_db)):
|
||||
"""
|
||||
从 JWT 令牌中解析用户,并从数据库中获取该用户
|
||||
"""
|
||||
credentials_exception = HTTPException(
|
||||
status_code=status.HTTP_401_UNAUTHORIZED,
|
||||
detail="Could not validate credentials",
|
||||
headers={"WWW-Authenticate": "Bearer"},
|
||||
)
|
||||
try:
|
||||
payload = jwt.decode(token, security.SECRET_KEY, algorithms=[security.ALGORITHM])
|
||||
username: str = payload.get("sub")
|
||||
if username is None:
|
||||
raise credentials_exception
|
||||
except JWTError:
|
||||
raise credentials_exception
|
||||
|
||||
user = get_user(db, username)
|
||||
if user is None:
|
||||
raise credentials_exception
|
||||
return user
|
||||
|
||||
async def get_current_active_user(current_user: db_models.User = Depends(get_current_user)):
|
||||
"""
|
||||
检查当前用户是否处于激活状态
|
||||
"""
|
||||
if current_user.disabled:
|
||||
raise HTTPException(status_code=400, detail="Inactive user")
|
||||
return current_user
|
||||
37
web/api/auth/models.py
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
# api/auth/models.py
|
||||
from pydantic import BaseModel
|
||||
from typing import Optional
|
||||
|
||||
class Token(BaseModel):
|
||||
access_token: str
|
||||
token_type: str
|
||||
|
||||
class TokenData(BaseModel):
|
||||
username: Optional[str] = None
|
||||
|
||||
class User(BaseModel):
|
||||
username: str
|
||||
email: Optional[str] = None
|
||||
full_name: Optional[str] = None
|
||||
disabled: Optional[bool] = None
|
||||
|
||||
class UserInDB(User):
|
||||
hashed_password: str
|
||||
|
||||
# 用户注册时请求数据模型
|
||||
class UserCreate(BaseModel):
|
||||
username: str
|
||||
email: Optional[str] = None
|
||||
full_name: Optional[str] = None
|
||||
password: str
|
||||
|
||||
# 用户响应数据模型(不返回密码)
|
||||
class UserResponse(BaseModel):
|
||||
id: int
|
||||
username: str
|
||||
email: Optional[str] = None
|
||||
full_name: Optional[str] = None
|
||||
disabled: Optional[bool] = None
|
||||
|
||||
class Config:
|
||||
orm_mode = True
|
||||
51
web/api/auth/security.py
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
# api/auth/security.py
|
||||
import bcrypt
|
||||
from datetime import datetime, timedelta
|
||||
from jose import JWTError, jwt
|
||||
from fastapi.security import OAuth2PasswordBearer
|
||||
|
||||
oauth2_scheme = OAuth2PasswordBearer(tokenUrl="/auth/login")
|
||||
|
||||
# JWT 配置
|
||||
SECRET_KEY = "9f24447481c6012c3ee0217fa252dd1692af0f67c5eab78b5c19eab87f196215" # 建议放到环境变量中
|
||||
ALGORITHM = "HS256"
|
||||
ACCESS_TOKEN_EXPIRE_MINUTES = 30
|
||||
|
||||
def get_password_hash(password: str) -> str:
|
||||
"""
|
||||
生成密码哈希
|
||||
获取密码hash
|
||||
"""
|
||||
# 生成盐并计算密码哈希
|
||||
hashed = bcrypt.hashpw(password.encode('utf-8'), bcrypt.gensalt())
|
||||
return hashed.decode('utf-8')
|
||||
|
||||
def verify_password(plain_password: str, hashed_password: str) -> bool:
|
||||
"""
|
||||
校验密码
|
||||
校验密码是否匹配
|
||||
"""
|
||||
return bcrypt.checkpw(plain_password.encode('utf-8'), hashed_password.encode('utf-8'))
|
||||
|
||||
def create_access_token(data: dict, expires_delta: timedelta = None) -> str:
|
||||
"""
|
||||
生成 JWT 令牌
|
||||
"""
|
||||
to_encode = data.copy()
|
||||
if expires_delta:
|
||||
expire = datetime.utcnow() + expires_delta
|
||||
else:
|
||||
expire = datetime.utcnow() + timedelta(minutes=15)
|
||||
to_encode.update({"exp": expire})
|
||||
encoded_jwt = jwt.encode(to_encode, SECRET_KEY, algorithm=ALGORITHM)
|
||||
return encoded_jwt
|
||||
|
||||
def decode_access_token(token: str) -> dict:
|
||||
"""
|
||||
解码 JWT 令牌并返回 payload 数据
|
||||
"""
|
||||
try:
|
||||
payload = jwt.decode(token, SECRET_KEY, algorithms=[ALGORITHM])
|
||||
return payload # payload 是一个字典,包含 "sub" 等数据
|
||||
except JWTError:
|
||||
return None # 令牌无效时返回 None
|
||||
0
web/api/db/__init__.py
Normal file
31
web/api/db/database.py
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
# api/db/database.py
|
||||
import os
|
||||
from sqlalchemy import create_engine
|
||||
from sqlalchemy.ext.declarative import declarative_base
|
||||
from sqlalchemy.orm import sessionmaker
|
||||
|
||||
# 获取数据库连接 URL,可通过环境变量设置,例如:
|
||||
# SQLite: sqlite:///./sql_app.db
|
||||
# PostgreSQL: postgresql+asyncpg://user:password@localhost/dbname
|
||||
# MySQL: mysql+pymysql://user:password@localhost/dbname
|
||||
DATABASE_URL = os.getenv("DATABASE_URL", "sqlite:///./sql_app.db")
|
||||
|
||||
if DATABASE_URL.startswith("sqlite"):
|
||||
engine = create_engine(
|
||||
DATABASE_URL, connect_args={"check_same_thread": False}
|
||||
)
|
||||
else:
|
||||
engine = create_engine(DATABASE_URL)
|
||||
|
||||
SessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine)
|
||||
Base = declarative_base()
|
||||
|
||||
def get_db():
|
||||
"""
|
||||
获取数据库会话
|
||||
"""
|
||||
db = SessionLocal()
|
||||
try:
|
||||
yield db
|
||||
finally:
|
||||
db.close()
|
||||
13
web/api/db/models.py
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
# api/db/models.py
|
||||
from sqlalchemy import Column, Integer, String, Boolean
|
||||
from api.db.database import Base
|
||||
|
||||
class User(Base):
|
||||
__tablename__ = "users"
|
||||
|
||||
id = Column(Integer, primary_key=True, index=True)
|
||||
username = Column(String(50), unique=True, index=True, nullable=False)
|
||||
email = Column(String(100), unique=True, index=True, nullable=True)
|
||||
full_name = Column(String(100), nullable=True)
|
||||
hashed_password = Column(String, nullable=False)
|
||||
disabled = Column(Boolean, default=False)
|
||||
24
web/index.html
Normal file → Executable file
|
|
@ -1,27 +1,15 @@
|
|||
<!doctype html>
|
||||
<html lang="en" style="height: 100%;">
|
||||
<html lang="zh">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<link rel="icon" href="/favicon.ico" />
|
||||
<meta name="theme-color" content="#000000" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>智控台</title>
|
||||
<style>
|
||||
html, body {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
#app {
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
}
|
||||
</style>
|
||||
<title>Kalicyh</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div id="app"></div>
|
||||
<script type="module" src="/src/main.js"></script>
|
||||
<div id="root"></div>
|
||||
<script type="module" src="/src/main.tsx"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
|||
1046
web/package-lock.json
generated
53
web/package.json
Normal file → Executable file
|
|
@ -1,24 +1,53 @@
|
|||
{
|
||||
"name": "web",
|
||||
"private": true,
|
||||
"version": "0.0.0",
|
||||
"name": "dash",
|
||||
"author": "kalicyh",
|
||||
"licence": "MIT",
|
||||
"version": "1.0.0",
|
||||
"private": false,
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "concurrently -n 'Frontend,Backend' -c 'blue,green' 'yarn run dev:ui' 'npm run dev:api'",
|
||||
"dev": "concurrently -n 'Frontend,Backend' -c 'blue,green' 'yarn run dev:ui' 'yarn run dev:api'",
|
||||
"dev:ui": "vite",
|
||||
"dev:api": "cd .. && poetry run python app.py",
|
||||
"dev:d": "docker exec xiaozhi-env poetry run python app.py",
|
||||
"build": "vite build",
|
||||
"preview": "vite preview"
|
||||
"dev:api": "poetry run uvicorn api.app:app --host 0.0.0.0 --port 8888 --reload",
|
||||
"start": "vite preview",
|
||||
"build": "tsc && vite build",
|
||||
"dev:host": "vite --host",
|
||||
"lib": "yarn install && poetry install --no-root"
|
||||
},
|
||||
"engines": {
|
||||
"node": "20.x"
|
||||
},
|
||||
"packageManager": "yarn@1.22.22",
|
||||
"dependencies": {
|
||||
"@emotion/cache": "^11.13.1",
|
||||
"@emotion/react": "^11.14.0",
|
||||
"@emotion/styled": "^11.14.0",
|
||||
"@fontsource-variable/dm-sans": "^5.0.7",
|
||||
"@fontsource/barlow": "^5.0.14",
|
||||
"@iconify/react": "^5.0.2",
|
||||
"@mui/icons-material": "^6.4.4",
|
||||
"@mui/lab": "^6.0.0-beta.27",
|
||||
"@mui/material": "^6.4.4",
|
||||
"apexcharts": "^4.4.0",
|
||||
"axios": "^1.7.9",
|
||||
"vue": "^3.5.10",
|
||||
"vue-router": "^4.0.0"
|
||||
"dayjs": "^1.11.13",
|
||||
"history": "^5.3.0",
|
||||
"react": "^19.0.0",
|
||||
"react-apexcharts": "^1.4.1",
|
||||
"react-dom": "^19.0.0",
|
||||
"react-helmet-async": "^2.0.5",
|
||||
"react-router-dom": "^7.1.5",
|
||||
"simplebar-react": "^3.2.6",
|
||||
"sonner": "^2.0.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@vitejs/plugin-vue": "^5.1.4",
|
||||
"@types/node": "^22.5.0",
|
||||
"@types/react": "^19.0.8",
|
||||
"@types/react-dom": "^19.0.3",
|
||||
"@vitejs/plugin-react-swc": "^3.7.0",
|
||||
"concurrently": "^9.1.2",
|
||||
"vite": "^5.4.8"
|
||||
"typescript": "^5.5.4",
|
||||
"vite": "^6.1.0",
|
||||
"vite-plugin-checker": "^0.8.0"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
1739
web/poetry.lock
generated
Normal file
15
web/prettier.config.mjs
Executable file
|
|
@ -0,0 +1,15 @@
|
|||
/**
|
||||
* @type {import("prettier").Config}
|
||||
* Need to restart IDE when changing configuration
|
||||
* Open the command palette (Ctrl + Shift + P) and execute the command > Reload Window.
|
||||
*/
|
||||
const config = {
|
||||
semi: true,
|
||||
tabWidth: 2,
|
||||
endOfLine: 'lf',
|
||||
printWidth: 100,
|
||||
singleQuote: true,
|
||||
trailingComma: 'es5',
|
||||
};
|
||||
|
||||
export default config;
|
||||
BIN
web/public/assets/background/overlay.jpg
Executable file
|
After Width: | Height: | Size: 25 KiB |
1
web/public/assets/background/shape-square.svg
Executable file
|
After Width: | Height: | Size: 145 KiB |
1
web/public/assets/icons/flags/ic-flag-de.svg
Executable file
|
|
@ -0,0 +1 @@
|
|||
<svg height="20" viewBox="0 0 28 20" width="28" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"><defs><path id="a" d="m0 6.667h28v6.667h-28z"/><filter id="b" height="145%" width="110.7%" x="-5.4%" y="-22.5%"><feMorphology in="SourceAlpha" operator="dilate" radius=".5" result="shadowSpreadOuter1"/><feOffset in="shadowSpreadOuter1" result="shadowOffsetOuter1"/><feColorMatrix in="shadowOffsetOuter1" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.06 0"/></filter><path id="c" d="m0 13.333h28v6.667h-28z"/><filter id="d" height="145%" width="110.7%" x="-5.4%" y="-22.5%"><feMorphology in="SourceAlpha" operator="dilate" radius=".5" result="shadowSpreadOuter1"/><feOffset in="shadowSpreadOuter1" result="shadowOffsetOuter1"/><feColorMatrix in="shadowOffsetOuter1" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.06 0"/></filter><mask id="e" fill="#fff"><rect fill="#fff" fill-rule="evenodd" height="20" rx="3" width="28"/></mask></defs><g fill="none" fill-rule="evenodd"><path d="m0 0h28v6.667h-28z" fill="#262626" mask="url(#e)"/><g mask="url(#e)"><use fill="#000" filter="url(#b)" xlink:href="#a"/><use fill="#f01515" xlink:href="#a"/></g><g mask="url(#e)"><use fill="#000" filter="url(#d)" xlink:href="#c"/><use fill="#ffd521" xlink:href="#c"/></g></g></svg>
|
||||
|
After Width: | Height: | Size: 1.3 KiB |
1
web/public/assets/icons/flags/ic-flag-en.svg
Executable file
|
|
@ -0,0 +1 @@
|
|||
<svg height="20" viewBox="0 0 28 20" width="28" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"><defs><rect id="a" height="20" rx="3" width="28"/><mask id="b" fill="#fff"><use fill="#fff" fill-rule="evenodd" xlink:href="#a"/></mask></defs><g fill="none" fill-rule="evenodd"><use fill="#0a17a7" xlink:href="#a"/><path d="m29.2824692-1.91644623 1.4911811 2.21076686-9.4483006 6.37223314 6.6746503.0001129v6.66666663l-6.6746503-.0007795 9.4483006 6.3731256-1.4911811 2.2107668-11.9501195-8.0608924.0009836 7.4777795h-6.6666666l-.000317-7.4777795-11.9488189 8.0608924-1.49118107-2.2107668 9.448-6.3731256-6.67434973.0007795v-6.66666663l6.67434973-.0001129-9.448-6.37223314 1.49118107-2.21076686 11.9488189 8.06.000317-7.4768871h6.6666666l-.0009836 7.4768871z" fill="#fff" mask="url(#b)"/><g stroke="#db1f35" stroke-linecap="round" stroke-width=".667"><path d="m18.668 6.332 12.665-8.332" mask="url(#b)"/><path d="m20.013 21.35 11.354-7.652" mask="url(#b)" transform="matrix(1 0 0 -1 0 35.048)"/><path d="m8.006 6.31-11.843-7.981" mask="url(#b)"/><path d="m9.29 22.31-13.127-8.705" mask="url(#b)" transform="matrix(1 0 0 -1 0 35.915)"/></g><path d="m0 12h12v8h4v-8h12v-4h-12v-8h-4v8h-12z" fill="#e6273e" mask="url(#b)"/></g></svg>
|
||||
|
After Width: | Height: | Size: 1.2 KiB |
1
web/public/assets/icons/flags/ic-flag-fr.svg
Executable file
|
|
@ -0,0 +1 @@
|
|||
<svg height="20" viewBox="0 0 28 20" width="28" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"><defs><rect id="a" height="20" rx="3" width="28"/><mask id="b" fill="#fff"><use fill="#fff" fill-rule="evenodd" xlink:href="#a"/></mask></defs><g fill="none" fill-rule="evenodd"><use fill="#fff" xlink:href="#a"/><path d="m19 0h9v20h-9z" fill="#f44653" mask="url(#b)"/><path d="m0 0h9v20h-9z" fill="#1035bb" mask="url(#b)"/></g></svg>
|
||||
|
After Width: | Height: | Size: 459 B |
30
web/public/assets/icons/glass/ic-glass-bag.svg
Executable file
|
|
@ -0,0 +1,30 @@
|
|||
<svg width="64" height="64" viewBox="0 0 64 64" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path opacity="0.48" d="M32.912 22.4416L32.9128 22.4377L33.0211 22.0336C34.1115 17.1555 31.1485 12.2812 26.3038 10.9831C21.459 9.68494 16.4559 12.4247 14.9612 17.1944C14.9012 17.323 14.8642 17.4611 14.8519 17.6024L17.5128 18.3154C17.5728 18.1868 17.6098 18.0488 17.6222 17.9074C18.551 14.441 22.1237 12.3865 25.6021 13.3185C29.0804 14.2505 31.1472 17.8162 30.2184 21.2826C30.1828 21.4226 30.1724 21.5679 30.1878 21.7117L14.7102 17.5644C12.3936 16.9437 9.50735 17.8095 7.68682 21.7279L3.2802 32.5497C-0.0732567 40.4637 3.60985 43.6537 9.13788 45.1349L24.1243 49.1505C29.6363 50.6274 34.5399 48.7512 35.4737 41.176L37.0844 29.605C37.3083 25.3821 35.3524 23.0955 33.0677 22.4833L32.912 22.4416Z" fill="url(#paint0_linear_2581_180288)"/>
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M45.9755 17.205C45.8697 16.7652 45.7895 16.4418 45.7745 16.3935L45.633 15.8655C43.8335 10.1231 37.8101 6.82466 31.9774 8.38753C26.1447 9.9504 22.5775 15.8187 23.8902 21.6915C23.8957 21.7545 24.0451 22.3389 24.2347 23.0573C21.6807 23.9935 19.543 26.6156 19.9728 31.4506L21.8927 45.3864C23.1601 55.6563 28.9205 56.7652 35.5758 54.9819L53.6183 50.1475C60.2544 48.3693 64.2376 43.4614 60.6513 35.001L55.3653 21.9672C53.0567 17.4295 49.641 16.2228 46.8904 16.9598L45.9755 17.205ZM42.6309 18.1012L27.4716 22.1631C27.2796 21.4577 27.1203 20.8898 27.0938 20.8331C25.9756 16.6598 28.4639 12.367 32.6516 11.2449C36.8393 10.1228 41.1406 12.5963 42.2588 16.7696L42.2928 16.8918C42.3521 17.105 42.4797 17.5636 42.6309 18.1012Z" fill="url(#paint1_linear_2581_180288)"/>
|
||||
<path opacity="0.48" fill-rule="evenodd" clip-rule="evenodd" d="M45.9755 17.205C45.8697 16.7652 45.7895 16.4418 45.7745 16.3935L45.633 15.8655C43.8335 10.1231 37.8101 6.82466 31.9774 8.38753C26.1447 9.9504 22.5775 15.8187 23.8902 21.6915C23.8957 21.7545 24.0451 22.3389 24.2347 23.0573C21.6807 23.9935 19.543 26.6156 19.9728 31.4506L21.8927 45.3864C23.1601 55.6563 28.9205 56.7652 35.5758 54.9819L53.6183 50.1475C60.2544 48.3693 64.2376 43.4614 60.6513 35.001L55.3653 21.9672C53.0567 17.4295 49.641 16.2228 46.8904 16.9598L45.9755 17.205ZM42.6309 18.1012L27.4716 22.1631C27.2796 21.4577 27.1203 20.8898 27.0938 20.8331C25.9756 16.6598 28.4639 12.367 32.6516 11.2449C36.8393 10.1228 41.1406 12.5963 42.2588 16.7696L42.2928 16.8918C42.3521 17.105 42.4797 17.5636 42.6309 18.1012Z" fill="url(#paint2_linear_2581_180288)"/>
|
||||
<path opacity="0.04" d="M45.4893 17.3219L45.6093 17.8208L46.1049 17.688L47.0198 17.4428C49.489 16.7812 52.6838 17.8142 54.91 22.175L60.1879 35.1889L60.1879 35.189L60.1909 35.1962C61.945 39.3341 61.8111 42.5072 60.53 44.8393C59.2417 47.1846 56.7302 48.796 53.4889 49.6645L35.4464 54.499C32.1554 55.3808 29.2119 55.5087 26.9549 54.2661C24.7238 53.0378 23.013 50.3817 22.3889 45.3251L22.3889 45.3251L22.388 45.3181L20.4698 31.3944C20.2645 29.064 20.6803 27.3113 21.4171 26.0431C22.1545 24.774 23.2316 23.9575 24.4068 23.5267L24.8343 23.37L24.7182 22.9297C24.6236 22.5712 24.5393 22.2473 24.4781 22.0059C24.4475 21.8849 24.4231 21.7864 24.4063 21.7152C24.3916 21.6535 24.3873 21.6308 24.3869 21.6309L24.3855 21.6149L24.3782 21.5824C23.1242 15.9726 26.5315 10.3644 32.1068 8.87049C37.6787 7.37749 43.43 10.526 45.1528 16.0051L45.2915 16.5229L45.2941 16.5327L45.2972 16.5423C45.297 16.5418 45.297 16.5419 45.2973 16.5429C45.2983 16.5467 45.3031 16.5642 45.3131 16.6031C45.3239 16.6452 45.3382 16.7024 45.3556 16.7727C45.3904 16.9131 45.4366 17.1027 45.4893 17.3219ZM42.7603 18.5841L43.2493 18.4531L43.1122 17.9658C42.9612 17.429 42.8338 16.971 42.7746 16.7578L42.7745 16.7577L42.7418 16.6402C42.7416 16.6394 42.7413 16.6386 42.7411 16.6378C41.55 12.1977 36.9742 9.56905 32.5222 10.762C28.0693 11.9551 25.4208 16.5209 26.6109 20.9625L26.6222 21.0048L26.6334 21.0287C26.6331 21.0293 26.6406 21.0508 26.6581 21.1092C26.6786 21.1778 26.7062 21.2733 26.7395 21.391C26.806 21.6259 26.8934 21.9424 26.9892 22.2944L27.12 22.7749L27.601 22.646L42.7603 18.5841Z" stroke="black"/>
|
||||
<path d="M32.4467 32.8606C31.3844 33.1452 30.2857 32.4896 29.9927 31.3962C29.6997 30.3028 30.3234 29.1857 31.3858 28.901C32.4481 28.6164 33.5468 29.272 33.8397 30.3654C34.1327 31.4588 33.509 32.5759 32.4467 32.8606Z" fill="url(#paint3_linear_2581_180288)"/>
|
||||
<path d="M42.5916 28.0206C42.8846 29.114 43.9833 29.7696 45.0456 29.485C46.1079 29.2003 46.7316 28.0832 46.4386 26.9898C46.1456 25.8964 45.047 25.2408 43.9846 25.5254C42.9223 25.8101 42.2986 26.9272 42.5916 28.0206Z" fill="url(#paint4_linear_2581_180288)"/>
|
||||
<defs>
|
||||
<linearGradient id="paint0_linear_2581_180288" x1="2" y1="10.6612" x2="40.7444" y2="45.5736" gradientUnits="userSpaceOnUse">
|
||||
<stop stop-color="#73BAFB"/>
|
||||
<stop offset="1" stop-color="#1877F2"/>
|
||||
</linearGradient>
|
||||
<linearGradient id="paint1_linear_2581_180288" x1="19.9175" y1="8" x2="67.2278" y2="49.7565" gradientUnits="userSpaceOnUse">
|
||||
<stop stop-color="#73BAFB"/>
|
||||
<stop offset="1" stop-color="#1877F2"/>
|
||||
</linearGradient>
|
||||
<linearGradient id="paint2_linear_2581_180288" x1="19.9175" y1="8" x2="67.2278" y2="49.7565" gradientUnits="userSpaceOnUse">
|
||||
<stop stop-color="#1877F2"/>
|
||||
<stop offset="1" stop-color="#0C44AE"/>
|
||||
</linearGradient>
|
||||
<linearGradient id="paint3_linear_2581_180288" x1="30.1261" y1="29.9601" x2="38.3844" y2="37.9524" gradientUnits="userSpaceOnUse">
|
||||
<stop stop-color="white" stop-opacity="0.16"/>
|
||||
<stop offset="1" stop-color="white" stop-opacity="0.64"/>
|
||||
</linearGradient>
|
||||
<linearGradient id="paint4_linear_2581_180288" x1="30.1261" y1="29.9601" x2="38.3844" y2="37.9524" gradientUnits="userSpaceOnUse">
|
||||
<stop stop-color="white" stop-opacity="0.16"/>
|
||||
<stop offset="1" stop-color="white" stop-opacity="0.64"/>
|
||||
</linearGradient>
|
||||
</defs>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 5.6 KiB |
47
web/public/assets/icons/glass/ic-glass-buy.svg
Executable file
|
|
@ -0,0 +1,47 @@
|
|||
<svg width="64" height="64" viewBox="0 0 64 64" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path opacity="0.48" d="M43.4118 15.2792C42.6075 14.3345 41.8032 13.9033 40.5766 13.9033H13.4218C12.7783 13.9033 12.2555 13.4104 12.1952 12.7512L11.8132 8.15124C11.7528 7.45303 11.2502 6.88008 10.5665 6.75481L5.77093 6.01758C4.94653 5.89232 4.16235 6.44883 4.0216 7.28874C3.88085 8.11017 4.44385 8.91106 5.24814 9.05481C7.03701 9.36938 8.38864 10.8509 8.53822 12.661L10.1342 31.9746C10.3554 34.6853 12.5672 36.7779 15.2415 36.7779H37.1785C39.7321 36.7779 41.9037 34.8702 42.2656 32.2806L44.1758 18.8092C44.3568 17.5792 44.216 16.2238 43.4118 15.2792Z" fill="url(#paint0_linear_2581_180285)"/>
|
||||
<path d="M20.2268 22.7221C18.893 22.7221 18.0184 23.191 17.1439 24.2182C16.2693 25.2454 16.1162 26.7192 16.313 28.0568L18.3901 42.7055C18.7837 45.5214 21.1451 47.5959 23.9219 47.5959H47.7762C50.6842 47.5959 53.0893 45.3204 53.3298 42.3728L55.3413 18.0304L58.6429 17.4498C59.5175 17.2935 60.1297 16.4226 59.9766 15.5294C59.8236 14.6161 58.9708 14.011 58.0744 14.1472L52.8597 14.9488C52.1163 15.0851 51.5697 15.7081 51.5041 16.4673L51.0887 21.4693C51.0231 22.1861 50.4546 22.7221 49.7549 22.7221H20.2268Z" fill="url(#paint1_linear_2581_180285)"/>
|
||||
<path d="M48.1267 51.1256C49.9633 51.1256 51.4501 52.6441 51.4501 54.5199C51.4501 56.3733 49.9633 57.8917 48.1267 57.8917C46.312 57.8917 44.8252 56.3733 44.8252 54.5199C44.8252 52.6441 46.312 51.1256 48.1267 51.1256Z" fill="url(#paint2_linear_2581_180285)"/>
|
||||
<path d="M23.5292 51.1256C25.3659 51.1256 26.8527 52.6441 26.8527 54.5199C26.8527 56.3733 25.3659 57.8917 23.5292 57.8917C21.7145 57.8917 20.2277 56.3733 20.2277 54.5199C20.2277 52.6441 21.7145 51.1256 23.5292 51.1256Z" fill="url(#paint3_linear_2581_180285)"/>
|
||||
<g opacity="0.48">
|
||||
<path d="M20.2268 22.7221C18.893 22.7221 18.0184 23.191 17.1439 24.2182C16.2693 25.2454 16.1162 26.7192 16.313 28.0568L18.3901 42.7055C18.7837 45.5214 21.1451 47.5959 23.9219 47.5959H47.7762C50.6842 47.5959 53.0893 45.3204 53.3298 42.3728L55.3413 18.0304L58.6429 17.4498C59.5175 17.2935 60.1297 16.4226 59.9766 15.5294C59.8236 14.6161 58.9708 14.011 58.0744 14.1472L52.8597 14.9488C52.1163 15.0851 51.5697 15.7081 51.5041 16.4673L51.0887 21.4693C51.0231 22.1861 50.4546 22.7221 49.7549 22.7221H20.2268Z" fill="url(#paint4_linear_2581_180285)"/>
|
||||
<path d="M48.1267 51.1256C49.9633 51.1256 51.4501 52.6441 51.4501 54.5199C51.4501 56.3733 49.9633 57.8917 48.1267 57.8917C46.312 57.8917 44.8252 56.3733 44.8252 54.5199C44.8252 52.6441 46.312 51.1256 48.1267 51.1256Z" fill="url(#paint5_linear_2581_180285)"/>
|
||||
<path d="M23.5292 51.1256C25.3659 51.1256 26.8527 52.6441 26.8527 54.5199C26.8527 56.3733 25.3659 57.8917 23.5292 57.8917C21.7145 57.8917 20.2277 56.3733 20.2277 54.5199C20.2277 52.6441 21.7145 51.1256 23.5292 51.1256Z" fill="url(#paint6_linear_2581_180285)"/>
|
||||
</g>
|
||||
<path opacity="0.04" d="M16.8081 27.9866L16.8077 27.984C16.6205 26.7118 16.7842 25.4118 17.5246 24.5423C17.9333 24.0623 18.3195 23.7393 18.7355 23.5328C19.1484 23.3277 19.6216 23.2221 20.2268 23.2221H49.7549C50.7264 23.2221 51.4987 22.4756 51.5866 21.5149L51.5869 21.5107L52.0022 16.5103C52.0491 15.9681 52.4342 15.5381 52.9434 15.4418L58.1495 14.6415C58.1497 14.6415 58.1499 14.6414 58.1501 14.6414C58.7781 14.5463 59.3759 14.9702 59.4835 15.6121L59.4838 15.6139C59.5909 16.2391 59.1563 16.8498 58.5555 16.9575C58.5553 16.9576 58.5551 16.9576 58.5549 16.9576L55.2547 17.538L54.8748 17.6048L54.843 17.9893L52.8315 42.3316L52.8314 42.3322C52.6113 45.0302 50.4139 47.0959 47.7762 47.0959H23.9219C21.4007 47.0959 19.2452 45.2114 18.8853 42.6363L18.8852 42.6353L16.8081 27.9866ZM48.1267 51.6256C49.6773 51.6256 50.9501 52.9103 50.9501 54.5199C50.9501 56.105 49.6795 57.3917 48.1267 57.3917C46.598 57.3917 45.3252 56.1071 45.3252 54.5199C45.3252 52.9081 46.6001 51.6256 48.1267 51.6256ZM23.5292 51.6256C25.0798 51.6256 26.3527 52.9103 26.3527 54.5199C26.3527 56.105 25.082 57.3917 23.5292 57.3917C22.0005 57.3917 20.7277 56.1071 20.7277 54.5199C20.7277 52.9081 22.0026 51.6256 23.5292 51.6256Z" stroke="black"/>
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M27.4194 34.3307H33.4759C34.3942 34.3307 35.1157 33.5715 35.1157 32.6559C35.1157 31.718 34.3942 30.9811 33.4759 30.9811H27.4194C26.5011 30.9811 25.7795 31.718 25.7795 32.6559C25.7795 33.5715 26.5011 34.3307 27.4194 34.3307Z" fill="url(#paint7_linear_2581_180285)"/>
|
||||
<defs>
|
||||
<linearGradient id="paint0_linear_2581_180285" x1="4" y1="6" x2="33.7031" y2="44.8405" gradientUnits="userSpaceOnUse">
|
||||
<stop stop-color="#FFD666"/>
|
||||
<stop offset="1" stop-color="#FFAB00"/>
|
||||
</linearGradient>
|
||||
<linearGradient id="paint1_linear_2581_180285" x1="16.2368" y1="14.1281" x2="60.0005" y2="57.8913" gradientUnits="userSpaceOnUse">
|
||||
<stop stop-color="#FFD666"/>
|
||||
<stop offset="1" stop-color="#FFAB00"/>
|
||||
</linearGradient>
|
||||
<linearGradient id="paint2_linear_2581_180285" x1="16.2368" y1="14.1281" x2="60.0005" y2="57.8913" gradientUnits="userSpaceOnUse">
|
||||
<stop stop-color="#FFD666"/>
|
||||
<stop offset="1" stop-color="#FFAB00"/>
|
||||
</linearGradient>
|
||||
<linearGradient id="paint3_linear_2581_180285" x1="16.2368" y1="14.1281" x2="60.0005" y2="57.8913" gradientUnits="userSpaceOnUse">
|
||||
<stop stop-color="#FFD666"/>
|
||||
<stop offset="1" stop-color="#FFAB00"/>
|
||||
</linearGradient>
|
||||
<linearGradient id="paint4_linear_2581_180285" x1="16.2368" y1="14.1281" x2="60.0005" y2="57.8913" gradientUnits="userSpaceOnUse">
|
||||
<stop stop-color="#FFAB00"/>
|
||||
<stop offset="1" stop-color="#B76E00"/>
|
||||
</linearGradient>
|
||||
<linearGradient id="paint5_linear_2581_180285" x1="16.2368" y1="14.1281" x2="60.0005" y2="57.8913" gradientUnits="userSpaceOnUse">
|
||||
<stop stop-color="#FFAB00"/>
|
||||
<stop offset="1" stop-color="#B76E00"/>
|
||||
</linearGradient>
|
||||
<linearGradient id="paint6_linear_2581_180285" x1="16.2368" y1="14.1281" x2="60.0005" y2="57.8913" gradientUnits="userSpaceOnUse">
|
||||
<stop stop-color="#FFAB00"/>
|
||||
<stop offset="1" stop-color="#B76E00"/>
|
||||
</linearGradient>
|
||||
<linearGradient id="paint7_linear_2581_180285" x1="35" y1="33" x2="31.3628" y2="37.4165" gradientUnits="userSpaceOnUse">
|
||||
<stop stop-color="white" stop-opacity="0.16"/>
|
||||
<stop offset="1" stop-color="white" stop-opacity="0.64"/>
|
||||
</linearGradient>
|
||||
</defs>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 6 KiB |
30
web/public/assets/icons/glass/ic-glass-message.svg
Executable file
|
|
@ -0,0 +1,30 @@
|
|||
<svg width="64" height="64" viewBox="0 0 64 64" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path opacity="0.48" d="M39.4251 10.5168C37.1706 9.21199 34.4888 8.86675 31.9774 9.53967L13.4762 14.497C8.2306 15.9026 5.13409 21.2687 6.53413 26.4937L10.4984 41.2886C11.8985 46.5137 17.2819 49.6075 22.5088 48.207L41.0099 43.2496C46.2369 41.8491 49.354 36.4775 47.9539 31.2525L43.9896 16.4575C43.3172 13.948 41.6805 11.8173 39.4251 10.5168Z" fill="url(#paint0_linear_2581_180287)"/>
|
||||
<path d="M56.7953 20.2744C54.7416 18.2164 51.95 17.0695 49.048 17.0695H27.6693C21.6078 17.0695 16.7192 21.9602 16.7192 27.9979V45.0939C16.7192 51.1316 21.6295 56.0224 27.6693 56.0224H49.048C55.0879 56.0224 60.0003 51.1316 60.0003 45.0939V27.9979C60.0003 25.0981 58.8512 22.3281 56.7953 20.2744Z" fill="url(#paint1_linear_2581_180287)"/>
|
||||
<path opacity="0.48" d="M56.7953 20.2744C54.7416 18.2164 51.95 17.0695 49.048 17.0695H27.6693C21.6078 17.0695 16.7192 21.9602 16.7192 27.9979V45.0939C16.7192 51.1316 21.6295 56.0224 27.6693 56.0224H49.048C55.0879 56.0224 60.0003 51.1316 60.0003 45.0939V27.9979C60.0003 25.0981 58.8512 22.3281 56.7953 20.2744Z" fill="url(#paint2_linear_2581_180287)"/>
|
||||
<g opacity="0.04">
|
||||
<mask id="path-4-inside-1_2581_180287" fill="white">
|
||||
<path d="M56.7953 20.2744C54.7416 18.2164 51.95 17.0695 49.048 17.0695H27.6693C21.6078 17.0695 16.7192 21.9602 16.7192 27.9979V45.0939C16.7192 51.1316 21.6295 56.0224 27.6693 56.0224H49.048C55.0879 56.0224 60.0003 51.1316 60.0003 45.0939V27.9979C60.0003 25.0981 58.8512 22.3281 56.7953 20.2744Z"/>
|
||||
</mask>
|
||||
<path d="M57.5032 19.5681C55.2602 17.3204 52.2132 16.0695 49.048 16.0695V18.0695C51.6868 18.0695 54.223 19.1124 56.0875 20.9808L57.5032 19.5681ZM49.048 16.0695H27.6693V18.0695H49.048V16.0695ZM27.6693 16.0695C21.0567 16.0695 15.7192 21.4068 15.7192 27.9979H17.7192C17.7192 22.5137 22.159 18.0695 27.6693 18.0695V16.0695ZM15.7192 27.9979V45.0939H17.7192V27.9979H15.7192ZM15.7192 45.0939C15.7192 51.6864 21.0796 57.0224 27.6693 57.0224V55.0224C22.1793 55.0224 17.7192 50.5769 17.7192 45.0939H15.7192ZM27.6693 57.0224H49.048V55.0224H27.6693V57.0224ZM49.048 57.0224C55.6374 57.0224 61.0003 51.6866 61.0003 45.0939H59.0003C59.0003 50.5766 54.5383 55.0224 49.048 55.0224V57.0224ZM61.0003 45.0939V27.9979H59.0003V45.0939H61.0003ZM61.0003 27.9979C61.0003 24.8322 59.7453 21.8078 57.502 19.5669L56.0886 20.9819C57.957 22.8484 59.0003 25.364 59.0003 27.9979H61.0003Z" fill="black" mask="url(#path-4-inside-1_2581_180287)"/>
|
||||
</g>
|
||||
<path d="M52.6642 31.0492L52.4911 31.2223L42.7291 39.0345C41.5194 39.9867 40.024 40.5061 38.4897 40.5061C36.9511 40.5061 35.4817 39.9867 34.2698 39.0345L24.4234 31.3521L24.1399 31.0708C23.6443 30.4216 23.7092 29.4911 24.2935 28.9068C24.854 28.3225 25.7846 28.2576 26.4576 28.7553L36.1958 36.5459C37.4704 37.5868 39.2688 37.5868 40.5239 36.5459L50.2816 28.7553C50.6084 28.4523 51.0412 28.2987 51.4957 28.3225C51.9263 28.3658 52.3396 28.5627 52.6404 28.8851C53.1815 29.5127 53.1815 30.4216 52.6642 31.0492Z" fill="url(#paint3_linear_2581_180287)"/>
|
||||
<defs>
|
||||
<linearGradient id="paint0_linear_2581_180287" x1="4" y1="17.0362" x2="47.5044" y2="45.3021" gradientUnits="userSpaceOnUse">
|
||||
<stop stop-color="#FFAC82"/>
|
||||
<stop offset="1" stop-color="#FF5630"/>
|
||||
</linearGradient>
|
||||
<linearGradient id="paint1_linear_2581_180287" x1="16.7192" y1="17.0695" x2="55.457" y2="60.1114" gradientUnits="userSpaceOnUse">
|
||||
<stop stop-color="#FFAC82"/>
|
||||
<stop offset="1" stop-color="#FF5630"/>
|
||||
</linearGradient>
|
||||
<linearGradient id="paint2_linear_2581_180287" x1="16.7192" y1="17.0695" x2="55.457" y2="60.1114" gradientUnits="userSpaceOnUse">
|
||||
<stop stop-color="#FF5630"/>
|
||||
<stop offset="1" stop-color="#B71D18"/>
|
||||
</linearGradient>
|
||||
<linearGradient id="paint3_linear_2581_180287" x1="24.1701" y1="35.6649" x2="37.6395" y2="49.7453" gradientUnits="userSpaceOnUse">
|
||||
<stop stop-color="white" stop-opacity="0.16"/>
|
||||
<stop offset="1" stop-color="white" stop-opacity="0.64"/>
|
||||
</linearGradient>
|
||||
</defs>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 3.8 KiB |
39
web/public/assets/icons/glass/ic-glass-users.svg
Executable file
|
|
@ -0,0 +1,39 @@
|
|||
<svg width="64" height="64" viewBox="0 0 64 64" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<g opacity="0.48">
|
||||
<path d="M12.133 21.5614C12.133 27.0199 16.5998 31.3942 22.1736 31.3942C27.7454 31.3942 32.2141 27.0199 32.2141 21.5614C32.2141 16.1029 27.7454 11.7286 22.1736 11.7286C16.5998 11.7286 12.133 16.1029 12.133 21.5614Z" fill="url(#paint0_linear_2581_180286)"/>
|
||||
<path d="M37.3479 42.5273C37.3479 37.4744 30.3579 36.2102 22.174 36.2102C13.9456 36.2102 7 37.518 7 42.5748C7 47.6278 13.99 48.892 22.174 48.892C30.4024 48.892 37.3479 47.5842 37.3479 42.5273Z" fill="url(#paint1_linear_2581_180286)"/>
|
||||
</g>
|
||||
<path d="M23.9326 20.8952C23.9326 28.0537 29.7904 33.7903 37.1002 33.7903C44.4073 33.7903 50.2678 28.0537 50.2678 20.8952C50.2678 13.7367 44.4073 8 37.1002 8C29.7904 8 23.9326 13.7367 23.9326 20.8952Z" fill="url(#paint2_linear_2581_180286)"/>
|
||||
<path d="M56.9997 48.3917C56.9997 41.7651 47.8328 40.1072 37.1 40.1072C26.3089 40.1072 17.2002 41.8222 17.2002 48.454C17.2002 55.0806 26.3672 56.7386 37.1 56.7386C47.891 56.7386 56.9997 55.0235 56.9997 48.3917Z" fill="url(#paint3_linear_2581_180286)"/>
|
||||
<g opacity="0.48">
|
||||
<path d="M23.9326 20.8952C23.9326 28.0537 29.7904 33.7903 37.1002 33.7903C44.4073 33.7903 50.2678 28.0537 50.2678 20.8952C50.2678 13.7367 44.4073 8 37.1002 8C29.7904 8 23.9326 13.7367 23.9326 20.8952Z" fill="url(#paint4_linear_2581_180286)"/>
|
||||
<path d="M56.9997 48.3917C56.9997 41.7651 47.8328 40.1072 37.1 40.1072C26.3089 40.1072 17.2002 41.8222 17.2002 48.454C17.2002 55.0806 26.3672 56.7386 37.1 56.7386C47.891 56.7386 56.9997 55.0235 56.9997 48.3917Z" fill="url(#paint5_linear_2581_180286)"/>
|
||||
</g>
|
||||
<path opacity="0.04" d="M37.1002 33.2903C30.0567 33.2903 24.4326 27.7677 24.4326 20.8952C24.4326 14.0226 30.0567 8.5 37.1002 8.5C44.1411 8.5 49.7678 14.0227 49.7678 20.8952C49.7678 27.7677 44.1411 33.2903 37.1002 33.2903ZM37.1 40.6072C42.4554 40.6072 47.3613 41.0227 50.9128 42.2376C52.6857 42.844 54.0846 43.6377 55.0362 44.645C55.9765 45.6404 56.4997 46.8641 56.4997 48.3917C56.4997 49.9219 55.9793 51.1507 55.0427 52.1522C54.0952 53.1654 52.7015 53.9662 50.9327 54.5797C47.3891 55.8088 42.4838 56.2386 37.1 56.2386C31.7445 56.2386 26.8386 55.823 23.2871 54.6082C21.5142 54.0017 20.1153 53.2081 19.1637 52.2007C18.2234 51.2053 17.7002 49.9817 17.7002 48.454C17.7002 46.9239 18.2206 45.695 19.1572 44.6936C20.1048 43.6804 21.4985 42.8796 23.2673 42.2661C26.8109 41.0369 31.7162 40.6072 37.1 40.6072Z" stroke="black"/>
|
||||
<defs>
|
||||
<linearGradient id="paint0_linear_2581_180286" x1="7" y1="11.7286" x2="43.4135" y2="41.4641" gradientUnits="userSpaceOnUse">
|
||||
<stop stop-color="#C684FF"/>
|
||||
<stop offset="1" stop-color="#8E33FF"/>
|
||||
</linearGradient>
|
||||
<linearGradient id="paint1_linear_2581_180286" x1="7" y1="11.7286" x2="43.4135" y2="41.4641" gradientUnits="userSpaceOnUse">
|
||||
<stop stop-color="#C684FF"/>
|
||||
<stop offset="1" stop-color="#8E33FF"/>
|
||||
</linearGradient>
|
||||
<linearGradient id="paint2_linear_2581_180286" x1="17.2002" y1="8" x2="64.9552" y2="46.9963" gradientUnits="userSpaceOnUse">
|
||||
<stop stop-color="#C684FF"/>
|
||||
<stop offset="1" stop-color="#8E33FF"/>
|
||||
</linearGradient>
|
||||
<linearGradient id="paint3_linear_2581_180286" x1="17.2002" y1="8" x2="64.9552" y2="46.9963" gradientUnits="userSpaceOnUse">
|
||||
<stop stop-color="#C684FF"/>
|
||||
<stop offset="1" stop-color="#8E33FF"/>
|
||||
</linearGradient>
|
||||
<linearGradient id="paint4_linear_2581_180286" x1="17.2002" y1="8" x2="64.9552" y2="46.9963" gradientUnits="userSpaceOnUse">
|
||||
<stop stop-color="#8E33FF"/>
|
||||
<stop offset="1" stop-color="#5119B7"/>
|
||||
</linearGradient>
|
||||
<linearGradient id="paint5_linear_2581_180286" x1="17.2002" y1="8" x2="64.9552" y2="46.9963" gradientUnits="userSpaceOnUse">
|
||||
<stop stop-color="#8E33FF"/>
|
||||
<stop offset="1" stop-color="#5119B7"/>
|
||||
</linearGradient>
|
||||
</defs>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 3.7 KiB |
8
web/public/assets/icons/navbar/ic-analytics.svg
Executable file
|
|
@ -0,0 +1,8 @@
|
|||
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M20.9603 6.0506C20.9106 7.03855 19.9709 7.40975 19.242 6.741C18.9106 6.4369 18.5138 6.06255 18.0418 5.60285C16.9756 6.5731 15.322 8.08585 13.3506 9.91645C12.8329 10.3972 11.992 10.3435 11.5397 9.8007L11.5394 9.8003C10.6518 8.73835 9.75755 7.6807 8.8322 6.6514C7.7509 7.4453 5.81 8.95825 3.88389 10.8844C3.39573 11.3725 2.60427 11.3725 2.11612 10.8844C1.62796 10.3962 1.62796 9.60475 2.11612 9.1166C4.00573 7.227 6.079 5.4545 8.30255 3.96314L8.306 3.96082C8.30685 3.96027 8.3066 3.96042 8.3066 3.96042C8.8024 3.6299 9.46255 3.69527 9.8839 4.1166C10.8519 5.08455 11.7265 6.14925 12.6118 7.19265C14.1169 5.80065 15.3848 4.64087 16.274 3.8314C15.8705 3.41506 15.5362 3.06006 15.26 2.75898C14.591 2.02997 14.9624 1.08998 15.9506 1.04025C17.2115 0.976795 18.5055 0.939456 19.7511 1.17232C20.3119 1.27718 20.7233 1.68863 20.8281 2.24948C21.061 3.49521 21.0238 4.78949 20.9603 6.0506Z" fill="#637381"/>
|
||||
<g opacity="0.4">
|
||||
<path d="M2.60946 22.9843C1.77292 22.9631 1.13928 22.4599 1.07089 21.6259C1.02993 21.1264 1 20.4398 1 19.5C1 18.5602 1.02993 17.8736 1.07089 17.3741C1.13928 16.5401 1.77292 16.0369 2.60946 16.0157C2.97545 16.0064 3.43306 16 4 16C4.56694 16 5.02455 16.0064 5.39055 16.0157C6.2271 16.0369 6.8607 16.5401 6.9291 17.3741C6.97005 17.8736 7 18.5602 7 19.5C7 20.4398 6.97005 21.1264 6.9291 21.6259C6.8607 22.4599 6.2271 22.9631 5.39055 22.9843C5.02455 22.9936 4.56694 23 4 23C3.43306 23 2.97545 22.9936 2.60946 22.9843Z" fill="#637381"/>
|
||||
<path d="M18.8455 22.9792C17.8709 22.9408 17.1875 22.2557 17.1243 21.2823C17.0588 20.2731 17 18.6337 17 16C17 13.3663 17.0588 11.727 17.1243 10.7177C17.1875 9.74435 17.8709 9.0592 18.8455 9.02075C19.1671 9.00805 19.5489 9 20 9C20.4511 9 20.8329 9.00805 21.1545 9.02075C22.1291 9.0592 22.8125 9.74435 22.8757 10.7177C22.9412 11.727 23 13.3663 23 16C23 18.6337 22.9412 20.2731 22.8757 21.2823C22.8125 22.2557 22.1291 22.9408 21.1545 22.9792C20.8329 22.9919 20.4511 23 20 23C19.5489 23 19.1671 22.9919 18.8455 22.9792Z" fill="#637381"/>
|
||||
<path d="M10.7766 22.9832C9.8427 22.9548 9.162 22.3419 9.0949 21.41C9.0422 20.6775 9 19.5936 9 18C9 16.4064 9.0422 15.3225 9.0949 14.59C9.162 13.6581 9.8427 13.0453 10.7766 13.0169C11.1121 13.0067 11.5163 13 12 13C12.4837 13 12.8879 13.0067 13.2234 13.0169C14.1573 13.0453 14.838 13.6581 14.9051 14.59C14.9578 15.3225 15 16.4064 15 18C15 19.5936 14.9578 20.6775 14.9051 21.41C14.838 22.3419 14.1573 22.9548 13.2234 22.9832C12.8879 22.9934 12.4837 23 12 23C11.5163 23 11.1121 22.9934 10.7766 22.9832Z" fill="#637381"/>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 2.6 KiB |
4
web/public/assets/icons/navbar/ic-blog.svg
Executable file
|
|
@ -0,0 +1,4 @@
|
|||
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path opacity="0.4" d="M16.9841 2H7C4.25397 2 2 4.25397 2 7.01587V17C2 19.746 4.25397 22 7 22H16.9841C19.746 22 22 19.746 22 16.9841V7.01587C22 4.25397 19.746 2 16.9841 2Z" fill="#637381"/>
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M14.254 18.1905C16.4286 18.1905 18.2064 16.4445 18.2223 14.2858V11.127L18.1905 10.9683L18.0794 10.7461L17.9048 10.6032C17.8005 10.5267 17.5196 10.5203 17.2101 10.5132C16.813 10.5041 16.3689 10.4939 16.1905 10.3334C15.9837 10.1413 15.9419 9.81166 15.8858 9.3701C15.8817 9.33731 15.8775 9.3039 15.8731 9.26989C15.7801 8.45979 15.6982 8.29413 15.5903 8.07571C15.5693 8.03306 15.5472 7.98841 15.5239 7.93655C14.9842 6.77782 13.4921 5.80957 12.4762 5.80957H9.71433C7.53973 5.80957 5.80957 7.53973 5.80957 9.69846V14.3016C5.80957 16.4604 7.53973 18.1905 9.71433 18.1905H14.254ZM9.7619 8.98413H11.9524C12.381 8.98413 12.7143 9.28572 12.7143 9.69842C12.7143 10.1111 12.3651 10.4127 11.9524 10.4127H9.7619C9.34921 10.4127 9 10.1111 9 9.69842C9 9.28572 9.34921 8.98413 9.7619 8.98413ZM9.7619 13.4286H14.2222C14.6349 13.4286 14.9683 13.8095 14.9683 14.2222C14.9683 14.6349 14.6349 15.0159 14.2222 15.0159H9.7619C9.33333 15.0159 9 14.6349 9 14.2222C9 13.8095 9.34921 13.4286 9.7619 13.4286Z" fill="#637381"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 1.3 KiB |
7
web/public/assets/icons/navbar/ic-cart.svg
Executable file
|
|
@ -0,0 +1,7 @@
|
|||
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M17.5505 10.5941C17.6091 10.0083 17.1491 9.5 16.5604 9.5C16.0492 9.5 15.6212 9.88735 15.5703 10.3961L15.2694 13.4059C15.2108 13.9917 15.6708 14.5 16.2595 14.5C16.7707 14.5 17.1987 14.1126 17.2496 13.6039L17.5505 10.5941Z" fill="#637381"/>
|
||||
<path d="M12.7496 10.3961C12.6987 9.88735 12.2707 9.5 11.7595 9.5C11.1708 9.5 10.7108 10.0083 10.7694 10.5941L11.0703 13.6039C11.1212 14.1126 11.5492 14.5 12.0604 14.5C12.6491 14.5 13.1091 13.9917 13.0505 13.4059L12.7496 10.3961Z" fill="#637381"/>
|
||||
<path d="M16.6602 19C16.6602 20.6569 18.0033 22 19.6602 22C21.317 22 22.6602 20.6569 22.6602 19C22.6602 17.3432 21.317 16 19.6602 16C18.0033 16 16.6602 17.3432 16.6602 19Z" fill="#637381"/>
|
||||
<path d="M6.16016 19C6.16016 20.6569 7.50331 22 9.16016 22C10.817 22 12.1602 20.6569 12.1602 19C12.1602 17.3432 10.817 16 9.16016 16C7.50331 16 6.16016 17.3432 6.16016 19Z" fill="#637381"/>
|
||||
<path opacity="0.4" d="M3.41016 2.00012C2.71981 2.00012 2.16016 2.55977 2.16016 3.25012C2.16016 3.94048 2.71981 4.50012 3.41016 4.50012H4.25251C4.48986 4.50012 4.69436 4.66605 4.74281 4.89837C4.96591 5.96777 5.59766 8.95907 6.10461 11.0001C6.73135 13.5236 7.29935 15.342 7.6574 16.4029C8.09928 16.1467 8.61259 16 9.16016 16C10.446 16 11.5429 16.809 11.9697 17.9457C12.7178 17.9791 13.5912 18.0001 14.6046 18.0001C15.462 18.0001 16.2042 17.9851 16.8452 17.9602C17.2681 16.8159 18.3689 16 19.6602 16C20.2143 16 20.7334 16.1503 21.1789 16.4123C21.5323 15.5226 22.0073 14.0331 22.4102 11.7501C22.6992 10.1123 22.8768 8.88287 22.986 7.99032C23.1201 6.89392 22.2647 6.00012 21.1602 6.00012H7.66016L7.03891 3.51505C6.81631 2.62472 6.01636 2.00012 5.09861 2.00012H3.41016Z" fill="#637381"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 1.7 KiB |
4
web/public/assets/icons/navbar/ic-disabled.svg
Executable file
|
|
@ -0,0 +1,4 @@
|
|||
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path opacity="0.4" fill-rule="evenodd" clip-rule="evenodd" d="M12 22.5C17.799 22.5 22.5 17.799 22.5 12C22.5 6.20101 17.799 1.5 12 1.5C6.20101 1.5 1.5 6.20101 1.5 12C1.5 17.799 6.20101 22.5 12 22.5ZM12 18.3C15.4794 18.3 18.3 15.4794 18.3 12C18.3 8.52061 15.4794 5.7 12 5.7C8.52061 5.7 5.7 8.52061 5.7 12C5.7 15.4794 8.52061 18.3 12 18.3Z" fill="#637381"/>
|
||||
<path d="M18.6028 3.01136C19.2179 2.39628 20.2151 2.39628 20.8302 3.01136C21.4453 3.62643 21.4453 4.62367 20.8302 5.23874L5.2385 20.8304C4.62342 21.4455 3.62619 21.4455 3.01111 20.8304C2.39604 20.2154 2.39604 19.2181 3.01111 18.6031L18.6028 3.01136Z" fill="#637381"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 727 B |
4
web/public/assets/icons/navbar/ic-lock.svg
Executable file
|
|
@ -0,0 +1,4 @@
|
|||
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path opacity="0.4" d="M2.32694 4.28658C2.42248 3.46288 2.9222 2.78287 3.73187 2.60381C4.9948 2.32451 7.44275 2 12 2C16.5573 2 19.0052 2.32451 20.2682 2.60381C21.0778 2.78287 21.5775 3.46288 21.673 4.28658C21.8176 5.5322 22 7.58365 22 10C22 14.5142 19.6175 18.7382 15.6037 20.8039C14.2629 21.494 12.9543 22 12 22C11.0457 22 9.7371 21.494 8.3963 20.8039C4.38247 18.7382 2 14.5142 2 10C2 7.58365 2.18247 5.5322 2.32694 4.28658Z" fill="#637381"/>
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M9.12105 7.7538C9.1895 6.21355 10.4582 5 12 5C13.5418 5 14.8105 6.21355 14.879 7.7538L14.9386 9.0968L15.0076 9.10265C15.8102 9.172 16.3768 9.7301 16.4377 10.5334C16.4735 11.0057 16.5 11.6444 16.5 12.5C16.5 13.3556 16.4735 13.9943 16.4377 14.4666C16.3768 15.2699 15.8102 15.828 15.0076 15.8974C14.3596 15.9534 13.3997 16 12 16C10.6003 16 9.6404 15.9534 8.9924 15.8974C8.18975 15.828 7.62325 15.2699 7.56235 14.4666C7.52655 13.9943 7.5 13.3556 7.5 12.5C7.5 11.7185 7.519 11.1179 7.54565 10.6598C7.5963 9.79025 8.19675 9.1729 9.0614 9.0959L9.12105 7.7538ZM12.8809 7.8426L12.9327 9.00755C12.6459 9.0027 12.3356 9 12 9C11.6648 9 11.3544 9.0027 11.0673 9.0075L11.1191 7.84265C11.14 7.3713 11.5283 7 12 7C12.4717 7 12.86 7.3713 12.8809 7.8426ZM13 12C13 12.4089 12.7545 12.7605 12.403 12.9155L12.4734 13.5415C12.4908 13.6961 12.4655 13.8652 12.3258 13.9338C12.2501 13.971 12.1446 14 12 14C11.8554 14 11.7499 13.971 11.6742 13.9338C11.5345 13.8652 11.5092 13.6961 11.5266 13.5415L11.597 12.9155C11.2455 12.7605 11 12.4089 11 12C11 11.4477 11.4477 11 12 11C12.5523 11 13 11.4477 13 12Z" fill="#637381"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 1.7 KiB |
4
web/public/assets/icons/navbar/ic-user.svg
Executable file
|
|
@ -0,0 +1,4 @@
|
|||
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path opacity="0.4" d="M2.28099 19.6575C2.36966 20.5161 2.93261 21.1957 3.77688 21.3755C5.1095 21.6592 7.6216 22 12 22C16.3784 22 18.8905 21.6592 20.2232 21.3755C21.0674 21.1957 21.6303 20.5161 21.719 19.6575C21.8505 18.3844 22 16.0469 22 12C22 7.95305 21.8505 5.6156 21.719 4.34251C21.6303 3.48389 21.0674 2.80424 20.2231 2.62451C18.8905 2.34081 16.3784 2 12 2C7.6216 2 5.1095 2.34081 3.77688 2.62451C2.93261 2.80424 2.36966 3.48389 2.28099 4.34251C2.14952 5.6156 2 7.95305 2 12C2 16.0469 2.14952 18.3844 2.28099 19.6575Z" fill="#637381"/>
|
||||
<path d="M13.9382 13.8559C15.263 13.1583 16.1663 11.7679 16.1663 10.1666C16.1663 7.8655 14.3008 6 11.9996 6C9.69841 6 7.83291 7.8655 7.83291 10.1666C7.83291 11.768 8.73626 13.1584 10.0612 13.856C8.28691 14.532 6.93216 16.1092 6.51251 18.0529C6.45446 18.3219 6.60246 18.5981 6.87341 18.6471C7.84581 18.8231 9.45616 19 12.0006 19C14.545 19 16.1554 18.8231 17.1278 18.6471C17.3977 18.5983 17.5454 18.3231 17.4876 18.0551C17.0685 16.1103 15.7133 14.5321 13.9382 13.8559Z" fill="#637381"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 1.1 KiB |
1
web/public/assets/icons/notification/ic-notification-chat.svg
Executable file
|
|
@ -0,0 +1 @@
|
|||
<svg height="24" viewBox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"><linearGradient id="a" x1="39.907%" x2="113.315%" y1="39.91%" y2="113.318%"><stop offset="0" stop-color="#a7f3ce"/><stop offset="1" stop-color="#61db99"/></linearGradient><linearGradient id="b" x1="0%" x2="100%" y1="0%" y2="100%"><stop offset="0" stop-color="#5be584"/><stop offset="1" stop-color="#00ab55"/></linearGradient><linearGradient id="c" x1="0%" x2="100%" y1="0%" y2="100%"><stop offset="0" stop-color="#74caff"/><stop offset="1" stop-color="#0c53b7"/></linearGradient><g fill="none" fill-rule="evenodd"><path d="m15.9546562 7.27185938c4.38225-.0669375 7.9590001 3.38217192 8.0438438 7.76409372.0124687.6433594-.0518438 1.2695625-.1843125 1.8702188-.2243437 1.0170469-.3577031 2.052-.3577031 3.0935156v2.0131875c0 .3084375-.2500313.5584688-.5584688.5584688h-2.0131875c-1.0415156 0-2.0764687.1333593-3.0935156.3577031-.6006094.1324687-1.2268125.1967812-1.8701719.1843125-4.381875-.0847969-7.83098435-3.6614531-7.7641406-8.0436094.06520313-4.2773437 3.5203594-7.73254688 7.7976562-7.79789062z" fill="url(#a)" fill-rule="nonzero"/><path d="m15.9546562 7.27185938c4.38225-.0669375 7.9590001 3.38217192 8.0438438 7.76409372.0124687.6433594-.0518438 1.2695625-.1843125 1.8702188-.2243437 1.0170469-.3577031 2.052-.3577031 3.0935156v2.0131875c0 .3084375-.2500313.5584688-.5584688.5584688h-2.0131875c-1.0415156 0-2.0764687.1333593-3.0935156.3577031-.6006094.1324687-1.2268125.1967812-1.8701719.1843125-4.381875-.0847969-7.83098435-3.6614531-7.7641406-8.0436094.06520313-4.2773437 3.5203594-7.73254688 7.7976562-7.79789062z" fill="url(#b)"/><path d="m9.80146875.04260938c-5.33878125-.08156251-9.69623437 4.12035937-9.79964062 9.45876562-.01514063.7837031.06318749 1.5466875.224625 2.2784063.27328125 1.239.43575 2.4998906.43575 3.7687499v2.4525938c0 .37575.30459375.6803906.68039062.6803906h2.45259375c1.2688125 0 2.52970312.1624688 3.76875.43575.73171875.1613907 1.49465625.2397656 2.27835937.2245782 5.33831253-.1033594 9.54023433-4.4606719 9.45885933-9.79935942-.0794999-5.21095313-4.2887812-9.42032813-9.49968745-9.499875z" fill="url(#c)"/><g fill="#0c53b7"><path d="m6.19654688 9.17526562c-.272625-.28968749-.6585-.47160937-1.08778125-.47160937-.82560938 0-1.49489063.66928125-1.49489063 1.49489065 0 .4292343.181875.8151094.47160938 1.0877812l3.22471875 3.2247188c.27267187.2896875.65854687.4716093 1.08778125.4716093.82560937 0 1.49489062-.6692812 1.49489062-1.4948906 0-.4292344-.18192188-.8151094-.47160937-1.0877812z"/><path d="m10.4242031 9.17526562c-.272625-.28968749-.65849997-.47160937-1.08778122-.47160937-.82560938 0-1.49489063.66928125-1.49489063 1.49489065 0 .4292343.181875.8151094.47160938 1.0877812l3.22471877 3.2247188c.2726719.2896875.6585469.4716093 1.0877812.4716093.8256094 0 1.4948907-.6692812 1.4948907-1.4948906 0-.4292344-.1819219-.8151094-.4716094-1.0877812z"/><path d="m14.6518125 9.17526562c-.272625-.28968749-.6585-.47160937-1.0877813-.47160937-.8256093 0-1.4948906.66928125-1.4948906 1.49489065 0 .4292343.1819219.8151094.4716094 1.0877812l3.2247187 3.2247188c.2726719.2896875.6585469.4716093 1.0877813.4716093.8256094 0 1.4948906-.6692812 1.4948906-1.4948906 0-.4292344-.1819219-.8151094-.4716094-1.0877812z"/></g><g fill="#fff" fill-rule="nonzero"><circle cx="5.109" cy="10.198" r="1.495"/><circle cx="9.336" cy="10.198" r="1.495"/><circle cx="13.564" cy="10.198" r="1.495"/></g></g></svg>
|
||||
|
After Width: | Height: | Size: 3.4 KiB |
1
web/public/assets/icons/notification/ic-notification-mail.svg
Executable file
|
|
@ -0,0 +1 @@
|
|||
<svg height="24" viewBox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"><defs><linearGradient id="a" x1="0%" x2="100%" y1="37.93%" y2="62.07%"><stop offset="0" stop-color="#ffa48d"/><stop offset="1" stop-color="#b72136"/></linearGradient><path id="b" d="m2.15609375.29484375h12.00031245c1.1045695 0 2 .8954305 2 2v15.99953125h-16.00031245v-15.99953125c0-1.1045695.8954305-2 2-2z"/><mask id="c" fill="#fff"><use fill="#fff" fill-rule="evenodd" xlink:href="#b"/></mask></defs><g fill="none" fill-rule="evenodd"><path d="m24 9.585-.703 8.935h-22.594l-.703-8.935 4-2.857h16z" fill="url(#a)"/><g transform="translate(3.844 .719)"><use fill="#d0f2ff" xlink:href="#b"/><path d="m3.21345312 3.02020312h4.74279688c.11045695 0 .2.08954306.2.2v1.00625c0 .11045695-.08954305.2-.2.2h-4.74279688c-.11045694 0-.2-.08954305-.2-.2v-1.00625c0-.11045694.08954306-.2.2-.2zm.00014063 3.42839063h9.88531245c.110457 0 .2.08954305.2.2v1.00625c0 .11045695-.089543.2-.2.2h-9.88531245c-.11045695 0-.2-.08954305-.2-.2v-1.00625c0-.11045695.08954305-.2.2-.2zm0 3.4284375h9.88531245c.110457 0 .2.08954305.2.19999995v1.00625c0 .110457-.089543.2-.2.2h-9.88531245c-.11045695 0-.2-.089543-.2-.2v-1.00625c0-.1104569.08954305-.19999995.2-.19999995z" fill="#74caff" mask="url(#c)"/></g><path d="m24 9.585v13.714l-12-1.115-12 1.115v-13.714l9.6 6.857h4.8z" fill="#ffa48d"/><path d="m24 9.585v13.714l-12-1.115v-5.742h2.4z" fill="#ff4842"/><path d="m24 23.299h-24l12-8.571z" fill="#ff4842"/><path d="m24 23.299h-12v-8.571z" fill="#b72136"/></g></svg>
|
||||
|
After Width: | Height: | Size: 1.5 KiB |
1
web/public/assets/icons/notification/ic-notification-package.svg
Executable file
|
|
@ -0,0 +1 @@
|
|||
<svg height="24" viewBox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"><linearGradient id="a" x1="0%" x2="100%" y1=".004%" y2="99.996%"><stop offset="0" stop-color="#5be584"/><stop offset="1" stop-color="#00ab55"/></linearGradient><linearGradient id="b"><stop offset="0" stop-color="#ffe16a"/><stop offset="1" stop-color="#b78103"/></linearGradient><linearGradient id="c" x1="0%" x2="100%" xlink:href="#b" y1="33.335%" y2="66.665%"/><linearGradient id="d" x1="46.26%" x2="53.74%" xlink:href="#b" y1="0%" y2="100%"/><g fill="none" fill-rule="evenodd"><path d="m15.048 20.02c-1.0907987-1.8799016-.7822977-4.2581652.7520392-5.7975424 1.534337-1.5393772 3.9115761-1.8556761 5.7950449-.7710485 1.8834688 1.0846277 2.8030986 3.2994848 2.2418005 5.3992029-.5612982 2.0997182-2.4634376 3.5602579-4.6368846 3.5604215-1.7129421.0063742-3.2977706-.9062763-4.152-2.3910335z" fill="url(#a)"/><path d="m19.2 5.5775v7.2335c-1.7166788.0001456-3.3026139.9169895-4.1593869 2.4045801-.856773 1.4875907-.8539564 3.3194709.0073869 4.8044199l-5.448 3.145v-12.046l9.599-5.542z" fill="#ffe16a"/><path d="m9.6 11.119-3.343-1.93 9.6-5.542 3.342 1.93z" fill="#ffc107"/><path d="m15.857 3.647-9.6 5.542-2.446-1.412 9.598-5.542z" fill="url(#c)"/><path d="m9.6.035 3.809 2.2-9.598 5.542h-.001l-3.809-2.2z" fill="#ffe16a"/><path d="m9.6 11.119v12.046l-9.6-5.543v-12.045h.001l3.809 2.2v7.987l1.163-.48 1.267 1.44v-7.525l.017-.01z" fill="#ffc107"/><path d="m6.257 9.189-.017.01v7.525l-1.267-1.44-1.163.48v-7.987h.001z" fill="url(#d)"/><path d="m1.2415 17.7185c-.19329966 0-.35-.1567003-.35-.35v-1.296c0-.1932997.15670034-.35.35-.35s.35.1567003.35.35v1.296c0 .1932997-.15670034.35-.35.35zm1.421.8315c-.19329966 0-.35-.1567003-.35-.35v-1.1675c0-.1932997.15670034-.35.35-.35s.35.1567003.35.35v1.1675c0 .1932997-.15670034.35-.35.35zm1.4215.8205c-.19329966 0-.35-.1567003-.35-.35v-1.028c0-.1932997.15670034-.35.35-.35s.35.1567003.35.35v1.028c0 .1932997-.15670034.35-.35.35zm1.421.8205c-.19329966 0-.35-.1567003-.35-.35v-.8885c0-.1932997.15670034-.35.35-.35s.35.1567003.35.35v.8885c0 .1932997-.15670034.35-.35.35zm1.421.8395c-.19329966 0-.35-.1567003-.35-.35v-.768c0-.1932997.15670034-.35.35-.35s.35.1567003.35.35v.768c0 .1932997-.15670034.35-.35.35z" fill="#ffe16a"/><path d="m11.5888 18.0470503c-.1585311.0002073-.2974056-.1061671-.3384968-.2592803-.0410911-.1531132.0258634-.3147262.1631968-.39392l1.5945-.9205c.1082961-.0625215.2417207-.0625184.350014.000008.1082932.0625265.175.1780771.175.3031251 0 .1250479-.0667179.2405954-.175014.3031169l-1.5945.9204c-.0530713.0308005-.1133385.0470316-.1747.0470503z" fill="#b78103"/><path d="m18.11 19.3200003c-.1025165.0001366-.1999191-.0447622-.2664-.1228003l-1.16-1.35895c-.0822583-.0949733-.1072983-.2267514-.0656083-.3452769s.1437126-.2056108.2673136-.2281755c.1236009-.0225647.2498135.0228536.3306947.1190024l.93805 1.09895 3.075-2.50175c.0969003-.0798306.2291361-.1016444.3465425-.0571661.1174065.0444783.2019957.1484341.2216779.2724309s-.0285581.2490369-.1264204.3276852l-3.34 2.71755c-.0623537.0508655-.1403809.0785998-.22085.0785003z" fill="#005249" fill-rule="nonzero"/><path d="m12.5425 11.3317c-.0771973-.0817777-.1889878-.1214799-.3004729-.1067123-.1114852.0147677-.2090836.082206-.2623271.1812623l-.845 1.572c-.0583242.1084299-.0553868.2395303.0077352.3452392s.1771439.1704773.3002648.1705608c.1305767.0002905.2510292-.0702925.3146-.18435l.1927-.34735v3.00865c0 .1932997.1567003.35.35.35s.35-.1567003.35-.35v-3.51845l.2845.30775c.0631331.0674517.1505922.1068933.2429416.1095598s.1819386-.0316631.2488584-.0953598c.0673574-.0639388.106541-.152027.108923-.2448683.002382-.0928414-.032233-.182823-.096223-.2501317z" fill="#b78103"/></g></svg>
|
||||
|
After Width: | Height: | Size: 3.6 KiB |
1
web/public/assets/icons/notification/ic-notification-shipping.svg
Executable file
|
|
@ -0,0 +1 @@
|
|||
<svg height="24" viewBox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"><linearGradient id="a" x1="14.104%" x2="85.896%" y1="0%" y2="100%"><stop offset="0" stop-color="#ffe16a"/><stop offset="1" stop-color="#b78103"/></linearGradient><g fill="none" fill-rule="evenodd" transform="translate(0 1)"><path d="m15.1110698 8.30009302h4.3585116c.3817736 0 .7460423.16013285 1.004093.44148838l3.5106977 3.8249302v4.8429768c0 .361502-.1435207.7082149-.3991412.9638355-.2556206.2556205-.6023335.3991412-.9638356.3991412h-1.0733023c0-1.3171606-1.0677696-2.3849302-2.3849302-2.3849302s-2.3849302 1.0677696-2.3849302 2.3849302h-1.6671628z" fill="url(#a)"/><circle cx="19.163" cy="18.772" fill="#7a4f01" r="2.385"/><path d="m15.1110698 12.5665116v6.2059535h-7.25860468c0-1.3173147-1.06789458-2.3852093-2.38520931-2.3852093-1.31731472 0-2.3852093 1.0678946-2.3852093 2.3852093h-1.70344186c-.36150206 0-.70821494-.1435207-.96383551-.3991412-.25562056-.2556206-.39914125-.6023335-.39914125-.9638355v-11.37934887c0-.36150206.14352069-.70821494.39914125-.9638355.25562057-.25562056.60233345-.39914126.96383551-.39914126h1.47851163c.08500164 2.4030825 2.05774024 4.30727527 4.46232558 4.30727527s4.37732394-1.90419277 4.46232554-4.30727527h1.9663256c.7527258 0 1.3629768.61025103 1.3629768 1.36297676z" fill="#b78103"/><path d="m11.7845581 4.51702326c0 .05023255-.0005581.10046511-.0027907.15013953-.0850016 2.40308248-2.0577402 4.30727525-4.46232554 4.30727525s-4.37732394-1.90419277-4.46232558-4.30727525c-.00223256-.04967442-.0027907-.09990698-.0027907-.15013953 0-2.46601563 1.99910065-4.46511628 4.46511628-4.46511628s4.46511624 1.99910065 4.46511624 4.46511628z" fill="#74caff" stroke="#74caff"/><path d="m5.46697674 16.3875349c1.3171606 0 2.38493024 1.0677696 2.38493024 2.3849302s-1.06776964 2.3849302-2.38493024 2.3849302c-1.31716059 0-2.38493023-1.0677696-2.38493023-2.3849302 0-1.3171478 1.06778241-2.3849302 2.38493023-2.3849302z" fill="#7a4f01"/><path d="m8.8096186 6.30306977c-.09917416.00012442-.19465699-.03760557-.26695813-.10548837l-1.49023256-1.39534884c-.0788836-.07387832-.12362791-.17713235-.12362791-.2852093v-2.89562791c0-.21577637.17492131-.39069768.39069767-.39069768.21577637 0 .39069768.17492131.39069768.39069768v2.72651163l1.36654884 1.27953488c.11707405.10960812.15527467.27962928.09633971.42878338-.05893496.14915409-.20303407.2471236-.36340948.2471236z" fill="#0c53b7"/></g></svg>
|
||||
|
After Width: | Height: | Size: 2.4 KiB |
1
web/public/assets/icons/shape-avatar.svg
Executable file
|
|
@ -0,0 +1 @@
|
|||
<svg height="62" viewBox="0 0 144 62" width="144" xmlns="http://www.w3.org/2000/svg"><path d="m111.34 23.88c-10.62-10.46-18.5-23.88-38.74-23.88h-1.2c-20.24 0-28.12 13.42-38.74 23.88-7.72 9.64-19.44 11.74-32.66 12.12v26h144v-26c-13.22-.38-24.94-2.48-32.66-12.12z" fill="#fff" fill-rule="evenodd"/></svg>
|
||||
|
After Width: | Height: | Size: 302 B |
40
web/public/assets/illustrations/illustration-404.svg
Executable file
|
|
@ -0,0 +1,40 @@
|
|||
<svg width="480" height="360" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path fill-rule="evenodd" clip-rule="evenodd"
|
||||
d="M0 198.781c0 41.457 14.945 79.235 39.539 107.785 28.214 32.765 69.128 53.365 114.734 53.434a148.458 148.458 0 0056.495-11.036c9.051-3.699 19.182-3.274 27.948 1.107a75.774 75.774 0 0033.957 8.011c5.023 0 9.942-.495 14.7-1.434 13.581-2.67 25.94-8.99 36.089-17.94 6.379-5.627 14.548-8.456 22.898-8.446h.142c27.589 0 53.215-8.732 74.492-23.696 19.021-13.36 34.554-31.696 44.904-53.225C474.92 234.581 480 213.388 480 190.958c0-76.931-59.774-139.305-133.498-139.305-7.516 0-14.88.663-22.063 1.899C305.418 21.42 271.355 0 232.498 0a103.647 103.647 0 00-45.879 10.661c-13.24 6.487-25.011 15.705-34.641 26.939-32.697.544-62.93 11.69-87.675 30.291C25.351 97.155 0 144.882 0 198.781z"
|
||||
fill="url(#prefix__paint0_linear)" opacity=".2" />
|
||||
<g filter="url(#prefix__filter0_d)">
|
||||
<circle opacity=".15" cx="182.109" cy="97.623" r="44.623" fill="#FFC107" />
|
||||
<circle cx="182.109" cy="97.623" r="23.406" fill="url(#prefix__paint1_linear)" />
|
||||
<path fill-rule="evenodd" clip-rule="evenodd"
|
||||
d="M244.878 306.611c34.56 0 62.575-28.016 62.575-62.575 0-34.56-28.015-62.576-62.575-62.576-34.559 0-62.575 28.016-62.575 62.576 0 34.559 28.016 62.575 62.575 62.575zm0-23.186c21.754 0 39.389-17.635 39.389-39.389 0-21.755-17.635-39.39-39.389-39.39s-39.389 17.635-39.389 39.39c0 21.754 17.635 39.389 39.389 39.389z"
|
||||
fill="#061B64" />
|
||||
<path fill-rule="evenodd" clip-rule="evenodd"
|
||||
d="M174.965 264.592c0-4.133-1.492-5.625-5.637-5.625h-11.373v-66.611c0-4.476-1.492-5.637-5.638-5.637h-9.172a9.866 9.866 0 00-7.948 3.974l-55.03 68.274a11.006 11.006 0 00-1.957 6.787v5.968c0 4.145 1.492 5.637 5.625 5.637h54.676v21.707c0 4.133 1.492 5.625 5.625 5.625h8.12c4.146 0 5.638-1.492 5.638-5.625v-21.707h11.434c4.414 0 5.637-1.492 5.637-5.637v-7.13zm-72.42-5.625l35.966-44.415v44.415h-35.966zM411.607 264.592c0-4.133-1.492-5.625-5.638-5.625h-11.422v-66.611c0-4.476-1.492-5.637-5.637-5.637h-9.111a9.87 9.87 0 00-7.949 3.974l-55.03 68.274a11.011 11.011 0 00-1.981 6.787v5.968c0 4.145 1.492 5.637 5.626 5.637h54.687v21.707c0 4.133 1.492 5.625 5.626 5.625h8.12c4.145 0 5.637-1.492 5.637-5.625v-21.707h11.434c4.476 0 5.638-1.492 5.638-5.637v-7.13zm-72.42-5.625l35.965-44.415v44.415h-35.965z"
|
||||
fill="#2065D1" />
|
||||
<path opacity=".24"
|
||||
d="M425.621 117.222a8.267 8.267 0 00-9.599-8.157 11.129 11.129 0 00-9.784-5.87h-.403a13.23 13.23 0 00-20.365-14.078 13.23 13.23 0 00-5.316 14.078h-.403a11.153 11.153 0 100 22.293h38.68v-.073a8.279 8.279 0 007.19-8.193zM104.258 199.045a7.093 7.093 0 00-7.093-7.092c-.381.007-.761.039-1.138.097a9.552 9.552 0 00-8.425-5.026h-.343a11.348 11.348 0 10-22.012 0h-.342a9.564 9.564 0 100 19.114h33.177v-.061a7.107 7.107 0 006.176-7.032z"
|
||||
fill="#2065D1" />
|
||||
</g>
|
||||
<defs>
|
||||
<linearGradient id="prefix__paint0_linear" x1="328.81" y1="424.032" x2="505.393" y2="26.048"
|
||||
gradientUnits="userSpaceOnUse">
|
||||
<stop stop-color="#2065D1" />
|
||||
<stop offset="1" stop-color="#2065D1" stop-opacity=".01" />
|
||||
</linearGradient>
|
||||
<linearGradient id="prefix__paint1_linear" x1="135.297" y1="97.623" x2="182.109" y2="144.436"
|
||||
gradientUnits="userSpaceOnUse">
|
||||
<stop stop-color="#FFE16A" />
|
||||
<stop offset="1" stop-color="#B78103" />
|
||||
</linearGradient>
|
||||
<filter id="prefix__filter0_d" x="51" y="49" width="394.621" height="277.611" filterUnits="userSpaceOnUse"
|
||||
color-interpolation-filters="sRGB">
|
||||
<feFlood flood-opacity="0" result="BackgroundImageFix" />
|
||||
<feColorMatrix in="SourceAlpha" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0" />
|
||||
<feOffset dx="8" dy="8" />
|
||||
<feGaussianBlur stdDeviation="6" />
|
||||
<feColorMatrix values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.12 0" />
|
||||
<feBlend in2="BackgroundImageFix" result="effect1_dropShadow" />
|
||||
<feBlend in="SourceGraphic" in2="effect1_dropShadow" result="shape" />
|
||||
</filter>
|
||||
</defs>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 3.9 KiB |
BIN
web/public/assets/illustrations/illustration-dashboard.webp
Executable file
|
After Width: | Height: | Size: 54 KiB |
BIN
web/public/favicon.ico
Normal file → Executable file
|
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 15 KiB |
|
|
@ -1 +0,0 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="31.88" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 257"><defs><linearGradient id="IconifyId1813088fe1fbc01fb466" x1="-.828%" x2="57.636%" y1="7.652%" y2="78.411%"><stop offset="0%" stop-color="#41D1FF"></stop><stop offset="100%" stop-color="#BD34FE"></stop></linearGradient><linearGradient id="IconifyId1813088fe1fbc01fb467" x1="43.376%" x2="50.316%" y1="2.242%" y2="89.03%"><stop offset="0%" stop-color="#FFEA83"></stop><stop offset="8.333%" stop-color="#FFDD35"></stop><stop offset="100%" stop-color="#FFA800"></stop></linearGradient></defs><path fill="url(#IconifyId1813088fe1fbc01fb466)" d="M255.153 37.938L134.897 252.976c-2.483 4.44-8.862 4.466-11.382.048L.875 37.958c-2.746-4.814 1.371-10.646 6.827-9.67l120.385 21.517a6.537 6.537 0 0 0 2.322-.004l117.867-21.483c5.438-.991 9.574 4.796 6.877 9.62Z"></path><path fill="url(#IconifyId1813088fe1fbc01fb467)" d="M185.432.063L96.44 17.501a3.268 3.268 0 0 0-2.634 3.014l-5.474 92.456a3.268 3.268 0 0 0 3.997 3.378l24.777-5.718c2.318-.535 4.413 1.507 3.936 3.838l-7.361 36.047c-.495 2.426 1.782 4.5 4.151 3.78l15.304-4.649c2.372-.72 4.652 1.36 4.15 3.788l-11.698 56.621c-.732 3.542 3.979 5.473 5.943 2.437l1.313-2.028l72.516-144.72c1.215-2.423-.88-5.186-3.54-4.672l-25.505 4.922c-2.396.462-4.435-1.77-3.759-4.114l16.646-57.705c.677-2.35-1.37-4.583-3.769-4.113Z"></path></svg>
|
||||
|
Before Width: | Height: | Size: 1.5 KiB |
22
web/pyproject.toml
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
[tool.poetry]
|
||||
name = "esp32-ai-server"
|
||||
version = "0.1.0"
|
||||
description = ""
|
||||
authors = ["kalicyh <34980061+kaliCYH@users.noreply.github.com>"]
|
||||
readme = "README.md"
|
||||
|
||||
[tool.poetry.dependencies]
|
||||
python = "^3.13"
|
||||
fastapi = {extras = ["all"], version = "^0.115.8"}
|
||||
uvicorn = "^0.34.0"
|
||||
pyjwt = "^2.10.1"
|
||||
python-jose = {extras = ["cryptography"], version = "^3.3.0"}
|
||||
bcrypt = "^4.2.1"
|
||||
sqlalchemy = "^2.0.38"
|
||||
pymysql = "^1.1.1"
|
||||
asyncpg = "^0.30.0"
|
||||
|
||||
|
||||
[build-system]
|
||||
requires = ["poetry-core"]
|
||||
build-backend = "poetry.core.masonry.api"
|
||||
|
|
@ -1,73 +0,0 @@
|
|||
<template>
|
||||
<div id="app">
|
||||
<div class="app-content">
|
||||
<router-view></router-view>
|
||||
</div>
|
||||
<Footer />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import Footer from './components/Footer.vue';
|
||||
|
||||
export default {
|
||||
name: 'App',
|
||||
components: {
|
||||
Footer
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style>
|
||||
#app {
|
||||
font-family: Avenir, Helvetica, Arial, sans-serif;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
-moz-osx-font-smoothing: grayscale;
|
||||
color: #2c3e50;
|
||||
min-height: 100vh;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.app-content {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
min-height: 0; /* 允许内容区域收缩 */
|
||||
}
|
||||
|
||||
/* 登录注册页面的布局 */
|
||||
.auth-layout {
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding: 20px;
|
||||
}
|
||||
|
||||
/* 主要页面的布局 */
|
||||
.main-layout {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
min-height: 0; /* 允许内容区域收缩 */
|
||||
}
|
||||
|
||||
/* 添加全局滚动条样式 */
|
||||
::-webkit-scrollbar {
|
||||
width: 8px;
|
||||
height: 8px;
|
||||
}
|
||||
|
||||
::-webkit-scrollbar-track {
|
||||
background: #f1f1f1;
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
::-webkit-scrollbar-thumb {
|
||||
background: #ccc;
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
::-webkit-scrollbar-thumb:hover {
|
||||
background: #999;
|
||||
}
|
||||
</style>
|
||||
189
web/src/_mock/_data.ts
Executable file
|
|
@ -0,0 +1,189 @@
|
|||
import {
|
||||
_id,
|
||||
_price,
|
||||
_times,
|
||||
_company,
|
||||
_boolean,
|
||||
_fullName,
|
||||
_taskNames,
|
||||
_postTitles,
|
||||
_description,
|
||||
_productNames,
|
||||
} from './_mock';
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
export const _myAccount = {
|
||||
displayName: 'Jaydon Frankie',
|
||||
email: 'demo@minimals.cc',
|
||||
photoURL: '/assets/images/avatar/avatar-25.webp',
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
export const _users = [...Array(24)].map((_, index) => ({
|
||||
id: _id(index),
|
||||
name: _fullName(index),
|
||||
company: _company(index),
|
||||
isVerified: _boolean(index),
|
||||
avatarUrl: `/assets/images/avatar/avatar-${index + 1}.webp`,
|
||||
status: index % 4 ? 'active' : 'banned',
|
||||
role:
|
||||
[
|
||||
'Leader',
|
||||
'Hr Manager',
|
||||
'UI Designer',
|
||||
'UX Designer',
|
||||
'UI/UX Designer',
|
||||
'Project Manager',
|
||||
'Backend Developer',
|
||||
'Full Stack Designer',
|
||||
'Front End Developer',
|
||||
'Full Stack Developer',
|
||||
][index] || 'UI Designer',
|
||||
}));
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
export const _posts = [...Array(23)].map((_, index) => ({
|
||||
id: _id(index),
|
||||
title: _postTitles(index),
|
||||
description: _description(index),
|
||||
coverUrl: `/assets/images/cover/cover-${index + 1}.webp`,
|
||||
totalViews: 8829,
|
||||
totalComments: 7977,
|
||||
totalShares: 8556,
|
||||
totalFavorites: 8870,
|
||||
postedAt: _times(index),
|
||||
author: {
|
||||
name: _fullName(index),
|
||||
avatarUrl: `/assets/images/avatar/avatar-${index + 1}.webp`,
|
||||
},
|
||||
}));
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
const COLORS = [
|
||||
'#00AB55',
|
||||
'#000000',
|
||||
'#FFFFFF',
|
||||
'#FFC0CB',
|
||||
'#FF4842',
|
||||
'#1890FF',
|
||||
'#94D82D',
|
||||
'#FFC107',
|
||||
];
|
||||
|
||||
export const _products = [...Array(24)].map((_, index) => {
|
||||
const setIndex = index + 1;
|
||||
|
||||
return {
|
||||
id: _id(index),
|
||||
price: _price(index),
|
||||
name: _productNames(index),
|
||||
priceSale: setIndex % 3 ? null : _price(index),
|
||||
coverUrl: `/assets/images/product/product-${setIndex}.webp`,
|
||||
colors:
|
||||
(setIndex === 1 && COLORS.slice(0, 2)) ||
|
||||
(setIndex === 2 && COLORS.slice(1, 3)) ||
|
||||
(setIndex === 3 && COLORS.slice(2, 4)) ||
|
||||
(setIndex === 4 && COLORS.slice(3, 6)) ||
|
||||
(setIndex === 23 && COLORS.slice(4, 6)) ||
|
||||
(setIndex === 24 && COLORS.slice(5, 6)) ||
|
||||
COLORS,
|
||||
status:
|
||||
([1, 3, 5].includes(setIndex) && 'sale') || ([4, 8, 12].includes(setIndex) && 'new') || '',
|
||||
};
|
||||
});
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
export const _langs = [
|
||||
{
|
||||
value: 'en',
|
||||
label: 'English',
|
||||
icon: '/assets/icons/flags/ic-flag-en.svg',
|
||||
},
|
||||
{
|
||||
value: 'de',
|
||||
label: 'German',
|
||||
icon: '/assets/icons/flags/ic-flag-de.svg',
|
||||
},
|
||||
{
|
||||
value: 'fr',
|
||||
label: 'French',
|
||||
icon: '/assets/icons/flags/ic-flag-fr.svg',
|
||||
},
|
||||
];
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
export const _timeline = [...Array(5)].map((_, index) => ({
|
||||
id: _id(index),
|
||||
title: [
|
||||
'1983, orders, $4220',
|
||||
'12 Invoices have been paid',
|
||||
'Order #37745 from September',
|
||||
'New order placed #XF-2356',
|
||||
'New order placed #XF-2346',
|
||||
][index],
|
||||
type: `order${index + 1}`,
|
||||
time: _times(index),
|
||||
}));
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
export const _tasks = [...Array(5)].map((_, index) => ({
|
||||
id: _id(index),
|
||||
name: _taskNames(index),
|
||||
}));
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
export const _notifications = [
|
||||
{
|
||||
id: _id(1),
|
||||
title: 'Your order is placed',
|
||||
description: 'waiting for shipping',
|
||||
avatarUrl: null,
|
||||
type: 'order-placed',
|
||||
postedAt: _times(1),
|
||||
isUnRead: true,
|
||||
},
|
||||
{
|
||||
id: _id(2),
|
||||
title: _fullName(2),
|
||||
description: 'answered to your comment on the Minimal',
|
||||
avatarUrl: '/assets/images/avatar/avatar-2.webp',
|
||||
type: 'friend-interactive',
|
||||
postedAt: _times(2),
|
||||
isUnRead: true,
|
||||
},
|
||||
{
|
||||
id: _id(3),
|
||||
title: 'You have new message',
|
||||
description: '5 unread messages',
|
||||
avatarUrl: null,
|
||||
type: 'chat-message',
|
||||
postedAt: _times(3),
|
||||
isUnRead: false,
|
||||
},
|
||||
{
|
||||
id: _id(4),
|
||||
title: 'You have new mail',
|
||||
description: 'sent from Guido Padberg',
|
||||
avatarUrl: null,
|
||||
type: 'mail',
|
||||
postedAt: _times(4),
|
||||
isUnRead: false,
|
||||
},
|
||||
{
|
||||
id: _id(5),
|
||||
title: 'Delivery processing',
|
||||
description: 'Your order is being shipped',
|
||||
avatarUrl: null,
|
||||
type: 'order-shipped',
|
||||
postedAt: _times(5),
|
||||
isUnRead: false,
|
||||
},
|
||||
];
|
||||
232
web/src/_mock/_mock.ts
Executable file
|
|
@ -0,0 +1,232 @@
|
|||
export const _id = (index: number) => `e99f09a7-dd88-49d5-b1c8-1daf80c2d7b${index}`;
|
||||
|
||||
export const _times = (index: number) =>
|
||||
// 'MM/DD/YYYY'
|
||||
[
|
||||
'11/08/2023',
|
||||
'04/09/2024',
|
||||
'09/12/2023',
|
||||
'01/01/2024',
|
||||
'04/23/2024',
|
||||
'02/29/2024',
|
||||
'05/14/2024',
|
||||
'01/13/2024',
|
||||
'06/22/2024',
|
||||
'10/05/2023',
|
||||
'07/11/2024',
|
||||
'05/22/2024',
|
||||
'03/29/2024',
|
||||
'08/29/2023',
|
||||
'11/19/2023',
|
||||
'10/24/2023',
|
||||
'12/02/2023',
|
||||
'02/13/2024',
|
||||
'09/19/2023',
|
||||
'04/17/2024',
|
||||
'12/18/2023',
|
||||
'06/27/2024',
|
||||
'10/19/2023',
|
||||
'08/09/2024',
|
||||
][index];
|
||||
|
||||
export const _fullName = (index: number) =>
|
||||
[
|
||||
'Billy Stoltenberg',
|
||||
'Eloise Ebert',
|
||||
'Teresa Luettgen',
|
||||
'Salvador Mayert',
|
||||
'Dr. Guadalupe Rath',
|
||||
'Kelvin Pouros',
|
||||
'Thelma Langworth',
|
||||
'Kristen Wunsch',
|
||||
'Steve Welch',
|
||||
'Brian Jacobs',
|
||||
'Lillie Schultz',
|
||||
'Mr. Conrad Spinka',
|
||||
'Charlene Krajcik',
|
||||
'Kerry Kuhlman',
|
||||
'Betty Hammes',
|
||||
'Tony Paucek PhD',
|
||||
'Sherri Davis',
|
||||
'Angel Rolfson-Kulas',
|
||||
'Dr. Lee Doyle-Grant',
|
||||
'Cheryl Romaguera',
|
||||
'Billy Braun',
|
||||
'Adam Trantow',
|
||||
'Brandon Von',
|
||||
'Willis Ankunding',
|
||||
][index];
|
||||
|
||||
export const _price = (index: number) =>
|
||||
[
|
||||
35.17, 57.22, 64.78, 50.79, 9.57, 61.46, 96.73, 63.04, 33.18, 36.3, 54.42, 20.52, 62.82, 19.96,
|
||||
25.93, 70.39, 23.11, 67.23, 14.31, 31.5, 26.72, 44.8, 37.87, 75.53,
|
||||
][index];
|
||||
|
||||
export const _company = (index: number) =>
|
||||
[
|
||||
'Medhurst, Moore and Franey',
|
||||
'Hahn, Homenick and Lind',
|
||||
'Larkin LLC',
|
||||
'Stamm, Larson and Mertz',
|
||||
'Spencer, Raynor and Langosh',
|
||||
'Lehner - Feeney',
|
||||
'Leuschke, Harris and Kuhlman',
|
||||
'Gutmann - Kassulke',
|
||||
'Turcotte - Runolfsson',
|
||||
'Howe - Anderson',
|
||||
'Sipes - Yost',
|
||||
'Johns - Aufderhar',
|
||||
'Schmidt LLC',
|
||||
'Smitham - Gerlach',
|
||||
'Waelchi - VonRueden',
|
||||
'Padberg - Macejkovic',
|
||||
'Lemke - Ferry',
|
||||
'Koch and Sons',
|
||||
'Klein - Rolfson',
|
||||
'Weimann LLC',
|
||||
'White, Cassin and Goldner',
|
||||
'Mohr, Langworth and Hills',
|
||||
'Mitchell, Volkman and Prosacco',
|
||||
'Streich Group',
|
||||
][index];
|
||||
|
||||
export const _boolean = (index: number) =>
|
||||
[
|
||||
true,
|
||||
false,
|
||||
true,
|
||||
false,
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
false,
|
||||
false,
|
||||
true,
|
||||
false,
|
||||
true,
|
||||
true,
|
||||
false,
|
||||
true,
|
||||
false,
|
||||
false,
|
||||
true,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
true,
|
||||
true,
|
||||
false,
|
||||
][index];
|
||||
|
||||
export const _postTitles = (index: number) =>
|
||||
[
|
||||
'Whiteboard Templates By Industry Leaders',
|
||||
'Tesla Cybertruck-inspired camper trailer for Tesla fans who can’t just wait for the truck!',
|
||||
'Designify Agency Landing Page Design',
|
||||
'✨What is Done is Done ✨',
|
||||
'Fresh Prince',
|
||||
'Six Socks Studio',
|
||||
'vincenzo de cotiis’ crossing over showcases a research on contamination',
|
||||
'Simple, Great Looking Animations in Your Project | Video Tutorial',
|
||||
'40 Free Serif Fonts for Digital Designers',
|
||||
'Examining the Evolution of the Typical Web Design Client',
|
||||
'Katie Griffin loves making that homey art',
|
||||
'The American Dream retold through mid-century railroad graphics',
|
||||
'Illustration System Design',
|
||||
'CarZio-Delivery Driver App SignIn/SignUp',
|
||||
'How to create a client-serverless Jamstack app using Netlify, Gatsby and Fauna',
|
||||
'Tylko Organise effortlessly -3D & Motion Design',
|
||||
'RAYO ?? A expanded visual arts festival identity',
|
||||
'Anthony Burrill and Wired mag’s Andrew Diprose discuss how they made January’s Change Everything cover',
|
||||
'Inside the Mind of Samuel Day',
|
||||
'Portfolio Review: Is This Portfolio Too Creative?',
|
||||
'Akkers van Margraten',
|
||||
'Gradient Ticket icon',
|
||||
'Here’s a Dyson motorcycle concept that doesn’t ‘suck’!',
|
||||
'How to Animate a SVG with border-image',
|
||||
][index];
|
||||
|
||||
export const _description = (index: number) =>
|
||||
[
|
||||
'The Nagasaki Lander is the trademarked name of several series of Nagasaki sport bikes, that started with the 1984 ABC800J',
|
||||
'New range of formal shirts are designed keeping you in mind. With fits and styling that will make you stand apart',
|
||||
'Andy shoes are designed to keeping in mind durability as well as trends, the most stylish range of shoes & sandals',
|
||||
'The Football Is Good For Training And Recreational Purposes',
|
||||
'New ABC 13 9370, 13.3, 5th Gen CoreA5-8250U, 8GB RAM, 256GB SSD, power UHD Graphics, OS 10 Home, OS Office A & J 2016',
|
||||
'Andy shoes are designed to keeping in mind durability as well as trends, the most stylish range of shoes & sandals',
|
||||
'Carbonite web goalkeeper gloves are ergonomically designed to give easy fit',
|
||||
'The Apollotech B340 is an affordable wireless mouse with reliable connectivity, 12 months battery life and modern design',
|
||||
'The Nagasaki Lander is the trademarked name of several series of Nagasaki sport bikes, that started with the 1984 ABC800J',
|
||||
'The automobile layout consists of a front-engine design, with transaxle-type transmissions mounted at the rear of the engine and four wheel drive',
|
||||
'The automobile layout consists of a front-engine design, with transaxle-type transmissions mounted at the rear of the engine and four wheel drive',
|
||||
'The Apollotech B340 is an affordable wireless mouse with reliable connectivity, 12 months battery life and modern design',
|
||||
'New range of formal shirts are designed keeping you in mind. With fits and styling that will make you stand apart',
|
||||
"Boston's most advanced compression wear technology increases muscle oxygenation, stabilizes active muscles",
|
||||
'New range of formal shirts are designed keeping you in mind. With fits and styling that will make you stand apart',
|
||||
'Andy shoes are designed to keeping in mind durability as well as trends, the most stylish range of shoes & sandals',
|
||||
'Andy shoes are designed to keeping in mind durability as well as trends, the most stylish range of shoes & sandals',
|
||||
'The beautiful range of Apple Naturalé that has an exciting mix of natural ingredients. With the Goodness of 100% Natural Ingredients',
|
||||
"Boston's most advanced compression wear technology increases muscle oxygenation, stabilizes active muscles",
|
||||
'New ABC 13 9370, 13.3, 5th Gen CoreA5-8250U, 8GB RAM, 256GB SSD, power UHD Graphics, OS 10 Home, OS Office A & J 2016',
|
||||
'The Nagasaki Lander is the trademarked name of several series of Nagasaki sport bikes, that started with the 1984 ABC800J',
|
||||
'Ergonomic executive chair upholstered in bonded black leather and PVC padded seat and back for all-day comfort and support',
|
||||
'The Football Is Good For Training And Recreational Purposes',
|
||||
'The automobile layout consists of a front-engine design, with transaxle-type transmissions mounted at the rear of the engine and four wheel drive',
|
||||
][index];
|
||||
|
||||
export const _taskNames = (index: number) =>
|
||||
[
|
||||
`Prepare Monthly Financial Report`,
|
||||
`Design New Marketing Campaign`,
|
||||
`Analyze Customer Feedback`,
|
||||
`Update Website Content`,
|
||||
`Conduct Market Research`,
|
||||
`Develop Software Application`,
|
||||
`Organize Team Meeting`,
|
||||
`Create Social Media Posts`,
|
||||
`Review Project Plan`,
|
||||
`Implement Security Protocols`,
|
||||
`Write Technical Documentation`,
|
||||
`Test New Product Features`,
|
||||
`Manage Client Inquiries`,
|
||||
`Train New Employees`,
|
||||
`Coordinate Logistics`,
|
||||
`Monitor Network Performance`,
|
||||
`Develop Training Materials`,
|
||||
`Draft Press Release`,
|
||||
`Prepare Budget Proposal`,
|
||||
`Evaluate Vendor Proposals`,
|
||||
`Perform Data Analysis`,
|
||||
`Conduct Quality Assurance`,
|
||||
`Plan Event Logistics`,
|
||||
`Optimize SEO Strategies`,
|
||||
][index];
|
||||
|
||||
export const _productNames = (index: number) =>
|
||||
[
|
||||
'Nike Air Force 1 NDESTRUKT',
|
||||
'Nike Space Hippie 04',
|
||||
'Nike Air Zoom Pegasus 37 A.I.R. Chaz Bear',
|
||||
'Nike Blazer Low 77 Vintage',
|
||||
'Nike ZoomX SuperRep Surge',
|
||||
'Zoom Freak 2',
|
||||
'Nike Air Max Zephyr',
|
||||
'Jordan Delta',
|
||||
'Air Jordan XXXV PF',
|
||||
'Nike Waffle Racer Crater',
|
||||
'Kyrie 7 EP Sisterhood',
|
||||
'Nike Air Zoom BB NXT',
|
||||
'Nike Air Force 1 07 LX',
|
||||
'Nike Air Force 1 Shadow SE',
|
||||
'Nike Air Zoom Tempo NEXT%',
|
||||
'Nike DBreak-Type',
|
||||
'Nike Air Max Up',
|
||||
'Nike Air Max 270 React ENG',
|
||||
'NikeCourt Royale',
|
||||
'Nike Air Zoom Pegasus 37 Premium',
|
||||
'Nike Air Zoom SuperRep',
|
||||
'NikeCourt Royale',
|
||||
'Nike React Art3mis',
|
||||
'Nike React Infinity Run Flyknit A.I.R. Chaz Bear',
|
||||
][index];
|
||||
2
web/src/_mock/index.ts
Executable file
|
|
@ -0,0 +1,2 @@
|
|||
export * from './_mock';
|
||||
export * from './_data';
|
||||
44
web/src/app.tsx
Executable file
|
|
@ -0,0 +1,44 @@
|
|||
import 'src/global.css';
|
||||
|
||||
import Fab from '@mui/material/Fab';
|
||||
|
||||
import { Router } from 'src/routes/sections';
|
||||
|
||||
import { useScrollToTop } from 'src/hooks/use-scroll-to-top';
|
||||
|
||||
import { ThemeProvider } from 'src/theme/theme-provider';
|
||||
|
||||
import { Iconify } from 'src/components/iconify';
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
export default function App() {
|
||||
useScrollToTop();
|
||||
|
||||
const githubButton = (
|
||||
<Fab
|
||||
size="medium"
|
||||
aria-label="Github"
|
||||
href="https://github.com/xinnan-tech/xiaozhi-esp32-server"
|
||||
sx={{
|
||||
zIndex: 9,
|
||||
right: 20,
|
||||
bottom: 20,
|
||||
width: 44,
|
||||
height: 44,
|
||||
position: 'fixed',
|
||||
bgcolor: 'grey.800',
|
||||
color: 'common.white',
|
||||
}}
|
||||
>
|
||||
<Iconify width={24} icon="eva:github-fill" />
|
||||
</Fab>
|
||||
);
|
||||
|
||||
return (
|
||||
<ThemeProvider>
|
||||
<Router />
|
||||
{githubButton}
|
||||
</ThemeProvider>
|
||||
);
|
||||
}
|
||||
|
Before Width: | Height: | Size: 1.1 KiB |
|
Before Width: | Height: | Size: 3.3 KiB |
|
|
@ -1 +0,0 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="37.07" height="36" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 198"><path fill="#41B883" d="M204.8 0H256L128 220.8L0 0h97.92L128 51.2L157.44 0h47.36Z"></path><path fill="#41B883" d="m0 0l128 220.8L256 0h-51.2L128 132.48L50.56 0H0Z"></path><path fill="#35495E" d="M50.56 0L128 133.12L204.8 0h-47.36L128 51.2L97.92 0H50.56Z"></path></svg>
|
||||
|
Before Width: | Height: | Size: 496 B |
|
|
@ -1,206 +0,0 @@
|
|||
<template>
|
||||
<div class="device-card">
|
||||
<div class="device-header">
|
||||
<h2 class="device-id">{{ deviceId }} <span class="note">[{{ deviceNote || '备注' }}]</span></h2>
|
||||
</div>
|
||||
|
||||
<div class="device-details">
|
||||
<p class="device-type">设备型号:{{ deviceType }}</p>
|
||||
<p class="device-role">角色昵称:{{ deviceRole }}</p>
|
||||
<p class="device-modules">
|
||||
当前模型:
|
||||
<span class="module-item">LLM: {{ selectedModules?.LLM || '-' }}</span>
|
||||
<span class="module-item">TTS: {{ selectedModules?.TTS || '-' }}</span>
|
||||
</p>
|
||||
<p class="last-activity">最近对话:{{ lastActivity }}</p>
|
||||
</div>
|
||||
|
||||
<div class="device-actions">
|
||||
<button class="action-btn primary" @click="handleConfigure">配置角色</button>
|
||||
<button class="action-btn" @click="$emit('voiceprint')">声纹识别</button>
|
||||
<button class="action-btn" @click="$emit('history')">历史对话</button>
|
||||
<div class="delete-container">
|
||||
<button class="action-btn danger" @click="handleDelete">
|
||||
<i class="icon-delete"></i> 删除设备
|
||||
</button>
|
||||
<div class="delete-warning">删除后设备配置将不可恢复</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, watch, computed } from 'vue';
|
||||
import SwitchToggle from './SwitchToggle.vue';
|
||||
|
||||
const props = defineProps({
|
||||
deviceId: String,
|
||||
deviceNote: String,
|
||||
deviceType: {
|
||||
type: String,
|
||||
default: '未知型号(待实现)'
|
||||
},
|
||||
lastActivity: {
|
||||
type: String,
|
||||
default: '3 天前'
|
||||
},
|
||||
selectedModules: {
|
||||
type: Object,
|
||||
default: () => ({
|
||||
LLM: '-',
|
||||
TTS: '-',
|
||||
ASR: '-',
|
||||
VAD: '-'
|
||||
})
|
||||
},
|
||||
deviceConfig: {
|
||||
type: Object,
|
||||
default: () => ({})
|
||||
}
|
||||
});
|
||||
|
||||
const deviceRole = computed(() => {
|
||||
return props.deviceConfig?.nickname || '小智';
|
||||
});
|
||||
|
||||
// Store device config when it changes
|
||||
watch(() => props.selectedModules, (newValue) => {
|
||||
if (props.deviceId) {
|
||||
localStorage.setItem(`deviceConfig_${props.deviceId}`, JSON.stringify({
|
||||
selected_module: newValue
|
||||
}));
|
||||
}
|
||||
}, { deep: true });
|
||||
|
||||
const otaEnabled = ref(false);
|
||||
|
||||
const emit = defineEmits(['configure', 'voiceprint', 'history', 'delete']);
|
||||
|
||||
const handleDelete = () => {
|
||||
if (confirm('确认要删除此设备吗?\n\n警告:删除后设备所有配置将不可恢复!')) {
|
||||
emit('delete');
|
||||
}
|
||||
};
|
||||
|
||||
const handleConfigure = () => {
|
||||
// 保存设备配置到 localStorage,确保 RoleSetting 可以访问
|
||||
if (props.deviceId && props.deviceConfig) {
|
||||
localStorage.setItem(`deviceConfig_${props.deviceId}`, JSON.stringify({
|
||||
selected_module: props.selectedModules,
|
||||
prompt: props.deviceConfig.prompt || '',
|
||||
nickname: props.deviceConfig.nickname || '小智'
|
||||
}));
|
||||
}
|
||||
emit('configure');
|
||||
};
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.device-card {
|
||||
background: white;
|
||||
border-radius: 4px;
|
||||
padding: 20px;
|
||||
box-shadow: 0 1px 3px rgba(0,0,0,0.1);
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
|
||||
.device-id {
|
||||
font-size: 18px;
|
||||
font-weight: bold;
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
|
||||
.note {
|
||||
color: #4178EE;
|
||||
font-size: 14px;
|
||||
font-weight: normal;
|
||||
}
|
||||
|
||||
.device-details p {
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
|
||||
.ota-upgrade {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
margin-left: 16px;
|
||||
}
|
||||
|
||||
.device-actions {
|
||||
display: flex;
|
||||
margin-top: 20px;
|
||||
}
|
||||
|
||||
.action-btn {
|
||||
padding: 8px 16px;
|
||||
margin-right: 12px;
|
||||
border: 1px solid #ddd;
|
||||
border-radius: 4px;
|
||||
background: white;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.action-btn.primary {
|
||||
background: #4178EE;
|
||||
color: white;
|
||||
border-color: #4178EE;
|
||||
}
|
||||
|
||||
.action-btn.danger {
|
||||
background: #fff3f3;
|
||||
border-color: #ffa4a4;
|
||||
color: #f56c6c;
|
||||
}
|
||||
|
||||
.action-btn.danger:hover {
|
||||
background: #fde2e2;
|
||||
border-color: #f56c6c;
|
||||
}
|
||||
|
||||
.device-modules {
|
||||
margin-bottom: 12px;
|
||||
color: #666;
|
||||
}
|
||||
|
||||
.module-item {
|
||||
display: inline-block;
|
||||
margin-right: 16px;
|
||||
padding: 4px 8px;
|
||||
background: #f5f7fa;
|
||||
border-radius: 4px;
|
||||
font-size: 0.9em;
|
||||
}
|
||||
|
||||
.device-role {
|
||||
color: #666;
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
|
||||
.delete-container {
|
||||
position: relative;
|
||||
margin-left: auto; /* Push delete button to the right */
|
||||
}
|
||||
|
||||
.delete-warning {
|
||||
position: absolute;
|
||||
bottom: calc(100% + 5px); /* Position above the button */
|
||||
left: 50%;
|
||||
transform: translateX(-50%);
|
||||
white-space: nowrap;
|
||||
background: #fff3f3;
|
||||
padding: 4px 8px;
|
||||
border-radius: 4px;
|
||||
border: 1px solid #ffa4a4;
|
||||
font-size: 12px;
|
||||
color: #f56c6c;
|
||||
display: none;
|
||||
}
|
||||
|
||||
.delete-container:hover .delete-warning {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.icon-delete {
|
||||
margin-right: 4px;
|
||||
}
|
||||
</style>
|
||||
|
|
@ -1,15 +0,0 @@
|
|||
<template>
|
||||
<footer class="footer">
|
||||
<div class="copyright">© 2025 小智 AI 管理后台</div>
|
||||
</footer>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.footer {
|
||||
text-align: center;
|
||||
padding: 16px;
|
||||
color: #666;
|
||||
font-size: 12px;
|
||||
background: #f0f2f5;
|
||||
}
|
||||
</style>
|
||||
|
|
@ -1,149 +0,0 @@
|
|||
<template>
|
||||
<div class="login-container">
|
||||
<h1>登录</h1>
|
||||
<form @submit.prevent="handleLogin">
|
||||
<div class="form-group">
|
||||
<label for="username">用户名</label>
|
||||
<input type="text" v-model="username" id="username" required />
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="password">密码</label>
|
||||
<input type="password" v-model="password" id="password" required />
|
||||
</div>
|
||||
<button type="submit" :disabled="isLoading">登录</button>
|
||||
</form>
|
||||
<p>还没注册账户? <router-link to="/register">点击注册</router-link></p>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref } from 'vue';
|
||||
import { useRouter } from 'vue-router';
|
||||
import apiClient from '../utils/api';
|
||||
|
||||
const router = useRouter();
|
||||
const username = ref('');
|
||||
const password = ref('');
|
||||
const isLoading = ref(false);
|
||||
|
||||
const handleLogin = async () => {
|
||||
if (!username.value || !password.value) {
|
||||
alert('请输入用户名和密码!');
|
||||
return;
|
||||
}
|
||||
|
||||
isLoading.value = true;
|
||||
try {
|
||||
const response = await apiClient.post('/api/login', {
|
||||
username: username.value,
|
||||
password: password.value
|
||||
});
|
||||
|
||||
const data = response.data;
|
||||
|
||||
if (data.success) {
|
||||
localStorage.setItem('session_id', data.session_id);
|
||||
localStorage.setItem('isLoggedIn', 'true');
|
||||
router.push('/panel');
|
||||
} else {
|
||||
alert(data.message || '登录失败');
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Login error:', error);
|
||||
alert('登录失败,请检查网络连接');
|
||||
} finally {
|
||||
isLoading.value = false;
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.login-container {
|
||||
max-width: 420px;
|
||||
margin: 20px auto;
|
||||
padding: 40px 50px;
|
||||
border: none;
|
||||
border-radius: 12px;
|
||||
background-color: #ffffff;
|
||||
box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
|
||||
transition: all 0.3s ease;
|
||||
}
|
||||
|
||||
h1 {
|
||||
text-align: center;
|
||||
color: #2c3e50;
|
||||
font-size: 28px;
|
||||
margin-bottom: 25px;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.form-group {
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
label {
|
||||
display: block;
|
||||
margin-bottom: 8px;
|
||||
font-weight: 500;
|
||||
color: #4a5568;
|
||||
}
|
||||
|
||||
input {
|
||||
width: 100%;
|
||||
padding: 12px 16px;
|
||||
border: 1px solid #e2e8f0;
|
||||
border-radius: 8px;
|
||||
background-color: #f8fafc;
|
||||
transition: all 0.3s ease;
|
||||
font-size: 15px;
|
||||
}
|
||||
|
||||
input:focus {
|
||||
outline: none;
|
||||
border-color: #28a745;
|
||||
box-shadow: 0 0 0 3px rgba(40, 167, 69, 0.2);
|
||||
}
|
||||
|
||||
button {
|
||||
width: 100%;
|
||||
padding: 12px;
|
||||
background-color: #28a745;
|
||||
color: white;
|
||||
border: none;
|
||||
border-radius: 8px;
|
||||
cursor: pointer;
|
||||
font-size: 16px;
|
||||
font-weight: 500;
|
||||
transition: all 0.3s ease;
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
button:hover {
|
||||
background-color: #218838;
|
||||
transform: translateY(-1px);
|
||||
box-shadow: 0 4px 12px rgba(40, 167, 69, 0.2);
|
||||
}
|
||||
|
||||
button:disabled {
|
||||
opacity: 0.7;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
|
||||
p {
|
||||
margin-top: 20px;
|
||||
color: #666;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
a {
|
||||
color: #28a745;
|
||||
text-decoration: none;
|
||||
font-weight: 500;
|
||||
transition: color 0.3s ease;
|
||||
}
|
||||
|
||||
a:hover {
|
||||
color: #218838;
|
||||
text-decoration: underline;
|
||||
}
|
||||
</style>
|
||||
|
|
@ -1,184 +0,0 @@
|
|||
<template>
|
||||
<div class="main-container">
|
||||
<NavBar current-tab="home" @tab-change="handleTabChange"/>
|
||||
<div class="landing-page">
|
||||
<div class="content">
|
||||
<div class="robot-image">
|
||||
<img src="../assets/robot.png" alt="Robot mascot" />
|
||||
</div>
|
||||
|
||||
<h1 class="slogan">让我们一起探索人工智能与机器人技术的迷人世界!</h1>
|
||||
|
||||
<div class="button-group">
|
||||
<button class="action-button tutorial-button" @click="openTutorial">
|
||||
<i class="icon-tutorial"></i> DIY 教程
|
||||
</button>
|
||||
|
||||
<button class="action-button github-button" @click="openGithubClient">
|
||||
<i class="icon-github"></i> Github客户端
|
||||
</button>
|
||||
|
||||
<button class="action-button github-button" @click="openGithubServer">
|
||||
<i class="icon-github"></i> Github服务端
|
||||
</button>
|
||||
|
||||
<button class="action-button github-button" @click="openGithubWeb">
|
||||
<i class="icon-github"></i> Web客户端
|
||||
</button>
|
||||
|
||||
<button class="action-button control-panel-button" @click="enterPanel">
|
||||
<i class="icon-control-panel"></i> 控制台
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import NavBar from './NavBar.vue';
|
||||
import { useRouter } from 'vue-router';
|
||||
|
||||
const router = useRouter();
|
||||
|
||||
const openTutorial = () => {
|
||||
window.open('https://ccnphfhqs21z.feishu.cn/wiki/F5krwD16viZoF0kKkvDcrZNYnhb', '_blank');
|
||||
};
|
||||
|
||||
const openGithubClient = () => {
|
||||
window.open('https://github.com/78/xiaozhi-esp32', '_blank');
|
||||
};
|
||||
|
||||
const openGithubServer = () => {
|
||||
window.open('https://github.com/xinnan-tech/xiaozhi-esp32-server', '_blank');
|
||||
};
|
||||
|
||||
const openGithubWeb = () => {
|
||||
window.open('https://github.com/TOM88812/xiaozhi-web-client', '_blank');
|
||||
};
|
||||
|
||||
const enterPanel = () => {
|
||||
router.push('/panel');
|
||||
};
|
||||
|
||||
const handleTabChange = (tab) => {
|
||||
if (tab === 'device') {
|
||||
router.push('/panel');
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.main-container {
|
||||
min-height: 100%;
|
||||
width: 100%;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.landing-page {
|
||||
flex: 1;
|
||||
width: 100%;
|
||||
background-color: #f5f7fa;
|
||||
padding: 40px 20px;
|
||||
overflow: hidden;
|
||||
display: flex;
|
||||
align-items: flex-start; /* 改为flex-start */
|
||||
justify-content: center;
|
||||
padding-top: 15vh; /* 添加顶部内边距,视窗高度的15% */
|
||||
}
|
||||
|
||||
.content {
|
||||
max-width: 800px;
|
||||
text-align: center;
|
||||
padding: 0 20px;
|
||||
margin: 0 auto; /* 改为0 auto */
|
||||
}
|
||||
|
||||
.robot-image {
|
||||
margin-bottom: 30px; /* 减小间距 */
|
||||
}
|
||||
|
||||
.robot-image img {
|
||||
width: 100px; /* 稍微调小图片尺寸 */
|
||||
height: auto;
|
||||
}
|
||||
|
||||
.slogan {
|
||||
font-size: 22px; /* 稍微调小字体 */
|
||||
line-height: 1.4;
|
||||
color: #333;
|
||||
margin-bottom: 40px; /* 减小间距 */
|
||||
}
|
||||
|
||||
.button-group {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
justify-content: center;
|
||||
gap: 15px; /* 减小按钮间距 */
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
.action-button {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding: 12px 24px;
|
||||
border-radius: 8px;
|
||||
border: 1px solid #e0e0e0;
|
||||
background-color: white;
|
||||
color: #333;
|
||||
font-size: 16px;
|
||||
cursor: pointer;
|
||||
transition: all 0.2s ease;
|
||||
}
|
||||
|
||||
.action-button:hover {
|
||||
transform: translateY(-2px);
|
||||
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
|
||||
.tutorial-button i:before {
|
||||
content: '\1F4D6';
|
||||
margin-right: 8px;
|
||||
}
|
||||
|
||||
.github-button {
|
||||
background-color: #24292e;
|
||||
color: white;
|
||||
border-color: #24292e;
|
||||
margin: 0 10px; /* 添加按钮间距 */
|
||||
}
|
||||
|
||||
.github-button i:before {
|
||||
content: '\f09b';
|
||||
font-family: 'Font Awesome 5 Brands';
|
||||
margin-right: 8px;
|
||||
}
|
||||
|
||||
.control-panel-button {
|
||||
background-color: #4178EE;
|
||||
color: white;
|
||||
border-color: #4178EE;
|
||||
}
|
||||
|
||||
.control-panel-button i:before {
|
||||
content: '\1F39B';
|
||||
margin-right: 8px;
|
||||
}
|
||||
|
||||
@media (max-width: 600px) {
|
||||
.button-group {
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.action-button {
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
|
||||
/* 移除 margin-top: 60px */
|
||||
#app {
|
||||
margin-top: 0;
|
||||
}
|
||||
</style>
|
||||
|
|
@ -1,60 +0,0 @@
|
|||
<template>
|
||||
<header class="header">
|
||||
<div class="nav-item" :class="{ active: $route.path === '/' }" @click="switchTab('/')">小智 AI</div>
|
||||
<nav class="nav">
|
||||
<div class="nav-item" :class="{ active: $route.path === '/panel' }" @click="switchTab('/panel')">
|
||||
<i class="icon-device"></i> 设备管理
|
||||
</div>
|
||||
</nav>
|
||||
</header>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { useRouter, useRoute } from 'vue-router';
|
||||
|
||||
const router = useRouter();
|
||||
const route = useRoute();
|
||||
|
||||
const switchTab = (path) => {
|
||||
router.push(path);
|
||||
};
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
height: 60px;
|
||||
padding: 0;
|
||||
background-color: #001529;
|
||||
color: white;
|
||||
width: 100%;
|
||||
position: relative;
|
||||
left: 0;
|
||||
right: 0;
|
||||
}
|
||||
|
||||
.nav {
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.nav-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
padding: 0 20px;
|
||||
height: 60px;
|
||||
color: white;
|
||||
text-decoration: none;
|
||||
cursor: pointer;
|
||||
font-weight: bold;
|
||||
transition: background-color 0.3s;
|
||||
}
|
||||
|
||||
.active {
|
||||
background-color: #4178EE;
|
||||
}
|
||||
|
||||
.icon-device {
|
||||
margin-right: 8px;
|
||||
}
|
||||
</style>
|
||||
|
|
@ -1,173 +0,0 @@
|
|||
<template>
|
||||
<div class="registration-container">
|
||||
<h1>注册</h1>
|
||||
<form @submit.prevent="handleRegistration">
|
||||
<div class="form-group">
|
||||
<label for="username">用户名</label>
|
||||
<input type="text" v-model="username" id="username" required />
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="password">密码</label>
|
||||
<input type="password" v-model="password" id="password" required />
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="confirmPassword">确认密码</label>
|
||||
<input type="password" v-model="confirmPassword" id="confirmPassword" required />
|
||||
</div>
|
||||
<button type="submit" :disabled="isLoading">{{ isLoading ? '注册中...' : '注册' }}</button>
|
||||
</form>
|
||||
<p>
|
||||
已有账号?
|
||||
<router-link to="/login">点击登录</router-link>
|
||||
</p>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref } from 'vue';
|
||||
import { useRouter } from 'vue-router';
|
||||
import { API_BASE_URL } from '../config/api';
|
||||
|
||||
const router = useRouter();
|
||||
const username = ref('');
|
||||
const password = ref('');
|
||||
const confirmPassword = ref('');
|
||||
const isLoading = ref(false);
|
||||
|
||||
const handleRegistration = async () => {
|
||||
if (password.value !== confirmPassword.value) {
|
||||
alert('密码不匹配,请重试!');
|
||||
return;
|
||||
}
|
||||
|
||||
if (!username.value || !password.value) {
|
||||
alert('用户名和密码不能为空!');
|
||||
return;
|
||||
}
|
||||
|
||||
isLoading.value = true;
|
||||
try {
|
||||
const response = await fetch(`${API_BASE_URL}/api/register`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: JSON.stringify({
|
||||
username: username.value,
|
||||
password: password.value
|
||||
})
|
||||
});
|
||||
|
||||
const data = await response.json();
|
||||
|
||||
if (data.success) {
|
||||
alert('注册成功!即将跳转到登录页面。');
|
||||
// 清空表单数据
|
||||
username.value = '';
|
||||
password.value = '';
|
||||
confirmPassword.value = '';
|
||||
|
||||
// 使用路由导航到登录页面
|
||||
router.push('/login');
|
||||
} else {
|
||||
alert(data.message || '注册失败');
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Registration error:', error);
|
||||
alert('注册失败,请检查网络连接');
|
||||
} finally {
|
||||
isLoading.value = false;
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.registration-container {
|
||||
max-width: 420px;
|
||||
margin: 20px auto;
|
||||
padding: 40px 50px;
|
||||
border: none;
|
||||
border-radius: 12px;
|
||||
background-color: #ffffff;
|
||||
box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
|
||||
transition: all 0.3s ease;
|
||||
}
|
||||
|
||||
h1 {
|
||||
text-align: center;
|
||||
color: #2c3e50;
|
||||
font-size: 28px;
|
||||
margin-bottom: 25px;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.form-group {
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
label {
|
||||
display: block;
|
||||
margin-bottom: 8px;
|
||||
font-weight: 500;
|
||||
color: #4a5568;
|
||||
}
|
||||
|
||||
input {
|
||||
width: 100%;
|
||||
padding: 12px 16px;
|
||||
border: 1px solid #e2e8f0;
|
||||
border-radius: 8px;
|
||||
background-color: #f8fafc;
|
||||
transition: all 0.3s ease;
|
||||
font-size: 15px;
|
||||
}
|
||||
|
||||
input:focus {
|
||||
outline: none;
|
||||
border-color: #007bff;
|
||||
box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.2);
|
||||
}
|
||||
|
||||
button {
|
||||
width: 100%;
|
||||
padding: 12px;
|
||||
background-color: #007bff;
|
||||
color: white;
|
||||
border: none;
|
||||
border-radius: 8px;
|
||||
cursor: pointer;
|
||||
font-size: 16px;
|
||||
font-weight: 500;
|
||||
transition: all 0.3s ease;
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
button:hover {
|
||||
background-color: #0056b3;
|
||||
transform: translateY(-1px);
|
||||
box-shadow: 0 4px 12px rgba(0, 123, 255, 0.2);
|
||||
}
|
||||
|
||||
button:disabled {
|
||||
opacity: 0.7;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
|
||||
p {
|
||||
margin-top: 20px;
|
||||
color: #666;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
a {
|
||||
color: #007bff;
|
||||
text-decoration: none;
|
||||
font-weight: 500;
|
||||
transition: color 0.3s ease;
|
||||
}
|
||||
|
||||
a:hover {
|
||||
color: #0056b3;
|
||||
text-decoration: underline;
|
||||
}
|
||||
</style>
|
||||
|
|
@ -1,500 +0,0 @@
|
|||
<template>
|
||||
<div class="app-container">
|
||||
<NavBar current-tab="device" @tab-change="handleTabChange"/>
|
||||
|
||||
<!-- Breadcrumb -->
|
||||
<div class="breadcrumb">
|
||||
<router-link to="/">首页</router-link> /
|
||||
<router-link to="/panel">设备管理</router-link> /
|
||||
<span>配置角色</span>
|
||||
</div>
|
||||
|
||||
<!-- Main Content -->
|
||||
<div class="main-content">
|
||||
<h1 class="page-title">配置角色: {{ deviceId }}</h1>
|
||||
|
||||
<div class="form-section">
|
||||
<div class="form-group">
|
||||
<label>助手昵称</label>
|
||||
<input type="text" v-model="nickname" placeholder="小智" class="form-input" />
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label>角色模板</label>
|
||||
<div class="role-templates">
|
||||
<button
|
||||
v-for="template in roleTemplates"
|
||||
:key="template.id"
|
||||
:class="['template-btn', { active: selectedTemplate === template.id }]"
|
||||
@click="selectTemplate(template.id)"
|
||||
>
|
||||
{{ template.name }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>角色介绍</label>
|
||||
<textarea
|
||||
v-model="roleDescription"
|
||||
class="form-textarea"
|
||||
:placeholder="'请输入角色介绍...'"
|
||||
></textarea>
|
||||
<div class="char-count">{{ roleDescription.length }} / 2000</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label>语言模型选择</label>
|
||||
<div class="model-select">
|
||||
<select v-model="selectedModules.LLM" class="form-input">
|
||||
<option v-for="model in moduleOptions.LLM" :key="model" :value="model">
|
||||
{{ model }}
|
||||
</option>
|
||||
</select>
|
||||
<div class="model-description">
|
||||
除了"qwen-turbo",其他模型通常会增加约 1 秒的延迟。改变模型后,建议清空记忆体,以免影响体验。
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label>语音合成选择</label>
|
||||
<div class="model-select">
|
||||
<select v-model="selectedModules.TTS" class="form-input">
|
||||
<option v-for="model in moduleOptions.TTS" :key="model" :value="model">
|
||||
{{ model }}
|
||||
</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label>语音活动检测选择</label>
|
||||
<div class="model-select">
|
||||
<select v-model="selectedModules.VAD" class="form-input">
|
||||
<option v-for="model in moduleOptions.VAD" :key="model" :value="model">
|
||||
{{ model }}
|
||||
</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label>语音识别选择</label>
|
||||
<div class="model-select">
|
||||
<select v-model="selectedModules.ASR" class="form-input">
|
||||
<option v-for="model in moduleOptions.ASR" :key="model" :value="model">
|
||||
{{ model }}
|
||||
</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-actions">
|
||||
<button class="refresh-btn" @click="refreshModuleOptions">刷新配置选项</button>
|
||||
<button class="save-btn" @click="saveConfig">
|
||||
<i class="icon-save"></i>
|
||||
保存配置
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="form-note">
|
||||
注意:保存配置后,需要重启设备,新的配置才会生效。。
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, onMounted } from 'vue';
|
||||
import { useRouter, useRoute } from 'vue-router';
|
||||
import NavBar from './NavBar.vue';
|
||||
import RoleTemplates from '../utils/RoleTemplates';
|
||||
import apiClient from '../utils/api'; // 替换 API_BASE_URL 导入
|
||||
|
||||
const router = useRouter();
|
||||
const route = useRoute();
|
||||
const deviceId = ref(route.params.deviceId);
|
||||
|
||||
const roleTemplates = RoleTemplates.getTemplates();
|
||||
const nickname = ref('小智');
|
||||
const selectedTemplate = ref('');
|
||||
const selectedVoice = ref('qingchun');
|
||||
const roleDescription = ref('');
|
||||
const activeMemoryTab = ref('recent');
|
||||
const memoryContent = ref('');
|
||||
const selectedModel = ref('qianwen');
|
||||
|
||||
const moduleOptions = ref({
|
||||
LLM: [],
|
||||
TTS: [],
|
||||
VAD: [],
|
||||
ASR: []
|
||||
});
|
||||
|
||||
const selectedModules = ref({
|
||||
LLM: '',
|
||||
TTS: '',
|
||||
VAD: '',
|
||||
ASR: ''
|
||||
});
|
||||
|
||||
const selectTemplate = (templateId) => {
|
||||
selectedTemplate.value = templateId;
|
||||
const template = RoleTemplates.getTemplateById(templateId);
|
||||
if (template) {
|
||||
roleDescription.value = template.description;
|
||||
}
|
||||
};
|
||||
|
||||
const handleTabChange = (tab) => {
|
||||
if (tab === 'device' || tab === 'home') {
|
||||
router.push('/panel');
|
||||
}
|
||||
};
|
||||
|
||||
const loadModuleOptions = async () => {
|
||||
try {
|
||||
// First try to load from cache
|
||||
const cached = localStorage.getItem('moduleOptions');
|
||||
if (cached) {
|
||||
moduleOptions.value = JSON.parse(cached);
|
||||
return;
|
||||
}
|
||||
await refreshModuleOptions();
|
||||
} catch (error) {
|
||||
console.error('Error loading module options:', error);
|
||||
}
|
||||
};
|
||||
|
||||
const refreshModuleOptions = async () => {
|
||||
try {
|
||||
const response = await apiClient.get('/api/config/module-options');
|
||||
if (response.data.success) {
|
||||
moduleOptions.value = response.data.data;
|
||||
// Update cache
|
||||
localStorage.setItem('moduleOptions', JSON.stringify(response.data.data));
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Error refreshing module options:', error);
|
||||
alert(error.response?.data?.message || '刷新配置选项失败');
|
||||
}
|
||||
};
|
||||
|
||||
const saveConfig = async () => {
|
||||
try {
|
||||
const moduleOptionsData = localStorage.getItem('moduleOptions');
|
||||
if (!moduleOptionsData) {
|
||||
throw new Error('No module options data available');
|
||||
}
|
||||
|
||||
// Replace {{assistant_name}} with current nickname in role description
|
||||
const processedDescription = roleDescription.value.replace(/{{assistant_name}}/g, nickname.value);
|
||||
|
||||
// Prepare the configuration including full module settings
|
||||
const config = {
|
||||
id: deviceId.value,
|
||||
config: {
|
||||
selected_module: selectedModules.value,
|
||||
prompt: processedDescription,
|
||||
nickname: nickname.value, // Add nickname to config
|
||||
modules: {
|
||||
LLM: {},
|
||||
TTS: {},
|
||||
ASR: {},
|
||||
VAD: {}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const response = await apiClient.post('/api/config/save_device_config', config);
|
||||
|
||||
if (response.data.success) {
|
||||
// Save the original description and nickname to local storage
|
||||
localStorage.setItem(`deviceConfig_${deviceId.value}`, JSON.stringify({
|
||||
selected_module: selectedModules.value,
|
||||
prompt: roleDescription.value,
|
||||
nickname: nickname.value
|
||||
}));
|
||||
alert('保存成功');
|
||||
} else {
|
||||
throw new Error(response.data.message || '保存失败');
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Error saving config:', error);
|
||||
alert(error.response?.data?.message || '保存失败');
|
||||
}
|
||||
};
|
||||
|
||||
const loadDeviceConfig = async () => {
|
||||
try {
|
||||
// 首先尝试从 localStorage 获取配置
|
||||
const localConfig = localStorage.getItem(`deviceConfig_${deviceId.value}`);
|
||||
if (localConfig) {
|
||||
const config = JSON.parse(localConfig);
|
||||
selectedModules.value = config.selected_module || {
|
||||
LLM: '',
|
||||
TTS: '',
|
||||
VAD: '',
|
||||
ASR: ''
|
||||
};
|
||||
roleDescription.value = config.prompt || '';
|
||||
nickname.value = config.nickname || '小智';
|
||||
return; // 如果找到本地配置就直接返回
|
||||
}
|
||||
|
||||
// 如果没有本地配置,则从服务器获取
|
||||
const response = await apiClient.get('/api/config/devices');
|
||||
if (response.data.success && response.data.data) {
|
||||
const deviceConfig = response.data.data[deviceId.value];
|
||||
|
||||
if (deviceConfig && deviceConfig.config) {
|
||||
selectedModules.value = deviceConfig.config.selected_module || {
|
||||
LLM: '',
|
||||
TTS: '',
|
||||
VAD: '',
|
||||
ASR: ''
|
||||
};
|
||||
roleDescription.value = deviceConfig.config.prompt || '';
|
||||
nickname.value = deviceConfig.config.nickname || '小智';
|
||||
|
||||
// 保存到 localStorage
|
||||
localStorage.setItem(`deviceConfig_${deviceId.value}`, JSON.stringify({
|
||||
selected_module: selectedModules.value,
|
||||
prompt: roleDescription.value,
|
||||
nickname: nickname.value
|
||||
}));
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Error loading device config:', error);
|
||||
alert(error.response?.data?.message || '加载设备配置失败');
|
||||
}
|
||||
};
|
||||
|
||||
onMounted(async () => {
|
||||
await Promise.all([
|
||||
loadModuleOptions(),
|
||||
loadDeviceConfig()
|
||||
]);
|
||||
});
|
||||
|
||||
const resetConfig = async () => {
|
||||
await loadDeviceConfig();
|
||||
};
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.app-container {
|
||||
min-height: 100vh;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
background-color: #f5f7fa;
|
||||
}
|
||||
|
||||
.breadcrumb {
|
||||
padding: 12px 24px;
|
||||
background-color: #f0f2f5;
|
||||
}
|
||||
|
||||
.main-content {
|
||||
flex: 1;
|
||||
max-width: 1000px;
|
||||
margin: 0 auto;
|
||||
padding: 16px 24px;
|
||||
width: 100%;
|
||||
overflow-y: auto;
|
||||
height: calc(100vh - 120px); /* 减去头部和面包屑的高度 */
|
||||
}
|
||||
|
||||
.page-title {
|
||||
font-size: 18px;
|
||||
font-weight: bold;
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
|
||||
.form-section {
|
||||
background: white;
|
||||
border-radius: 4px;
|
||||
padding: 20px;
|
||||
box-shadow: 0 1px 3px rgba(0,0,0,0.1);
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.form-group {
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
|
||||
.form-group label {
|
||||
display: block;
|
||||
margin-bottom: 6px;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.form-input,
|
||||
.form-textarea,
|
||||
.voice-select {
|
||||
width: 100%;
|
||||
padding: 8px 10px;
|
||||
border: 1px solid #d9d9d9;
|
||||
border-radius: 4px;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.form-textarea {
|
||||
min-height: 100px;
|
||||
max-height: 200px;
|
||||
resize: vertical;
|
||||
}
|
||||
|
||||
.role-templates {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 8px;
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
|
||||
.template-btn {
|
||||
padding: 6px 12px;
|
||||
border: 1px solid #d9d9d9;
|
||||
border-radius: 4px;
|
||||
background: white;
|
||||
cursor: pointer;
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.voice-selector {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.voice-player {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
padding: 8px;
|
||||
background: #f9f9f9;
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
.memory-tabs {
|
||||
display: flex;
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
|
||||
.tab-btn {
|
||||
padding: 6px 12px;
|
||||
background: none;
|
||||
border: none;
|
||||
border-bottom: 2px solid transparent;
|
||||
cursor: pointer;
|
||||
color: #666;
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.model-select {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 8px;
|
||||
padding: 10px;
|
||||
border: 1px solid #d9d9d9;
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
.model-description {
|
||||
color: #666;
|
||||
font-size: 12px;
|
||||
line-height: 1.4;
|
||||
}
|
||||
|
||||
.form-actions {
|
||||
display: flex;
|
||||
gap: 10px;
|
||||
margin-top: 20px;
|
||||
padding-top: 16px;
|
||||
border-top: 1px solid #eee;
|
||||
}
|
||||
|
||||
.save-btn,
|
||||
.cancel-btn {
|
||||
padding: 6px 16px;
|
||||
border-radius: 4px;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.form-note {
|
||||
margin-top: 12px;
|
||||
color: #666;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.char-count {
|
||||
text-align: right;
|
||||
color: #999;
|
||||
font-size: 12px;
|
||||
margin-top: 2px;
|
||||
}
|
||||
|
||||
/* 优化滚动条样式 */
|
||||
::-webkit-scrollbar {
|
||||
width: 6px;
|
||||
height: 6px;
|
||||
}
|
||||
|
||||
::-webkit-scrollbar-thumb {
|
||||
background: #ccc;
|
||||
border-radius: 3px;
|
||||
}
|
||||
|
||||
::-webkit-scrollbar-track {
|
||||
background: #f1f1f1;
|
||||
}
|
||||
|
||||
.refresh-btn {
|
||||
padding: 8px 16px;
|
||||
margin-right: 12px;
|
||||
background: #fff;
|
||||
border: 1px solid #ddd;
|
||||
border-radius: 4px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.refresh-btn:hover {
|
||||
background: #f5f5f5;
|
||||
}
|
||||
|
||||
.save-btn {
|
||||
padding: 8px 24px;
|
||||
border-radius: 4px;
|
||||
font-size: 14px;
|
||||
background: #4178EE;
|
||||
color: white;
|
||||
border: none;
|
||||
font-weight: 500;
|
||||
cursor: pointer;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
transition: all 0.3s ease;
|
||||
}
|
||||
|
||||
.save-btn:hover {
|
||||
background: #2856c8;
|
||||
transform: translateY(-1px);
|
||||
box-shadow: 0 2px 4px rgba(65, 120, 238, 0.2);
|
||||
}
|
||||
|
||||
.save-btn:active {
|
||||
transform: translateY(0);
|
||||
box-shadow: none;
|
||||
}
|
||||
|
||||
.icon-save {
|
||||
display: inline-block;
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='white'%3E%3Cpath d='M17 3H5C3.89 3 3 3.9 3 5V19C3 20.1 3.89 21 5 21H19C20.1 21 21 20.1 21 19V7L17 3ZM12 19C10.34 19 9 17.66 9 16C9 14.34 10.34 13 12 13C13.66 13 15 14.34 15 16C15 17.66 13.66 19 12 19ZM15 9H5V5H15V9Z'/%3E%3C/svg%3E");
|
||||
background-size: contain;
|
||||
}
|
||||
</style>
|
||||
|
|
@ -1,50 +0,0 @@
|
|||
<!-- components/SwitchToggle.vue -->
|
||||
<template>
|
||||
<div class="switch" :class="{ 'is-checked': isChecked }" @click="toggle">
|
||||
<div class="switch-core"></div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref } from 'vue';
|
||||
|
||||
const isChecked = ref(false);
|
||||
|
||||
const toggle = () => {
|
||||
isChecked.value = !isChecked.value;
|
||||
};
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.switch {
|
||||
position: relative;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
width: 40px;
|
||||
height: 20px;
|
||||
line-height: 20px;
|
||||
background-color: #dcdfe6;
|
||||
border-radius: 10px;
|
||||
cursor: pointer;
|
||||
transition: all 0.3s;
|
||||
}
|
||||
|
||||
.switch.is-checked {
|
||||
background-color: #4178EE;
|
||||
}
|
||||
|
||||
.switch-core {
|
||||
position: absolute;
|
||||
left: 2px;
|
||||
top: 2px;
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
border-radius: 50%;
|
||||
background-color: #fff;
|
||||
transition: all 0.3s;
|
||||
}
|
||||
|
||||
.switch.is-checked .switch-core {
|
||||
left: 22px;
|
||||
}
|
||||
</style>
|
||||
75
web/src/components/chart/chart-legends.tsx
Executable file
|
|
@ -0,0 +1,75 @@
|
|||
import type { BoxProps } from '@mui/material/Box';
|
||||
|
||||
import Box from '@mui/material/Box';
|
||||
import Stack from '@mui/material/Stack';
|
||||
import { styled } from '@mui/material/styles';
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
export const StyledLegend = styled(Box)(({ theme }) => ({
|
||||
gap: 6,
|
||||
alignItems: 'center',
|
||||
display: 'inline-flex',
|
||||
justifyContent: 'flex-start',
|
||||
fontSize: theme.typography.pxToRem(13),
|
||||
fontWeight: theme.typography.fontWeightMedium,
|
||||
}));
|
||||
|
||||
export const StyledDot = styled("div")(() => ({
|
||||
width: 12,
|
||||
height: 12,
|
||||
flexShrink: 0,
|
||||
display: "flex",
|
||||
borderRadius: "50%",
|
||||
position: "relative",
|
||||
alignItems: "center",
|
||||
justifyContent: "center",
|
||||
backgroundColor: "currentColor",
|
||||
}));
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
type Props = BoxProps & {
|
||||
labels?: string[];
|
||||
colors?: string[];
|
||||
values?: string[];
|
||||
sublabels?: string[];
|
||||
icons?: React.ReactNode[];
|
||||
};
|
||||
|
||||
export function ChartLegends({
|
||||
icons,
|
||||
values,
|
||||
sublabels,
|
||||
labels = [],
|
||||
colors = [],
|
||||
...other
|
||||
}: Props) {
|
||||
return (
|
||||
<Box gap={2} display="flex" flexWrap="wrap" {...other}>
|
||||
{labels?.map((series, index) => (
|
||||
<Stack key={series} spacing={1}>
|
||||
<StyledLegend>
|
||||
{icons?.length ? (
|
||||
<Box
|
||||
component="span"
|
||||
sx={{ color: colors[index], '& svg, & img': { width: 20, height: 20 } }}
|
||||
>
|
||||
{icons?.[index]}
|
||||
</Box>
|
||||
) : (
|
||||
<StyledDot sx={{ color: colors[index] }} />
|
||||
)}
|
||||
|
||||
<Box component="span" sx={{ flexShrink: 0 }}>
|
||||
{series}
|
||||
{sublabels && <> {` (${sublabels[index]})`}</>}
|
||||
</Box>
|
||||
</StyledLegend>
|
||||
|
||||
{values && <Box sx={{ typography: 'h6' }}>{values[index]}</Box>}
|
||||
</Stack>
|
||||
))}
|
||||
</Box>
|
||||
);
|
||||
}
|
||||
40
web/src/components/chart/chart.tsx
Executable file
|
|
@ -0,0 +1,40 @@
|
|||
import type { BoxProps } from '@mui/material/Box';
|
||||
|
||||
import ApexChart from 'react-apexcharts';
|
||||
|
||||
import Box from '@mui/material/Box';
|
||||
|
||||
import { chartClasses } from './classes';
|
||||
|
||||
import type { ChartProps } from './types';
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
export function Chart({
|
||||
sx,
|
||||
type,
|
||||
series,
|
||||
height,
|
||||
options,
|
||||
className,
|
||||
width = '100%',
|
||||
...other
|
||||
}: BoxProps & ChartProps) {
|
||||
return (
|
||||
<Box
|
||||
dir="ltr"
|
||||
className={chartClasses.root.concat(className ? ` ${className}` : '')}
|
||||
sx={{
|
||||
width,
|
||||
height,
|
||||
flexShrink: 0,
|
||||
borderRadius: 1.5,
|
||||
position: 'relative',
|
||||
...sx,
|
||||
}}
|
||||
{...other}
|
||||
>
|
||||
<ApexChart type={type} series={series} options={options} width="100%" height="100%" />
|
||||
</Box>
|
||||
);
|
||||
}
|
||||
3
web/src/components/chart/classes.ts
Executable file
|
|
@ -0,0 +1,3 @@
|
|||
// ----------------------------------------------------------------------
|
||||
|
||||
export const chartClasses = { root: 'mnl__chart__root' };
|
||||
7
web/src/components/chart/index.ts
Executable file
|
|
@ -0,0 +1,7 @@
|
|||
export * from './chart';
|
||||
|
||||
export * from './use-chart';
|
||||
|
||||
export type * from './types';
|
||||
|
||||
export * from './chart-legends';
|
||||
56
web/src/components/chart/styles.css
Executable file
|
|
@ -0,0 +1,56 @@
|
|||
.apexcharts-canvas {
|
||||
/**
|
||||
* Tooltip
|
||||
*/
|
||||
.apexcharts-tooltip {
|
||||
min-width: 80px;
|
||||
border-radius: 10px;
|
||||
backdrop-filter: blur(6px);
|
||||
color: var(--palette-text-primary);
|
||||
box-shadow: var(--customShadows-dropdown);
|
||||
background-color: rgba(var(--palette-background-defaultChannel) / 0.9);
|
||||
}
|
||||
.apexcharts-xaxistooltip {
|
||||
border-radius: 10px;
|
||||
border-color: transparent;
|
||||
backdrop-filter: blur(6px);
|
||||
color: var(--palette-text-primary);
|
||||
box-shadow: var(--customShadows-dropdown);
|
||||
background-color: rgba(var(--palette-background-defaultChannel) / 0.9);
|
||||
&::before {
|
||||
border-bottom-color: rgba(var(--palette-grey-500Channel) / 0.16);
|
||||
}
|
||||
&::after {
|
||||
border-bottom-color: rgba(var(--palette-background-defaultChannel) / 0.9);
|
||||
}
|
||||
}
|
||||
.apexcharts-tooltip-title {
|
||||
font-weight: 700;
|
||||
text-align: center;
|
||||
color: var(--palette-text-secondary);
|
||||
background-color: var(--palette-background-neutral);
|
||||
}
|
||||
/**
|
||||
* Tooltip: group
|
||||
*/
|
||||
.apexcharts-tooltip-series-group {
|
||||
padding: 4px 12px;
|
||||
}
|
||||
.apexcharts-tooltip-marker {
|
||||
margin-right: 8px;
|
||||
}
|
||||
/**
|
||||
* Legend
|
||||
*/
|
||||
.apexcharts-legend {
|
||||
padding: 0;
|
||||
}
|
||||
.apexcharts-legend-marker {
|
||||
margin-right: 6px;
|
||||
}
|
||||
.apexcharts-legend-text {
|
||||
margin-left: 0;
|
||||
padding-left: 0;
|
||||
line-height: 18px;
|
||||
}
|
||||
}
|
||||
19
web/src/components/chart/types.ts
Executable file
|
|
@ -0,0 +1,19 @@
|
|||
import type { Props } from 'react-apexcharts';
|
||||
import type { Theme, SxProps } from '@mui/material/styles';
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
export type ChartProps = {
|
||||
type: Props['type'];
|
||||
series: Props['series'];
|
||||
options: Props['options'];
|
||||
};
|
||||
|
||||
export type ChartBaseProps = Props;
|
||||
|
||||
export type ChartOptions = Props['options'];
|
||||
|
||||
export type ChartLoadingProps = {
|
||||
disabled?: boolean;
|
||||
sx?: SxProps<Theme>;
|
||||
};
|
||||
327
web/src/components/chart/use-chart.ts
Executable file
|
|
@ -0,0 +1,327 @@
|
|||
import { useTheme } from '@mui/material/styles';
|
||||
|
||||
import { varAlpha } from 'src/theme/styles';
|
||||
|
||||
import type { ChartOptions } from './types';
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
export function useChart(options?: ChartOptions): ChartOptions {
|
||||
const theme = useTheme();
|
||||
|
||||
const LABEL_TOTAL = {
|
||||
show: true,
|
||||
label: 'Total',
|
||||
color: theme.vars.palette.text.secondary,
|
||||
fontSize: theme.typography.subtitle2.fontSize as string,
|
||||
fontWeight: theme.typography.subtitle2.fontWeight,
|
||||
};
|
||||
|
||||
const LABEL_VALUE = {
|
||||
offsetY: 8,
|
||||
color: theme.vars.palette.text.primary,
|
||||
fontSize: theme.typography.h4.fontSize as string,
|
||||
fontWeight: theme.typography.h4.fontWeight,
|
||||
};
|
||||
|
||||
const RESPONSIVE = [
|
||||
{
|
||||
breakpoint: theme.breakpoints.values.sm, // sm ~ 600
|
||||
options: {
|
||||
plotOptions: {
|
||||
bar: {
|
||||
borderRadius: 3,
|
||||
columnWidth: '80%',
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
breakpoint: theme.breakpoints.values.md, // md ~ 900
|
||||
options: {
|
||||
plotOptions: {
|
||||
bar: {
|
||||
columnWidth: '60%',
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
...(options?.responsive ?? []),
|
||||
];
|
||||
|
||||
return {
|
||||
...options,
|
||||
|
||||
/** **************************************
|
||||
* Chart
|
||||
*************************************** */
|
||||
chart: {
|
||||
toolbar: {
|
||||
show: false,
|
||||
},
|
||||
zoom: {
|
||||
enabled: false,
|
||||
},
|
||||
parentHeightOffset: 0,
|
||||
fontFamily: theme.typography.fontFamily,
|
||||
foreColor: theme.vars.palette.text.disabled,
|
||||
...options?.chart,
|
||||
animations: {
|
||||
enabled: true,
|
||||
speed: 360,
|
||||
animateGradually: { enabled: true, delay: 120 },
|
||||
dynamicAnimation: { enabled: true, speed: 360 },
|
||||
...options?.chart?.animations,
|
||||
},
|
||||
},
|
||||
|
||||
/** **************************************
|
||||
* Colors
|
||||
*************************************** */
|
||||
colors: options?.colors ?? [
|
||||
theme.palette.primary.main,
|
||||
theme.palette.warning.main,
|
||||
theme.palette.info.main,
|
||||
theme.palette.error.main,
|
||||
theme.palette.success.main,
|
||||
theme.palette.warning.dark,
|
||||
theme.palette.success.darker,
|
||||
theme.palette.info.dark,
|
||||
theme.palette.info.darker,
|
||||
],
|
||||
|
||||
/** **************************************
|
||||
* States
|
||||
*************************************** */
|
||||
states: {
|
||||
...options?.states,
|
||||
hover: {
|
||||
...options?.states?.hover,
|
||||
filter: { type: 'darken', ...options?.states?.hover?.filter },
|
||||
},
|
||||
active: {
|
||||
...options?.states?.active,
|
||||
filter: { type: 'darken', ...options?.states?.active?.filter },
|
||||
},
|
||||
},
|
||||
|
||||
/** **************************************
|
||||
* Fill
|
||||
*************************************** */
|
||||
fill: {
|
||||
opacity: 1,
|
||||
...options?.fill,
|
||||
gradient: {
|
||||
type: 'vertical',
|
||||
shadeIntensity: 0,
|
||||
opacityFrom: 0.4,
|
||||
opacityTo: 0,
|
||||
stops: [0, 100],
|
||||
...options?.fill?.gradient,
|
||||
},
|
||||
},
|
||||
|
||||
/** **************************************
|
||||
* Data labels
|
||||
*************************************** */
|
||||
dataLabels: {
|
||||
enabled: false,
|
||||
...options?.dataLabels,
|
||||
},
|
||||
|
||||
/** **************************************
|
||||
* Stroke
|
||||
*************************************** */
|
||||
stroke: {
|
||||
width: 2.5,
|
||||
curve: 'smooth',
|
||||
lineCap: 'round',
|
||||
...options?.stroke,
|
||||
},
|
||||
|
||||
/** **************************************
|
||||
* Grid
|
||||
*************************************** */
|
||||
grid: {
|
||||
strokeDashArray: 3,
|
||||
borderColor: theme.vars.palette.divider,
|
||||
...options?.grid,
|
||||
padding: {
|
||||
top: 0,
|
||||
right: 0,
|
||||
bottom: 0,
|
||||
...options?.grid?.padding,
|
||||
},
|
||||
xaxis: {
|
||||
lines: {
|
||||
show: false,
|
||||
},
|
||||
...options?.grid?.xaxis,
|
||||
},
|
||||
},
|
||||
|
||||
/** **************************************
|
||||
* Axis
|
||||
*************************************** */
|
||||
xaxis: {
|
||||
axisBorder: {
|
||||
show: false,
|
||||
},
|
||||
axisTicks: {
|
||||
show: false,
|
||||
},
|
||||
...options?.xaxis,
|
||||
},
|
||||
yaxis: {
|
||||
tickAmount: 5,
|
||||
...options?.yaxis,
|
||||
},
|
||||
|
||||
/** **************************************
|
||||
* Markers
|
||||
*************************************** */
|
||||
markers: {
|
||||
size: 0,
|
||||
strokeColors: theme.vars.palette.background.paper,
|
||||
...options?.markers,
|
||||
},
|
||||
|
||||
/** **************************************
|
||||
* Tooltip
|
||||
*************************************** */
|
||||
tooltip: {
|
||||
theme: 'false',
|
||||
fillSeriesColor: false,
|
||||
x: {
|
||||
show: true,
|
||||
},
|
||||
...options?.tooltip,
|
||||
},
|
||||
|
||||
/** **************************************
|
||||
* Legend
|
||||
*************************************** */
|
||||
legend: {
|
||||
show: false,
|
||||
position: 'top',
|
||||
fontWeight: 500,
|
||||
fontSize: '13px',
|
||||
horizontalAlign: 'right',
|
||||
...options?.legend,
|
||||
markers: {
|
||||
shape: 'circle',
|
||||
...options?.legend?.markers,
|
||||
},
|
||||
labels: {
|
||||
colors: theme.vars.palette.text.primary,
|
||||
...options?.legend?.labels,
|
||||
},
|
||||
itemMargin: {
|
||||
horizontal: 8,
|
||||
vertical: 8,
|
||||
...options?.legend?.itemMargin,
|
||||
},
|
||||
},
|
||||
|
||||
/** **************************************
|
||||
* plotOptions
|
||||
*************************************** */
|
||||
plotOptions: {
|
||||
...options?.plotOptions,
|
||||
// plotOptions: Bar
|
||||
bar: {
|
||||
borderRadius: 4,
|
||||
columnWidth: '48%',
|
||||
borderRadiusApplication: 'end',
|
||||
...options?.plotOptions?.bar,
|
||||
},
|
||||
|
||||
// plotOptions: Pie + Donut
|
||||
pie: {
|
||||
...options?.plotOptions?.pie,
|
||||
donut: {
|
||||
...options?.plotOptions?.pie?.donut,
|
||||
labels: {
|
||||
show: true,
|
||||
...options?.plotOptions?.pie?.donut?.labels,
|
||||
value: {
|
||||
...LABEL_VALUE,
|
||||
...options?.plotOptions?.pie?.donut?.labels?.value,
|
||||
},
|
||||
total: {
|
||||
...LABEL_TOTAL,
|
||||
...options?.plotOptions?.pie?.donut?.labels?.total,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
// plotOptions: Radialbar
|
||||
radialBar: {
|
||||
...options?.plotOptions?.radialBar,
|
||||
hollow: {
|
||||
margin: -8,
|
||||
size: '100%',
|
||||
...options?.plotOptions?.radialBar?.hollow,
|
||||
},
|
||||
track: {
|
||||
margin: -8,
|
||||
strokeWidth: '50%',
|
||||
background: varAlpha(theme.vars.palette.grey['500Channel'], 0.16),
|
||||
...options?.plotOptions?.radialBar?.track,
|
||||
},
|
||||
dataLabels: {
|
||||
...options?.plotOptions?.radialBar?.dataLabels,
|
||||
value: {
|
||||
...LABEL_VALUE,
|
||||
...options?.plotOptions?.radialBar?.dataLabels?.value,
|
||||
},
|
||||
total: {
|
||||
...LABEL_TOTAL,
|
||||
...options?.plotOptions?.radialBar?.dataLabels?.total,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
// plotOptions: Radar
|
||||
radar: {
|
||||
...options?.plotOptions?.radar,
|
||||
polygons: {
|
||||
fill: {
|
||||
colors: ['transparent'],
|
||||
},
|
||||
strokeColors: theme.vars.palette.divider,
|
||||
connectorColors: theme.vars.palette.divider,
|
||||
...options?.plotOptions?.radar?.polygons,
|
||||
},
|
||||
},
|
||||
|
||||
// plotOptions: polarArea
|
||||
polarArea: {
|
||||
rings: {
|
||||
strokeColor: theme.vars.palette.divider,
|
||||
},
|
||||
spokes: {
|
||||
connectorColors: theme.vars.palette.divider,
|
||||
},
|
||||
...options?.plotOptions?.polarArea,
|
||||
},
|
||||
|
||||
// plotOptions: heatmap
|
||||
heatmap: {
|
||||
distributed: true,
|
||||
...options?.plotOptions?.heatmap,
|
||||
},
|
||||
},
|
||||
|
||||
/** **************************************
|
||||
* Responsive
|
||||
*************************************** */
|
||||
responsive: RESPONSIVE.reduce((acc: typeof RESPONSIVE, cur) => {
|
||||
if (!acc.some((item) => item.breakpoint === cur.breakpoint)) {
|
||||
acc.push(cur);
|
||||
}
|
||||
return acc;
|
||||
}, []),
|
||||
};
|
||||
}
|
||||
107
web/src/components/color-utils/color-picker.tsx
Executable file
|
|
@ -0,0 +1,107 @@
|
|||
import type { BoxProps } from '@mui/material/Box';
|
||||
|
||||
import { forwardRef, useCallback } from 'react';
|
||||
|
||||
import Box from '@mui/material/Box';
|
||||
import Stack from '@mui/material/Stack';
|
||||
import ButtonBase from '@mui/material/ButtonBase';
|
||||
import { alpha as hexAlpha } from '@mui/material/styles';
|
||||
|
||||
import { varAlpha } from 'src/theme/styles';
|
||||
|
||||
import { Iconify } from '../iconify';
|
||||
|
||||
import type { ColorPickerProps } from './types';
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
export const ColorPicker = forwardRef<HTMLDivElement, BoxProps & ColorPickerProps>(
|
||||
({ colors, selected, onSelectColor, limit = 'auto', sx, slotProps, ...other }, ref) => {
|
||||
const singleSelect = typeof selected === 'string';
|
||||
|
||||
const handleSelect = useCallback(
|
||||
(color: string) => {
|
||||
if (singleSelect) {
|
||||
if (color !== selected) {
|
||||
onSelectColor(color);
|
||||
}
|
||||
} else {
|
||||
const newSelected = selected.includes(color)
|
||||
? selected.filter((value) => value !== color)
|
||||
: [...selected, color];
|
||||
|
||||
onSelectColor(newSelected);
|
||||
}
|
||||
},
|
||||
[onSelectColor, selected, singleSelect]
|
||||
);
|
||||
|
||||
return (
|
||||
<Box
|
||||
ref={ref}
|
||||
component="ul"
|
||||
sx={{
|
||||
flexWrap: 'wrap',
|
||||
flexDirection: 'row',
|
||||
display: 'inline-flex',
|
||||
...(limit !== 'auto' && {
|
||||
width: limit * 36,
|
||||
justifyContent: 'flex-end',
|
||||
}),
|
||||
...sx,
|
||||
}}
|
||||
{...other}
|
||||
>
|
||||
{colors.map((color) => {
|
||||
const hasSelected = singleSelect ? selected === color : selected.includes(color);
|
||||
|
||||
return (
|
||||
<Box component="li" key={color} sx={{ display: 'inline-flex' }}>
|
||||
<ButtonBase
|
||||
aria-label={color}
|
||||
onClick={() => handleSelect(color)}
|
||||
sx={{
|
||||
width: 36,
|
||||
height: 36,
|
||||
borderRadius: '50%',
|
||||
...slotProps?.button,
|
||||
}}
|
||||
>
|
||||
<Stack
|
||||
alignItems="center"
|
||||
justifyContent="center"
|
||||
sx={(theme) => ({
|
||||
width: 20,
|
||||
height: 20,
|
||||
bgcolor: color,
|
||||
borderRadius: '50%',
|
||||
border: `solid 1px ${varAlpha(theme.vars.palette.grey['500Channel'], 0.16)}`,
|
||||
...(hasSelected && {
|
||||
transform: 'scale(1.3)',
|
||||
boxShadow: `4px 4px 8px 0 ${hexAlpha(color, 0.48)}`,
|
||||
outline: `solid 2px ${hexAlpha(color, 0.08)}`,
|
||||
transition: theme.transitions.create('all', {
|
||||
duration: theme.transitions.duration.shortest,
|
||||
}),
|
||||
}),
|
||||
})}
|
||||
>
|
||||
<Iconify
|
||||
width={hasSelected ? 12 : 0}
|
||||
icon="eva:checkmark-fill"
|
||||
sx={(theme) => ({
|
||||
color: theme.palette.getContrastText(color),
|
||||
transition: theme.transitions.create('all', {
|
||||
duration: theme.transitions.duration.shortest,
|
||||
}),
|
||||
})}
|
||||
/>
|
||||
</Stack>
|
||||
</ButtonBase>
|
||||
</Box>
|
||||
);
|
||||
})}
|
||||
</Box>
|
||||
);
|
||||
}
|
||||
);
|
||||
53
web/src/components/color-utils/color-preview.tsx
Executable file
|
|
@ -0,0 +1,53 @@
|
|||
import type { BoxProps } from '@mui/material/Box';
|
||||
|
||||
import { forwardRef } from 'react';
|
||||
|
||||
import Box from '@mui/material/Box';
|
||||
|
||||
import { varAlpha } from 'src/theme/styles';
|
||||
|
||||
import type { ColorPreviewProps } from './types';
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
export const ColorPreview = forwardRef<HTMLDivElement, BoxProps & ColorPreviewProps>(
|
||||
({ colors, limit = 3, sx, ...other }, ref) => {
|
||||
const colorsRange = colors.slice(0, limit);
|
||||
|
||||
const restColors = colors.length - limit;
|
||||
|
||||
return (
|
||||
<Box
|
||||
ref={ref}
|
||||
sx={{
|
||||
display: 'flex',
|
||||
flexDirection: 'row',
|
||||
alignItems: 'center',
|
||||
justifyContent: 'flex-end',
|
||||
...sx,
|
||||
}}
|
||||
{...other}
|
||||
>
|
||||
{colorsRange.map((color, index) => (
|
||||
<Box
|
||||
key={color + index}
|
||||
sx={{
|
||||
ml: -0.75,
|
||||
width: 16,
|
||||
height: 16,
|
||||
bgcolor: color,
|
||||
borderRadius: '50%',
|
||||
border: (theme) => `solid 2px ${theme.vars.palette.background.paper}`,
|
||||
boxShadow: (theme) =>
|
||||
`inset -1px 1px 2px ${varAlpha(theme.vars.palette.common.blackChannel, 0.24)}`,
|
||||
}}
|
||||
/>
|
||||
))}
|
||||
|
||||
{colors.length > limit && (
|
||||
<Box component="span" sx={{ typography: 'subtitle2' }}>{`+${restColors}`}</Box>
|
||||
)}
|
||||
</Box>
|
||||
);
|
||||
}
|
||||
);
|
||||
5
web/src/components/color-utils/index.ts
Executable file
|
|
@ -0,0 +1,5 @@
|
|||
export type * from './types';
|
||||
|
||||
export * from './color-picker';
|
||||
|
||||
export * from './color-preview';
|
||||
19
web/src/components/color-utils/types.ts
Executable file
|
|
@ -0,0 +1,19 @@
|
|||
import type { Theme, SxProps } from '@mui/material/styles';
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
export type ColorPickerProps = {
|
||||
multi?: boolean;
|
||||
colors: string[];
|
||||
selected: string | string[];
|
||||
limit?: 'auto' | number;
|
||||
onSelectColor: (color: string | string[]) => void;
|
||||
slotProps?: {
|
||||
button?: SxProps<Theme>;
|
||||
};
|
||||
};
|
||||
|
||||
export type ColorPreviewProps = {
|
||||
limit?: number;
|
||||
colors: ColorPickerProps['colors'];
|
||||
};
|
||||
4
web/src/components/iconify/classes.ts
Executable file
|
|
@ -0,0 +1,4 @@
|
|||
export const iconifyClasses = {
|
||||
root: 'mnl__icon__root',
|
||||
flag: 'mnl__icon__flag',
|
||||
};
|
||||
57
web/src/components/iconify/flag-icon.tsx
Executable file
|
|
@ -0,0 +1,57 @@
|
|||
import type { BoxProps } from '@mui/material/Box';
|
||||
import type { Theme, SxProps } from '@mui/material/styles';
|
||||
|
||||
import { forwardRef } from 'react';
|
||||
|
||||
import Box from '@mui/material/Box';
|
||||
|
||||
import { iconifyClasses } from './classes';
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
export type FlagIconProps = BoxProps & {
|
||||
code?: string;
|
||||
};
|
||||
|
||||
export const FlagIcon = forwardRef<HTMLSpanElement, FlagIconProps>(
|
||||
({ code, className, sx, ...other }, ref) => {
|
||||
const baseStyles: SxProps<Theme> = {
|
||||
width: 26,
|
||||
height: 20,
|
||||
flexShrink: 0,
|
||||
overflow: 'hidden',
|
||||
borderRadius: '5px',
|
||||
alignItems: 'center',
|
||||
display: 'inline-flex',
|
||||
justifyContent: 'center',
|
||||
bgcolor: 'background.neutral',
|
||||
};
|
||||
|
||||
if (!code) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (
|
||||
<Box
|
||||
ref={ref}
|
||||
component="span"
|
||||
className={iconifyClasses.flag.concat(className ? ` ${className}` : '')}
|
||||
sx={{ ...baseStyles, ...sx }}
|
||||
{...other}
|
||||
>
|
||||
<Box
|
||||
component="img"
|
||||
loading="lazy"
|
||||
alt={code}
|
||||
src={`https://purecatamphetamine.github.io/country-flag-icons/3x2/${code?.toUpperCase()}.svg`}
|
||||
sx={{
|
||||
width: 1,
|
||||
height: 1,
|
||||
maxWidth: 'unset',
|
||||
objectFit: 'cover',
|
||||
}}
|
||||
/>
|
||||
</Box>
|
||||
);
|
||||
}
|
||||
);
|
||||