fix: route & viteconfig

This commit is contained in:
KarolChang 2022-04-24 10:08:45 +08:00
parent 0d24a3b730
commit fa4af5adef
8 changed files with 194 additions and 26 deletions

View File

@ -1,12 +1,14 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang=""> <html lang="en">
<head> <head>
<meta charset="utf-8" /> <meta charset="utf-8" />
<!-- <link rel="icon" href="<%= BASE_URL %>favicon.ico" /> -->
<link rel="icon" href="/favicon.ico" />
<!-- <meta http-equiv="X-UA-Compatible" content="IE=edge"> --> <!-- <meta http-equiv="X-UA-Compatible" content="IE=edge"> -->
<meta name="viewport" content="width=device-width,initial-scale=1.0" /> <meta name="viewport" content="width=device-width,initial-scale=1.0" />
<meta http-equiv="Content-Security-Policy" content="upgrade-insecure-requests" /> <meta http-equiv="Content-Security-Policy" content="upgrade-insecure-requests" />
<!-- <link rel="icon" href="<%= BASE_URL %>favicon.ico" /> -->
<link rel="icon" href="/favicon.ico" />
<!-- <title><%= htmlWebpackPlugin.options.title %></title> --> <!-- <title><%= htmlWebpackPlugin.options.title %></title> -->
<title>JM Expense</title> <title>JM Expense</title>
<script src="https://kit.fontawesome.com/ccfd93e9a7.js" crossorigin="anonymous"></script> <script src="https://kit.fontawesome.com/ccfd93e9a7.js" crossorigin="anonymous"></script>

View File

@ -14,7 +14,7 @@ cd dist
git init git init
git add -A git add -A
git commit -m 'deploy' git commit -m 'deploy: config'
# if you are deploying to https://<USERNAME>.github.io # if you are deploying to https://<USERNAME>.github.io
# git push -f https://github.com/<USERNAME>/<USERNAME>.GitHub.io.git master # git push -f https://github.com/<USERNAME>/<USERNAME>.GitHub.io.git master

View File

@ -1,12 +1,13 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang=""> <html lang="en">
<head> <head>
<meta charset="utf-8" /> <meta charset="utf-8" />
<!-- <link rel="icon" href="<%= BASE_URL %>favicon.ico" /> -->
<link rel="icon" href="/favicon.ico" />
<!-- <meta http-equiv="X-UA-Compatible" content="IE=edge"> --> <!-- <meta http-equiv="X-UA-Compatible" content="IE=edge"> -->
<meta name="viewport" content="width=device-width,initial-scale=1.0" /> <meta name="viewport" content="width=device-width,initial-scale=1.0" />
<meta http-equiv="Content-Security-Policy" content="upgrade-insecure-requests" /> <meta http-equiv="Content-Security-Policy" content="upgrade-insecure-requests" />
<!-- <link rel="icon" href="<%= BASE_URL %>favicon.ico" /> -->
<link rel="icon" href="/favicon.ico" />
<!-- <title><%= htmlWebpackPlugin.options.title %></title> --> <!-- <title><%= htmlWebpackPlugin.options.title %></title> -->
<title>JM Expense</title> <title>JM Expense</title>
<script src="https://kit.fontawesome.com/ccfd93e9a7.js" crossorigin="anonymous"></script> <script src="https://kit.fontawesome.com/ccfd93e9a7.js" crossorigin="anonymous"></script>

14
postcss.config.js Normal file
View File

@ -0,0 +1,14 @@
module.exports = {
plugins: [
{
postcssPlugin: 'internal:charset-removal',
AtRule: {
charset: (atRule) => {
if (atRule.name === 'charset') {
atRule.remove()
}
}
}
}
]
}

View File

@ -5,13 +5,165 @@ import AppLayout from '@/views/App.vue'
const root = '/jm-expense-vue-ts' const root = '/jm-expense-vue-ts'
// export const routes: RouteRecordRaw[] = [
// {
// path: '/',
// redirect: `${root}/`
// },
// {
// path: `${root}/register`,
// name: 'Register',
// component: () => import('../views/Register.vue'),
// meta: {
// pageTitle: '註冊頁',
// show: false
// }
// },
// {
// path: `${root}/login`,
// name: 'Login',
// component: () => import('../views/Login.vue'),
// meta: {
// pageTitle: '登入頁',
// show: false
// }
// },
// {
// path: `${root}/`,
// name: 'Home',
// component: () => import('../views/Home.vue'),
// meta: {
// pageTitle: '首頁',
// show: true
// }
// },
// {
// path: `${root}/record`,
// name: 'Record',
// component: () => import('../views/Record.vue'),
// meta: {
// pageTitle: '未結算紀錄',
// show: true
// }
// },
// {
// path: `${root}/closedRecord`,
// name: 'ClosedRecord',
// component: () => import('../views/ClosedRecord.vue'),
// meta: {
// pageTitle: '已結算紀錄',
// show: true
// }
// },
// {
// path: `${root}/logs`,
// name: 'Logs',
// component: () => import('../views/Logs.vue'),
// meta: {
// pageTitle: '更動紀錄',
// show: true
// }
// },
// {
// path: `${root}/expense`,
// name: 'Expense',
// component: () => import('../views/Expense.vue'),
// meta: {
// pageTitle: '豬涵記帳',
// show: true
// }
// },
// // {
// // path: `${root}/tools`,
// // name: 'Tools',
// // component: () => import('../views/Tools.vue'),
// // meta: {
// // pageTitle: '小工具',
// // show: true
// // }
// // },
// {
// path: `${root}/game`,
// name: 'Game',
// component: () => import('../views/Game.vue'),
// meta: {
// pageTitle: '小遊戲',
// show: true
// // auth: ['root', 'admin', 'member']
// }
// },
// // {
// // path: `${root}/admin`,
// // name: 'Admin',
// // redirect: { name: 'Admin-Role' },
// // component: AppLayout,
// // meta: {
// // pageTitle: '管理面板',
// // show: true
// // },
// // children: [
// // {
// // path: 'role',
// // name: 'Admin-Role',
// // component: () => import('../views/Role.vue'),
// // meta: {
// // pageTitle: '角色管理',
// // show: true
// // }
// // },
// // {
// // path: 'permission',
// // name: 'Admin-Permission',
// // component: () => import('../views/Permission.vue'),
// // meta: {
// // pageTitle: '權限管理',
// // show: true
// // }
// // }
// // ]
// // },
// // {
// // path: `${root}/admin/role`,
// // name: 'Admin-Role',
// // component: () => import('@/views/Role.vue'),
// // meta: {
// // pageTitle: '角色管理',
// // show: true
// // }
// // },
// // {
// // path: '/admin/role/:id/access',
// // name: 'Admin-Role-Access',
// // component: () => import('@/views/Access.vue'),
// // meta: {
// // pageTitle: '角色管理 / 設置權限[角色名稱]',
// // show: false
// // }
// // },
// // {
// // path: '/admin/permission',
// // name: 'Admin-Permission',
// // component: () => import('../views/Permission.vue'),
// // meta: {
// // pageTitle: '權限管理',
// // show: true
// // }
// // },
// {
// path: '/:pathMatch(.*)*',
// name: 'NotFound',
// component: () => import('../views/NotFound.vue')
// }
// ]
// new
export const routes: RouteRecordRaw[] = [ export const routes: RouteRecordRaw[] = [
// {
// path: '/',
// redirect: `${root}/`
// },
{ {
path: '/', path: '/register',
redirect: `${root}/`
},
{
path: `${root}/register`,
name: 'Register', name: 'Register',
component: () => import('../views/Register.vue'), component: () => import('../views/Register.vue'),
meta: { meta: {
@ -20,7 +172,7 @@ export const routes: RouteRecordRaw[] = [
} }
}, },
{ {
path: `${root}/login`, path: '/login',
name: 'Login', name: 'Login',
component: () => import('../views/Login.vue'), component: () => import('../views/Login.vue'),
meta: { meta: {
@ -29,7 +181,7 @@ export const routes: RouteRecordRaw[] = [
} }
}, },
{ {
path: `${root}/`, path: '/',
name: 'Home', name: 'Home',
component: () => import('../views/Home.vue'), component: () => import('../views/Home.vue'),
meta: { meta: {
@ -38,7 +190,7 @@ export const routes: RouteRecordRaw[] = [
} }
}, },
{ {
path: `${root}/record`, path: '/record',
name: 'Record', name: 'Record',
component: () => import('../views/Record.vue'), component: () => import('../views/Record.vue'),
meta: { meta: {
@ -47,7 +199,7 @@ export const routes: RouteRecordRaw[] = [
} }
}, },
{ {
path: `${root}/closedRecord`, path: '/closedRecord',
name: 'ClosedRecord', name: 'ClosedRecord',
component: () => import('../views/ClosedRecord.vue'), component: () => import('../views/ClosedRecord.vue'),
meta: { meta: {
@ -56,7 +208,7 @@ export const routes: RouteRecordRaw[] = [
} }
}, },
{ {
path: `${root}/logs`, path: '/logs',
name: 'Logs', name: 'Logs',
component: () => import('../views/Logs.vue'), component: () => import('../views/Logs.vue'),
meta: { meta: {
@ -65,7 +217,7 @@ export const routes: RouteRecordRaw[] = [
} }
}, },
{ {
path: `${root}/expense`, path: '/expense',
name: 'Expense', name: 'Expense',
component: () => import('../views/Expense.vue'), component: () => import('../views/Expense.vue'),
meta: { meta: {
@ -74,7 +226,7 @@ export const routes: RouteRecordRaw[] = [
} }
}, },
// { // {
// path: `${root}/tools`, // path: '/tools',
// name: 'Tools', // name: 'Tools',
// component: () => import('../views/Tools.vue'), // component: () => import('../views/Tools.vue'),
// meta: { // meta: {
@ -83,7 +235,7 @@ export const routes: RouteRecordRaw[] = [
// } // }
// }, // },
{ {
path: `${root}/game`, path: '/game',
name: 'Game', name: 'Game',
component: () => import('../views/Game.vue'), component: () => import('../views/Game.vue'),
meta: { meta: {

View File

@ -5,7 +5,7 @@ import { useRoute } from 'vue-router'
const route = useRoute() const route = useRoute()
// created // created
if (import.meta.env.NODE_ENV === 'production') { if (import.meta.env.MODE === 'production') {
onLoad() onLoad()
} }
</script> </script>

View File

@ -14,5 +14,8 @@ export default defineConfig({
}, },
server: { server: {
port: 8080 port: 8080
} },
// base: import.meta.env.DEV ? '/' : '/jm-expense-vue-ts/'
// base: '/jm-expense-vue-ts/'
base: './'
}) })

View File

@ -1,4 +0,0 @@
module.exports = {
// publicPath: process.env.NODE_ENV === 'production' ? '/jm-expense-vue-ts/' : '/'
publicPath: import.meta.env.NODE_ENV === 'production' ? '/jm-expense-vue-ts/' : '/'
}