Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8cbbd1153c | ||
|
|
f41aecd0eb | ||
|
|
a05c31b4de | ||
|
|
f3a0d7c069 | ||
|
|
7bfe22fe10 | ||
|
|
59ebfd3d6c | ||
|
|
0787595f98 | ||
|
|
bd621067b5 | ||
|
|
01ae389264 | ||
|
|
84700cfc2f | ||
|
|
b68f609a44 | ||
|
|
703e198780 | ||
|
|
4f75ef8709 |
No files matched your search
@@ -66,6 +66,7 @@ jobs:
|
||||
- name: Update CDN links
|
||||
run: |
|
||||
sed -i 's#artalk@.[^/]*#artalk@${{ steps.get_version.outputs.VERSION }}#g' docs/code/ArtalkCDN.json
|
||||
perl -pi -e 's#"Artalk"(\W+)?:(\W+)?".*?"#"Artalk": "${{ steps.get_version.outputs.VERSION }}"#g' docs/code/ArtalkVersion.json
|
||||
sed -i 's#artalk@.[^/]*#artalk@${{ steps.get_version.outputs.VERSION }}#g' docs/code/quick-start/cdn.html
|
||||
|
||||
- uses: stefanzweifel/git-auto-commit-action@v4
|
||||
|
||||
@@ -125,8 +125,14 @@ docker-compose up -d
|
||||
## TODOs
|
||||
|
||||
- [x] [Golang 后端](https://github.com/ArtalkJS/ArtalkGo)
|
||||
- [x] 多站点支持
|
||||
- [x] 多数据库支持
|
||||
- [x] SQLite
|
||||
- [X] MySQL
|
||||
- [x] 多缓存支持
|
||||
- [x] In-memory (内建缓存)
|
||||
- [x] Redis
|
||||
- [x] Memcache
|
||||
- [x] 多站点支持
|
||||
- [x] 评论获取分页
|
||||
- [x] 评论点赞投票
|
||||
- [x] 浏览量统计
|
||||
|
||||
+16
-16
@@ -10,23 +10,23 @@
|
||||
"build:all": "pnpm build && pnpm build:sidebar"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@rollup/plugin-dynamic-import-vars": "^1.4.1",
|
||||
"@types/node": "^16.11.7",
|
||||
"@typescript-eslint/eslint-plugin": "^5.4.0",
|
||||
"@typescript-eslint/parser": "^5.4.0",
|
||||
"autoprefixer": "^10.4.0",
|
||||
"eslint": "^8.2.0",
|
||||
"@rollup/plugin-dynamic-import-vars": "^1.4.3",
|
||||
"@types/node": "^16.11.27",
|
||||
"@typescript-eslint/eslint-plugin": "^5.20.0",
|
||||
"@typescript-eslint/parser": "^5.20.0",
|
||||
"autoprefixer": "^10.4.4",
|
||||
"eslint": "^8.13.0",
|
||||
"eslint-config-airbnb-base": "15.0.0",
|
||||
"eslint-config-airbnb-typescript": "^16.0.0",
|
||||
"eslint-config-prettier": "^8.3.0",
|
||||
"eslint-import-resolver-typescript": "^2.5.0",
|
||||
"eslint-plugin-import": "^2.25.2",
|
||||
"eslint-config-airbnb-typescript": "^16.2.0",
|
||||
"eslint-config-prettier": "^8.5.0",
|
||||
"eslint-import-resolver-typescript": "^2.7.1",
|
||||
"eslint-plugin-import": "^2.26.0",
|
||||
"less": "^4.1.2",
|
||||
"postcss": "^8.1.0",
|
||||
"prettier": "^2.4.1",
|
||||
"rollup": "^2.59.0",
|
||||
"typescript": "^4.5.2",
|
||||
"vite": "^2.6.14",
|
||||
"vite-tsconfig-paths": "^3.3.17"
|
||||
"postcss": "^8.4.12",
|
||||
"prettier": "^2.6.2",
|
||||
"rollup": "^2.70.2",
|
||||
"typescript": "^4.6.3",
|
||||
"vite": "^2.9.5",
|
||||
"vite-tsconfig-paths": "^3.4.1"
|
||||
}
|
||||
}
|
||||
@@ -21,7 +21,7 @@
|
||||
|
||||
InitSidebar({
|
||||
el: '#ArtalkSidebar',
|
||||
server: (import.meta.env.MODE === 'development') ? 'http://localhost:23366/api' : '../api',
|
||||
server: (import.meta.env.MODE === 'development') ? 'http://localhost:23366' : '../',
|
||||
pageKey,
|
||||
site,
|
||||
darkMode,
|
||||
|
||||
@@ -26,14 +26,20 @@ export default class PageList extends Component {
|
||||
initPageList() {
|
||||
this.pages = []
|
||||
|
||||
this.$el.innerHTML = `<div class="atk-header-action-bar">
|
||||
<span class="atk-update-all-title-btn"><i class="atk-icon atk-icon-sync"></i> <span class="atk-text">更新标题</span></span>
|
||||
<span class="atk-cache-flush-all-btn"><span class="atk-text">缓存清除</span></span>
|
||||
<span class="atk-cache-warm-up-btn"><span class="atk-text">缓存预热</span></span>
|
||||
</div>`
|
||||
|
||||
// 缓存操作按钮
|
||||
const $cacheFlushBtn = this.$el.querySelector<HTMLElement>('.atk-cache-flush-all-btn')!
|
||||
$cacheFlushBtn.onclick = () => { new Api(this.ctx).cacheFlushAll().then((d: any) => alert(d.msg)).catch(() => alert('操作失败')) }
|
||||
const $cacheWarmBtn = this.$el.querySelector<HTMLElement>('.atk-cache-warm-up-btn')!
|
||||
$cacheWarmBtn.onclick = () => { new Api(this.ctx).cacheWarmUp().then((d: any) => alert(d.msg)).catch(() => alert('操作失败')) }
|
||||
|
||||
// 更新全部页面标题按钮
|
||||
;(async () => {
|
||||
this.$el.innerHTML = `<div class="atk-header-action-bar">
|
||||
<span class="atk-update-all-title-btn">
|
||||
<i class="atk-icon atk-icon-sync"></i> <span class="atk-text">更新标题</span>
|
||||
</span>
|
||||
</div>`
|
||||
|
||||
const $updateAllTitleBtn = this.$el.querySelector<HTMLElement>('.atk-update-all-title-btn')!
|
||||
const $updateAllTitleIcon = $updateAllTitleBtn.querySelector<HTMLElement>('i')!
|
||||
const $updateAllTitleText = $updateAllTitleBtn.querySelector<HTMLElement>('.atk-text')!
|
||||
|
||||
@@ -135,7 +135,7 @@ export default class TransferView extends SidebarView {
|
||||
formData.append('token', this.ctx.user.data.token)
|
||||
|
||||
// 开始上传
|
||||
xhr.open('post', `${this.ctx.conf.server}/admin/import-upload`)
|
||||
xhr.open('post', `${this.ctx.conf.server}/api/admin/import-upload`)
|
||||
xhr.timeout = 2*60*1000 // 2min
|
||||
xhr.send(formData)
|
||||
|
||||
@@ -256,7 +256,7 @@ export default class TransferView extends SidebarView {
|
||||
const $formTmp = document.createElement('form')
|
||||
$formTmp.style.display = 'none'
|
||||
$formTmp.setAttribute('method', 'post')
|
||||
$formTmp.setAttribute('action', `${this.ctx.conf.server}/admin/import`)
|
||||
$formTmp.setAttribute('action', `${this.ctx.conf.server}/api/admin/import`)
|
||||
$formTmp.setAttribute("target", frameName)
|
||||
|
||||
Object.entries(formParams).forEach(([key, val]) => {
|
||||
|
||||
@@ -64,7 +64,7 @@
|
||||
el: '#comments',
|
||||
pageKey: 'https://artalk.js.org/',
|
||||
pageTitle: 'Artalk Home',
|
||||
server: (import.meta.env.MODE === 'development') ? 'http://localhost:23366/api' : 'https://artalk.qwqaq.com/api',
|
||||
server: (import.meta.env.MODE === 'development') ? 'http://localhost:23366' : 'https://artalk.qwqaq.com',
|
||||
site: 'ArtalkDemo',
|
||||
});
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "artalk",
|
||||
"version": "2.2.5",
|
||||
"version": "2.2.7",
|
||||
"backendMinVersion": "2.1.2",
|
||||
"license": "LGPL-3.0",
|
||||
"description": "A Selfhosted Comment System",
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import Context from '../context'
|
||||
import { CommentData, ListData, UserData, PageData, SiteData, NotifyData } from '~/types/artalk-data'
|
||||
import Context from '../context'
|
||||
import { Fetch, ToFormData, POST, GET } from './request'
|
||||
import * as Utils from '../lib/utils'
|
||||
|
||||
@@ -9,7 +9,7 @@ export default class Api {
|
||||
|
||||
constructor (ctx: Context) {
|
||||
this.ctx = ctx
|
||||
this.baseURL = ctx.conf.server
|
||||
this.baseURL = `${ctx.conf.server}/api`
|
||||
}
|
||||
|
||||
// ============================
|
||||
@@ -318,4 +318,20 @@ export default class Api {
|
||||
const data = await POST<any>(this.ctx, `${this.baseURL}/captcha/status`)
|
||||
return (data || { is_pass: false }) as { is_pass: boolean }
|
||||
}
|
||||
|
||||
// ============================
|
||||
// 管理员缓存操作
|
||||
// ============================
|
||||
|
||||
/** 缓存清除 */
|
||||
public cacheFlushAll() {
|
||||
const params: any = { flush_all: true }
|
||||
return POST(this.ctx, `${this.baseURL}/admin/cache-flush`, params)
|
||||
}
|
||||
|
||||
/** 缓存预热 */
|
||||
public cacheWarmUp() {
|
||||
const params: any = {}
|
||||
return POST(this.ctx, `${this.baseURL}/admin/cache-warm`, params)
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,8 @@
|
||||
import './style/main.less'
|
||||
|
||||
import Context from './context'
|
||||
import ArtalkConfig from '~/types/artalk-config'
|
||||
import { EventPayloadMap, Handler } from '~/types/event'
|
||||
import Context from './context'
|
||||
import defaults from './defaults'
|
||||
|
||||
import CheckerLauncher from './lib/checker'
|
||||
@@ -10,7 +11,6 @@ import List from './components/list'
|
||||
import SidebarLayer from './components/sidebar-layer'
|
||||
|
||||
import Layer, { GetLayerWrap } from './components/layer'
|
||||
import { EventPayloadMap, Handler } from '~/types/event'
|
||||
import Api from './api'
|
||||
import * as Utils from './lib/utils'
|
||||
|
||||
@@ -33,22 +33,31 @@ export default class Artalk {
|
||||
constructor (customConf: ArtalkConfig) {
|
||||
// 配置
|
||||
this.conf = { ...Artalk.defaults, ...customConf }
|
||||
this.conf.server = this.conf.server.replace(/\/$/, '')
|
||||
this.conf.server = this.conf.server.replace(/\/$/, '').replace(/\/api\/?$/, '')
|
||||
|
||||
// 默认 pageKey
|
||||
if (!this.conf.pageKey) {
|
||||
// @link http://bl.ocks.org/abernier/3070589
|
||||
this.conf.pageKey = `${window.location.protocol}//${window.location.host}${window.location.pathname}`
|
||||
this.conf.pageKey = `${window.location.pathname}`
|
||||
}
|
||||
|
||||
// 默认 pageTitle
|
||||
if (!this.conf.pageTitle) {
|
||||
this.conf.pageTitle = `${document.title}`
|
||||
}
|
||||
|
||||
// 装载元素
|
||||
try {
|
||||
const $root = document.querySelector<HTMLElement>(this.conf.el)
|
||||
if (!$root) throw Error(`Sorry, target element "${this.conf.el}" was not found.`)
|
||||
this.$root = $root
|
||||
} catch (e) {
|
||||
console.error(e)
|
||||
throw new Error('Please check your Artalk `el` config.')
|
||||
if (!!this.conf.el && this.conf.el instanceof HTMLElement) {
|
||||
this.$root = this.conf.el
|
||||
} else {
|
||||
try {
|
||||
const $root = document.querySelector<HTMLElement>(this.conf.el)
|
||||
if (!$root) throw Error(`Sorry, target element "${this.conf.el}" was not found.`)
|
||||
this.$root = $root
|
||||
} catch (e) {
|
||||
console.error(e)
|
||||
throw new Error('Please check your Artalk `el` config.')
|
||||
}
|
||||
}
|
||||
|
||||
// Context 初始化
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import '../style/comment.less'
|
||||
|
||||
import { CommentData } from '~/types/artalk-data'
|
||||
import Context from '../context'
|
||||
import Component from '../lib/component'
|
||||
import * as Utils from '../lib/utils'
|
||||
import * as Ui from '../lib/ui'
|
||||
import UADetect from '../lib/detect'
|
||||
import { CommentData } from '~/types/artalk-data'
|
||||
import CommentHTML from './html/comment.html?raw'
|
||||
import Api from '../api'
|
||||
import ActionBtn from './action-btn'
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import './emoticons-plug.less'
|
||||
|
||||
import Editor from '../editor'
|
||||
import EditorPlug from './editor-plug'
|
||||
import * as Utils from '~/src/lib/utils'
|
||||
import * as Ui from '~/src/lib/ui'
|
||||
import { EmoticonListData, EmoticonGrpData } from '~/types/artalk-data'
|
||||
import EditorPlug from './editor-plug'
|
||||
import Editor from '../editor'
|
||||
|
||||
type OwOFormatType = {
|
||||
[key: string] : {
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import './preview-plug.less'
|
||||
|
||||
import * as Utils from '~/src/lib/utils'
|
||||
import Editor from '../editor'
|
||||
import EditorPlug from './editor-plug'
|
||||
import * as Utils from '~/src/lib/utils'
|
||||
|
||||
export default class PreviewPlug extends EditorPlug {
|
||||
$el!: HTMLElement
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import '../style/editor.less'
|
||||
|
||||
import { CommentData } from '~/types/artalk-data'
|
||||
import Context from '../context'
|
||||
import Component from '../lib/component'
|
||||
import * as Utils from '../lib/utils'
|
||||
@@ -8,7 +9,6 @@ import EditorHTML from './html/editor.html?raw'
|
||||
|
||||
import EmoticonsPlug from './editor-plugs/emoticons-plug'
|
||||
import PreviewPlug from './editor-plugs/preview-plug'
|
||||
import { CommentData } from '~/types/artalk-data'
|
||||
import Api from '../api'
|
||||
|
||||
export default class Editor extends Component {
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import { ListData, CommentData, NotifyData, ApiVersionData } from '~/types/artalk-data'
|
||||
import Context from '../context'
|
||||
import Component from '../lib/component'
|
||||
import * as Utils from '../lib/utils'
|
||||
import * as Ui from '../lib/ui'
|
||||
import Api from '../api'
|
||||
import Comment from './comment'
|
||||
import { ListData, CommentData, NotifyData, ApiVersionData } from '~/types/artalk-data'
|
||||
import Pagination from './pagination'
|
||||
import ReadMoreBtn from './read-more-btn'
|
||||
import { backendMinVersion } from '../../package.json'
|
||||
@@ -49,6 +49,9 @@ export default class ListLite extends Component {
|
||||
</div>`)
|
||||
this.$commentsWrap = this.$el.querySelector('.atk-list-comments-wrap')!
|
||||
|
||||
// 评论为空时显示字符
|
||||
if (ctx.conf.noComment) this.noCommentText = ctx.conf.noComment
|
||||
|
||||
// 评论时间自动更新
|
||||
window.setInterval(() => {
|
||||
this.$el.querySelectorAll<HTMLElement>('[data-atk-comment-date]').forEach(el => {
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
import '../style/list.less'
|
||||
|
||||
import { ListData } from '~/types/artalk-data'
|
||||
import Context from '../context'
|
||||
import * as Utils from '../lib/utils'
|
||||
import * as Ui from '../lib/ui'
|
||||
import Api from '../api'
|
||||
import ListHTML from './html/list.html?raw'
|
||||
import ListLite from './list-lite'
|
||||
import { ListData } from '~/types/artalk-data'
|
||||
|
||||
export default class List extends ListLite {
|
||||
private $closeCommentBtn!: HTMLElement
|
||||
|
||||
@@ -3,11 +3,11 @@ import '../style/sidebar-layer.less'
|
||||
import Context from '@/context'
|
||||
import Component from '@/lib/component'
|
||||
import * as Utils from '@/lib/utils'
|
||||
import SidebarHTML from './html/sidebar-layer.html?raw'
|
||||
import * as Ui from '@/lib/ui'
|
||||
import { SidebarShowPayload } from '~/types/event'
|
||||
import SidebarHTML from './html/sidebar-layer.html?raw'
|
||||
import Layer from './layer'
|
||||
import Api from '../api'
|
||||
import { SidebarShowPayload } from '~/types/event'
|
||||
|
||||
export default class SidebarLayer extends Component {
|
||||
public layer?: Layer
|
||||
@@ -88,7 +88,7 @@ export default class SidebarLayer extends Component {
|
||||
|
||||
// 准备 Iframe 参数
|
||||
const baseURL = (import.meta.env.MODE === 'development') ? 'http://localhost:23367/'
|
||||
: Utils.getURLBasedOnApi(this.ctx, 'sidebar/')
|
||||
: Utils.getURLBasedOnApi(this.ctx, '/sidebar/')
|
||||
|
||||
const query: any = {
|
||||
pageKey: this.conf.pageKey,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { marked as libMarked } from 'marked'
|
||||
import User from './lib/user'
|
||||
import ArtalkConfig from '~/types/artalk-config'
|
||||
import { EventPayloadMap, Event, EventScopeType, Handler } from '~/types/event'
|
||||
import User from './lib/user'
|
||||
|
||||
/**
|
||||
* Artalk Context
|
||||
|
||||
@@ -15,7 +15,7 @@ const CaptchaChecker: Checker = {
|
||||
const $iframe = Utils.createElement<HTMLIFrameElement>(`<iframe class="atk-fade-in"></iframe>`)
|
||||
$iframe.style.display = 'none'
|
||||
Ui.showLoading($iframeWrap, { transparentBg: true })
|
||||
$iframe.src = `${that.ctx.conf.server}/captcha/get?t=${+new Date()}`
|
||||
$iframe.src = `${that.ctx.conf.server}/api/captcha/get?t=${+new Date()}`
|
||||
$iframe.onload = () => {
|
||||
$iframe.style.display = ''
|
||||
Ui.hideLoading($iframeWrap)
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import Context from '@/context'
|
||||
import Layer from '@/components/layer'
|
||||
import Dialog from '@/components/dialog'
|
||||
import { CheckerPayload } from '~/types/event'
|
||||
import * as Utils from '../utils'
|
||||
import * as Ui from '../ui'
|
||||
import { CheckerPayload } from '~/types/event'
|
||||
import CaptchaChecker from './captcha-checker'
|
||||
import AdminChecker from './admin-checker'
|
||||
|
||||
|
||||
@@ -286,7 +286,7 @@ export function isValidURL(urlRaw: string) {
|
||||
|
||||
/** 获取基于 conf.server 的 URL */
|
||||
export function getURLBasedOnApi(ctx: Context, path: string) {
|
||||
return `${ctx.conf.server.replace(/\/api\/?$/, '')}/${path.replace(/^\//, '')}`
|
||||
return getURLBasedOn(ctx.conf.server, path)
|
||||
}
|
||||
|
||||
/** 获取基于某个 baseURL 的 URL */
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
export default interface ArtalkConfig {
|
||||
/** 装载元素 */
|
||||
el: string
|
||||
el: string|HTMLElement
|
||||
|
||||
/** 页面唯一标识(完整 URL) */
|
||||
pageKey: string
|
||||
|
||||
@@ -1,41 +1,3 @@
|
||||
# @artalkjs/plugin-katex
|
||||
|
||||
食用方法
|
||||
|
||||
```html
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Document</title>
|
||||
|
||||
<!-- 引入 katex -->
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.15.3/dist/katex.min.css">
|
||||
<script defer src="https://cdn.jsdelivr.net/npm/katex@0.15.3/dist/katex.min.js"></script>
|
||||
|
||||
<!-- 引入 Artalk -->
|
||||
<link href="https://cdn.jsdelivr.net/npm/artalk/dist/Artalk.css" rel="stylesheet">
|
||||
<script src="https://cdn.jsdelivr.net/npm/artalk/dist/Artalk.js"></script>
|
||||
|
||||
<!-- 引入 @artalkjs/plugin-katex -->
|
||||
<script defer src="https://cdn.jsdelivr.net/npm/@artalkjs/plugin-katex/dist/artalk-plugin-katex.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<!-- Artalk -->
|
||||
<div id="Comments"></div>
|
||||
<script>
|
||||
new Artalk({
|
||||
el: '#Comments',
|
||||
pageKey: '<页面链接>',
|
||||
pageTitle: '<页面标题>',
|
||||
server: '<后端地址>',
|
||||
site: '<站点名称>',
|
||||
})
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
```
|
||||
食用方法参考:[官方文档](https://artalk.js.org/guide/frontend/latex.html)
|
||||
Vendored
-1
@@ -1 +0,0 @@
|
||||
import './main'
|
||||
@@ -20,7 +20,7 @@
|
||||
el: '#comments',
|
||||
pageKey: 'https://artalk.js.org/',
|
||||
pageTitle: 'Artalk Home',
|
||||
server: (import.meta.env.MODE === 'development') ? 'http://localhost:23366/api' : 'https://artalk.qwqaq.com/api',
|
||||
server: (import.meta.env.MODE === 'development') ? 'http://localhost:23366' : 'https://artalk.qwqaq.com',
|
||||
site: 'ArtalkDemo',
|
||||
});
|
||||
</script>
|
||||
|
||||
@@ -14,7 +14,6 @@
|
||||
"unpkg": "./dist/artalk-plugin-katex.iife.js",
|
||||
"jsdelivr": "./dist/artalk-plugin-katex.iife.js",
|
||||
"module": "./dist/artalk-plugin-katex.es.js",
|
||||
"types": "./index.d.ts",
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
"build": "vite build",
|
||||
|
||||
@@ -18,9 +18,6 @@ export default defineConfig({
|
||||
// 确保外部化处理那些你不想打包进库的依赖
|
||||
external: ['artalk', 'katex'],
|
||||
output: {
|
||||
assetFileNames: assetInfo => {
|
||||
return "[name].[ext]"
|
||||
},
|
||||
// 在 UMD 构建模式下为这些外部化的依赖提供一个全局变量
|
||||
globals: {
|
||||
artalk: 'Artalk',
|
||||
|
||||
Generated
+471
-424
File diff suppressed because it is too large.
Load diff
Reference in new issue
Block a user