mirror of
https://github.com/kou029w/hasura-rest-hands-on.git
synced 2025-01-18 16:08:14 +00:00
use vite and composition api
This commit is contained in:
parent
5c9c50a4b4
commit
1cd14fe1d5
8 changed files with 346 additions and 7985 deletions
|
@ -10,10 +10,6 @@
|
|||
{{#include ../frontend/src/App.vue}}
|
||||
```
|
||||
|
||||
![](https://lh3.googleusercontent.com/Z6UJraog11NnBg8lhyrAcdWRhfTEjTbOMv2kRLGTDzJF-d28Bn4MN7W-kymVztsbMa5SGXx8qS-NQoKF9o_pu2UlI9FJyS4AljIEOcJMULEsic-jk5TbOHtBF0eCerbGaQAcxb45qw=w1280)
|
||||
|
||||
![](https://lh3.googleusercontent.com/WYpxLUGM52BZ0m5cQ_ZsEjfljdwLbaFkN47XTKp0Z9BPsDPhVImcR3rt9oWop-59ABCF2ubfsQOw2yyZAoT1GIkcjnZ4DCReg5Qn22pyOVT6DblipYIg3S0OZekcCziKxX9Fc6x_BA=w1280)
|
||||
|
||||
Hasuraのコンソールにアクセスすると、実際にデータが更新されていることを確認できます。
|
||||
|
||||
![](https://lh3.googleusercontent.com/twteosRUkmMlBoa8PXU3UXC9umek-TzQ1kwOWZIShW7fKvW_4tVtG7B3Ue-olldhxh05x1JTFtt_Oxn2nLxcDPEGBv32bkE2zjpqL7heEjV54jkDgYqOm1tEq02qvnKoqu5yaSKRZA=w800)
|
||||
|
|
|
@ -1,3 +0,0 @@
|
|||
module.exports = {
|
||||
presets: ["@vue/cli-plugin-babel/preset"],
|
||||
};
|
|
@ -1 +1,3 @@
|
|||
{ "template": "vue-cli" }
|
||||
{
|
||||
"template": "nuxt"
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width" />
|
||||
<title>vue3-hasura-rest</title>
|
||||
<script type="module" src="/src/main.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="app"></div>
|
|
@ -3,18 +3,17 @@
|
|||
"version": "1.0.0",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"serve": "vue-cli-service serve",
|
||||
"build": "vue-cli-service build"
|
||||
"dev": "vite",
|
||||
"build": "vite build"
|
||||
},
|
||||
"dependencies": {
|
||||
"@vueup/vue-quill": "^1.0.0-beta.7",
|
||||
"axios": "^0.21.1",
|
||||
"@vueup/vue-quill": "^1.0.0-beta.8",
|
||||
"axios": "^0.26.0",
|
||||
"lodash.debounce": "^4.0.8",
|
||||
"vue": "^3.1.5"
|
||||
"vue": "^3.2.31"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@vue/cli-plugin-babel": "^4.5.13",
|
||||
"@vue/cli-service": "^4.5.13",
|
||||
"@vue/compiler-sfc": "^3.1.5"
|
||||
"@vitejs/plugin-vue": "^2.2.2",
|
||||
"vite": "^2.8.4"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,13 +1,5 @@
|
|||
<template>
|
||||
<QuillEditor
|
||||
ref="editor"
|
||||
:content="{ ops: [{ insert: '読み込み中…' }] }"
|
||||
@update:content="update"
|
||||
toolbar="full"
|
||||
/>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { ref, onMounted } from "vue";
|
||||
import { QuillEditor } from "@vueup/vue-quill";
|
||||
import "@vueup/vue-quill/dist/vue-quill.snow.css";
|
||||
import axios from "axios";
|
||||
|
@ -17,19 +9,29 @@ import debounce from "lodash.debounce";
|
|||
const endpoint = "https://memo-demo.hasura.app/api/rest/page/1";
|
||||
|
||||
export default {
|
||||
name: "App",
|
||||
components: { QuillEditor },
|
||||
beforeMount() {
|
||||
this.update = debounce(async (content) => {
|
||||
setup() {
|
||||
const editor = ref();
|
||||
onMounted(async () => {
|
||||
const res = await axios.get(endpoint);
|
||||
const content = res.data.page?.content;
|
||||
editor.value.setContents(content);
|
||||
console.log("content", content);
|
||||
});
|
||||
const update = debounce(async (content) => {
|
||||
await axios.put(endpoint, { content });
|
||||
console.log("updated", content);
|
||||
}, 1000);
|
||||
},
|
||||
async mounted() {
|
||||
const res = await axios.get(endpoint);
|
||||
const content = res.data.page?.content;
|
||||
this.$refs.editor.setContents(content);
|
||||
console.log("content", content);
|
||||
return { editor, update };
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<QuillEditor
|
||||
ref="editor"
|
||||
:content="{ ops: [{ insert: '読み込み中…' }] }"
|
||||
@update:content="update"
|
||||
toolbar="full"
|
||||
/>
|
||||
</template>
|
||||
|
|
13
frontend/vite.config.js
Normal file
13
frontend/vite.config.js
Normal file
|
@ -0,0 +1,13 @@
|
|||
import { defineConfig } from "vite";
|
||||
import vue from "@vitejs/plugin-vue";
|
||||
|
||||
export default defineConfig({
|
||||
plugins: [vue()],
|
||||
...(process.env.CODESANDBOX_SSE === "true" && {
|
||||
server: {
|
||||
hmr: {
|
||||
port: 443,
|
||||
},
|
||||
},
|
||||
}),
|
||||
});
|
8253
frontend/yarn.lock
8253
frontend/yarn.lock
File diff suppressed because it is too large
Load diff
Loading…
Add table
Reference in a new issue