From 915b5f48b4810091a99de4976a50f32bca2ab11a Mon Sep 17 00:00:00 2001 From: qwqcode Date: Mon, 8 Apr 2024 14:59:21 +0800 Subject: [PATCH] refactor(ui/prettier): add prettier code formatter --- .circleci/conditional_config.yml | 72 +- .circleci/config.yml | 2 +- .eslintrc.cjs | 4 +- .github/chglog/config.yml | 4 +- .github/dependabot.yml | 8 +- .github/workflows/build-app.yml | 6 +- .github/workflows/build-nightly.yml | 6 +- .github/workflows/build-tagging.yml | 2 +- .github/workflows/build-ui.yml | 2 +- .github/workflows/build.yml | 12 +- .github/workflows/codeql.yml | 69 +- .github/workflows/docs-cn.yml | 6 +- .github/workflows/release.yml | 8 +- .github/workflows/repo-dispatch.yml | 2 +- .github/workflows/test-docs.yml | 10 +- .github/workflows/test-frontend.yml | 12 +- .goreleaser.yml | 12 +- .prettierignore | 17 + .prettierrc | 26 +- .vscode/launch.json | 24 +- .vscode/settings.json | 34 +- .vscode/tasks.json | 24 +- CONTRIBUTING.md | 6 +- README.en.md | 7 +- README.md | 8 +- conf/artalk.example.simple.yml | 66 +- conf/artalk.example.yml | 66 +- conf/artalk.example.zh-CN.yml | 72 +- docs/docs/.vitepress/config.ts | 237 ++-- docs/docs/.vitepress/theme/Artalk.vue | 67 +- docs/docs/.vitepress/theme/Artransfer.vue | 12 +- docs/docs/.vitepress/theme/Layout.vue | 3 - docs/docs/.vitepress/theme/index.ts | 2 +- docs/docs/.vitepress/theme/style.scss | 53 +- docs/docs/.vitepress/types/shims-vue.d.ts | 6 +- docs/docs/develop/api-old.md | 546 +++---- docs/docs/develop/event.md | 53 +- docs/docs/develop/fe-api.md | 6 +- docs/docs/develop/index.md | 17 +- docs/docs/develop/plugs.md | 46 +- docs/docs/guide/backend/admin_notify.md | 143 +- docs/docs/guide/backend/build.md | 6 +- docs/docs/guide/backend/captcha.md | 55 +- docs/docs/guide/backend/config.md | 78 +- docs/docs/guide/backend/daemon.md | 2 +- docs/docs/guide/backend/docker.md | 2 +- docs/docs/guide/backend/email.md | 72 +- docs/docs/guide/backend/fe-control.md | 10 +- docs/docs/guide/backend/img-upload.md | 30 +- docs/docs/guide/backend/moderator.md | 42 +- docs/docs/guide/backend/multi-site.md | 22 +- docs/docs/guide/backend/notify.md | 5 +- docs/docs/guide/backend/relative-path.md | 12 +- docs/docs/guide/backend/reverse-proxy.md | 3 +- docs/docs/guide/deploy.md | 49 +- docs/docs/guide/describe.md | 2 +- docs/docs/guide/extras.md | 1 - docs/docs/guide/frontend/config.md | 12 +- docs/docs/guide/frontend/emoticons.md | 137 +- docs/docs/guide/frontend/i18n.md | 20 +- docs/docs/guide/frontend/import-blog.md | 25 +- docs/docs/guide/frontend/import-framework.md | 82 +- docs/docs/guide/frontend/ip-region.md | 16 +- docs/docs/guide/frontend/latex.md | 12 +- docs/docs/guide/frontend/lightbox.md | 32 +- docs/docs/guide/frontend/pv.md | 12 +- docs/docs/guide/intro.md | 54 +- docs/docs/guide/transfer.md | 60 +- docs/docs/tsconfig.json | 2 +- i18n/fr.yml | 26 +- i18n/zh-CN.yml | 14 +- i18n/zh-TW.yml | 14 +- internal/captcha/pages/geetest.html | 106 +- internal/captcha/pages/hcaptcha.html | 91 +- internal/captcha/pages/recaptcha.html | 90 +- internal/captcha/pages/turnstile.html | 93 +- internal/template/email_tpl/default.html | 57 +- package.json | 3 + pnpm-lock.yaml | 90 +- pnpm-workspace.yaml | 5 +- public/index.html | 26 +- test/fixtures/comments.yml | 116 +- test/fixtures/pages.yml | 2 +- test/ssg-test/.vitepress/config.mts | 18 +- test/ssg-test/.vitepress/theme/Artalk.vue | 37 +- test/ssg-test/.vitepress/theme/Footer.vue | 7 +- test/ssg-test/.vitepress/theme/Layout.vue | 4 - test/ssg-test/.vitepress/theme/index.ts | 4 +- test/ssg-test/.vitepress/theme/style.css | 17 +- test/ssg-test/api-examples.md | 6 + test/ssg-test/index.md | 5 +- test/ssg-test/package.json | 2 +- test/ssg-test/pnpm-lock.yaml | 1249 ----------------- test/testdata/example_site_conf.yml | 78 +- test/testdata/model_test_conf.yml | 21 +- test/vue-test/README.md | 4 +- test/vue-test/index.html | 8 +- test/vue-test/package.json | 2 +- test/vue-test/pnpm-lock.yaml | 1012 ------------- test/vue-test/src/components/Artalk.vue | 4 - test/vue-test/src/router/index.ts | 8 +- test/vue-test/vite.config.ts | 10 +- ui/artalk-sidebar/.eslintrc.cjs | 8 +- ui/artalk-sidebar/index.html | 2 +- ui/artalk-sidebar/src/App.vue | 43 +- .../src/components/FileUploader.vue | 22 +- ui/artalk-sidebar/src/components/Header.vue | 13 +- .../src/components/ItemTextEditor.vue | 24 +- .../src/components/LoadingLayer.vue | 6 +- .../src/components/LogTerminal.vue | 5 +- .../src/components/PageEditor.vue | 53 +- .../src/components/Pagination.vue | 71 +- .../src/components/PreferenceArr.vue | 2 +- .../src/components/PreferenceGrp.vue | 18 +- .../src/components/PreferenceItem.vue | 54 +- .../src/components/SiteCreate.vue | 55 +- .../src/components/SiteEditor.vue | 53 +- .../src/components/SiteSwitcher.vue | 36 +- ui/artalk-sidebar/src/components/Tab.vue | 50 +- .../src/components/UserEditor.vue | 81 +- ui/artalk-sidebar/src/global.ts | 14 +- ui/artalk-sidebar/src/i18n/messages.ts | 6 +- ui/artalk-sidebar/src/lib/settings-option.ts | 59 +- ui/artalk-sidebar/src/lib/settings.ts | 8 +- ui/artalk-sidebar/src/main.ts | 4 +- ui/artalk-sidebar/src/pages/comments.vue | 49 +- ui/artalk-sidebar/src/pages/index.vue | 4 +- ui/artalk-sidebar/src/pages/login.vue | 91 +- ui/artalk-sidebar/src/pages/pages.vue | 67 +- ui/artalk-sidebar/src/pages/settings.vue | 41 +- ui/artalk-sidebar/src/pages/sites.vue | 38 +- ui/artalk-sidebar/src/pages/transfer.vue | 43 +- ui/artalk-sidebar/src/pages/users.vue | 70 +- ui/artalk-sidebar/src/stores/nav.ts | 43 +- ui/artalk-sidebar/src/stores/user.ts | 5 +- ui/artalk-sidebar/src/style.scss | 21 +- ui/artalk-sidebar/src/style/_extends.scss | 6 +- ui/artalk-sidebar/src/style/_variables.scss | 3 +- ui/artalk-sidebar/vite.config.ts | 20 +- ui/artalk/.eslintrc.cjs | 4 +- ui/artalk/index.html | 393 ++++-- ui/artalk/playwright.config.ts | 23 +- ui/artalk/postcss.config.js | 2 +- ui/artalk/scripts/build-i18n.ts | 4 +- ui/artalk/src/api/fetch.ts | 23 +- ui/artalk/src/api/handler.ts | 17 +- ui/artalk/src/api/index.ts | 2 +- ui/artalk/src/artalk.ts | 10 +- ui/artalk/src/comment/actions.ts | 70 +- ui/artalk/src/comment/comment-node.ts | 11 +- ui/artalk/src/comment/height-limit.ts | 31 +- ui/artalk/src/comment/render.ts | 40 +- ui/artalk/src/comment/renders/actions.ts | 22 +- ui/artalk/src/comment/renders/avatar.ts | 4 +- ui/artalk/src/comment/renders/header.ts | 13 +- ui/artalk/src/comment/renders/index.ts | 11 +- ui/artalk/src/comment/renders/reply-at.ts | 8 +- ui/artalk/src/comment/renders/reply-to.ts | 4 +- ui/artalk/src/components/action-btn.ts | 10 +- ui/artalk/src/components/checker/admin.ts | 16 +- .../src/components/checker/captcha-renders.ts | 27 +- ui/artalk/src/components/checker/captcha.ts | 6 +- ui/artalk/src/components/checker/index.ts | 54 +- ui/artalk/src/components/dialog.ts | 10 +- ui/artalk/src/components/error-dialog.ts | 7 +- ui/artalk/src/components/pagination.ts | 43 +- ui/artalk/src/components/read-more-btn.ts | 13 +- ui/artalk/src/config.ts | 48 +- ui/artalk/src/context.ts | 22 +- ui/artalk/src/data.ts | 22 +- ui/artalk/src/defaults.ts | 2 +- ui/artalk/src/editor/editor.html | 8 +- ui/artalk/src/editor/editor.ts | 22 +- ui/artalk/src/editor/state.ts | 15 +- ui/artalk/src/i18n/external.ts | 7 +- ui/artalk/src/i18n/index.ts | 12 +- ui/artalk/src/i18n/jp.ts | 166 +-- ui/artalk/src/layer/layer.ts | 5 +- ui/artalk/src/layer/scrollbar-helper.ts | 7 +- ui/artalk/src/layer/sidebar-layer.html | 4 +- ui/artalk/src/layer/sidebar-layer.ts | 42 +- ui/artalk/src/layer/wrap.ts | 10 +- ui/artalk/src/lib/component.ts | 4 +- ui/artalk/src/lib/event-manager.ts | 24 +- ui/artalk/src/lib/marked-renderer.ts | 47 +- ui/artalk/src/lib/marked.ts | 40 +- ui/artalk/src/lib/merge-deep.test.ts | 20 +- ui/artalk/src/lib/merge-deep.ts | 4 +- ui/artalk/src/lib/sanitizer.ts | 77 +- ui/artalk/src/lib/ui.ts | 49 +- ui/artalk/src/lib/user.ts | 8 +- ui/artalk/src/lib/utils.ts | 58 +- ui/artalk/src/lib/watch-conf.ts | 10 +- ui/artalk/src/list/comment.ts | 14 +- ui/artalk/src/list/layout/flat.ts | 12 +- ui/artalk/src/list/layout/index.ts | 6 +- ui/artalk/src/list/layout/nest.ts | 4 +- ui/artalk/src/list/list.html | 2 +- ui/artalk/src/list/list.ts | 26 +- ui/artalk/src/list/nest.ts | 11 +- ui/artalk/src/list/page.ts | 11 +- ui/artalk/src/list/paginator/up-down.ts | 4 +- ui/artalk/src/load.ts | 78 +- ui/artalk/src/plugins/admin-only-elem.ts | 18 +- ui/artalk/src/plugins/dark-mode.ts | 4 +- ui/artalk/src/plugins/editor-kit.ts | 100 +- ui/artalk/src/plugins/editor/_kit.ts | 7 +- ui/artalk/src/plugins/editor/_plug.ts | 5 +- ui/artalk/src/plugins/editor/closable.ts | 6 +- ui/artalk/src/plugins/editor/emoticons.scss | 2 +- ui/artalk/src/plugins/editor/emoticons.ts | 93 +- ui/artalk/src/plugins/editor/header-event.ts | 21 +- ui/artalk/src/plugins/editor/header-user.ts | 42 +- ui/artalk/src/plugins/editor/index.ts | 21 +- ui/artalk/src/plugins/editor/mover.ts | 5 +- ui/artalk/src/plugins/editor/preview.ts | 4 +- ui/artalk/src/plugins/editor/state-edit.ts | 9 +- ui/artalk/src/plugins/editor/state-reply.ts | 22 +- ui/artalk/src/plugins/editor/submit-add.ts | 12 +- ui/artalk/src/plugins/editor/submit.ts | 2 +- ui/artalk/src/plugins/editor/upload.ts | 30 +- ui/artalk/src/plugins/index.ts | 8 +- ui/artalk/src/plugins/list/copyright.ts | 4 +- ui/artalk/src/plugins/list/count.ts | 6 +- ui/artalk/src/plugins/list/dropdown.ts | 58 +- ui/artalk/src/plugins/list/error-dialog.ts | 3 +- ui/artalk/src/plugins/list/fetch.ts | 13 +- ui/artalk/src/plugins/list/goto-dispatcher.ts | 9 +- ui/artalk/src/plugins/list/goto-focus.ts | 10 +- ui/artalk/src/plugins/list/index.ts | 20 +- ui/artalk/src/plugins/list/loading.ts | 3 +- ui/artalk/src/plugins/list/reach-bottom.ts | 37 +- ui/artalk/src/plugins/list/sidebar-btn.ts | 7 +- ui/artalk/src/plugins/list/time-ticking.ts | 4 +- ui/artalk/src/plugins/list/unread-badge.ts | 2 +- ui/artalk/src/plugins/list/unread.ts | 15 +- ui/artalk/src/plugins/list/with-editor.ts | 8 +- ui/artalk/src/plugins/notifies.ts | 9 +- ui/artalk/src/plugins/stat.ts | 39 +- ui/artalk/src/plugins/version-check.ts | 11 +- ui/artalk/src/service.ts | 18 +- ui/artalk/src/style/_color.scss | 7 +- ui/artalk/src/style/_extend.scss | 6 +- ui/artalk/src/style/comment.scss | 29 +- ui/artalk/src/style/list.scss | 9 +- ui/artalk/src/style/main.scss | 141 +- ui/artalk/src/types/config.ts | 14 +- ui/artalk/src/types/context.ts | 19 +- ui/artalk/src/types/data.ts | 14 +- ui/artalk/src/types/event.ts | 55 +- ui/artalk/src/types/sidebar.ts | 2 +- ui/artalk/tests/e2e/comment-add.spec.ts | 4 +- ui/artalk/tests/html/ArtalkCount.html | 4 +- ui/artalk/tests/html/ArtalkI18n.html | 4 +- ui/artalk/tests/html/ArtalkLite.html | 4 +- ui/artalk/tests/html/CSRF.html | 44 +- ui/artalk/tests/setup.ts | 2 +- ui/artalk/tests/ui-api.test.ts | 108 +- ui/artalk/tsconfig.json | 2 +- ui/artalk/vite.config.ts | 60 +- ui/artalk/vitest.config.ts | 4 +- ui/plugin-katex/index.html | 48 +- ui/plugin-katex/main.ts | 38 +- ui/plugin-katex/tsconfig.json | 2 +- ui/plugin-katex/vite.config.ts | 13 +- ui/plugin-lightbox/global.d.ts | 8 +- ui/plugin-lightbox/index.html | 132 +- ui/plugin-lightbox/main.ts | 38 +- ui/plugin-lightbox/tsconfig.json | 2 +- ui/plugin-lightbox/vite.config.ts | 13 +- 270 files changed, 4626 insertions(+), 5716 deletions(-) create mode 100644 .prettierignore delete mode 100644 test/ssg-test/pnpm-lock.yaml delete mode 100644 test/vue-test/pnpm-lock.yaml diff --git a/.circleci/conditional_config.yml b/.circleci/conditional_config.yml index cd85891f7..181601d57 100644 --- a/.circleci/conditional_config.yml +++ b/.circleci/conditional_config.yml @@ -10,7 +10,7 @@ executors: - image: cimg/base:stable node: docker: - - image: 'cimg/node:20.12.1' + - image: "cimg/node:20.12.1" go: docker: - image: cimg/go:1.22.1 @@ -26,43 +26,43 @@ parameters: jobs: ## Backend test_app: - executor: go - working_directory: ~/go/src/github.com/ArtalkJS/Artalk - environment: - GO111MODULE: "on" - steps: - - checkout - - run: - name: "Print the Go version" - command: > - go version - - restore_cache: - keys: - - go-mod-1.22.1-{{ checksum "go.sum" }} - - run: - name: Install Dependencies - command: go mod download - - save_cache: - key: go-mod-1.22.1-{{ checksum "go.sum" }} - paths: - - "~/go/pkg/mod" - - run: - name: Run tests - command: | - mkdir -p /tmp/test-reports - gotestsum --junitfile /tmp/test-reports/unit-tests.xml -- -coverprofile=/tmp/test-reports/coverage.out ./... - - store_test_results: - path: /tmp/test-reports - - codecov/upload: - flags: go - file: /tmp/test-reports/coverage.out + executor: go + working_directory: ~/go/src/github.com/ArtalkJS/Artalk + environment: + GO111MODULE: "on" + steps: + - checkout + - run: + name: "Print the Go version" + command: > + go version + - restore_cache: + keys: + - go-mod-1.22.1-{{ checksum "go.sum" }} + - run: + name: Install Dependencies + command: go mod download + - save_cache: + key: go-mod-1.22.1-{{ checksum "go.sum" }} + paths: + - "~/go/pkg/mod" + - run: + name: Run tests + command: | + mkdir -p /tmp/test-reports + gotestsum --junitfile /tmp/test-reports/unit-tests.xml -- -coverprofile=/tmp/test-reports/coverage.out ./... + - store_test_results: + path: /tmp/test-reports + - codecov/upload: + flags: go + file: /tmp/test-reports/coverage.out all_projects: - executor: base - steps: - - run: - command: | - echo "all" + executor: base + steps: + - run: + command: | + echo "all" workflows: build-app: diff --git a/.circleci/config.yml b/.circleci/config.yml index dd75a5fb7..64fc3e6ce 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -17,7 +17,7 @@ workflows: mapping: | (cmd|internal|server|pkg|test|conf)/.* trigger-app true main.go|go.mod|go.sum trigger-app true - base-revision: master # git branch name + base-revision: master # git branch name config-path: .circleci/conditional_config.yml filters: branches: diff --git a/.eslintrc.cjs b/.eslintrc.cjs index 0cfca7b7b..2d853bdcd 100644 --- a/.eslintrc.cjs +++ b/.eslintrc.cjs @@ -40,9 +40,7 @@ module.exports = { settings: { 'import/resolver': { typescript: { - project: ['ui/artalk/tsconfig.json'].map((p) => - path.resolve(__dirname, p), - ), + project: ['ui/artalk/tsconfig.json'].map((p) => path.resolve(__dirname, p)), }, }, polyfills: ['AbortController'], diff --git a/.github/chglog/config.yml b/.github/chglog/config.yml index 7ea56f784..1eb399858 100755 --- a/.github/chglog/config.yml +++ b/.github/chglog/config.yml @@ -4,8 +4,8 @@ info: title: CHANGELOG repository_url: https://github.com/ArtalkJS/Artalk options: - tag_filter_pattern: '^v' - sort: "date" + tag_filter_pattern: "^v" + sort: date commits: filters: Type: diff --git a/.github/dependabot.yml b/.github/dependabot.yml index de3e91017..4411a2deb 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -14,7 +14,7 @@ updates: groups: deps: patterns: - - '*' + - "*" open-pull-requests-limit: 15 - package-ecosystem: npm @@ -39,7 +39,7 @@ updates: groups: deps: patterns: - - '*' + - "*" open-pull-requests-limit: 15 - package-ecosystem: docker @@ -51,7 +51,7 @@ updates: groups: deps: patterns: - - '*' + - "*" open-pull-requests-limit: 15 - package-ecosystem: github-actions @@ -63,5 +63,5 @@ updates: groups: deps: patterns: - - '*' + - "*" open-pull-requests-limit: 15 diff --git a/.github/workflows/build-app.yml b/.github/workflows/build-app.yml index 3efee2280..af2c5f294 100644 --- a/.github/workflows/build-app.yml +++ b/.github/workflows/build-app.yml @@ -51,9 +51,9 @@ jobs: - name: Setup git-chglog run: | - curl -sL $(curl -s https://api.github.com/repos/git-chglog/git-chglog/releases/latest \ - | grep -oP '"https://.+linux_amd64.tar.gz"' | tr -d \") | tar -C /usr/local/bin -xz git-chglog - git-chglog --version + curl -sL $(curl -s https://api.github.com/repos/git-chglog/git-chglog/releases/latest \ + | grep -oP '"https://.+linux_amd64.tar.gz"' | tr -d \") | tar -C /usr/local/bin -xz git-chglog + git-chglog --version - name: Pre Build run: |- diff --git a/.github/workflows/build-nightly.yml b/.github/workflows/build-nightly.yml index 58831743e..70fc31756 100644 --- a/.github/workflows/build-nightly.yml +++ b/.github/workflows/build-nightly.yml @@ -3,11 +3,11 @@ run-name: Build Nightly on: schedule: - - cron: '0 10 * * *' + - cron: "0 10 * * *" workflow_dispatch: inputs: dry_run: - description: 'Dry run' + description: "Dry run" type: boolean default: true @@ -59,7 +59,7 @@ jobs: with: node-version: 20.x registry-url: https://registry.npmjs.org/ - cache: 'pnpm' + cache: "pnpm" - name: Get pnpm store directory shell: bash diff --git a/.github/workflows/build-tagging.yml b/.github/workflows/build-tagging.yml index a6a6204fa..d0791a7a1 100644 --- a/.github/workflows/build-tagging.yml +++ b/.github/workflows/build-tagging.yml @@ -11,7 +11,7 @@ on: type: number outputs: version: - description: 'Version' + description: "Version" value: ${{ jobs.tagging.outputs.version }} jobs: diff --git a/.github/workflows/build-ui.yml b/.github/workflows/build-ui.yml index a2fca10ed..b54b59b95 100644 --- a/.github/workflows/build-ui.yml +++ b/.github/workflows/build-ui.yml @@ -30,7 +30,7 @@ jobs: with: node-version: 20.x registry-url: https://registry.npmjs.org/ - cache: 'pnpm' + cache: "pnpm" - name: Install dependencies run: pnpm install --frozen-lockfile diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index fb894a102..3a366e6d0 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -9,13 +9,13 @@ on: workflow_dispatch: inputs: dry_run: - description: 'Dry run' + description: "Dry run" type: boolean default: true build_items: - description: 'Build items' + description: "Build items" type: string - default: 'ui,app,docker' + default: "ui,app,docker" jobs: # Tag the release version code before building @@ -54,7 +54,11 @@ jobs: # since docker push actions will override the previous images, # so need to build `linux/amd64` and push first, # then build `linux/amd64` twice with other archs (build very slow so keep it last). - target: ["linux/amd64", "linux/amd64,linux/arm64,linux/arm/v7"] + target: + - linux/amd64 + - linux/amd64 + - linux/arm64 + - linux/arm/v7 with: version: ${{ needs.tagging.outputs.version }} dry_run: ${{ inputs.dry_run || false }} diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index f81db81f5..7d07c4e54 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -9,16 +9,18 @@ # the `language` matrix defined below to confirm you have the correct set of # supported CodeQL languages. # -name: "CodeQL" +name: CodeQL on: push: - branches: [ "master" ] + branches: + - master pull_request: # The branches below must be a subset of the branches above - branches: [ "master" ] + branches: + - master schedule: - - cron: '40 17 * * 4' + - cron: "40 17 * * 4" jobs: analyze: @@ -32,43 +34,44 @@ jobs: strategy: fail-fast: false matrix: - language: [ 'go', 'javascript' ] + language: + - go + - javascript # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ] # Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support steps: - - name: Checkout repository - uses: actions/checkout@v4 + - name: Checkout repository + uses: actions/checkout@v4 - # Initializes the CodeQL tools for scanning. - - name: Initialize CodeQL - uses: github/codeql-action/init@v3 - with: - languages: ${{ matrix.language }} - # If you wish to specify custom queries, you can do so here or in a config file. - # By default, queries listed here will override any specified in a config file. - # Prefix the list here with "+" to use these queries and those in the config file. + # Initializes the CodeQL tools for scanning. + - name: Initialize CodeQL + uses: github/codeql-action/init@v3 + with: + languages: ${{ matrix.language }} + # If you wish to specify custom queries, you can do so here or in a config file. + # By default, queries listed here will override any specified in a config file. + # Prefix the list here with "+" to use these queries and those in the config file. - # Details on CodeQL's query packs refer to : https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs - # queries: security-extended,security-and-quality + # Details on CodeQL's query packs refer to : https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs + # queries: security-extended,security-and-quality + # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). + # If this step fails, then you should remove it and run the build manually (see below) + - name: Autobuild + uses: github/codeql-action/autobuild@v3 - # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). - # If this step fails, then you should remove it and run the build manually (see below) - - name: Autobuild - uses: github/codeql-action/autobuild@v3 + # ℹ️ Command-line programs to run using the OS shell. + # 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun - # ℹ️ Command-line programs to run using the OS shell. - # 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun + # If the Autobuild fails above, remove it and uncomment the following three lines. + # modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance. - # If the Autobuild fails above, remove it and uncomment the following three lines. - # modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance. + # - run: | + # echo "Run, Build Application using script" + # ./location_of_script_within_repo/buildscript.sh - # - run: | - # echo "Run, Build Application using script" - # ./location_of_script_within_repo/buildscript.sh - - - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v3 - with: - category: "/language:${{matrix.language}}" + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v3 + with: + category: "/language:${{matrix.language}}" diff --git a/.github/workflows/docs-cn.yml b/.github/workflows/docs-cn.yml index 3048fa428..44705073d 100644 --- a/.github/workflows/docs-cn.yml +++ b/.github/workflows/docs-cn.yml @@ -2,8 +2,8 @@ name: Docs CN Mirror Deploy on: push: - branches: ['master'] - paths: ['docs/**'] + branches: ["master"] + paths: ["docs/**"] jobs: deploy: @@ -20,7 +20,7 @@ jobs: uses: actions/setup-node@v4 with: node-version: 20 - cache: "pnpm" + cache: pnpm - name: Install dependencies run: pnpm install diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 0c091cd02..159198424 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -13,7 +13,7 @@ on: - major required: true dry_run: - description: 'Dry run?' + description: "Dry run?" type: boolean default: false @@ -49,9 +49,9 @@ jobs: - name: Setup git-chglog run: | - curl -sL $(curl -s https://api.github.com/repos/git-chglog/git-chglog/releases/latest \ - | grep -oP '"https://.+linux_amd64.tar.gz"' | tr -d \") | tar -C /usr/local/bin -xz git-chglog - git-chglog --version + curl -sL $(curl -s https://api.github.com/repos/git-chglog/git-chglog/releases/latest \ + | grep -oP '"https://.+linux_amd64.tar.gz"' | tr -d \") | tar -C /usr/local/bin -xz git-chglog + git-chglog --version - name: Version Changelog run: | diff --git a/.github/workflows/repo-dispatch.yml b/.github/workflows/repo-dispatch.yml index 472df0b21..d8f775f05 100644 --- a/.github/workflows/repo-dispatch.yml +++ b/.github/workflows/repo-dispatch.yml @@ -8,7 +8,7 @@ on: type: string description: Event Type required: true - default: '' + default: "" jobs: release: diff --git a/.github/workflows/test-docs.yml b/.github/workflows/test-docs.yml index 592374d64..8ec7670c0 100644 --- a/.github/workflows/test-docs.yml +++ b/.github/workflows/test-docs.yml @@ -2,12 +2,12 @@ name: Test Docs on: push: - branches: ['*', '!release/*', '!nightly'] - paths: ['docs/**'] - tags-ignore: ['v*'] + branches: ["*", "!release/*", "!nightly"] + paths: ["docs/**"] + tags-ignore: ["v*"] pull_request: - paths: ['docs/**'] - branches: ['*', '!release/*', '!nightly'] + paths: ["docs/**"] + branches: ["*", "!release/*", "!nightly"] jobs: test_docs: diff --git a/.github/workflows/test-frontend.yml b/.github/workflows/test-frontend.yml index f8a89144a..4613af325 100644 --- a/.github/workflows/test-frontend.yml +++ b/.github/workflows/test-frontend.yml @@ -2,12 +2,12 @@ name: Test Frontend on: push: - branches: ['*', '!release/*', '!nightly'] - paths: ['ui/**'] - tags-ignore: ['v*'] + branches: ["*", "!release/*", "!nightly"] + paths: ["ui/**"] + tags-ignore: ["v*"] pull_request: - paths: ['ui/**'] - branches: ['*', '!release/*', '!nightly'] + paths: ["ui/**"] + branches: ["*", "!release/*", "!nightly"] jobs: test_ui: @@ -42,5 +42,5 @@ jobs: run: pnpm test # https://github.com/arethetypeswrong/arethetypeswrong.github.io - - name: 'arethetypeswrong test' + - name: "arethetypeswrong test" run: pnpm -F artalk attw || true diff --git a/.goreleaser.yml b/.goreleaser.yml index ab6c61028..f11688c9b 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -14,9 +14,9 @@ env: before: hooks: - # install dependencies - - make install - - make build-frontend + # install dependencies + - make install + - make build-frontend # build multi-platform builds: @@ -60,7 +60,7 @@ builds: goarch: - arm goarm: - - '7' + - "7" env: - CC=arm-linux-gnueabihf-gcc - CXX=arm-linux-gnueabihf-g++ @@ -118,7 +118,7 @@ builds: # https://go-review.googlesource.com/c/go/+/224588/ # https://github.com/ArtalkJS/Artalk/issues/35 &win_common_flags | - -tags=timetzdata + -tags=timetzdata # Win (arm_64) - id: windows-arm64 @@ -156,7 +156,7 @@ archives: - artalk.yml checksum: - name_template: 'checksums.txt' + name_template: "checksums.txt" snapshot: name_template: "{{.Version}}-SNAPSHOT-{{.ShortCommit}}" diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 000000000..2dd50a18a --- /dev/null +++ b/.prettierignore @@ -0,0 +1,17 @@ +CHANGELOG.md +CHANGELOG.tpl.md +CDN.html +internal/template/notify_tpl/default.html + +# generated files +# @link https://github.com/prettier/prettier/issues/3634 +pnpm-lock.yaml +**/auto-imports.d.ts +**/components.d.ts +**/typed-router.d.ts +ui/artalk/src/api/v2.ts +docs/swagger/swagger.json +docs/swagger/swagger.yaml +docs/** +ui/artalk-sidebar/src/lib/md5.js +ui/artalk/src/lib/detect.ts diff --git a/.prettierrc b/.prettierrc index ac0eda864..7e674532e 100644 --- a/.prettierrc +++ b/.prettierrc @@ -1,6 +1,26 @@ { - "semi": false, "arrowParens": "always", + "bracketSpacing": true, + "htmlWhitespaceSensitivity": "css", + "insertPragma": false, + "bracketSameLine": false, + "jsxSingleQuote": false, + "printWidth": 100, + "proseWrap": "preserve", + "quoteProps": "as-needed", + "requirePragma": false, + "semi": false, "singleQuote": true, - "htmlWhitespaceSensitivity": "ignore" -} \ No newline at end of file + "tabWidth": 2, + "trailingComma": "all", + "useTabs": false, + "vueIndentScriptAndStyle": false, + "overrides": [ + { + "files": ["*.yaml", "*.yml"], + "options": { + "singleQuote": false + } + } + ] +} diff --git a/.vscode/launch.json b/.vscode/launch.json index 3114aa6aa..39fa5e4a2 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -1,14 +1,14 @@ { - "version": "0.2.0", - "configurations": [ - { - "name": "Launch Artalk for Debugging", - "type": "go", - "request": "launch", - "mode": "exec", - "program": "${workspaceFolder}/bin/artalk", - "preLaunchTask": "Build for debugging", - "args": ["server", "-c", "${workspaceFolder}/data/artalk.yml"] - } - ], + "version": "0.2.0", + "configurations": [ + { + "name": "Launch Artalk for Debugging", + "type": "go", + "request": "launch", + "mode": "exec", + "program": "${workspaceFolder}/bin/artalk", + "preLaunchTask": "Build for debugging", + "args": ["server", "-c", "${workspaceFolder}/data/artalk.yml"] + } + ] } diff --git a/.vscode/settings.json b/.vscode/settings.json index 89cacccad..4b3fa8a4f 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,19 +1,19 @@ { - "cSpell.words": [ - "akismet", - "artalk", - "artran", - "artrans", - "artransfer", - "gomail", - "Goreleaser", - "gorm", - "ldflags", - "lfshook", - "Metas", - "pgsql", - "sendmail", - "sqlite", - "pkged" - ] + "cSpell.words": [ + "akismet", + "artalk", + "artran", + "artrans", + "artransfer", + "gomail", + "Goreleaser", + "gorm", + "ldflags", + "lfshook", + "Metas", + "pgsql", + "sendmail", + "sqlite", + "pkged" + ] } diff --git a/.vscode/tasks.json b/.vscode/tasks.json index 40fdf5037..16ebcef2c 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -1,14 +1,14 @@ { - "version": "2.0.0", - "tasks": [ - { - "label": "Build for debugging", - "type": "shell", - "command": "make build-debug", - "group": { - "kind": "build", - "isDefault": true - } - } - ] + "version": "2.0.0", + "tasks": [ + { + "label": "Build for debugging", + "type": "shell", + "command": "make build-debug", + "group": { + "kind": "build", + "isDefault": true + } + } + ] } diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 1e7c69d1e..f0e9d0264 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -84,9 +84,9 @@ And open in your browser to view the example site. Here is the default admin account (only created in test mode): ```yaml -name: "admin" -email: "admin@test.com" -password: "admin" +name: 'admin' +email: 'admin@test.com' +password: 'admin' ``` ## Testing diff --git a/README.en.md b/README.en.md index 54b7b35ca..b034287fc 100644 --- a/README.en.md +++ b/README.en.md @@ -61,6 +61,9 @@ Reference to:[**Documentation**](https://artalk.js.org/guide/deploy.html) $ pnpm add artalk ``` + + + ```ts import Artalk from 'artalk' @@ -74,6 +77,8 @@ Artalk.init({ }) ``` + + ### Docker ```sh @@ -94,7 +99,7 @@ vim docker-compose.yaml ``` ```yaml -version: "3.5" +version: '3.5' services: artalk: container_name: artalk diff --git a/README.md b/README.md index 2616a4d76..b26596a09 100644 --- a/README.md +++ b/README.md @@ -65,6 +65,8 @@ npm install artalk ``` + + ```ts import Artalk from 'artalk' @@ -76,6 +78,8 @@ Artalk.init({ }) ``` + + ### Docker ```bash @@ -94,7 +98,7 @@ vim docker-compose.yaml ``` ```yaml -version: "3.5" +version: '3.5' services: artalk: container_name: artalk @@ -124,7 +128,7 @@ see [CONTRIBUTING.md](./CONTRIBUTING.md) ## Repobeats Analytics -![Alt](https://repobeats.axiom.co/api/embed/a9fc9191ac561bc5a8ee2cddc81e635ecaebafb6.svg "Repobeats analytics image") +![Alt](https://repobeats.axiom.co/api/embed/a9fc9191ac561bc5a8ee2cddc81e635ecaebafb6.svg 'Repobeats analytics image') ## 特别致谢 diff --git a/conf/artalk.example.simple.yml b/conf/artalk.example.simple.yml index bec244974..47e546a9d 100644 --- a/conf/artalk.example.simple.yml +++ b/conf/artalk.example.simple.yml @@ -2,33 +2,33 @@ host: "0.0.0.0" port: 23366 app_key: "" debug: false -locale: "en" -timezone: "Asia/Shanghai" -site_default: "Default Site" +locale: en +timezone: Asia/Shanghai +site_default: Default Site login_timeout: 259200 db: - type: "sqlite" - file: "./data/artalk.db" + type: sqlite + file: ./data/artalk.db table_prefix: "" - name: "artalk" - host: "localhost" + name: artalk + host: localhost port: 3306 - user: "root" + user: root password: "" - charset: "utf8mb4" + charset: utf8mb4 ssl: false prepare_stmt: true log: enabled: true - filename: "./data/artalk.log" + filename: ./data/artalk.log cache: enabled: false - type: "builtin" + type: builtin expires: 30 warm_up: false server: "" redis: - network: "tcp" + network: tcp username: "" password: "" db: 0 @@ -45,23 +45,23 @@ moderator: enabled: false secret_id: "" secret_key: "" - region: "ap-guangzhou" + region: ap-guangzhou aliyun: enabled: false access_key_id: "" access_key_secret: "" - region: "cn-shanghai" + region: cn-shanghai keywords: enabled: false pending: false files: - - "./data/keywords_1.txt" + - ./data/keywords_1.txt file_sep: "\n" - replac_to: "x" + replac_to: x captcha: enabled: true always: false - captcha_type: "image" + captcha_type: image action_limit: 3 action_reset: 60 turnstile: @@ -78,31 +78,31 @@ captcha: captcha_key: "" img_upload: enabled: true - path: "./data/artalk-img/" + path: ./data/artalk-img/ max_size: 5 public_path: null upgit: enabled: false - exec: "upgit -c UPGIT_CONF_FILE_PATH -t /artalk-img" + exec: upgit -c UPGIT_CONF_FILE_PATH -t /artalk-img del_local: true email: enabled: false - send_type: "smtp" + send_type: smtp send_name: "{{reply_nick}}" - send_addr: "noreply@example.com" + send_addr: noreply@example.com mail_subject: "[{{site_name}}] You got a reply from @{{reply_nick}}" - mail_tpl: "default" + mail_tpl: default smtp: - host: "smtp.qq.com" + host: smtp.qq.com port: 587 - username: "example@qq.com" + username: example@qq.com password: "" ali_dm: access_key_id: "" access_key_secret: "" - account_name: "noreply@example.com" + account_name: noreply@example.com admin_notify: - notify_tpl: "default" + notify_tpl: default notify_pending: false noise_mode: false email: @@ -116,7 +116,7 @@ admin_notify: - 7777777 bark: enabled: false - server: "http://day.app/xxxxxxx/" + server: http://day.app/xxxxxxx/ lark: enabled: false webhook_url: "" @@ -137,14 +137,14 @@ admin_notify: channel_secret: "" channel_access_token: "" receivers: - - "USER_ID_1" - - "GROUP_ID_1" + - USER_ID_1 + - GROUP_ID_1 frontend: placeholder: "" noComment: "" sendBtn: "" editorTravel: true - emoticons: "https://cdn.jsdelivr.net/gh/ArtalkJS/Emoticons/grps/default.json" + emoticons: https://cdn.jsdelivr.net/gh/ArtalkJS/Emoticons/grps/default.json vote: true voteDown: false uaBadge: false @@ -152,12 +152,12 @@ frontend: pvEl: "#ArtalkPV" countEl: "#ArtalkCount" preview: true - flatMode: "auto" + flatMode: auto nestMax: 2 nestSort: DATE_ASC gravatar: - mirror: "https://www.gravatar.com/avatar/" - params: "d=mp&s=240" + mirror: https://www.gravatar.com/avatar/ + params: d=mp&s=240 pagination: pageSize: 20 readMore: true diff --git a/conf/artalk.example.yml b/conf/artalk.example.yml index b03e77500..7c1989e71 100644 --- a/conf/artalk.example.yml +++ b/conf/artalk.example.yml @@ -12,14 +12,14 @@ debug: false # Language (follow Unicode BCP 47) ["en", "zh-CN", "zh-TW", "jp"] # -- see https://www.techonthenet.com/js/language_tags.php -- -locale: "en" +locale: en # Timezone (follow IANA Time Zone Database) # -- see https://en.wikipedia.org/wiki/List_of_tz_database_time_zones -- -timezone: "Asia/Shanghai" +timezone: Asia/Shanghai # Default site name (create when app is first launched) -site_default: "Default Site" +site_default: Default Site # Login timeout (in seconds) login_timeout: 259200 @@ -27,24 +27,24 @@ login_timeout: 259200 # Database db: # Database type ["sqlite", "mysql", "pgsql", "mssql"] - type: "sqlite" + type: sqlite # Database file (only for SQLite) - file: "./data/artalk.db" + file: ./data/artalk.db # Table prefix (e.g. "atk_") table_prefix: "" # -- The following is not necessary for SQLite -- # Database name - name: "artalk" + name: artalk # Host address - host: "localhost" + host: localhost # Host port port: 3306 # Database user - user: "root" + user: root # Database password password: "" # Database charset - charset: "utf8mb4" + charset: utf8mb4 # Enable SSL mode ssl: false # Prepared Statement @@ -55,14 +55,14 @@ log: # Enable logging enabled: true # Log file path - filename: "./data/artalk.log" + filename: ./data/artalk.log # Cache cache: # Enable cache enabled: false # Cache type ["redis", "memcache", "builtin"] - type: "builtin" + type: builtin # Cache expiration time (in minutes) expires: 30 # Cache warm up (warm up cache when program starts) @@ -73,7 +73,7 @@ cache: # Redis config redis: # Connection type ["tcp", "unix"] - network: "tcp" + network: tcp # Redis username username: "" # Redis password @@ -113,7 +113,7 @@ moderator: enabled: false secret_id: "" secret_key: "" - region: "ap-guangzhou" + region: ap-guangzhou # Aliyun Content Security # (Auto review comments with Aliyun Content Security) # -- see https://help.aliyun.com/document_detail/28417.html -- @@ -121,7 +121,7 @@ moderator: enabled: false access_key_id: "" access_key_secret: "" - region: "cn-shanghai" + region: cn-shanghai # Keyword filter (local offline dictionary) keywords: # Enable keyword filter @@ -130,9 +130,9 @@ moderator: pending: false # Dictionary file (support multiple dictionary files) files: - - "./data/keywords_1.txt" + - ./data/keywords_1.txt file_sep: "\n" - replac_to: "x" + replac_to: x # Captcha captcha: @@ -141,7 +141,7 @@ captcha: # Captcha is required always always: false # Captcha type ["image", "turnstile", "recaptcha", "hcaptcha", "geetest"] - captcha_type: "image" + captcha_type: image # Action limit # (the number of actions required to activate captcha) action_limit: 3 @@ -171,7 +171,7 @@ img_upload: # Enable image upload enabled: true # Image storage - path: "./data/artalk-img/" + path: ./data/artalk-img/ # Image size limit (unit: MB) max_size: 5 # Image link base path (default: "/static/images/") @@ -181,7 +181,7 @@ img_upload: # Enable Upgit enabled: false # Command line arguments - exec: "upgit -c UPGIT_CONF_FILE_PATH -t /artalk-img" + exec: upgit -c UPGIT_CONF_FILE_PATH -t /artalk-img # Delete local image after upload success del_local: true @@ -190,23 +190,23 @@ email: # Enable email notification enabled: false # Send method ["smtp", "ali_dm", "sendmail"] - send_type: "smtp" + send_type: smtp # Nick name of sender send_name: "{{reply_nick}}" # Email address of sender - send_addr: "noreply@example.com" + send_addr: noreply@example.com # Email subject mail_subject: "[{{site_name}}] You got a reply from @{{reply_nick}}" # Email template file (set to file path to use custom template) - mail_tpl: "default" + mail_tpl: default # SMTP send (set send method to "smtp" to enable) smtp: # Email address of sender - host: "smtp.qq.com" + host: smtp.qq.com # Email port port: 587 # Email address of sender - username: "example@qq.com" + username: example@qq.com # Password password: "" # Aliyun mail push @@ -214,12 +214,12 @@ email: ali_dm: access_key_id: "" access_key_secret: "" - account_name: "noreply@example.com" + account_name: noreply@example.com # Multi-Push admin_notify: # Notification template (set to file path to use custom template) - notify_tpl: "default" + notify_tpl: default # Pending comment still send notification (notifications are still sent when comments are intercepted) notify_pending: false # Noise mode @@ -244,7 +244,7 @@ admin_notify: # Bark bark: enabled: false - server: "http://day.app/xxxxxxx/" + server: http://day.app/xxxxxxx/ lark: enabled: false webhook_url: "" @@ -268,8 +268,8 @@ admin_notify: channel_secret: "" channel_access_token: "" receivers: - - "USER_ID_1" - - "GROUP_ID_1" + - USER_ID_1 + - GROUP_ID_1 # UI Settings frontend: @@ -282,7 +282,7 @@ frontend: # Movable comment box editorTravel: true # Emoticons - emoticons: "https://cdn.jsdelivr.net/gh/ArtalkJS/Emoticons/grps/default.json" + emoticons: https://cdn.jsdelivr.net/gh/ArtalkJS/Emoticons/grps/default.json # Vote button vote: true # Dislike button @@ -298,7 +298,7 @@ frontend: # Editor real-time preview preview: true # Flatten mode ["auto", true, false] - flatMode: "auto" + flatMode: auto # Maximum nesting level nestMax: 2 # Nesting comment sorting rules ["DATE_ASC", "DATE_DESC", "VOTE_UP_DESC"] @@ -306,9 +306,9 @@ frontend: # Gravatar gravatar: # API URL - mirror: "https://www.gravatar.com/avatar/" + mirror: https://www.gravatar.com/avatar/ # API parameters - params: "d=mp&s=240" + params: d=mp&s=240 # Comment pagination pagination: # Number of comments per page diff --git a/conf/artalk.example.zh-CN.yml b/conf/artalk.example.zh-CN.yml index 437d38158..4e19b02f2 100644 --- a/conf/artalk.example.zh-CN.yml +++ b/conf/artalk.example.zh-CN.yml @@ -11,13 +11,13 @@ app_key: "" debug: false # 语言 ["en", "zh-CN", "zh-TW", "jp"] -locale: "zh-CN" +locale: zh-CN # 时间区域 -timezone: "Asia/Shanghai" +timezone: Asia/Shanghai # 默认站点名 -site_default: "默认站点" +site_default: 默认站点 # 登录有效时长 (单位:秒) login_timeout: 259200 @@ -25,21 +25,21 @@ login_timeout: 259200 # 数据库 db: # 数据库类型 ["sqlite", "mysql", "pgsql", "mssql"] - type: "sqlite" + type: sqlite # 数据库文件 (仅 SQLite 数据库需填写) - file: "./data/artalk.db" + file: ./data/artalk.db # 数据库名称 - name: "artalk" + name: artalk # 数据库地址 - host: "localhost" + host: localhost # 数据库端口 port: 3306 # 数据库账户 - user: "root" + user: root # 数据库密码 password: "" # 编码格式 - charset: "utf8mb4" + charset: utf8mb4 # 表前缀 (例如:"atk_") table_prefix: "" # 启用 SSL @@ -52,14 +52,14 @@ log: # 启用日志 enabled: true # 日志文件路径 - filename: "./data/artalk.log" + filename: ./data/artalk.log # 缓存 cache: # 启用缓存 enabled: false # 缓存类型 ["redis", "memcache", "builtin"] - type: "builtin" + type: builtin # 缓存过期时间 (单位:分钟) expires: 30 # 缓存启动预热 (程序启动时预热缓存) @@ -69,7 +69,7 @@ cache: # Redis 配置 redis: # 连接方式 ["tcp", "unix"] - network: "tcp" + network: tcp # 用户名 username: "" # 密码 @@ -112,14 +112,14 @@ moderator: enabled: false secret_id: "" secret_key: "" - region: "ap-guangzhou" + region: ap-guangzhou # 阿里云内容安全 # (https://help.aliyun.com/document_detail/28417.html) aliyun: enabled: false access_key_id: "" access_key_secret: "" - region: "cn-shanghai" + region: cn-shanghai # 关键词过滤 (本地离线词库) keywords: enabled: false @@ -127,11 +127,11 @@ moderator: pending: false # 词库文件 (支持多个词库文件) files: - - "./data/词库_1.txt" + - ./data/词库_1.txt # 词库文件内容分割符 (例如填写 "\n" 文件中一行一个关键词) file_sep: "\n" # 替换字符 - replac_to: "x" + replac_to: x # 验证码 captcha: @@ -140,7 +140,7 @@ captcha: # 总是需要验证码 always: false # 验证类型 ["image", "turnstile", "recaptcha", "hcaptcha", "geetest"] - captcha_type: "image" + captcha_type: image # 激活验证码所需操作次数 action_limit: 3 # 重置操作计数器超时 (单位:s, 设为 -1 不重置) @@ -169,16 +169,16 @@ ip_region: # 启用 IP 属地展示 enabled: false # 数据文件路径 (.xdb 格式) - db_path: "./data/ip2region.xdb" + db_path: ./data/ip2region.xdb # 显示精度 ["province", "city", "country"] - precision: "province" + precision: province # 图片上传 img_upload: # 启用图片上传 enabled: true # 图片存放路径 - path: "./data/artalk-img/" + path: ./data/artalk-img/ # 图片大小限制 (单位:MB) max_size: 5 # 图片链接基础路径 (默认为 "/static/images/") @@ -189,7 +189,7 @@ img_upload: # 启用 Upgit enabled: false # 命令行参数 - exec: "upgit -c -t /artalk-img" + exec: upgit -c -t /artalk-img # 上传后删除本地的图片 del_local: true @@ -198,23 +198,23 @@ email: # 启用邮件通知 enabled: false # 发送方式 ["smtp", "ali_dm", "sendmail"] - send_type: "smtp" + send_type: smtp # 发信人昵称 send_name: "{{reply_nick}}" # 发信人地址 - send_addr: "noreply@example.com" + send_addr: noreply@example.com # 邮件标题 mail_subject: "[{{site_name}}] 您收到了来自 @{{reply_nick}} 的回复" # 邮件模板文件 (填入文件路径使用自定义模板) - mail_tpl: "default" + mail_tpl: default # SMTP 发送 (启用请将发送方式设为 "smtp") smtp: # 发件地址 - host: "smtp.qq.com" + host: smtp.qq.com # 发件端口 port: 587 # 用户名 - username: "example@qq.com" + username: example@qq.com # 密码 password: "" # 阿里云邮件推送 @@ -222,12 +222,12 @@ email: ali_dm: access_key_id: "" access_key_secret: "" - account_name: "noreply@example.com" + account_name: noreply@example.com # 多元推送 admin_notify: # 通知模版 (填入文件路径使用自定义模板) - notify_tpl: "default" + notify_tpl: default # 待审评论仍然发送通知 (当评论被拦截时仍然发送通知) notify_pending: false # 嘈杂模式 @@ -249,7 +249,7 @@ admin_notify: # Bark bark: enabled: false - server: "http://day.app/xxxxxxx/" + server: http://day.app/xxxxxxx/ # 飞书 lark: enabled: false @@ -268,15 +268,15 @@ admin_notify: enabled: false oauth_token: "" receivers: - - "CHANNEL_ID" + - CHANNEL_ID # LINE line: enabled: false channel_secret: "" channel_access_token: "" receivers: - - "USER_ID_1" - - "GROUP_ID_1" + - USER_ID_1 + - GROUP_ID_1 # 界面配置 frontend: @@ -289,7 +289,7 @@ frontend: # 评论框穿梭 editorTravel: true # 表情包 - emoticons: "https://cdn.jsdelivr.net/gh/ArtalkJS/Emoticons/grps/default.json" + emoticons: https://cdn.jsdelivr.net/gh/ArtalkJS/Emoticons/grps/default.json # 投票按钮 vote: true # 反对按钮 @@ -305,7 +305,7 @@ frontend: # 编辑器实时预览功能 preview: true # 平铺模式 ["auto", true, false] - flatMode: "auto" + flatMode: auto # 最大嵌套层数 nestMax: 2 # 嵌套评论排序规则 ["DATE_ASC", "DATE_DESC", "VOTE_UP_DESC"] @@ -313,9 +313,9 @@ frontend: # 头像 Gravatar gravatar: # API 地址 - mirror: "https://cravatar.cn/avatar/" + mirror: https://cravatar.cn/avatar/ # API 参数 - params: "d=mp&s=240" + params: d=mp&s=240 # 评论分页 pagination: # 每页评论数 diff --git a/docs/docs/.vitepress/config.ts b/docs/docs/.vitepress/config.ts index 1cdbadca2..329372e77 100644 --- a/docs/docs/.vitepress/config.ts +++ b/docs/docs/.vitepress/config.ts @@ -1,45 +1,44 @@ -import { defineConfig } from "vitepress"; -import iterator from "markdown-it-for-inline"; -import * as Version from "../code/ArtalkVersion.json"; +import { defineConfig } from 'vitepress' +import iterator from 'markdown-it-for-inline' +import * as Version from '../code/ArtalkVersion.json' export default defineConfig({ - title: "Artalk", - description: "一款简洁的自托管评论系统", - lang: "zh-CN", + title: 'Artalk', + description: '一款简洁的自托管评论系统', + lang: 'zh-CN', head: [ - ["link", { rel: "icon", href: "/favicon.png" }], + ['link', { rel: 'icon', href: '/favicon.png' }], [ - "meta", + 'meta', { - name: "viewport", + name: 'viewport', content: - "width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no, target-densitydpi=device-dpi", + 'width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no, target-densitydpi=device-dpi', }, ], - // artalk - // ['link', { href: `https://npm.elemecdn.com/artalk@${Version.latest}/dist/Artalk.css`, rel: 'stylesheet' }], - // [ - // "link", - // { href: `https://artalk.qwqaq.com/dist/Artalk.css`, rel: "stylesheet" }, - // ], - // ['script', { src: ArtalkCDN.JS }], // light gallery [ - "link", + 'link', { - href: "https://cdnjs.cloudflare.com/ajax/libs/lightgallery/2.3.0/css/lightgallery.css", - rel: "stylesheet", + href: 'https://cdnjs.cloudflare.com/ajax/libs/lightgallery/2.3.0/css/lightgallery.css', + rel: 'stylesheet', }, ], [ - "script", + 'script', { - src: "https://cdnjs.cloudflare.com/ajax/libs/lightgallery/2.3.0/lightgallery.min.js", + src: 'https://cdnjs.cloudflare.com/ajax/libs/lightgallery/2.3.0/lightgallery.min.js', }, ], // katex - ['link', { href: "https://unpkg.com/katex@0.15.3/dist/katex.min.css", rel: 'stylesheet' }], + [ + 'link', + { + href: 'https://unpkg.com/katex@0.15.3/dist/katex.min.css', + rel: 'stylesheet', + }, + ], ['script', { src: 'https://unpkg.com/katex@0.15.3/dist/katex.min.js' }], // ['script', { src: 'https://unpkg.com/@artalk/plugin-katex/dist/artalk-plugin-katex.js' }], ], @@ -49,132 +48,132 @@ export default defineConfig({ markdown: { // @link https://github.com/shikijs/shiki theme: { - light: "github-light", - dark: "github-dark", + light: 'github-light', + dark: 'github-dark', }, config: (md) => { - md.use(iterator, "artalk_version", "text", function (tokens, idx) { + md.use(iterator, 'artalk_version', 'text', function (tokens, idx) { tokens[idx].content = tokens[idx].content.replace( /:ArtalkVersion:/g, - Version.latest - ); - }); - md.use(iterator, "artalk_version_link", "link_open", (tokens, idx) => { - const href = tokens[idx].attrGet("href"); + Version.latest, + ) + }) + md.use(iterator, 'artalk_version_link', 'link_open', (tokens, idx) => { + const href = tokens[idx].attrGet('href') tokens[idx].attrSet( - "href", - href.replace(/:ArtalkVersion:/g, Version.latest) - ); - }); + 'href', + href.replace(/:ArtalkVersion:/g, Version.latest), + ) + }) }, }, locales: { root: { - label: "简体中文", - lang: "zh", - link: "https://artalk.js.org/", + label: '简体中文', + lang: 'zh', + link: 'https://artalk.js.org/', }, en: { - label: "English", - lang: "en", - link: "https://artalk-js-org.translate.goog/guide/intro?_x_tr_sl=auto&_x_tr_tl=en-US&_x_tr_hl=en-US&_x_tr_pto=wapp", + label: 'English', + lang: 'en', + link: 'https://artalk-js-org.translate.goog/guide/intro?_x_tr_sl=auto&_x_tr_tl=en-US&_x_tr_hl=en-US&_x_tr_pto=wapp', }, }, themeConfig: { sidebar: { - "/guide/": [ + '/guide/': [ { - text: "快速开始", + text: '快速开始', collapsed: false, items: [ - { text: "项目介绍", link: "/guide/intro.md" }, - { text: "程序部署", link: "/guide/deploy.md" }, - { text: "数据迁移", link: "/guide/transfer.md" }, + { text: '项目介绍', link: '/guide/intro.md' }, + { text: '程序部署', link: '/guide/deploy.md' }, + { text: '数据迁移', link: '/guide/transfer.md' }, ], }, { - text: "核心指南", + text: '核心指南', collapsed: false, items: [ - { text: "侧边栏", link: "/guide/frontend/sidebar.md" }, - { text: "邮件通知", link: "/guide/backend/email.md" }, - { text: "多元推送", link: "/guide/backend/admin_notify.md" }, - { text: "评论审核", link: "/guide/backend/moderator.md" }, - { text: "验证码", link: "/guide/backend/captcha.md" }, - { text: "图片上传", link: "/guide/backend/img-upload.md" }, - { text: "账户与多站点", link: "/guide/backend/multi-site.md" }, - { text: "解析相对路径", link: "/guide/backend/relative-path.md" }, - { text: "如何配置界面", link: "/guide/backend/fe-control.md" }, - { text: "English (i18n)", link: "/guide/frontend/i18n.md" }, + { text: '侧边栏', link: '/guide/frontend/sidebar.md' }, + { text: '邮件通知', link: '/guide/backend/email.md' }, + { text: '多元推送', link: '/guide/backend/admin_notify.md' }, + { text: '评论审核', link: '/guide/backend/moderator.md' }, + { text: '验证码', link: '/guide/backend/captcha.md' }, + { text: '图片上传', link: '/guide/backend/img-upload.md' }, + { text: '账户与多站点', link: '/guide/backend/multi-site.md' }, + { text: '解析相对路径', link: '/guide/backend/relative-path.md' }, + { text: '如何配置界面', link: '/guide/backend/fe-control.md' }, + { text: 'English (i18n)', link: '/guide/frontend/i18n.md' }, ], }, { - text: "进阶指南", + text: '进阶指南', collapsed: false, items: [ - { text: "表情包", link: "/guide/frontend/emoticons.md" }, - { text: "浏览量统计", link: "/guide/frontend/pv.md" }, - { text: "Latex", link: "/guide/frontend/latex.md" }, - { text: "图片灯箱", link: "/guide/frontend/lightbox.md" }, - { text: "IP 属地", link: "/guide/frontend/ip-region.md" }, - { text: "精简版本", link: "/guide/frontend/artalk-lite.md" }, - { text: "置入博客", link: "/guide/frontend/import-blog.md" }, - { text: "置入框架", link: "/guide/frontend/import-framework.md" }, - { text: "前端 API", link: "/develop/fe-api.md" }, - { text: "开发文档", link: "/develop/index.md" }, + { text: '表情包', link: '/guide/frontend/emoticons.md' }, + { text: '浏览量统计', link: '/guide/frontend/pv.md' }, + { text: 'Latex', link: '/guide/frontend/latex.md' }, + { text: '图片灯箱', link: '/guide/frontend/lightbox.md' }, + { text: 'IP 属地', link: '/guide/frontend/ip-region.md' }, + { text: '精简版本', link: '/guide/frontend/artalk-lite.md' }, + { text: '置入博客', link: '/guide/frontend/import-blog.md' }, + { text: '置入框架', link: '/guide/frontend/import-framework.md' }, + { text: '前端 API', link: '/develop/fe-api.md' }, + { text: '开发文档', link: '/develop/index.md' }, ], }, { - text: "配置文档", + text: '配置文档', collapsed: true, items: [ - { text: "后端配置", link: "/guide/backend/config.md" }, - { text: "前端配置", link: "/guide/frontend/config.md" }, + { text: '后端配置', link: '/guide/backend/config.md' }, + { text: '前端配置', link: '/guide/frontend/config.md' }, ], }, { - text: "部署说明", + text: '部署说明', collapsed: true, items: [ - { text: "守护进程", link: "/guide/backend/daemon.md" }, - { text: "反向代理", link: "/guide/backend/reverse-proxy.md" }, - { text: "编译构建", link: "/guide/backend/build.md" }, - { text: "程序升级", link: "/guide/backend/update.md" }, - { text: "Docker", link: "/guide/backend/docker.md" }, + { text: '守护进程', link: '/guide/backend/daemon.md' }, + { text: '反向代理', link: '/guide/backend/reverse-proxy.md' }, + { text: '编译构建', link: '/guide/backend/build.md' }, + { text: '程序升级', link: '/guide/backend/update.md' }, + { text: 'Docker', link: '/guide/backend/docker.md' }, ], }, { - text: "更多内容", + text: '更多内容', collapsed: true, items: [ - { text: "安全防范", link: "/guide/security.md" }, - { text: "扩展阅读", link: "/guide/extras.md" }, - { text: "案例展示", link: "/guide/cases.md" }, - { text: "关于我们", link: "/guide/about.md" }, + { text: '安全防范', link: '/guide/security.md' }, + { text: '扩展阅读', link: '/guide/extras.md' }, + { text: '案例展示', link: '/guide/cases.md' }, + { text: '关于我们', link: '/guide/about.md' }, ], }, ], - "/develop/": [ + '/develop/': [ { - text: "开发文档", + text: '开发文档', items: [ - { text: "开发说明", link: "/develop/index.md" }, - { text: "前端 API", link: "/develop/fe-api.md" }, - { text: "前端 Event", link: "/develop/event.md" }, - { text: "插件开发", link: "/develop/plugs.md" }, + { text: '开发说明', link: '/develop/index.md' }, + { text: '前端 API', link: '/develop/fe-api.md' }, + { text: '前端 Event', link: '/develop/event.md' }, + { text: '插件开发', link: '/develop/plugs.md' }, { - text: "🔬 HTTP API", - link: "https://artalk.js.org/http-api.html", + text: '🔬 HTTP API', + link: 'https://artalk.js.org/http-api.html', }, { - text: "📖 Contributing Guide", - link: "https://github.com/ArtalkJS/Artalk/blob/master/CONTRIBUTING.md", + text: '📖 Contributing Guide', + link: 'https://github.com/ArtalkJS/Artalk/blob/master/CONTRIBUTING.md', }, { - text: "🔖 Code of Conduct", - link: "https://github.com/ArtalkJS/Artalk/blob/master/CODE_OF_CONDUCT.md", + text: '🔖 Code of Conduct', + link: 'https://github.com/ArtalkJS/Artalk/blob/master/CODE_OF_CONDUCT.md', }, ], }, @@ -184,36 +183,36 @@ export default defineConfig({ nav: [ // NavbarItem { - text: "介绍", - link: "/guide/intro", + text: '介绍', + link: '/guide/intro', }, { - text: "部署", - link: "/guide/deploy", + text: '部署', + link: '/guide/deploy', }, { - text: "配置", - link: "/guide/backend/config", + text: '配置', + link: '/guide/backend/config', }, { - text: "迁移", - link: "/guide/transfer", + text: '迁移', + link: '/guide/transfer', }, { - text: "案例", - link: "/guide/cases", + text: '案例', + link: '/guide/cases', }, { - text: "开发", - link: "/develop/", + text: '开发', + link: '/develop/', }, // NavbarGroup { - text: "传送", + text: '传送', items: [ { - text: "代码仓库", - link: "https://github.com/ArtalkJS/Artalk", + text: '代码仓库', + link: 'https://github.com/ArtalkJS/Artalk', }, // { // text: "文档镜像 (国内)", @@ -224,30 +223,30 @@ export default defineConfig({ ], socialLinks: [ - { icon: "github", link: "https://github.com/ArtalkJS/Artalk" }, + { icon: 'github', link: 'https://github.com/ArtalkJS/Artalk' }, ], search: { - provider: "algolia", + provider: 'algolia', options: { - appId: "2WNJ32WVTY", - apiKey: "6c6ebc345a87b738264f19095b78c91c", - indexName: "artalk-js", + appId: '2WNJ32WVTY', + apiKey: '6c6ebc345a87b738264f19095b78c91c', + indexName: 'artalk-js', searchParameters: { - facetFilters: ["lang:zh-CN"], + facetFilters: ['lang:zh-CN'], }, }, }, editLink: { - pattern: "https://github.com/ArtalkJS/Artalk/edit/master/docs/:path", - text: "完善文档", + pattern: 'https://github.com/ArtalkJS/Artalk/edit/master/docs/:path', + text: '完善文档', }, }, vite: { server: { - open: "/guide/intro.html", + open: '/guide/intro.html', }, }, -}); +}) diff --git a/docs/docs/.vitepress/theme/Artalk.vue b/docs/docs/.vitepress/theme/Artalk.vue index 967011e75..a0ed84a23 100644 --- a/docs/docs/.vitepress/theme/Artalk.vue +++ b/docs/docs/.vitepress/theme/Artalk.vue @@ -1,5 +1,5 @@ - - diff --git a/docs/docs/.vitepress/theme/Artransfer.vue b/docs/docs/.vitepress/theme/Artransfer.vue index 613eca6b8..c20ee4b61 100644 --- a/docs/docs/.vitepress/theme/Artransfer.vue +++ b/docs/docs/.vitepress/theme/Artransfer.vue @@ -1,5 +1,9 @@ - - diff --git a/docs/docs/.vitepress/theme/Layout.vue b/docs/docs/.vitepress/theme/Layout.vue index 27a1ec69b..9f6b2f53b 100644 --- a/docs/docs/.vitepress/theme/Layout.vue +++ b/docs/docs/.vitepress/theme/Layout.vue @@ -4,9 +4,6 @@ import { onMounted } from 'vue' import './style.scss' const { Layout } = DefaultTheme - -onMounted(() => { -})