mirror of
https://github.com/r-ca/kidshift-web.git
synced 2024-10-25 16:34:01 +00:00
ログイン画面推移できるように
This commit is contained in:
parent
dfcdccb2d7
commit
268d7b1847
|
@ -18,15 +18,13 @@
|
|||
<script setup lang="ts">
|
||||
|
||||
import useStore from 'src/store';
|
||||
import router from 'src/router';
|
||||
|
||||
const store = useStore();
|
||||
|
||||
if (store.state.account.isLoggedIn) {
|
||||
// debug, show alert
|
||||
alert('User is logged in');
|
||||
} else {
|
||||
// debug, show alert
|
||||
alert('User is not logged in');
|
||||
if (!store.state.account.isLoggedIn) {
|
||||
// to /login
|
||||
router.push('/login');
|
||||
}
|
||||
|
||||
import { sendPing } from 'src/api/apiService';
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
import { ref, computed } from 'vue';
|
||||
import useStore from 'src/store';
|
||||
import { loginWithCode } from 'src/api/apiService';
|
||||
import router from 'src/router';
|
||||
|
||||
const loginCode = ref('');
|
||||
|
||||
|
@ -32,6 +33,7 @@ const login = () => {
|
|||
loginWithCode(loginCode.value).then((accessToken) => {
|
||||
store.commit('account/setToken', accessToken);
|
||||
store.commit('account/setLoggedIn', true);
|
||||
router.push('/');
|
||||
}).catch((error) => {
|
||||
alert('ログインエラー: ' + error);
|
||||
});
|
||||
|
|
|
@ -4,6 +4,7 @@ import {
|
|||
createRouter,
|
||||
createWebHashHistory,
|
||||
createWebHistory,
|
||||
Router,
|
||||
} from 'vue-router';
|
||||
import { RootStateInterface } from '../store';
|
||||
|
||||
|
@ -18,20 +19,18 @@ import routes from './routes';
|
|||
* with the Router instance.
|
||||
*/
|
||||
|
||||
export default route<RootStateInterface>(function (/* { store, ssrContext } */) {
|
||||
const createHistory = process.env.SERVER
|
||||
? createMemoryHistory
|
||||
: (process.env.VUE_ROUTER_MODE === 'history' ? createWebHistory : createWebHashHistory);
|
||||
const createHistory = process.env.SERVER
|
||||
? createMemoryHistory
|
||||
: (process.env.VUE_ROUTER_MODE === 'history' ? createWebHistory : createWebHashHistory);
|
||||
|
||||
const Router = createRouter({
|
||||
scrollBehavior: () => ({ left: 0, top: 0 }),
|
||||
routes,
|
||||
|
||||
// Leave this as is and make changes in quasar.conf.js instead!
|
||||
// quasar.conf.js -> build -> vueRouterMode
|
||||
// quasar.conf.js -> build -> publicPath
|
||||
history: createHistory(process.env.VUE_ROUTER_BASE),
|
||||
});
|
||||
|
||||
return Router;
|
||||
const router: Router = createRouter({
|
||||
scrollBehavior: () => ({ left: 0, top: 0 }),
|
||||
routes,
|
||||
// Leave this as is and make changes in quasar.conf.js instead!
|
||||
// quasar.conf.js -> build -> vueRouterMode
|
||||
// quasar.conf.js -> build -> publicPath
|
||||
history: createHistory(process.env.VUE_ROUTER_BASE),
|
||||
});
|
||||
|
||||
export default router;
|
||||
|
|
Loading…
Reference in New Issue
Block a user