Initial commit
This commit is contained in:
21
src/App.vue
Normal file
21
src/App.vue
Normal file
@@ -0,0 +1,21 @@
|
||||
<template>
|
||||
<div id="app">
|
||||
<nav>
|
||||
<router-link to="/">Home</router-link> |
|
||||
<router-link to="/about">About</router-link>
|
||||
</nav>
|
||||
<router-view />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { defineComponent } from 'vue'
|
||||
|
||||
export default defineComponent({
|
||||
name: 'App'
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
@import 'styles/app';
|
||||
</style>
|
||||
BIN
src/assets/logo.png
Normal file
BIN
src/assets/logo.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 6.7 KiB |
3
src/bus/busEvent.ts
Normal file
3
src/bus/busEvent.ts
Normal file
@@ -0,0 +1,3 @@
|
||||
export enum BusEvent {
|
||||
NEW_VERSION = 'NEW_VERSION'
|
||||
}
|
||||
34
src/components/FooterTranslation.vue
Normal file
34
src/components/FooterTranslation.vue
Normal file
@@ -0,0 +1,34 @@
|
||||
<template>
|
||||
<footer class="footer-translation">
|
||||
<button class="button" @click="toggleLanguage">
|
||||
{{ t('toggle-lang') }}
|
||||
</button>
|
||||
</footer>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { defineComponent } from 'vue'
|
||||
import { locales } from '@/locales/message'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
|
||||
export default defineComponent({
|
||||
name: 'FooterTranslation',
|
||||
setup() {
|
||||
const { t } = useI18n()
|
||||
|
||||
const i18n = useI18n()
|
||||
|
||||
return {
|
||||
t,
|
||||
toggleLanguage: () =>
|
||||
(i18n.locale.value =
|
||||
locales[(locales.indexOf(i18n.locale.value) + 1) % locales.length])
|
||||
}
|
||||
}
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.footer-translation {
|
||||
}
|
||||
</style>
|
||||
184
src/components/HelloWorld.vue
Normal file
184
src/components/HelloWorld.vue
Normal file
@@ -0,0 +1,184 @@
|
||||
<template>
|
||||
<div class="hello">
|
||||
<h1 class="title is-1">{{ t('hello') }}</h1>
|
||||
<h2 class="subtitle is-2">{{ upperMessage }}</h2>
|
||||
<p>
|
||||
For a guide and recipes on how to configure / customize this project,<br />
|
||||
check out the
|
||||
<a href="https://cli.vuejs.org" target="_blank" rel="noopener"
|
||||
>vue-cli documentation</a
|
||||
>.
|
||||
</p>
|
||||
<h3 class="title is-3">Installed CLI Plugins</h3>
|
||||
<ul>
|
||||
<li>
|
||||
<a
|
||||
href="https://github.com/vuejs/vue-cli/tree/dev/packages/%40vue/cli-plugin-babel"
|
||||
target="_blank"
|
||||
rel="noopener"
|
||||
>babel</a
|
||||
>
|
||||
</li>
|
||||
<li>
|
||||
<a
|
||||
href="https://github.com/vuejs/vue-cli/tree/dev/packages/%40vue/cli-plugin-pwa"
|
||||
target="_blank"
|
||||
rel="noopener"
|
||||
>pwa</a
|
||||
>
|
||||
</li>
|
||||
<li>
|
||||
<a
|
||||
href="https://github.com/vuejs/vue-cli/tree/dev/packages/%40vue/cli-plugin-router"
|
||||
target="_blank"
|
||||
rel="noopener"
|
||||
>router</a
|
||||
>
|
||||
</li>
|
||||
<li>
|
||||
<a
|
||||
href="https://github.com/vuejs/vue-cli/tree/dev/packages/%40vue/cli-plugin-vuex"
|
||||
target="_blank"
|
||||
rel="noopener"
|
||||
>vuex</a
|
||||
>
|
||||
</li>
|
||||
<li>
|
||||
<a
|
||||
href="https://github.com/vuejs/vue-cli/tree/dev/packages/%40vue/cli-plugin-eslint"
|
||||
target="_blank"
|
||||
rel="noopener"
|
||||
>eslint</a
|
||||
>
|
||||
</li>
|
||||
<li>
|
||||
<a
|
||||
href="https://github.com/vuejs/vue-cli/tree/dev/packages/%40vue/cli-plugin-unit-jest"
|
||||
target="_blank"
|
||||
rel="noopener"
|
||||
>unit-jest</a
|
||||
>
|
||||
</li>
|
||||
<li>
|
||||
<a
|
||||
href="https://github.com/vuejs/vue-cli/tree/dev/packages/%40vue/cli-plugin-typescript"
|
||||
target="_blank"
|
||||
rel="noopener"
|
||||
>typescript</a
|
||||
>
|
||||
</li>
|
||||
</ul>
|
||||
<h3 class="title is-3">Installed command</h3>
|
||||
<ul>
|
||||
<li>
|
||||
<code>yarn pwa:asset</code> (or <code>npm run pwa:asset</code>) creates
|
||||
all the assets for the PWA asset. Just change the logo.svg in the img
|
||||
folder and let the magic do the rest.
|
||||
</li>
|
||||
</ul>
|
||||
<h3 class="title is-3">Essential Links</h3>
|
||||
<ul>
|
||||
<li>
|
||||
<a href="https://vuejs.org" target="_blank" rel="noopener">Core Docs</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="https://forum.vuejs.org" target="_blank" rel="noopener"
|
||||
>Forum</a
|
||||
>
|
||||
</li>
|
||||
<li>
|
||||
<a href="https://chat.vuejs.org" target="_blank" rel="noopener"
|
||||
>Community Chat</a
|
||||
>
|
||||
</li>
|
||||
<li>
|
||||
<a href="https://twitter.com/vuejs" target="_blank" rel="noopener"
|
||||
>Twitter</a
|
||||
>
|
||||
</li>
|
||||
<li>
|
||||
<a href="https://news.vuejs.org" target="_blank" rel="noopener">News</a>
|
||||
</li>
|
||||
</ul>
|
||||
<h3 class="title is-3">Ecosystem</h3>
|
||||
<ul>
|
||||
<li>
|
||||
<a href="https://router.vuejs.org" target="_blank" rel="noopener"
|
||||
>vue-router</a
|
||||
>
|
||||
</li>
|
||||
<li>
|
||||
<a href="https://vuex.vuejs.org" target="_blank" rel="noopener">vuex</a>
|
||||
</li>
|
||||
<li>
|
||||
<a
|
||||
href="https://github.com/vuejs/vue-devtools#vue-devtools"
|
||||
target="_blank"
|
||||
rel="noopener"
|
||||
>vue-devtools</a
|
||||
>
|
||||
</li>
|
||||
<li>
|
||||
<a href="https://vue-loader.vuejs.org" target="_blank" rel="noopener"
|
||||
>vue-loader</a
|
||||
>
|
||||
</li>
|
||||
<li>
|
||||
<a
|
||||
href="https://github.com/vuejs/awesome-vue"
|
||||
target="_blank"
|
||||
rel="noopener"
|
||||
>awesome-vue</a
|
||||
>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<FooterTranslation class="footer-translation" />
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { defineComponent, computed } from 'vue'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import FooterTranslation from '@/components/FooterTranslation.vue'
|
||||
|
||||
export default defineComponent({
|
||||
name: 'HelloWorld',
|
||||
components: {
|
||||
FooterTranslation
|
||||
},
|
||||
props: {
|
||||
msg: String
|
||||
},
|
||||
setup(props) {
|
||||
const { t } = useI18n()
|
||||
const upperMessage = computed(() => {
|
||||
return (props.msg ?? '').toUpperCase()
|
||||
})
|
||||
|
||||
return {
|
||||
upperMessage,
|
||||
t
|
||||
}
|
||||
}
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
h3 {
|
||||
margin: 40px 0 0;
|
||||
}
|
||||
ul {
|
||||
list-style-type: none;
|
||||
padding: 0;
|
||||
}
|
||||
li {
|
||||
display: inline-block;
|
||||
margin: 0 10px;
|
||||
}
|
||||
a {
|
||||
color: #42b983;
|
||||
}
|
||||
.footer-translation {
|
||||
margin-top: 1rem;
|
||||
}
|
||||
</style>
|
||||
1
src/data/DataType.enum.ts
Normal file
1
src/data/DataType.enum.ts
Normal file
@@ -0,0 +1 @@
|
||||
export enum DataType {}
|
||||
70
src/data/data.ts
Normal file
70
src/data/data.ts
Normal file
@@ -0,0 +1,70 @@
|
||||
import PouchDb from 'pouchdb-browser'
|
||||
import { Model } from './models/Model'
|
||||
import indexedDb from 'pouchdb-adapter-indexeddb'
|
||||
import { DataType } from './DataType.enum'
|
||||
|
||||
PouchDb.plugin(indexedDb)
|
||||
|
||||
interface GetAllParams {
|
||||
prefix?: string
|
||||
includeDocs?: boolean
|
||||
includeAttachments?: boolean
|
||||
}
|
||||
|
||||
class Data {
|
||||
private locale = new PouchDb('local-db', {
|
||||
adapter: 'indexeddb'
|
||||
})
|
||||
|
||||
public async add<DT extends DataType>(model: Model<DT>): Promise<boolean> {
|
||||
try {
|
||||
const result = await this.locale.put(model)
|
||||
return result.ok
|
||||
} catch {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
public async remove(id: string): Promise<boolean> {
|
||||
try {
|
||||
const doc = await this.get(id)
|
||||
if (!doc) {
|
||||
return false
|
||||
}
|
||||
const { ok } = await this.locale.put({
|
||||
...doc,
|
||||
_deleted: true
|
||||
})
|
||||
return ok
|
||||
} catch {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
public async get<DT extends DataType, T extends Model<DT>>(
|
||||
id: string
|
||||
): Promise<T | null> {
|
||||
try {
|
||||
return ((await this.locale.get(id)) as T) || null
|
||||
} catch {
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
public async getAll<DT extends DataType, T extends Model<DT>>({
|
||||
prefix,
|
||||
includeDocs = true,
|
||||
includeAttachments = false
|
||||
}: GetAllParams): Promise<T[]> {
|
||||
const response = await this.locale.allDocs({
|
||||
include_docs: includeDocs,
|
||||
attachments: includeAttachments,
|
||||
startkey: prefix ? prefix : undefined,
|
||||
endkey: prefix ? `${prefix}\ufff0` : undefined
|
||||
})
|
||||
|
||||
return response.rows.map((row) => row.doc) as T[]
|
||||
}
|
||||
}
|
||||
|
||||
export const data = new Data()
|
||||
8
src/data/models/Model.ts
Normal file
8
src/data/models/Model.ts
Normal file
@@ -0,0 +1,8 @@
|
||||
import { DataType } from '../DataType.enum'
|
||||
|
||||
export interface Model<DT extends DataType> {
|
||||
_id?: string
|
||||
_rev?: string
|
||||
_deleted?: boolean
|
||||
$type: DT
|
||||
}
|
||||
4
src/locales/en.json
Normal file
4
src/locales/en.json
Normal file
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"hello": "Hello World",
|
||||
"toggle-lang": "Toggle lang"
|
||||
}
|
||||
4
src/locales/fr.json
Normal file
4
src/locales/fr.json
Normal file
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"hello": "Bonjour le monde",
|
||||
"toggle-lang": "Changer la langue"
|
||||
}
|
||||
9
src/locales/message.ts
Normal file
9
src/locales/message.ts
Normal file
@@ -0,0 +1,9 @@
|
||||
import en from './en.json'
|
||||
import fr from './fr.json'
|
||||
|
||||
export const messages = {
|
||||
en,
|
||||
fr
|
||||
}
|
||||
|
||||
export const locales = Object.keys(messages)
|
||||
19
src/main.ts
Normal file
19
src/main.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
import '@/registerServiceWorker'
|
||||
|
||||
import App from './App.vue'
|
||||
import { createApp } from 'vue'
|
||||
import { createI18n } from 'vue-i18n'
|
||||
import { messages } from '@/locales/message'
|
||||
import { router } from '@/router/router'
|
||||
import { store } from '@/store/store'
|
||||
|
||||
const i18n = createI18n({
|
||||
locale: 'en',
|
||||
messages
|
||||
})
|
||||
|
||||
createApp(App)
|
||||
.use(store)
|
||||
.use(router)
|
||||
.use(i18n)
|
||||
.mount('#app')
|
||||
37
src/registerServiceWorker.ts
Normal file
37
src/registerServiceWorker.ts
Normal file
@@ -0,0 +1,37 @@
|
||||
/* eslint-disable no-console */
|
||||
|
||||
import { register } from 'register-service-worker'
|
||||
import { emit } from 'retrobus'
|
||||
import { BusEvent } from '@/bus/busEvent'
|
||||
|
||||
if (process.env.NODE_ENV === 'production') {
|
||||
register(`${process.env.BASE_URL}service-worker.js`, {
|
||||
ready() {
|
||||
console.log(
|
||||
'App is being served from cache by a service worker.\n' +
|
||||
'For more details, visit https://goo.gl/AFskqB'
|
||||
)
|
||||
},
|
||||
registered() {
|
||||
console.log('Service worker has been registered.')
|
||||
},
|
||||
cached() {
|
||||
console.log('Content has been cached for offline use.')
|
||||
},
|
||||
updatefound() {
|
||||
console.log('New content is downloading.')
|
||||
},
|
||||
updated() {
|
||||
console.log('New content is available; please refresh.')
|
||||
emit(BusEvent.NEW_VERSION)
|
||||
},
|
||||
offline() {
|
||||
console.log(
|
||||
'No internet connection found. App is running in offline mode.'
|
||||
)
|
||||
},
|
||||
error(error) {
|
||||
console.error('Error during service worker registration:', error)
|
||||
}
|
||||
})
|
||||
}
|
||||
20
src/router/router.ts
Normal file
20
src/router/router.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
import { createRouter, createWebHistory, RouteRecordRaw } from 'vue-router'
|
||||
import Home from '@/views/Home.vue'
|
||||
|
||||
const routes: Array<RouteRecordRaw> = [
|
||||
{
|
||||
path: '/',
|
||||
name: 'Home',
|
||||
component: Home
|
||||
},
|
||||
{
|
||||
path: '/about',
|
||||
name: 'About',
|
||||
component: () => import(/* webpackChunkName: "about" */ '@/views/About.vue')
|
||||
}
|
||||
]
|
||||
|
||||
export const router = createRouter({
|
||||
history: createWebHistory(process.env.BASE_URL),
|
||||
routes
|
||||
})
|
||||
6
src/shims-vue.d.ts
vendored
Normal file
6
src/shims-vue.d.ts
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
declare module '*.vue' {
|
||||
import { defineComponent } from 'vue'
|
||||
const component: ReturnType<typeof defineComponent>
|
||||
export default component
|
||||
}
|
||||
declare module 'pouchdb-adapter-indexeddb'
|
||||
8
src/store/store.ts
Normal file
8
src/store/store.ts
Normal file
@@ -0,0 +1,8 @@
|
||||
import { createStore } from 'vuex'
|
||||
|
||||
export const store = createStore({
|
||||
state: {},
|
||||
mutations: {},
|
||||
actions: {},
|
||||
modules: {}
|
||||
})
|
||||
8
src/styles/app.scss
Normal file
8
src/styles/app.scss
Normal file
@@ -0,0 +1,8 @@
|
||||
@charset "utf-8";
|
||||
@import '~bulma/bulma.sass';
|
||||
|
||||
html,
|
||||
body {
|
||||
text-align: center;
|
||||
min-height: 100vh;
|
||||
}
|
||||
5
src/views/About.vue
Normal file
5
src/views/About.vue
Normal file
@@ -0,0 +1,5 @@
|
||||
<template>
|
||||
<div class="about">
|
||||
<h1>This is an about page</h1>
|
||||
</div>
|
||||
</template>
|
||||
18
src/views/Home.vue
Normal file
18
src/views/Home.vue
Normal file
@@ -0,0 +1,18 @@
|
||||
<template>
|
||||
<div class="home">
|
||||
<img alt="Vue logo" src="@/assets/logo.png" />
|
||||
<HelloWorld msg="Welcome to OVA Template!" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { defineComponent } from 'vue'
|
||||
import HelloWorld from '@/components/HelloWorld.vue'
|
||||
|
||||
export default defineComponent({
|
||||
name: 'Home',
|
||||
components: {
|
||||
HelloWorld
|
||||
}
|
||||
})
|
||||
</script>
|
||||
Reference in New Issue
Block a user