feat: 实现官网与设备用户界面
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
node_modules
|
||||
dist
|
||||
.git
|
||||
.env
|
||||
.env.*
|
||||
@@ -0,0 +1,11 @@
|
||||
/// <reference types="vite/client" />
|
||||
|
||||
export {}
|
||||
|
||||
declare module 'vue-router' {
|
||||
interface RouteMeta {
|
||||
title?: string
|
||||
auth?: boolean
|
||||
admin?: boolean
|
||||
}
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
<!doctype html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<meta name="description" content="TapRemly 让互相信任的手机和电脑互相发送文字和命令。" />
|
||||
<title>TapRemly</title>
|
||||
</head>
|
||||
<body>
|
||||
<div id="app"></div>
|
||||
<script type="module" src="/src/main.ts"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,25 @@
|
||||
{
|
||||
"name": "tapremly-web",
|
||||
"private": true,
|
||||
"version": "0.1.0",
|
||||
"type": "module",
|
||||
"packageManager": "pnpm@12.11.2",
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
"build": "vite build",
|
||||
"typecheck": "vue-tsc --noEmit"
|
||||
},
|
||||
"dependencies": {
|
||||
"@vicons/ionicons5": "^0.13.0",
|
||||
"naive-ui": "^2.45.3",
|
||||
"pinia": "^4.0.3",
|
||||
"vue": "^3.5.43",
|
||||
"vue-router": "^4.6.4"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@vitejs/plugin-vue": "^6.0.10",
|
||||
"typescript": "5.9.3",
|
||||
"vite": "^8.3.4",
|
||||
"vue-tsc": "^3.3.13"
|
||||
}
|
||||
}
|
||||
Generated
+1120
File diff suppressed because it is too large
Load Diff
+25
@@ -0,0 +1,25 @@
|
||||
<script setup lang="ts">
|
||||
import { dateZhCN, NConfigProvider, NDialogProvider, NMessageProvider, zhCN, type GlobalThemeOverrides } from 'naive-ui'
|
||||
import TopBar from './components/TopBar.vue'
|
||||
|
||||
const overrides: GlobalThemeOverrides = {
|
||||
common: {
|
||||
primaryColor: '#0F766E',
|
||||
primaryColorHover: '#0D9488',
|
||||
primaryColorPressed: '#115E59',
|
||||
primaryColorSuppl: '#14B8A6',
|
||||
borderRadius: '8px',
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<n-config-provider :locale="zhCN" :date-locale="dateZhCN" :theme-overrides="overrides">
|
||||
<n-dialog-provider>
|
||||
<n-message-provider>
|
||||
<TopBar />
|
||||
<router-view />
|
||||
</n-message-provider>
|
||||
</n-dialog-provider>
|
||||
</n-config-provider>
|
||||
</template>
|
||||
+102
@@ -0,0 +1,102 @@
|
||||
export class ApiError extends Error {
|
||||
status: number
|
||||
|
||||
constructor(message: string, status: number) {
|
||||
super(message)
|
||||
this.status = status
|
||||
}
|
||||
}
|
||||
|
||||
export type Me = {
|
||||
id: number
|
||||
username: string
|
||||
role: 'admin' | 'user'
|
||||
enabled: boolean
|
||||
}
|
||||
|
||||
export type Presence = 'online' | 'offline' | 'unknown'
|
||||
|
||||
export type Device = {
|
||||
id: number
|
||||
name: string
|
||||
endpoint_id: string
|
||||
group_id: number | null
|
||||
presence: Presence
|
||||
login_password?: string
|
||||
}
|
||||
|
||||
export type Group = { id: number; name: string }
|
||||
|
||||
export type LogItem = {
|
||||
at_ms: number
|
||||
summary: string
|
||||
ok: boolean
|
||||
result: string
|
||||
}
|
||||
|
||||
export type Account = {
|
||||
id: number
|
||||
username: string
|
||||
role: 'admin' | 'user'
|
||||
enabled: boolean
|
||||
}
|
||||
|
||||
type Envelope<T> = {
|
||||
ok: boolean
|
||||
data?: T
|
||||
error?: { message?: string }
|
||||
}
|
||||
|
||||
async function request<T>(method: string, path: string, body?: unknown): Promise<T> {
|
||||
const headers: Record<string, string> = {}
|
||||
if (body !== undefined) headers['Content-Type'] = 'application/json'
|
||||
if (method !== 'GET' && method !== 'HEAD') headers['X-Tapremly-Request'] = '1'
|
||||
const response = await fetch(path, {
|
||||
method,
|
||||
headers,
|
||||
credentials: 'include',
|
||||
body: body === undefined ? undefined : JSON.stringify(body),
|
||||
})
|
||||
const payload = (await response.json().catch(() => null)) as Envelope<T> | null
|
||||
if (!response.ok || !payload?.ok || payload.data === undefined) {
|
||||
throw new ApiError(payload?.error?.message || '操作没有完成', response.status)
|
||||
}
|
||||
return payload.data
|
||||
}
|
||||
|
||||
export const api = {
|
||||
me: () => request<Me>('GET', '/api/me'),
|
||||
login: (username: string, password: string) =>
|
||||
request<Me>('POST', '/api/login', { username, password }),
|
||||
register: (username: string, password: string) =>
|
||||
request<Me>('POST', '/api/register', { username, password }),
|
||||
logout: () => request<Record<string, never>>('POST', '/api/logout', {}),
|
||||
devices: () => request<{ devices: Device[]; groups: Group[] }>('GET', '/api/devices'),
|
||||
createDevice: (body: { name: string; endpoint_id?: string; group_id?: number | null }) =>
|
||||
request<Device>('POST', '/api/devices', body),
|
||||
updateDevice: (id: number, body: { name?: string; group_id?: number | null }) =>
|
||||
request<Device>('PATCH', `/api/devices/${id}`, body),
|
||||
deleteDevice: (id: number) => request<Record<string, never>>('DELETE', `/api/devices/${id}`),
|
||||
logs: (id: number) => request<{ items: LogItem[] }>('GET', `/api/devices/${id}/command-logs`),
|
||||
createGroup: (name: string) => request<Group>('POST', '/api/groups', { name }),
|
||||
renameGroup: (id: number, name: string) => request<Group>('PATCH', `/api/groups/${id}`, { name }),
|
||||
deleteGroup: (id: number) => request<Record<string, never>>('DELETE', `/api/groups/${id}`),
|
||||
users: () => request<{ items: Account[] }>('GET', '/api/admin/users'),
|
||||
setEnabled: (id: number, enabled: boolean) =>
|
||||
request<Account>('POST', `/api/admin/users/${id}/status`, { enabled }),
|
||||
}
|
||||
|
||||
export function errorText(err: unknown) {
|
||||
if (err instanceof ApiError) return err.message
|
||||
return '操作没有完成'
|
||||
}
|
||||
|
||||
export function presenceText(presence: Presence) {
|
||||
if (presence === 'online') return '在线'
|
||||
if (presence === 'offline') return '不在线'
|
||||
return '未知'
|
||||
}
|
||||
|
||||
export function formatTime(ms: number) {
|
||||
return new Date(ms).toLocaleString('zh-CN', { hour12: false })
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
<script setup lang="ts">
|
||||
import { HelpCircleOutline } from '@vicons/ionicons5'
|
||||
import { NIcon, NTooltip } from 'naive-ui'
|
||||
|
||||
defineProps<{ text: string }>()
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<n-tooltip trigger="hover">
|
||||
<template #trigger>
|
||||
<n-icon class="help-icon" :size="16"><HelpCircleOutline /></n-icon>
|
||||
</template>
|
||||
{{ text }}
|
||||
</n-tooltip>
|
||||
</template>
|
||||
@@ -0,0 +1,36 @@
|
||||
<script setup lang="ts">
|
||||
import { NButton, NSpace } from 'naive-ui'
|
||||
import { storeToRefs } from 'pinia'
|
||||
import { useRouter } from 'vue-router'
|
||||
import { useSession } from '../stores/session'
|
||||
|
||||
const router = useRouter()
|
||||
const session = useSession()
|
||||
const { me } = storeToRefs(session)
|
||||
|
||||
async function logout() {
|
||||
await session.logout()
|
||||
await router.push('/')
|
||||
}
|
||||
|
||||
function go(path: string) {
|
||||
void router.push(path)
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<header class="topbar">
|
||||
<a class="brand" href="/" @click.prevent="go('/')">TapRemly</a>
|
||||
<n-space :size="8" align="center">
|
||||
<template v-if="me">
|
||||
<n-button quaternary @click="go('/app')">设备</n-button>
|
||||
<n-button v-if="me.role === 'admin'" quaternary @click="go('/admin')">用户</n-button>
|
||||
<n-button quaternary @click="logout">退出</n-button>
|
||||
</template>
|
||||
<template v-else>
|
||||
<n-button quaternary @click="go('/login')">登录</n-button>
|
||||
<n-button type="primary" @click="go('/register')">注册</n-button>
|
||||
</template>
|
||||
</n-space>
|
||||
</header>
|
||||
</template>
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
import { createPinia } from 'pinia'
|
||||
import { createApp } from 'vue'
|
||||
import App from './App.vue'
|
||||
import router from './router'
|
||||
import './styles.css'
|
||||
|
||||
const app = createApp(App)
|
||||
app.use(createPinia())
|
||||
app.use(router)
|
||||
app.mount('#app')
|
||||
@@ -0,0 +1,36 @@
|
||||
import { createRouter, createWebHistory } from 'vue-router'
|
||||
import { useSession } from './stores/session'
|
||||
import DevicesView from './views/DevicesView.vue'
|
||||
import DownloadView from './views/DownloadView.vue'
|
||||
import HomeView from './views/HomeView.vue'
|
||||
import LoginView from './views/LoginView.vue'
|
||||
import RegisterView from './views/RegisterView.vue'
|
||||
import UsersView from './views/UsersView.vue'
|
||||
|
||||
const router = createRouter({
|
||||
history: createWebHistory(),
|
||||
routes: [
|
||||
{ path: '/', component: HomeView, meta: { title: 'TapRemly' } },
|
||||
{ path: '/download', component: DownloadView, meta: { title: '下载客户端' } },
|
||||
{ path: '/login', component: LoginView, meta: { title: '登录' } },
|
||||
{ path: '/register', component: RegisterView, meta: { title: '注册' } },
|
||||
{ path: '/app', component: DevicesView, meta: { title: '设备', auth: true } },
|
||||
{ path: '/admin', component: UsersView, meta: { title: '用户', auth: true, admin: true } },
|
||||
{ path: '/:pathMatch(.*)*', redirect: '/' },
|
||||
],
|
||||
})
|
||||
|
||||
router.beforeEach(async (to) => {
|
||||
const session = useSession()
|
||||
if (!session.ready) await session.refresh()
|
||||
if ((to.path === '/login' || to.path === '/register') && session.me) return '/app'
|
||||
if (to.meta.auth && !session.me) return { path: '/login', query: { next: to.fullPath } }
|
||||
if (to.meta.admin && session.me?.role !== 'admin') return '/app'
|
||||
return true
|
||||
})
|
||||
|
||||
router.afterEach((to) => {
|
||||
document.title = to.meta.title || 'TapRemly'
|
||||
})
|
||||
|
||||
export default router
|
||||
@@ -0,0 +1,25 @@
|
||||
import { defineStore } from 'pinia'
|
||||
import { ref } from 'vue'
|
||||
import { api, type Me } from '../api'
|
||||
|
||||
export const useSession = defineStore('session', () => {
|
||||
const me = ref<Me | null>(null)
|
||||
const ready = ref(false)
|
||||
|
||||
async function refresh() {
|
||||
try {
|
||||
me.value = await api.me()
|
||||
} catch {
|
||||
me.value = null
|
||||
} finally {
|
||||
ready.value = true
|
||||
}
|
||||
}
|
||||
|
||||
async function logout() {
|
||||
await api.logout()
|
||||
me.value = null
|
||||
}
|
||||
|
||||
return { me, ready, refresh, logout }
|
||||
})
|
||||
+199
@@ -0,0 +1,199 @@
|
||||
:root {
|
||||
--top: 56px;
|
||||
--bg: #f4f7f7;
|
||||
--ink: #1c2430;
|
||||
--muted: #667085;
|
||||
--line: #e5ebec;
|
||||
}
|
||||
|
||||
* { box-sizing: border-box; }
|
||||
|
||||
html, body, #app { margin: 0; min-height: 100%; }
|
||||
|
||||
body {
|
||||
font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
|
||||
background: var(--bg);
|
||||
color: var(--ink);
|
||||
}
|
||||
|
||||
a { color: inherit; }
|
||||
|
||||
.topbar {
|
||||
position: sticky;
|
||||
top: 0;
|
||||
z-index: 30;
|
||||
height: var(--top);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 16px;
|
||||
padding: 0 20px;
|
||||
background: #fff;
|
||||
border-bottom: 1px solid var(--line);
|
||||
}
|
||||
|
||||
.brand {
|
||||
font-weight: 680;
|
||||
font-size: 18px;
|
||||
text-decoration: none;
|
||||
color: #0f766e;
|
||||
}
|
||||
|
||||
.page {
|
||||
max-width: 980px;
|
||||
margin: 0 auto;
|
||||
padding: 0 20px 56px;
|
||||
}
|
||||
|
||||
.page-head {
|
||||
position: sticky;
|
||||
top: var(--top);
|
||||
z-index: 20;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 12px;
|
||||
padding: 16px 0 12px;
|
||||
background: var(--bg);
|
||||
}
|
||||
|
||||
.page-head h1 {
|
||||
margin: 0;
|
||||
font-size: 20px;
|
||||
font-weight: 680;
|
||||
}
|
||||
|
||||
.hero { padding: 52px 0 12px; }
|
||||
|
||||
.hero h1 {
|
||||
margin: 0 0 12px;
|
||||
font-size: 36px;
|
||||
line-height: 1.25;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.lead {
|
||||
margin: 0 0 22px;
|
||||
max-width: 680px;
|
||||
color: #3d4754;
|
||||
font-size: 16px;
|
||||
line-height: 1.75;
|
||||
}
|
||||
|
||||
.grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(3, minmax(0, 1fr));
|
||||
gap: 12px;
|
||||
margin-top: 28px;
|
||||
}
|
||||
|
||||
.narrow { max-width: 440px; margin: 40px auto; }
|
||||
|
||||
.group {
|
||||
background: #fff;
|
||||
border: 1px solid var(--line);
|
||||
border-radius: 10px;
|
||||
margin-bottom: 12px;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.group-head, .device-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.group-head {
|
||||
justify-content: space-between;
|
||||
padding: 10px 12px;
|
||||
background: #fbfcfc;
|
||||
border-bottom: 1px solid var(--line);
|
||||
}
|
||||
|
||||
.group-title { font-weight: 650; }
|
||||
|
||||
.device-row {
|
||||
width: 100%;
|
||||
padding: 10px 12px;
|
||||
border: 0;
|
||||
background: #fff;
|
||||
text-align: left;
|
||||
cursor: pointer;
|
||||
font: inherit;
|
||||
color: inherit;
|
||||
}
|
||||
|
||||
.device-row + .device-row { border-top: 1px solid var(--line); }
|
||||
|
||||
.device-row:hover { background: #f4fbfa; }
|
||||
|
||||
.device-main {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.device-name { font-weight: 620; }
|
||||
|
||||
.device-id {
|
||||
margin-top: 2px;
|
||||
color: var(--muted);
|
||||
font-size: 12px;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.empty {
|
||||
padding: 28px 12px;
|
||||
color: var(--muted);
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.help-icon {
|
||||
margin-left: 4px;
|
||||
color: #98a2b3;
|
||||
vertical-align: -3px;
|
||||
cursor: help;
|
||||
}
|
||||
|
||||
.log-list {
|
||||
max-height: min(420px, calc(100vh - 280px));
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
.log-item {
|
||||
padding: 10px 0;
|
||||
border-bottom: 1px solid var(--line);
|
||||
}
|
||||
|
||||
.log-item:last-child { border-bottom: 0; }
|
||||
|
||||
.log-meta {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
gap: 8px;
|
||||
color: var(--muted);
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.mono {
|
||||
font-family: ui-monospace, Consolas, "Sarasa Mono SC", monospace;
|
||||
word-break: break-all;
|
||||
}
|
||||
|
||||
.section-title {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
margin: 28px 0 10px;
|
||||
font-size: 18px;
|
||||
}
|
||||
|
||||
@media (max-width: 720px) {
|
||||
.grid { grid-template-columns: 1fr; }
|
||||
.hero h1 { font-size: 28px; }
|
||||
.page-head { align-items: flex-start; flex-wrap: wrap; }
|
||||
.topbar { padding: 0 12px; }
|
||||
.page { padding: 0 12px 40px; }
|
||||
}
|
||||
@@ -0,0 +1,468 @@
|
||||
<script setup lang="ts">
|
||||
import {
|
||||
NAlert,
|
||||
NButton,
|
||||
NCard,
|
||||
NDrawer,
|
||||
NDrawerContent,
|
||||
NDropdown,
|
||||
NForm,
|
||||
NFormItem,
|
||||
NInput,
|
||||
NModal,
|
||||
NSelect,
|
||||
NSpace,
|
||||
NSpin,
|
||||
NTag,
|
||||
useDialog,
|
||||
useMessage,
|
||||
} from 'naive-ui'
|
||||
import { computed, onMounted, ref } from 'vue'
|
||||
import HelpTip from '../components/HelpTip.vue'
|
||||
import { api, errorText, formatTime, presenceText, type Device, type Group, type LogItem } from '../api'
|
||||
|
||||
const dialog = useDialog()
|
||||
const message = useMessage()
|
||||
const loading = ref(true)
|
||||
const loadError = ref('')
|
||||
const devices = ref<Device[]>([])
|
||||
const groups = ref<Group[]>([])
|
||||
const keyword = ref('')
|
||||
|
||||
const showAdd = ref(false)
|
||||
const addName = ref('')
|
||||
const addEndpoint = ref('')
|
||||
const addGroup = ref<number | null>(null)
|
||||
const adding = ref(false)
|
||||
|
||||
const showGroup = ref(false)
|
||||
const groupName = ref('')
|
||||
const groupTarget = ref<number | null>(null)
|
||||
const savingGroup = ref(false)
|
||||
|
||||
const secretShow = ref(false)
|
||||
const secretId = ref('')
|
||||
const secretPassword = ref('')
|
||||
|
||||
const drawer = ref(false)
|
||||
const current = ref<Device | null>(null)
|
||||
const nameDraft = ref('')
|
||||
const logs = ref<LogItem[]>([])
|
||||
const logsLoading = ref(false)
|
||||
const savingName = ref(false)
|
||||
|
||||
const searching = computed(() => keyword.value.trim() !== '')
|
||||
|
||||
const visibleDevices = computed(() => {
|
||||
const q = keyword.value.trim().toLowerCase()
|
||||
if (!q) return devices.value
|
||||
return devices.value.filter(
|
||||
(item) => item.name.toLowerCase().includes(q) || item.endpoint_id.toLowerCase().includes(q),
|
||||
)
|
||||
})
|
||||
|
||||
const ungrouped = computed(() => visibleDevices.value.filter((item) => item.group_id == null))
|
||||
|
||||
const sections = computed(() =>
|
||||
groups.value
|
||||
.map((group) => ({
|
||||
...group,
|
||||
devices: visibleDevices.value.filter((item) => item.group_id === group.id),
|
||||
}))
|
||||
.filter((group) => !searching.value || group.devices.length > 0),
|
||||
)
|
||||
|
||||
const groupChoices = computed(() => [
|
||||
{ label: '未分组', value: 0 },
|
||||
...groups.value.map((group) => ({ label: group.name, value: group.id })),
|
||||
])
|
||||
|
||||
const emptyAll = computed(() => devices.value.length === 0 && groups.value.length === 0 && !searching.value)
|
||||
|
||||
async function load() {
|
||||
const data = await api.devices()
|
||||
devices.value = data.devices
|
||||
groups.value = data.groups
|
||||
if (current.value) {
|
||||
current.value = devices.value.find((item) => item.id === current.value?.id) ?? null
|
||||
if (current.value) nameDraft.value = current.value.name
|
||||
else drawer.value = false
|
||||
}
|
||||
}
|
||||
|
||||
async function reload() {
|
||||
loading.value = true
|
||||
loadError.value = ''
|
||||
try {
|
||||
await load()
|
||||
} catch (err) {
|
||||
loadError.value = errorText(err)
|
||||
message.error(loadError.value)
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
function openAdd() {
|
||||
addName.value = ''
|
||||
addEndpoint.value = ''
|
||||
addGroup.value = null
|
||||
showAdd.value = true
|
||||
}
|
||||
|
||||
function openCreateGroup() {
|
||||
groupTarget.value = null
|
||||
groupName.value = ''
|
||||
showGroup.value = true
|
||||
}
|
||||
|
||||
function openRename(group: Group) {
|
||||
groupTarget.value = group.id
|
||||
groupName.value = group.name
|
||||
showGroup.value = true
|
||||
}
|
||||
|
||||
async function submitAdd() {
|
||||
adding.value = true
|
||||
try {
|
||||
const created = await api.createDevice({
|
||||
name: addName.value.trim(),
|
||||
endpoint_id: addEndpoint.value.trim() || undefined,
|
||||
group_id: addGroup.value,
|
||||
})
|
||||
showAdd.value = false
|
||||
await load()
|
||||
if (created.login_password) {
|
||||
secretId.value = created.endpoint_id
|
||||
secretPassword.value = created.login_password
|
||||
secretShow.value = true
|
||||
} else {
|
||||
message.success('已加入列表')
|
||||
}
|
||||
} catch (err) {
|
||||
message.error(errorText(err))
|
||||
} finally {
|
||||
adding.value = false
|
||||
}
|
||||
}
|
||||
|
||||
async function submitGroup() {
|
||||
savingGroup.value = true
|
||||
try {
|
||||
if (groupTarget.value == null) await api.createGroup(groupName.value.trim())
|
||||
else await api.renameGroup(groupTarget.value, groupName.value.trim())
|
||||
showGroup.value = false
|
||||
await load()
|
||||
} catch (err) {
|
||||
message.error(errorText(err))
|
||||
} finally {
|
||||
savingGroup.value = false
|
||||
}
|
||||
}
|
||||
|
||||
function removeGroup(group: Group) {
|
||||
dialog.warning({
|
||||
title: '删除分组',
|
||||
content: `删除「${group.name}」后,里面的设备会回到未分组。设备本身不会删除。`,
|
||||
positiveText: '删除',
|
||||
negativeText: '取消',
|
||||
onPositiveClick: async () => {
|
||||
try {
|
||||
await api.deleteGroup(group.id)
|
||||
await load()
|
||||
} catch (err) {
|
||||
message.error(errorText(err))
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
function moveOptions(device: Device) {
|
||||
return [
|
||||
{ label: '未分组', key: 'none', disabled: device.group_id == null },
|
||||
...groups.value.map((group) => ({
|
||||
label: group.name,
|
||||
key: String(group.id),
|
||||
disabled: device.group_id === group.id,
|
||||
})),
|
||||
]
|
||||
}
|
||||
|
||||
async function moveDevice(device: Device, key: string) {
|
||||
try {
|
||||
await api.updateDevice(device.id, { group_id: key === 'none' ? null : Number(key) })
|
||||
await load()
|
||||
} catch (err) {
|
||||
message.error(errorText(err))
|
||||
}
|
||||
}
|
||||
|
||||
async function openDevice(device: Device) {
|
||||
current.value = device
|
||||
nameDraft.value = device.name
|
||||
logs.value = []
|
||||
drawer.value = true
|
||||
logsLoading.value = true
|
||||
try {
|
||||
logs.value = (await api.logs(device.id)).items
|
||||
} catch (err) {
|
||||
message.error(errorText(err))
|
||||
} finally {
|
||||
logsLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
async function saveName() {
|
||||
if (!current.value) return
|
||||
savingName.value = true
|
||||
try {
|
||||
await api.updateDevice(current.value.id, { name: nameDraft.value.trim() })
|
||||
await load()
|
||||
message.success('已保存')
|
||||
} catch (err) {
|
||||
message.error(errorText(err))
|
||||
} finally {
|
||||
savingName.value = false
|
||||
}
|
||||
}
|
||||
|
||||
async function changeGroup(value: number) {
|
||||
if (!current.value) return
|
||||
try {
|
||||
await api.updateDevice(current.value.id, { group_id: value === 0 ? null : value })
|
||||
await load()
|
||||
} catch (err) {
|
||||
message.error(errorText(err))
|
||||
}
|
||||
}
|
||||
|
||||
function removeDevice() {
|
||||
if (!current.value) return
|
||||
const id = current.value.id
|
||||
dialog.warning({
|
||||
title: '从列表移除',
|
||||
content: '只从你的列表里移除,设备本身还在,也不会取消信任。',
|
||||
positiveText: '移除',
|
||||
negativeText: '取消',
|
||||
onPositiveClick: async () => {
|
||||
try {
|
||||
await api.deleteDevice(id)
|
||||
drawer.value = false
|
||||
current.value = null
|
||||
await load()
|
||||
} catch (err) {
|
||||
message.error(errorText(err))
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
async function copyText(text: string) {
|
||||
try {
|
||||
await navigator.clipboard.writeText(text)
|
||||
message.success('已复制')
|
||||
} catch {
|
||||
message.warning('请手动选择并复制')
|
||||
}
|
||||
}
|
||||
|
||||
function closeSecret() {
|
||||
secretShow.value = false
|
||||
secretId.value = ''
|
||||
secretPassword.value = ''
|
||||
}
|
||||
|
||||
function tagType(device: Device) {
|
||||
if (device.presence === 'online') return 'success'
|
||||
if (device.presence === 'unknown') return 'warning'
|
||||
return 'default'
|
||||
}
|
||||
|
||||
onMounted(reload)
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<main class="page">
|
||||
<div class="page-head">
|
||||
<h1>
|
||||
设备
|
||||
<help-tip text="在线状态来自连接服务。网页不能代替设备添加信任,也不能在这里发送命令。" />
|
||||
</h1>
|
||||
<n-space>
|
||||
<n-button @click="openCreateGroup">新建分组</n-button>
|
||||
<n-button type="primary" @click="openAdd">添加设备</n-button>
|
||||
</n-space>
|
||||
</div>
|
||||
<n-input v-model:value="keyword" clearable placeholder="搜索名称或端编号" style="margin-bottom: 12px" />
|
||||
<n-alert v-if="loadError" type="error" style="margin-bottom: 12px">
|
||||
{{ loadError }}
|
||||
<n-button text type="primary" @click="reload">重试</n-button>
|
||||
</n-alert>
|
||||
<n-spin :show="loading">
|
||||
<div v-if="!loading && !loadError && emptyAll" class="group">
|
||||
<div class="empty">
|
||||
还没有设备。
|
||||
<div style="margin-top: 12px">
|
||||
<n-button type="primary" @click="openAdd">添加设备</n-button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div v-else-if="!loading && searching && visibleDevices.length === 0" class="group">
|
||||
<div class="empty">没有匹配的设备</div>
|
||||
</div>
|
||||
<template v-else>
|
||||
<section v-if="!searching || ungrouped.length > 0" class="group">
|
||||
<div class="group-head"><span class="group-title">未分组</span></div>
|
||||
<div v-if="ungrouped.length === 0" class="empty">这里还没有设备</div>
|
||||
<button v-for="device in ungrouped" :key="device.id" class="device-row" type="button" @click="openDevice(device)">
|
||||
<span class="device-main">
|
||||
<span class="device-name">{{ device.name }}</span>
|
||||
<span class="device-id">{{ device.endpoint_id }}</span>
|
||||
</span>
|
||||
<n-tag size="small" :bordered="false" :type="tagType(device)">{{ presenceText(device.presence) }}</n-tag>
|
||||
<span @click.stop>
|
||||
<n-dropdown trigger="click" :options="moveOptions(device)" @select="(key: string) => moveDevice(device, key)">
|
||||
<n-button size="small" quaternary>移动</n-button>
|
||||
</n-dropdown>
|
||||
</span>
|
||||
</button>
|
||||
</section>
|
||||
<section v-for="group in sections" :key="group.id" class="group">
|
||||
<div class="group-head">
|
||||
<span class="group-title">{{ group.name }}</span>
|
||||
<n-space :size="4">
|
||||
<n-button size="small" quaternary @click="openRename(group)">重命名</n-button>
|
||||
<n-button size="small" quaternary type="error" @click="removeGroup(group)">删除</n-button>
|
||||
</n-space>
|
||||
</div>
|
||||
<div v-if="group.devices.length === 0" class="empty">这个分组里还没有设备</div>
|
||||
<button
|
||||
v-for="device in group.devices"
|
||||
:key="device.id"
|
||||
class="device-row"
|
||||
type="button"
|
||||
@click="openDevice(device)"
|
||||
>
|
||||
<span class="device-main">
|
||||
<span class="device-name">{{ device.name }}</span>
|
||||
<span class="device-id">{{ device.endpoint_id }}</span>
|
||||
</span>
|
||||
<n-tag size="small" :bordered="false" :type="tagType(device)">{{ presenceText(device.presence) }}</n-tag>
|
||||
<span @click.stop>
|
||||
<n-dropdown trigger="click" :options="moveOptions(device)" @select="(key: string) => moveDevice(device, key)">
|
||||
<n-button size="small" quaternary>移动</n-button>
|
||||
</n-dropdown>
|
||||
</span>
|
||||
</button>
|
||||
</section>
|
||||
</template>
|
||||
</n-spin>
|
||||
|
||||
<n-modal v-model:show="showAdd" :mask-closable="false">
|
||||
<n-card title="添加设备" style="width: 460px" :bordered="false">
|
||||
<template #header-extra>
|
||||
<help-tip text="端编号留空会新建一台设备。填写已有端编号,则只把它加进你的列表。" />
|
||||
</template>
|
||||
<n-form label-placement="left" label-width="88">
|
||||
<n-form-item label="名称">
|
||||
<n-input v-model:value="addName" placeholder="例如客厅电脑" />
|
||||
</n-form-item>
|
||||
<n-form-item label="端编号">
|
||||
<n-input v-model:value="addEndpoint" placeholder="留空则新建" />
|
||||
</n-form-item>
|
||||
<n-form-item label="分组">
|
||||
<n-select v-model:value="addGroup" clearable placeholder="未分组" :options="groups.map((g) => ({ label: g.name, value: g.id }))" />
|
||||
</n-form-item>
|
||||
</n-form>
|
||||
<template #footer>
|
||||
<n-space justify="end">
|
||||
<n-button @click="showAdd = false">取消</n-button>
|
||||
<n-button type="primary" :loading="adding" @click="submitAdd">保存</n-button>
|
||||
</n-space>
|
||||
</template>
|
||||
</n-card>
|
||||
</n-modal>
|
||||
|
||||
<n-modal v-model:show="showGroup" :mask-closable="false">
|
||||
<n-card :title="groupTarget == null ? '新建分组' : '重命名分组'" style="width: 420px" :bordered="false">
|
||||
<n-form label-placement="left" label-width="72">
|
||||
<n-form-item label="名称">
|
||||
<n-input v-model:value="groupName" />
|
||||
</n-form-item>
|
||||
</n-form>
|
||||
<template #footer>
|
||||
<n-space justify="end">
|
||||
<n-button @click="showGroup = false">取消</n-button>
|
||||
<n-button type="primary" :loading="savingGroup" @click="submitGroup">保存</n-button>
|
||||
</n-space>
|
||||
</template>
|
||||
</n-card>
|
||||
</n-modal>
|
||||
|
||||
<n-modal :show="secretShow" :mask-closable="false" :close-on-esc="false">
|
||||
<n-card title="请记下这台设备的信息" style="width: 460px" :bordered="false">
|
||||
<n-alert type="warning" :bordered="false" style="margin-bottom: 14px">
|
||||
端编号和初始密码只显示这一次。关闭后无法再查看。
|
||||
</n-alert>
|
||||
<n-form label-placement="left" label-width="88">
|
||||
<n-form-item label="端编号">
|
||||
<n-input :value="secretId" readonly class="mono" />
|
||||
</n-form-item>
|
||||
<n-form-item label="初始密码">
|
||||
<n-input :value="secretPassword" readonly class="mono" />
|
||||
</n-form-item>
|
||||
</n-form>
|
||||
<n-space>
|
||||
<n-button @click="copyText(secretId)">复制端编号</n-button>
|
||||
<n-button @click="copyText(secretPassword)">复制初始密码</n-button>
|
||||
</n-space>
|
||||
<template #footer>
|
||||
<n-space justify="end">
|
||||
<n-button type="primary" @click="closeSecret">我已记下</n-button>
|
||||
</n-space>
|
||||
</template>
|
||||
</n-card>
|
||||
</n-modal>
|
||||
|
||||
<n-drawer v-model:show="drawer" :width="420" placement="right">
|
||||
<n-drawer-content v-if="current" :title="current.name" closable>
|
||||
<n-form label-placement="left" label-width="72">
|
||||
<n-form-item label="名称">
|
||||
<n-input v-model:value="nameDraft" />
|
||||
</n-form-item>
|
||||
<n-form-item label="状态">
|
||||
<n-tag :bordered="false" :type="tagType(current)">{{ presenceText(current.presence) }}</n-tag>
|
||||
</n-form-item>
|
||||
<n-form-item label="端编号">
|
||||
<n-input :value="current.endpoint_id" readonly class="mono" />
|
||||
</n-form-item>
|
||||
<n-form-item label="分组">
|
||||
<n-select :value="current.group_id ?? 0" :options="groupChoices" @update:value="changeGroup" />
|
||||
</n-form-item>
|
||||
</n-form>
|
||||
<n-space style="margin-bottom: 16px">
|
||||
<n-button size="small" :loading="savingName" @click="saveName">保存名称</n-button>
|
||||
<n-button size="small" @click="copyText(current.endpoint_id)">复制端编号</n-button>
|
||||
<n-button size="small" type="error" quaternary @click="removeDevice">从列表移除</n-button>
|
||||
</n-space>
|
||||
<div class="group-title" style="margin-bottom: 8px">
|
||||
最近记录
|
||||
<help-tip text="这里只显示这台设备最近 20 条。更早的记录留在设备上。" />
|
||||
</div>
|
||||
<n-spin :show="logsLoading">
|
||||
<div class="log-list">
|
||||
<div v-if="!logsLoading && logs.length === 0" class="empty">还没有记录</div>
|
||||
<div v-for="(item, index) in logs" :key="index" class="log-item">
|
||||
<div class="log-meta">
|
||||
<span>{{ formatTime(item.at_ms) }}</span>
|
||||
<span>{{ item.ok ? '成功' : '失败' }}</span>
|
||||
</div>
|
||||
<div style="margin-top: 4px">{{ item.summary }}</div>
|
||||
<div v-if="item.result" class="device-id">{{ item.result }}</div>
|
||||
</div>
|
||||
</div>
|
||||
</n-spin>
|
||||
</n-drawer-content>
|
||||
</n-drawer>
|
||||
</main>
|
||||
</template>
|
||||
@@ -0,0 +1,39 @@
|
||||
<script setup lang="ts">
|
||||
import { NCard } from 'naive-ui'
|
||||
|
||||
const platforms = [
|
||||
{
|
||||
name: 'Android',
|
||||
text: '安装到手机后登录账号。离开界面后,手机会继续保持连接。',
|
||||
},
|
||||
{
|
||||
name: 'Windows',
|
||||
text: '安装后从桌面或开始菜单打开。关掉窗口不会停止已经在运行的被控程序。',
|
||||
},
|
||||
{
|
||||
name: 'macOS',
|
||||
text: '安装后从启动台或应用程序打开。被控程序在当前登录用户下运行。',
|
||||
},
|
||||
{
|
||||
name: 'Linux',
|
||||
text: '安装后从应用菜单打开。被控程序在当前登录用户下运行。',
|
||||
},
|
||||
]
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<main class="page">
|
||||
<div class="page-head">
|
||||
<h1>下载客户端</h1>
|
||||
</div>
|
||||
<p class="lead">
|
||||
手机和电脑使用同一个账号。安装包请向给你开通账号的人领取,拿到后直接安装,打开并登录即可。
|
||||
</p>
|
||||
<div class="grid">
|
||||
<n-card v-for="item in platforms" :key="item.name" :title="item.name" size="small">
|
||||
<p style="margin: 0 0 12px; line-height: 1.6">{{ item.text }}</p>
|
||||
<p style="margin: 0; color: #667085">请向管理员领取 {{ item.name }} 安装包。</p>
|
||||
</n-card>
|
||||
</div>
|
||||
</main>
|
||||
</template>
|
||||
@@ -0,0 +1,37 @@
|
||||
<script setup lang="ts">
|
||||
import { NButton, NCard, NSpace } from 'naive-ui'
|
||||
import { useRouter } from 'vue-router'
|
||||
|
||||
const router = useRouter()
|
||||
|
||||
const points = [
|
||||
{ title: '手机和电脑', text: '两边都能给另一台发送文字或命令,也可以同时管理多台远端。' },
|
||||
{ title: '按组查看', text: '把设备放进分组。删除分组后,设备回到未分组,不会被删掉。' },
|
||||
{ title: '信任在设备上', text: '只有在被控的那台设备上添加的信任才会生效。网页不能代替设备做这件事。' },
|
||||
]
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<main class="page">
|
||||
<section class="hero">
|
||||
<h1>让互相信任的设备互相操作</h1>
|
||||
<p class="lead">
|
||||
手机和电脑是同一类客户端。任意一台都可以给另一台发送文字或命令。发命令之前,先在被控的那台设备上把对方加为信任。
|
||||
</p>
|
||||
<n-space>
|
||||
<n-button type="primary" size="large" @click="router.push('/download')">下载客户端</n-button>
|
||||
<n-button size="large" @click="router.push('/register')">注册账号</n-button>
|
||||
</n-space>
|
||||
</section>
|
||||
<section class="grid">
|
||||
<n-card v-for="item in points" :key="item.title" :title="item.title" size="small">
|
||||
{{ item.text }}
|
||||
</n-card>
|
||||
</section>
|
||||
<h2 class="section-title">下载</h2>
|
||||
<p class="lead">
|
||||
提供 Android、Windows、macOS 和 Linux 客户端。安装后使用同一账号登录,就能看到自己的设备。
|
||||
</p>
|
||||
<n-button @click="router.push('/download')">查看下载说明</n-button>
|
||||
</main>
|
||||
</template>
|
||||
@@ -0,0 +1,57 @@
|
||||
<script setup lang="ts">
|
||||
import { NButton, NCard, NForm, NFormItem, NInput, useMessage } from 'naive-ui'
|
||||
import { ref } from 'vue'
|
||||
import { useRoute, useRouter } from 'vue-router'
|
||||
import { api, errorText } from '../api'
|
||||
import { useSession } from '../stores/session'
|
||||
|
||||
const route = useRoute()
|
||||
const router = useRouter()
|
||||
const message = useMessage()
|
||||
const session = useSession()
|
||||
const username = ref('')
|
||||
const password = ref('')
|
||||
const busy = ref(false)
|
||||
|
||||
async function submit() {
|
||||
if (!username.value.trim() || !password.value) {
|
||||
message.warning('请填写账号和密码')
|
||||
return
|
||||
}
|
||||
busy.value = true
|
||||
try {
|
||||
session.me = await api.login(username.value.trim(), password.value)
|
||||
session.ready = true
|
||||
const next = typeof route.query.next === 'string' ? route.query.next : '/app'
|
||||
await router.push(next.startsWith('/') && !next.startsWith('//') ? next : '/app')
|
||||
} catch (err) {
|
||||
message.error(errorText(err))
|
||||
} finally {
|
||||
busy.value = false
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<main class="page">
|
||||
<n-card class="narrow" title="登录">
|
||||
<n-form label-placement="left" label-width="72" @submit.prevent="submit">
|
||||
<n-form-item label="账号">
|
||||
<n-input v-model:value="username" autocomplete="username" />
|
||||
</n-form-item>
|
||||
<n-form-item label="密码">
|
||||
<n-input
|
||||
v-model:value="password"
|
||||
type="password"
|
||||
show-password-on="click"
|
||||
autocomplete="current-password"
|
||||
/>
|
||||
</n-form-item>
|
||||
<n-button attr-type="submit" type="primary" block :loading="busy">登录</n-button>
|
||||
</n-form>
|
||||
<div style="margin-top: 14px">
|
||||
<n-button text type="primary" @click="router.push('/register')">没有账号,去注册</n-button>
|
||||
</div>
|
||||
</n-card>
|
||||
</main>
|
||||
</template>
|
||||
@@ -0,0 +1,68 @@
|
||||
<script setup lang="ts">
|
||||
import { NButton, NCard, NForm, NFormItem, NInput, useMessage } from 'naive-ui'
|
||||
import { ref } from 'vue'
|
||||
import { useRouter } from 'vue-router'
|
||||
import { api, errorText } from '../api'
|
||||
import { useSession } from '../stores/session'
|
||||
|
||||
const router = useRouter()
|
||||
const message = useMessage()
|
||||
const session = useSession()
|
||||
const username = ref('')
|
||||
const password = ref('')
|
||||
const confirm = ref('')
|
||||
const busy = ref(false)
|
||||
|
||||
async function submit() {
|
||||
if (password.value !== confirm.value) {
|
||||
message.warning('两次输入的密码不一致')
|
||||
return
|
||||
}
|
||||
if (password.value.length < 8) {
|
||||
message.warning('密码至少 8 位')
|
||||
return
|
||||
}
|
||||
busy.value = true
|
||||
try {
|
||||
session.me = await api.register(username.value.trim(), password.value)
|
||||
session.ready = true
|
||||
await router.push('/app')
|
||||
} catch (err) {
|
||||
message.error(errorText(err))
|
||||
} finally {
|
||||
busy.value = false
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<main class="page">
|
||||
<n-card class="narrow" title="注册">
|
||||
<n-form label-placement="left" label-width="88" @submit.prevent="submit">
|
||||
<n-form-item label="账号">
|
||||
<n-input v-model:value="username" autocomplete="username" />
|
||||
</n-form-item>
|
||||
<n-form-item label="密码">
|
||||
<n-input
|
||||
v-model:value="password"
|
||||
type="password"
|
||||
show-password-on="click"
|
||||
autocomplete="new-password"
|
||||
/>
|
||||
</n-form-item>
|
||||
<n-form-item label="确认密码">
|
||||
<n-input
|
||||
v-model:value="confirm"
|
||||
type="password"
|
||||
show-password-on="click"
|
||||
autocomplete="new-password"
|
||||
/>
|
||||
</n-form-item>
|
||||
<n-button attr-type="submit" type="primary" block :loading="busy">注册并进入</n-button>
|
||||
</n-form>
|
||||
<div style="margin-top: 14px">
|
||||
<n-button text type="primary" @click="router.push('/login')">已有账号,去登录</n-button>
|
||||
</div>
|
||||
</n-card>
|
||||
</main>
|
||||
</template>
|
||||
@@ -0,0 +1,97 @@
|
||||
<script setup lang="ts">
|
||||
import { NButton, NCard, NDataTable, NTag, useDialog, useMessage, type DataTableColumns } from 'naive-ui'
|
||||
import { computed, h, onMounted, ref } from 'vue'
|
||||
import { api, errorText, type Account } from '../api'
|
||||
import HelpTip from '../components/HelpTip.vue'
|
||||
import { useSession } from '../stores/session'
|
||||
|
||||
const dialog = useDialog()
|
||||
const message = useMessage()
|
||||
const session = useSession()
|
||||
const loading = ref(true)
|
||||
const items = ref<Account[]>([])
|
||||
|
||||
const columns = computed<DataTableColumns<Account>>(() => [
|
||||
{ title: '账号', key: 'username' },
|
||||
{
|
||||
title: '身份',
|
||||
key: 'role',
|
||||
render: (row) => (row.role === 'admin' ? '管理员' : '用户'),
|
||||
},
|
||||
{
|
||||
title: '状态',
|
||||
key: 'enabled',
|
||||
render: (row) =>
|
||||
h(
|
||||
NTag,
|
||||
{ size: 'small', type: row.enabled ? 'success' : 'default', bordered: false },
|
||||
{ default: () => (row.enabled ? '正常' : '已停用') },
|
||||
),
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
key: 'actions',
|
||||
render: (row) => {
|
||||
if (session.me?.id === row.id) return '当前账号'
|
||||
return h(
|
||||
NButton,
|
||||
{
|
||||
size: 'small',
|
||||
quaternary: true,
|
||||
type: row.enabled ? 'warning' : 'primary',
|
||||
onClick: () => confirmToggle(row),
|
||||
},
|
||||
{ default: () => (row.enabled ? '停用' : '启用') },
|
||||
)
|
||||
},
|
||||
},
|
||||
])
|
||||
|
||||
async function load() {
|
||||
loading.value = true
|
||||
try {
|
||||
items.value = (await api.users()).items
|
||||
} catch (err) {
|
||||
message.error(errorText(err))
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
function confirmToggle(row: Account) {
|
||||
const enabling = !row.enabled
|
||||
dialog.warning({
|
||||
title: enabling ? '启用账号' : '停用账号',
|
||||
content: enabling
|
||||
? `确定启用「${row.username}」?`
|
||||
: `确定停用「${row.username}」?停用后这个账号无法登录。`,
|
||||
positiveText: '确定',
|
||||
negativeText: '取消',
|
||||
onPositiveClick: async () => {
|
||||
try {
|
||||
await api.setEnabled(row.id, enabling)
|
||||
message.success(enabling ? '已启用' : '已停用')
|
||||
await load()
|
||||
} catch (err) {
|
||||
message.error(errorText(err))
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
onMounted(load)
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<main class="page">
|
||||
<div class="page-head">
|
||||
<h1>
|
||||
用户
|
||||
<help-tip text="这里只管理账号是否可以登录,不能操作别人的设备。" />
|
||||
</h1>
|
||||
</div>
|
||||
<n-card size="small" :bordered="true">
|
||||
<n-data-table :columns="columns" :data="items" :loading="loading" :bordered="false" />
|
||||
</n-card>
|
||||
</main>
|
||||
</template>
|
||||
@@ -0,0 +1,20 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "ES2022",
|
||||
"useDefineForClassFields": true,
|
||||
"module": "ESNext",
|
||||
"moduleResolution": "bundler",
|
||||
"strict": true,
|
||||
"jsx": "preserve",
|
||||
"resolveJsonModule": true,
|
||||
"isolatedModules": true,
|
||||
"esModuleInterop": true,
|
||||
"lib": ["ES2022", "DOM", "DOM.Iterable"],
|
||||
"skipLibCheck": true,
|
||||
"noEmit": true,
|
||||
"noUnusedLocals": true,
|
||||
"noUnusedParameters": true,
|
||||
"types": ["vite/client"]
|
||||
},
|
||||
"include": ["src/**/*.ts", "src/**/*.vue", "env.d.ts", "vite.config.ts"]
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
import { defineConfig } from 'vite'
|
||||
import vue from '@vitejs/plugin-vue'
|
||||
|
||||
export default defineConfig({
|
||||
plugins: [vue()],
|
||||
server: { host: '127.0.0.1', port: 5173 },
|
||||
build: { outDir: 'dist', emptyOutDir: true },
|
||||
})
|
||||
Reference in New Issue
Block a user