From ffcc937235a505188a7c5cdb5eaace90357a6d9f Mon Sep 17 00:00:00 2001 From: Rohan Bansal Date: Fri, 20 Dec 2024 14:54:30 +0530 Subject: [PATCH] fix: check if router is already installed in Stonecrop --- nuxt/playground/doctypes/user.json | 440 +++++++++++------------ nuxt/src/runtime/pages/StonecropPage.vue | 13 +- nuxt/src/runtime/plugin.ts | 1 + stonecrop/src/plugins/index.ts | 9 +- 4 files changed, 232 insertions(+), 231 deletions(-) diff --git a/nuxt/playground/doctypes/user.json b/nuxt/playground/doctypes/user.json index abb81c07..61be5d80 100644 --- a/nuxt/playground/doctypes/user.json +++ b/nuxt/playground/doctypes/user.json @@ -4,305 +4,295 @@ "component": "ATable", "columns": [ { - "label": "Home Page", - "name": "home_page", - "fieldname": "home_page", + "label": "User ID", + "name": "id", + "fieldname": "id", "fieldtype": "Data", "align": "left", "edit": false, - "width": "35ch", - "format": "value => {return value.title}" + "width": "10ch" }, { - "label": "HTTP Method", - "name": "http_method", - "fieldname": "http_method", + "label": "Username", + "name": "username", + "fieldname": "username", "fieldtype": "Data", "align": "left", "edit": true, "width": "20ch" }, { - "label": "IP Address", - "name": "ip_address", - "fieldname": "ip_address", - "fieldtype": "Data", + "label": "Disabled", + "name": "disabled", + "fieldname": "disabled", + "fieldtype": "Check", "align": "left", "edit": false, - "width": "20ch" + "width": "10ch" }, { - "label": "Status", - "name": "status", - "fieldname": "status", - "fieldtype": "Data", + "label": "Created On", + "name": "creation", + "fieldname": "creation", + "fieldtype": "Date", + "align": "left", + "edit": true, + "width": "25ch" + }, + { + "label": "Modified On", + "name": "modified", + "fieldname": "modified", + "fieldtype": "Date", "align": "left", "edit": true, - "width": "35ch" + "width": "25ch" }, { - "label": "Report Date", - "name": "report_date", - "fieldname": "report_date", - "fieldtype": "component", - "modalComponent": "ADatePicker", + "label": "Owner", + "name": "owner", + "fieldname": "owner", + "fieldtype": "Data", "align": "center", "edit": true, - "width": "25ch", - "format": "value => { return (new Date(Number(value)).toLocaleDateString('en-US')) }" + "width": "20ch" + }, + { + "label": "Modified By", + "name": "modified_by", + "fieldname": "modified_by", + "fieldtype": "Data", + "align": "center", + "edit": true, + "width": "20ch" } ], "config": { "view": "list" }, "rows": [ { - "home_page": { - "title": "https://ceara.berlin", - "url": "https://ceara.berlin" - }, - "http_method": "HEAD", - "ip_address": "75.228.138.84", - "report_date": 1580804064118.311, - "status": "503 Service Unavailable" + "id": "usr_001", + "username": "john.doe", + "disabled": false, + "creation": "2024-01-15T08:30:00Z", + "modified": "2024-03-10T14:22:33Z", + "owner": "admin", + "modified_by": "system" }, { - "home_page": { - "title": "https://queenweed.info", - "url": "https://queenweed.info" - }, - "http_method": "DELETE", - "ip_address": "235.108.58.48", - "report_date": 1581164525628.4841, - "status": "510 Not Extended" + "id": "usr_002", + "username": "sarah.smith", + "disabled": false, + "creation": "2024-02-01T11:45:00Z", + "modified": "2024-02-01T11:45:00Z", + "owner": "admin", + "modified_by": "admin" }, { - "home_page": { - "title": "https://cequi.mil", - "url": "https://cequi.mil" - }, - "http_method": "OPTIONS", - "ip_address": "200.232.58.22", - "report_date": 1583326905436.858, - "status": "504 Gateway Timeout" + "id": "usr_003", + "username": "mike.wilson", + "disabled": true, + "creation": "2024-01-20T09:15:00Z", + "modified": "2024-03-15T16:30:00Z", + "owner": "admin", + "modified_by": "john.doe" }, { - "home_page": { - "title": "https://eel.net", - "url": "https://eel.net" - }, - "http_method": "DELETE", - "ip_address": "122.41.199.214", - "report_date": 1584696361760.598, - "status": "431 Request Header Fields Too Large" + "id": "usr_004", + "username": "emma.davis", + "disabled": false, + "creation": "2024-02-28T13:20:00Z", + "modified": "2024-02-28T13:20:00Z", + "owner": "system", + "modified_by": "system" }, { - "home_page": { - "title": "https://inmeats.jobs", - "url": "https://inmeats.jobs" - }, - "http_method": "PUT", - "ip_address": "5.123.57.245", - "report_date": 1585408663851.79, - "status": "409 Conflict" + "id": "usr_005", + "username": "robert.jones", + "disabled": false, + "creation": "2024-03-05T10:00:00Z", + "modified": "2024-03-05T10:00:00Z", + "owner": "admin", + "modified_by": "admin" }, { - "home_page": { - "title": "https://plimsol.biz", - "url": "https://plimsol.biz" - }, - "http_method": "DELETE", - "ip_address": "206.197.127.159", - "report_date": 1587534556173.34, - "status": "429 Too Many Requests" + "id": "usr_006", + "username": "wei.chen", + "disabled": false, + "creation": "2024-03-06T09:15:00Z", + "modified": "2024-03-06T09:15:00Z", + "owner": "system", + "modified_by": "system" }, { - "home_page": { - "title": "https://bogert.xxx", - "url": "https://bogert.xxx" - }, - "http_method": "HEAD", - "ip_address": "81.109.117.115", - "report_date": 1587553898966.296, - "status": "102 Processing" + "id": "usr_007", + "username": "sofia.rodriguez", + "disabled": false, + "creation": "2024-03-07T14:30:00Z", + "modified": "2024-03-15T11:20:00Z", + "owner": "admin", + "modified_by": "admin" }, { - "home_page": { - "title": "https://detail.helsinki", - "url": "https://detail.helsinki" - }, - "http_method": "GET", - "ip_address": "160.47.242.22", - "report_date": 1587619825150.0808, - "status": "511 Network Authentication Required" + "id": "usr_008", + "username": "yuki.tanaka", + "disabled": true, + "creation": "2024-03-08T16:45:00Z", + "modified": "2024-03-16T09:30:00Z", + "owner": "admin", + "modified_by": "system" }, { - "home_page": { - "title": "https://attentional.net", - "url": "https://attentional.net" - }, - "http_method": "PUT", - "ip_address": "103.146.82.109", - "report_date": 1587727848708.99, - "status": "424 Failed Dependency" + "id": "usr_009", + "username": "mohammed.ahmed", + "disabled": false, + "creation": "2024-03-09T10:20:00Z", + "modified": "2024-03-09T10:20:00Z", + "owner": "system", + "modified_by": "system" }, { - "home_page": { - "title": "https://abrar.com", - "url": "https://abrar.com" - }, - "http_method": "PUT", - "ip_address": "226.78.31.101", - "report_date": 1588241122692.152, - "status": "413 Request Entity Too Large" + "id": "usr_010", + "username": "priya.patel", + "disabled": false, + "creation": "2024-03-10T11:30:00Z", + "modified": "2024-03-10T11:30:00Z", + "owner": "admin", + "modified_by": "admin" }, { - "home_page": { - "title": "https://devastating.berlin", - "url": "https://devastating.berlin" - }, - "http_method": "OPTIONS", - "ip_address": "6.176.26.194", - "report_date": 1589238679474.172, - "status": "406 Not Acceptable" + "id": "usr_011", + "username": "hans.mueller", + "disabled": false, + "creation": "2024-03-11T13:15:00Z", + "modified": "2024-03-11T13:15:00Z", + "owner": "system", + "modified_by": "system" }, { - "home_page": { - "title": "https://bedlamic.travel", - "url": "https://bedlamic.travel" - }, - "http_method": "OPTIONS", - "ip_address": "87.81.29.141", - "report_date": 1591099793866.571, - "status": "307 Temporary Redirect" + "id": "usr_012", + "username": "ana.silva", + "disabled": true, + "creation": "2024-03-12T15:45:00Z", + "modified": "2024-03-17T14:20:00Z", + "owner": "admin", + "modified_by": "admin" }, { - "home_page": { - "title": "https://busybody.com", - "url": "https://busybody.com" - }, - "http_method": "PUT", - "ip_address": "27.160.191.202", - "report_date": 1593790276585.5168, - "status": "205 Reset Content" + "id": "usr_013", + "username": "jin.park", + "disabled": false, + "creation": "2024-03-13T09:30:00Z", + "modified": "2024-03-13T09:30:00Z", + "owner": "system", + "modified_by": "system" }, { - "home_page": { - "title": "https://diviner.rio", - "url": "https://diviner.rio" - }, - "http_method": "GET", - "ip_address": "150.205.7.49", - "report_date": 1597194101311.922, - "status": "306 Reserved" + "id": "usr_014", + "username": "olga.ivanova", + "disabled": false, + "creation": "2024-03-14T11:20:00Z", + "modified": "2024-03-14T11:20:00Z", + "owner": "admin", + "modified_by": "admin" }, { - "home_page": { - "title": "https://cinter.wf", - "url": "https://cinter.wf" - }, - "http_method": "DELETE", - "ip_address": "49.84.170.124", - "report_date": 1597294401553.942, - "status": "417 Expectation Failed" + "id": "usr_015", + "username": "ahmed.hassan", + "disabled": false, + "creation": "2024-03-15T14:40:00Z", + "modified": "2024-03-15T14:40:00Z", + "owner": "system", + "modified_by": "system" }, { - "home_page": { - "title": "https://amusing.istanbul", - "url": "https://amusing.istanbul" - }, - "http_method": "POST", - "ip_address": "133.171.161.201", - "report_date": 1597799367455.279, - "status": "409 Conflict" + "id": "usr_016", + "username": "maria.garcia", + "disabled": true, + "creation": "2024-03-16T16:15:00Z", + "modified": "2024-03-18T10:30:00Z", + "owner": "admin", + "modified_by": "system" }, { - "home_page": { - "title": "https://masseurs.ba", - "url": "https://masseurs.ba" - }, - "http_method": "OPTIONS", - "ip_address": "212.197.88.171", - "report_date": 1597877957532.915, - "status": "414 Request URI Too Long" + "id": "usr_017", + "username": "lars.andersson", + "disabled": false, + "creation": "2024-03-17T10:45:00Z", + "modified": "2024-03-17T10:45:00Z", + "owner": "system", + "modified_by": "system" }, { - "home_page": { - "title": "https://darrel.om", - "url": "https://darrel.om" - }, - "http_method": "GET", - "ip_address": "81.50.236.159", - "report_date": 1597945294250.901, - "status": "501 Not Implemented" + "id": "usr_018", + "username": "mei.wang", + "disabled": false, + "creation": "2024-03-18T13:20:00Z", + "modified": "2024-03-18T13:20:00Z", + "owner": "admin", + "modified_by": "admin" }, { - "home_page": { - "title": "https://pityriasis.data", - "url": "https://pityriasis.data" - }, - "http_method": "PUT", - "ip_address": "2.35.182.4", - "report_date": 1598567196827.72, - "status": "305 Use Proxy" + "id": "usr_019", + "username": "francesco.rossi", + "disabled": false, + "creation": "2024-03-19T15:50:00Z", + "modified": "2024-03-19T15:50:00Z", + "owner": "system", + "modified_by": "system" }, { - "home_page": { - "title": "https://carnell.int", - "url": "https://carnell.int" - }, - "http_method": "POST", - "ip_address": "254.216.8.135", - "report_date": 1598620551534.259, - "status": "406 Not Acceptable" + "id": "usr_020", + "username": "seo.jin", + "disabled": true, + "creation": "2024-03-20T09:10:00Z", + "modified": "2024-03-20T16:45:00Z", + "owner": "admin", + "modified_by": "admin" }, { - "home_page": { - "title": "https://spelter.dance", - "url": "https://spelter.dance" - }, - "http_method": "CONNECT", - "ip_address": "49.60.139.38", - "report_date": 1600670086438.613, - "status": "407 Proxy Authentication Required" + "id": "usr_021", + "username": "elena.popov", + "disabled": false, + "creation": "2024-03-21T11:30:00Z", + "modified": "2024-03-21T11:30:00Z", + "owner": "system", + "modified_by": "system" }, { - "home_page": { - "title": "https://apostrophe.mail", - "url": "https://apostrophe.mail" - }, - "http_method": "CONNECT", - "ip_address": "97.25.126.232", - "report_date": 1600735768366.907, - "status": "500 Internal Server Error" + "id": "usr_022", + "username": "carlos.lopez", + "disabled": false, + "creation": "2024-03-22T14:15:00Z", + "modified": "2024-03-22T14:15:00Z", + "owner": "admin", + "modified_by": "admin" }, { - "home_page": { - "title": "https://amelina.stockholm", - "url": "https://amelina.stockholm" - }, - "http_method": "POST", - "ip_address": "169.116.119.109", - "report_date": 1601126772802.768, - "status": "422 Unprocessable Entity" + "id": "usr_023", + "username": "fatima.ahmed", + "disabled": false, + "creation": "2024-03-23T16:40:00Z", + "modified": "2024-03-23T16:40:00Z", + "owner": "system", + "modified_by": "system" }, { - "home_page": { - "title": "https://arming.net", - "url": "https://arming.net" - }, - "http_method": "POST", - "ip_address": "107.147.13.95", - "report_date": 1605215400250.367, - "status": "307 Temporary Redirect" + "id": "usr_024", + "username": "antonio.ferrari", + "disabled": true, + "creation": "2024-03-24T10:20:00Z", + "modified": "2024-03-24T15:30:00Z", + "owner": "admin", + "modified_by": "system" }, { - "home_page": { - "title": "https://whimbrels.com", - "url": "https://whimbrels.com" - }, - "http_method": "OPTIONS", - "ip_address": "60.233.119.67", - "report_date": 1606020776334.481, - "status": "417 Expectation Failed" + "id": "usr_025", + "username": "ji.kim", + "disabled": false, + "creation": "2024-03-25T13:45:00Z", + "modified": "2024-03-25T13:45:00Z", + "owner": "system", + "modified_by": "system" } ] } diff --git a/nuxt/src/runtime/pages/StonecropPage.vue b/nuxt/src/runtime/pages/StonecropPage.vue index 59056fb5..2408af51 100644 --- a/nuxt/src/runtime/pages/StonecropPage.vue +++ b/nuxt/src/runtime/pages/StonecropPage.vue @@ -1,11 +1,18 @@ diff --git a/nuxt/src/runtime/plugin.ts b/nuxt/src/runtime/plugin.ts index 07e00bc3..7ab8dc08 100644 --- a/nuxt/src/runtime/plugin.ts +++ b/nuxt/src/runtime/plugin.ts @@ -9,6 +9,7 @@ import { defineNuxtPlugin } from '#app' export default defineNuxtPlugin(_nuxtApp => { const pinia = createPinia() const router = useRouter() + const app = _nuxtApp.vueApp app.use(pinia) app.use(AForm) diff --git a/stonecrop/src/plugins/index.ts b/stonecrop/src/plugins/index.ts index ea5ec49f..9d3cfc45 100644 --- a/stonecrop/src/plugins/index.ts +++ b/stonecrop/src/plugins/index.ts @@ -6,10 +6,13 @@ import type { InstallOptions } from '../types' const plugin: Plugin = { install: (app: App, options?: InstallOptions) => { - const registry = new Registry(options?.router, options?.getMeta) + // check if the router is already installed via another plugin + const existingRouter = app.config.globalProperties.$router + const appRouter = existingRouter || options?.router + const registry = new Registry(appRouter, options?.getMeta) - if (options?.router) { - app.use(options.router) + if (!existingRouter && appRouter) { + app.use(appRouter) } app.use(pinia)