diff --git a/.github/workflows/client.yml b/.github/workflows/client.yml index 756d6ae..783aba3 100644 --- a/.github/workflows/client.yml +++ b/.github/workflows/client.yml @@ -47,12 +47,15 @@ jobs: - name: Build run: pnpm build + # cdn 部署 - name: Deploy static source run: pnpm cdn ${{ secrets.ACCESS_KEY_ID }} ${{ secrets.ACCESS_KEY_SECRET }} ${{ secrets.OSS_BUCKET }} ${{ secrets.OSS_REGION }} + # 移除 部署 cdn 的文件 - name: remove static file which is deploy cdn run: rm -rf dist/assets + # 推到服务器 - name: Deploy to Server # 第二步,rsync推文件 uses: AEnterprise/rsync-deploy@v1.0 # 使用别人包装好的步骤镜像 env: @@ -64,6 +67,7 @@ jobs: USERNAME: ${{ secrets.SSH_USER }} # 引用配置,服务器登录名 SERVER_DESTINATION: /root/project/runcodeclient # 部署到目标文件夹 + # nginx 重启 - name: Restart server # 第三步,重启服务 uses: appleboy/ssh-action@master with: diff --git a/client/src/assets/github.png b/client/src/assets/github.png deleted file mode 100644 index 524dc52..0000000 Binary files a/client/src/assets/github.png and /dev/null differ diff --git a/client/src/pages/editor/components/Operator.tsx b/client/src/pages/editor/components/Operator.tsx index 84beb5e..b0bcd6b 100644 --- a/client/src/pages/editor/components/Operator.tsx +++ b/client/src/pages/editor/components/Operator.tsx @@ -95,18 +95,21 @@ function Operator(props: Props) { const editor = getEditor(); if (editor) { + const debounceSaveCode = debounce(saveCode, autoSaveDelay * 1000); const saveCodeListen = editor ?.getModel() - ?.onDidChangeContent(debounce(saveCode, autoSaveDelay * 1000)); + ?.onDidChangeContent(debounceSaveCode); const saveDisabledListen = editor?.getModel()?.onDidChangeContent(() => { setSaveDisabled(false); }); return () => { saveCodeListen?.dispose(); saveDisabledListen?.dispose(); + // 取消前一个 debounce + debounceSaveCode.cancel(); }; } - }, [autoSaveDelay]); + }, [codeType, getEditor, autoSaveDelay]); const renderInput = () => { return ( diff --git a/client/src/pages/editor/index.tsx b/client/src/pages/editor/index.tsx index cbff79c..3d5d9e7 100644 --- a/client/src/pages/editor/index.tsx +++ b/client/src/pages/editor/index.tsx @@ -7,6 +7,8 @@ import { observer } from 'mobx-react-lite'; import EditorConfig from '~store/config/editor'; import Header, { settingDrawerId } from './components/Header'; import Operator from './components/Operator'; +import storage from '~utils/storage'; +import { CodeStorageKey } from '~constant/storage'; const Component = observer(() => { const editorRef = useRef(null); @@ -31,6 +33,8 @@ const Component = observer(() => { codeType={codeType} themeType={editorThemeType} onCodeTypeChange={(type) => { + // 切换语言前保存代码 + storage.set(CodeStorageKey[codeType], getEditor()?.getValue()); setCodeType(type); }} onThemeTypeChange={(type) => {