diff --git a/.gitignore b/.gitignore index 71cb306..1d8670c 100644 --- a/.gitignore +++ b/.gitignore @@ -12,6 +12,7 @@ # next.js /.next/ /out/ +/public/casbin-version.json # production /build diff --git a/app/components/editor/index.tsx b/app/components/editor/index.tsx index b4fc4fa..f93a433 100755 --- a/app/components/editor/index.tsx +++ b/app/components/editor/index.tsx @@ -15,7 +15,7 @@ 'use client'; import React, { isValidElement, useState, useEffect } from 'react'; import { example, ModelKind } from './casbin-mode/example'; -import { e, m, p, r } from '@/app/components/editor/hooks/useSetupEnforceContext'; // prettier-ignore +import { e, m, p, r } from '@/app/components/editor/hooks/useSetupEnforceContext'; import { clsx } from 'clsx'; import CodeMirror from '@uiw/react-codemirror'; import { monokai } from '@uiw/codemirror-theme-monokai'; @@ -48,6 +48,16 @@ export const EditorScreen = () => { onChange: setEnforceContextDataPersistent, data: enforceContextData, }); + const [casbinVersion, setCasbinVersion] = useState(''); + + useEffect(() => { + const fetchCasbinVersion = async () => { + const response = await fetch('/casbin-version.json'); + const data = await response.json(); + setCasbinVersion(data.casbinVersion); + }; + fetchCasbinVersion(); + }, []); useEffect(() => { if (modelKind) { @@ -185,7 +195,14 @@ export const EditorScreen = () => {