init
This commit is contained in:
@@ -0,0 +1 @@
|
||||
node_modules
|
||||
Vendored
+3
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"recommendations": ["Vue.volar"]
|
||||
}
|
||||
Vendored
+12
@@ -0,0 +1,12 @@
|
||||
/* eslint-disable */
|
||||
/* prettier-ignore */
|
||||
/* oxlint-disable */
|
||||
/* oxfmt-ignore */
|
||||
// @ts-nocheck
|
||||
// noinspection JSUnusedGlobalSymbols
|
||||
// Generated by unplugin-auto-import
|
||||
// biome-ignore lint: disable
|
||||
export {}
|
||||
declare global {
|
||||
|
||||
}
|
||||
Vendored
+27
@@ -0,0 +1,27 @@
|
||||
/* eslint-disable */
|
||||
// @ts-nocheck
|
||||
// biome-ignore lint: disable
|
||||
// oxlint-disable
|
||||
// ------
|
||||
// Generated by unplugin-vue-components
|
||||
// Read more: https://github.com/vuejs/core/pull/3399
|
||||
|
||||
export {}
|
||||
|
||||
/* prettier-ignore */
|
||||
declare module 'vue' {
|
||||
export interface GlobalComponents {
|
||||
RouterLink: typeof import('vue-router')['RouterLink']
|
||||
RouterView: typeof import('vue-router')['RouterView']
|
||||
VanButton: typeof import('vant/es')['Button']
|
||||
VanCell: typeof import('vant/es')['Cell']
|
||||
VanCellGroup: typeof import('vant/es')['CellGroup']
|
||||
VanContactCard: typeof import('vant/es')['ContactCard']
|
||||
VanField: typeof import('vant/es')['Field']
|
||||
VanForm: typeof import('vant/es')['Form']
|
||||
VanNavBar: typeof import('vant/es')['NavBar']
|
||||
VanSearch: typeof import('vant/es')['Search']
|
||||
VanTabbar: typeof import('vant/es')['Tabbar']
|
||||
VanTabbarItem: typeof import('vant/es')['TabbarItem']
|
||||
}
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>jt-web</title>
|
||||
</head>
|
||||
<body>
|
||||
<div id="app"></div>
|
||||
<script type="module" src="/src/main.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,24 @@
|
||||
{
|
||||
"name": "jt-web",
|
||||
"private": true,
|
||||
"version": "0.0.0",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
"build": "vite build",
|
||||
"preview": "vite preview"
|
||||
},
|
||||
"dependencies": {
|
||||
"axios": "^1.20.0",
|
||||
"vant": "^4.10.2",
|
||||
"vue": "^3.5.42",
|
||||
"vue-router": "^5.4.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@vant/auto-import-resolver": "^1.3.0",
|
||||
"@vitejs/plugin-vue": "^6.0.8",
|
||||
"unplugin-auto-import": "^21.1.0",
|
||||
"unplugin-vue-components": "^32.1.0",
|
||||
"vite": "^8.3.0"
|
||||
}
|
||||
}
|
||||
Generated
+1401
File diff suppressed because it is too large
Load Diff
+16
@@ -0,0 +1,16 @@
|
||||
<script setup>
|
||||
import { ref } from 'vue';
|
||||
|
||||
const active = ref(0)
|
||||
|
||||
</script>
|
||||
|
||||
<template>
|
||||
|
||||
<RouterView />
|
||||
<van-tabbar v-model="active">
|
||||
<van-tabbar-item replace to="/" icon="list-switch">首页</van-tabbar-item>
|
||||
<van-tabbar-item replace to="/mine" icon="user-o">我的</van-tabbar-item>
|
||||
</van-tabbar>
|
||||
</template>
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
import { createApp } from 'vue'
|
||||
|
||||
import App from './App.vue'
|
||||
import { router } from './routes.js'
|
||||
|
||||
|
||||
createApp(App).use(router).mount('#app')
|
||||
@@ -0,0 +1,27 @@
|
||||
import { createMemoryHistory, createRouter } from 'vue-router'
|
||||
|
||||
import HomeView from './view/HomeView.vue'
|
||||
import MineView from './view/MineView.vue'
|
||||
import LoginView from './view/LoginView.vue'
|
||||
import RegView from './view/RegView.vue'
|
||||
|
||||
const routes = [
|
||||
{ path: '/', component: HomeView },
|
||||
{
|
||||
path: '/mine',
|
||||
component: MineView,
|
||||
beforeEnter: (to, from, next) => {
|
||||
const isAuthenticated = !!localStorage.getItem('token');
|
||||
if (!isAuthenticated) next({ path: '/login' });
|
||||
else next();
|
||||
}
|
||||
},
|
||||
{ path: '/login', component: LoginView },
|
||||
{ path: '/reg', component: RegView }
|
||||
|
||||
]
|
||||
|
||||
export const router = createRouter({
|
||||
history: createMemoryHistory(),
|
||||
routes,
|
||||
})
|
||||
@@ -0,0 +1,21 @@
|
||||
<script setup>
|
||||
import axios from 'axios';
|
||||
import { onMounted, ref } from 'vue';
|
||||
|
||||
const posts = ref([])
|
||||
|
||||
onMounted(async () => {
|
||||
const res = await axios.get("http://localhost:3000/api/post")
|
||||
console.log(res.data)
|
||||
posts.value = res.data
|
||||
})
|
||||
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<van-nav-bar title="首页" />
|
||||
<van-search placeholder="请输入搜索关键词" />
|
||||
<van-cell-group v-for="post in posts" :key="post.id">
|
||||
<van-cell :title="post.title" :value="post.user_id" :label="post.context" />
|
||||
</van-cell-group>
|
||||
</template>
|
||||
@@ -0,0 +1,48 @@
|
||||
<script setup>
|
||||
import { ref } from 'vue';
|
||||
import { router } from '../routes';
|
||||
|
||||
const username = ref('');
|
||||
const password = ref('');
|
||||
const onSubmit = (values) => {
|
||||
console.log('submit', values);
|
||||
};
|
||||
|
||||
const jump = () => {
|
||||
router.push({path:'/reg'})
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<van-nav-bar title="登录" />
|
||||
<van-form @submit="onSubmit">
|
||||
<van-cell-group inset>
|
||||
<van-field
|
||||
v-model="username"
|
||||
name="username"
|
||||
label="用户名"
|
||||
placeholder="用户名"
|
||||
:rules="[{ required: true, message: '请填写用户名' }]"
|
||||
/>
|
||||
<van-field
|
||||
v-model="password"
|
||||
type="password"
|
||||
name="password"
|
||||
label="密码"
|
||||
placeholder="密码"
|
||||
:rules="[{ required: true, message: '请填写密码' }]"
|
||||
/>
|
||||
</van-cell-group>
|
||||
<div style="margin: 16px;">
|
||||
<van-button round block type="primary" native-type="submit">
|
||||
登录
|
||||
</van-button>
|
||||
</div>
|
||||
<div style="margin: 16px;">
|
||||
<van-button round block type="primary" @click="jump">
|
||||
注册
|
||||
</van-button>
|
||||
</div>
|
||||
</van-form>
|
||||
|
||||
</template>
|
||||
@@ -0,0 +1,7 @@
|
||||
|
||||
|
||||
<template>
|
||||
<this class="1"></this>
|
||||
<van-nav-bar title="我的" />
|
||||
mine
|
||||
</template>
|
||||
@@ -0,0 +1,63 @@
|
||||
<script setup>
|
||||
import { onMounted, reactive, ref } from 'vue';
|
||||
import axios from 'axios';
|
||||
|
||||
const userInfo = reactive({
|
||||
nickname: '',
|
||||
username: '',
|
||||
password: ''
|
||||
});
|
||||
|
||||
// const onSubmit = (values) => {
|
||||
// console.log('submit', values);
|
||||
// };
|
||||
|
||||
const userReg = async () => {
|
||||
try{
|
||||
const res = await axios.post("http://localhost:3000/api/user", userInfo)
|
||||
console.log("注册成功", res.data)
|
||||
alert("注册成功")
|
||||
}catch(error){
|
||||
console.log("注册失败", error)
|
||||
alert("注册失败")
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<van-nav-bar title="注册" />
|
||||
<van-form @submit="userReg">
|
||||
<van-cell-group inset>
|
||||
<van-field
|
||||
v-model="userInfo.nickname"
|
||||
name="nickname"
|
||||
label="昵称"
|
||||
placeholder="昵称"
|
||||
:rules="[{ required: true, message: '请填写昵称' }]"
|
||||
/>
|
||||
<van-field
|
||||
v-model="userInfo.username"
|
||||
name="username"
|
||||
label="用户名"
|
||||
placeholder="用户名"
|
||||
:rules="[{ required: true, message: '请填写用户名' }]"
|
||||
/>
|
||||
<van-field
|
||||
v-model="userInfo.password"
|
||||
type="password"
|
||||
name="password"
|
||||
label="密码"
|
||||
placeholder="密码"
|
||||
:rules="[{ required: true, message: '请填写密码' }]"
|
||||
/>
|
||||
|
||||
</van-cell-group>
|
||||
<div style="margin: 16px;">
|
||||
<van-button round block type="primary" native-type="submit" @click="jump">
|
||||
注册
|
||||
</van-button>
|
||||
</div>
|
||||
</van-form>
|
||||
</template>
|
||||
@@ -0,0 +1,18 @@
|
||||
import vue from '@vitejs/plugin-vue'
|
||||
import { defineConfig } from 'vite'
|
||||
import AutoImport from 'unplugin-auto-import/vite';
|
||||
import Components from 'unplugin-vue-components/vite';
|
||||
import { VantResolver } from '@vant/auto-import-resolver';
|
||||
|
||||
// https://vite.dev/config/
|
||||
export default defineConfig({
|
||||
plugins: [
|
||||
vue(),
|
||||
AutoImport({
|
||||
resolvers: [VantResolver()],
|
||||
}),
|
||||
Components({
|
||||
resolvers: [VantResolver()],
|
||||
}),
|
||||
],
|
||||
})
|
||||
Reference in New Issue
Block a user