From 5ce8c0f979717a86d69ef59a54c47f20397cfd0f Mon Sep 17 00:00:00 2001 From: Kushizaki Date: Mon, 18 Aug 2025 13:52:23 +0900 Subject: [PATCH] =?UTF-8?q?=E8=B3=AA=E5=95=8F=E4=B8=80=E8=A6=A7=E3=81=AB?= =?UTF-8?q?=E9=96=A2=E3=81=99=E3=82=8Bvue=E3=83=95=E3=82=A1=E3=82=A4?= =?UTF-8?q?=E3=83=AB=E5=89=8A=E9=99=A4=E3=81=A8=E3=81=9D=E3=82=8C=E3=81=AB?= =?UTF-8?q?=E4=BC=B4=E3=81=86application.js=E3=81=AE=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/javascript/VueMounter.js | 76 ---------------- app/javascript/components/question.vue | 113 ----------------------- app/javascript/components/questions.vue | 115 ------------------------ app/javascript/packs/application.js | 7 -- 4 files changed, 311 deletions(-) delete mode 100644 app/javascript/VueMounter.js delete mode 100644 app/javascript/components/question.vue delete mode 100644 app/javascript/components/questions.vue diff --git a/app/javascript/VueMounter.js b/app/javascript/VueMounter.js deleted file mode 100644 index 900407b9ec5..00000000000 --- a/app/javascript/VueMounter.js +++ /dev/null @@ -1,76 +0,0 @@ -import Vue from 'vue' -import store from './check-store.js' - -export default class VueMounter { - constructor() { - this.components = {} - } - - addComponent(component) { - const name = component.name - this.components[name] = component - } - - mount() { - document.addEventListener('DOMContentLoaded', () => { - const elements = document.querySelectorAll('[data-vue]') - if (elements.length > 0) { - elements.forEach((element) => { - const name = element.dataset.vue - const props = this._convertProps(element.dataset) - const component = this.components[name] - - new Vue({ - store, - render: (h) => h(component, { props: props }) - }).$mount(`[data-vue="${name}"]`) - }) - } - }) - } - - _convertProps(props) { - const objects = {} - - Object.keys(props) - .filter((key) => key.match(/^vue.+/)) - .forEach((key) => { - const rawKey = key.replace(/^vue/, '') - const keyWithType = this._camelCase(rawKey) - const matches = keyWithType.match(/:(.+)$/) - - const type = matches ? matches[1] : undefined - const propKey = matches ? keyWithType.replace(/:.+$/, '') : keyWithType - const value = matches ? this._parse(props[key], type) : props[key] - - objects[propKey] = value - }) - return objects - } - - _parse(value, type) { - if (type === 'number') { - return Number(value) - } else if (type === 'boolean') { - const v = value.toLowerCase() - if (v === 'false' || v === 'nil' || v === '') { - return false - } else { - return true - } - } else if (type === 'json') { - return JSON.parse(value) - } else if (type === 'string') { - return String(value) - } else { - return value - } - } - - _camelCase(string) { - string = string.charAt(0).toLowerCase() + string.slice(1) - return string.replace(/[-_](.)/g, (_, group1) => { - return group1.toUpperCase() - }) - } -} diff --git a/app/javascript/components/question.vue b/app/javascript/components/question.vue deleted file mode 100644 index e8b76b6d75c..00000000000 --- a/app/javascript/components/question.vue +++ /dev/null @@ -1,113 +0,0 @@ - - diff --git a/app/javascript/components/questions.vue b/app/javascript/components/questions.vue deleted file mode 100644 index cab652836fb..00000000000 --- a/app/javascript/components/questions.vue +++ /dev/null @@ -1,115 +0,0 @@ - - - diff --git a/app/javascript/packs/application.js b/app/javascript/packs/application.js index a42ec30f151..9ef515d81ec 100644 --- a/app/javascript/packs/application.js +++ b/app/javascript/packs/application.js @@ -85,15 +85,8 @@ import '../action_completed_button.js' import '../toast.js' import '../tag.js' -import VueMounter from '../VueMounter.js' -import Questions from '../components/questions.vue' - import '../stylesheets/application' -const mounter = new VueMounter() -mounter.addComponent(Questions) -mounter.mount() - // Support component names relative to this directory: const componentRequireContext = require.context('components', true) const ReactRailsUJS = require('react_ujs')