Browse Source

store init

master
pvincent 4 years ago
parent
commit
b53ec237a7
  1. 32
      .vscode/settings.json
  2. 6
      README.md
  3. 6
      TODO.md
  4. 2
      src/App.vue
  5. 0
      src/assets/index.css
  6. 29
      src/components/Basket.vue
  7. 8
      src/main.ts
  8. 8
      src/shims-vue.d.ts
  9. 7
      src/stores/global.ts
  10. 50
      vite.config.ts

32
.vscode/settings.json

@ -1,16 +1,20 @@
{ {
"eslint.enable": true,
"vetur.validation.template": false,
"vetur.validation.templateProps": true,
"vetur.validation.interpolation": true,
"editor.formatOnSave": true,
"editor.defaultFormatter": "esbenp.prettier-vscode",
"cSpell.words": [
"Astrologia",
"Kamal",
"Kamalātmikā",
"Yantra",
"protovue",
"tmik"
]
"eslint.enable": true,
"vetur.validation.template": false,
"vetur.validation.templateProps": true,
"vetur.validation.interpolation": true,
"editor.formatOnSave": true,
"editor.defaultFormatter": "esbenp.prettier-vscode",
"cSpell.enableFiletypes": ["markdown", "!typescript", "!json"],
"cSpell.words": [
"Astrologia",
"Codium",
"Dolibarr's",
"Kamal",
"Kamalātmikā",
"Yantra",
"protovue",
"tmik",
"windi"
]
} }

6
README.md

@ -16,11 +16,7 @@ npm run dev
HOW TO DEBUG HOW TO DEBUG
------------ ------------
```
# open codium IDE
codium .
# , then launch Debug in Firefox (or Chromium)
```
Codium / Debug in Firefox
HOW TO DEPLOY HOW TO DEPLOY
------------- -------------

6
TODO.md

@ -5,7 +5,7 @@ ARCHITECTURE
------------ ------------
* [x] vite + vue3 (up-to-date) * [x] vite + vue3 (up-to-date)
* [x] typescript suppport
* [x] typescript support
* [x] codium debug (Firefox, Chromium) * [x] codium debug (Firefox, Chromium)
* [x] git version control awareness * [x] git version control awareness
* [x] eslint * [x] eslint
@ -18,15 +18,13 @@ ARCHITECTURE
* [ ] axios * [ ] axios
* [ ] store solution * [ ] store solution
* [ ] vue3 handcraft solution OR * [ ] vue3 handcraft solution OR
* [ ] [pinia](https://github.com/posva/pinia)
* [ ] [devtool-v3](https://github.com/vuejs/vue-devtools/releases)
FEATURES FEATURES
-------- --------
* [ ] grab products, categories and images from Dolibarr's API * [ ] grab products, categories and images from Dolibarr's API
* [ ] parallelization
* [ ] parallelize
* [ ] scheduled action * [ ] scheduled action
* [ ] cache for images * [ ] cache for images
* [ ] login/logout * [ ] login/logout

2
src/App.vue

@ -32,6 +32,7 @@
<script lang="ts"> <script lang="ts">
import { defineComponent } from 'vue' import { defineComponent } from 'vue'
import Basket from './components/Basket.vue' import Basket from './components/Basket.vue'
declare const APP_TITLE, APP_VERSION, APP_REPOSITORY, APP_LICENSE
export default defineComponent({ export default defineComponent({
components: { components: {
@ -39,7 +40,6 @@ export default defineComponent({
}, },
setup() { setup() {
return { return {
/* eslint-disable no-undef */
title: APP_TITLE, title: APP_TITLE,
version: APP_VERSION, version: APP_VERSION,
repository: APP_REPOSITORY, repository: APP_REPOSITORY,

0
src/index.css → src/assets/index.css

29
src/components/Basket.vue

@ -2,35 +2,40 @@
<h1>{{ msg }}</h1> <h1>{{ msg }}</h1>
<button <button
class="border border-purple-200 rounded-full font-semibold py-1 px-4 text-sm text-purple-600 hover:bg-purple-600 hover:border-transparent hover:text-white focus:outline-none focus:ring-2 focus:ring-purple-600 focus:ring-offset-2" class="border border-purple-200 rounded-full font-semibold py-1 px-4 text-sm text-purple-600 hover:bg-purple-600 hover:border-transparent hover:text-white focus:outline-none focus:ring-2 focus:ring-purple-600 focus:ring-offset-2"
@click="count++"
@click="inc1"
> >
inc product {{ count }}
inc product {{ count1 }}
</button> </button>
<button <button
class="border border-purple-200 rounded-full font-semibold py-1 px-4 text-sm text-purple-600 hover:bg-purple-600 hover:border-transparent hover:text-white focus:outline-none focus:ring-2 focus:ring-purple-600 focus:ring-offset-2" class="border border-purple-200 rounded-full font-semibold py-1 px-4 text-sm text-purple-600 hover:bg-purple-600 hover:border-transparent hover:text-white focus:outline-none focus:ring-2 focus:ring-purple-600 focus:ring-offset-2"
@click="inc"
@click="inc2"
> >
inc
inc {{ count2 }}
</button> </button>
state = {{ state.count }}
</template> </template>
<script lang="ts"> <script lang="ts">
import global from '@/stores/global'
import { defineComponent, ref } from 'vue' import { defineComponent, ref } from 'vue'
export default defineComponent({ export default defineComponent({
props: { props: {
msg: { type: String, required: true } msg: { type: String, required: true }
}, },
setup() { setup() {
return {
count: ref(0)
}
const count1 = ref(0)
const count2 = ref(0)
const { state } = global
return { count1, count2, state }
}, },
methods: { methods: {
inc() {
// console.log('log count')
console.warn('warn count')
console.error('err count')
this.count++
inc1() {
console.warn(`inc1 ${this.count1}`)
this.count1++
},
inc2() {
console.error(`inc2 ${this.count2}`)
this.count2++
} }
} }
}) })

8
src/main.ts

@ -1,10 +1,10 @@
import { createApp } from 'vue' import { createApp } from 'vue'
import App from './App.vue'
import './index.css'
import 'windi.css' import 'windi.css'
// define title and version from package.json
// eslint-disable-next-line no-undef
import App from '@/App.vue'
import '@/assets/index.css'
declare const APP_TITLE: string
document.title = APP_TITLE document.title = APP_TITLE
createApp(App).mount('#app') createApp(App).mount('#app')

8
src/shims-vue.d.ts

@ -5,7 +5,7 @@ declare module '*.vue' {
} }
/* declare const which helps leveraging visibility of defined constants, loaded from `main.ts` file */ /* declare const which helps leveraging visibility of defined constants, loaded from `main.ts` file */
declare const APP_VERSION: string
declare const APP_TITLE: string
declare const APP_REPOSITORY: string
declare const APP_LICENSE: string
// declare const APP_VERSION: string
// declare const APP_TITLE: string
// declare const APP_REPOSITORY: string
// declare const APP_LICENSE: string

7
src/stores/global.ts

@ -0,0 +1,7 @@
import { reactive } from "vue"
export default {
state: reactive({
count: 404
})
}

50
vite.config.ts

@ -2,37 +2,43 @@ import pkg from './package.json'
import { execSync } from 'child_process' import { execSync } from 'child_process'
import vue from '@vitejs/plugin-vue' import vue from '@vitejs/plugin-vue'
import WindiCSS from 'vite-plugin-windicss' import WindiCSS from 'vite-plugin-windicss'
import { resolve } from "path"
export default { export default {
plugins: [
vue(),
WindiCSS()
],
define: {
APP_TITLE: JSON.stringify(pkg.name),
APP_VERSION: JSON.stringify(buildVersion()),
APP_REPOSITORY: JSON.stringify(pkg.repository),
APP_LICENSE: JSON.stringify(pkg.license),
}
plugins: [
vue(),
WindiCSS()
],
define: {
APP_TITLE: JSON.stringify(pkg.name),
APP_VERSION: JSON.stringify(buildVersion()),
APP_REPOSITORY: JSON.stringify(pkg.repository),
APP_LICENSE: JSON.stringify(pkg.license),
},
resolve: {
alias: {
"@": resolve(__dirname, "src"),
},
},
} }
// FUNCTIONS // FUNCTIONS
//---------- //----------
function buildVersion(): string { function buildVersion(): string {
const version = pkg.version
if (!isGitCommand()) {
return version
}
const dirty = Number(execSync("git status -s | wc -l").toString())
return dirty > 0 ? `${version}${dirty}` : version
const version = pkg.version
if (!isGitCommand()) {
return version
}
const dirty = Number(execSync("git status -s | wc -l").toString())
return dirty > 0 ? `${version}${dirty}` : version
} }
function isGitCommand(): boolean { function isGitCommand(): boolean {
try {
execSync("command -v git")
return true
} catch (e) {
return false
}
try {
execSync("command -v git")
return true
} catch (e) {
return false
}
} }
Loading…
Cancel
Save