Skip to content

Commit

Permalink
Revert "refactor: comment & editor (#154)"
Browse files Browse the repository at this point in the history
This reverts commit 672cda6.
  • Loading branch information
qwqcode authored May 18, 2022
1 parent 672cda6 commit 9d72d59
Show file tree
Hide file tree
Showing 63 changed files with 1,604 additions and 1,733 deletions.
2 changes: 1 addition & 1 deletion packages/artalk-sidebar/src/admin/page-list.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import '../style/page-list.less'

import Context from 'artalk/types/context'
import Context from 'artalk/src/context'
import * as Utils from 'artalk/src/lib/utils'
import * as Ui from 'artalk/src/lib/ui'
import { PageData } from 'artalk/types/artalk-data'
Expand Down
2 changes: 1 addition & 1 deletion packages/artalk-sidebar/src/admin/site-list-floater.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import '../style/site-list.less'

import Context from 'artalk/types/context'
import Context from 'artalk/src/context'
import * as Utils from 'artalk/src/lib/utils'
import * as Ui from 'artalk/src/lib/ui'
import { SiteData } from 'artalk/types/artalk-data'
Expand Down
2 changes: 1 addition & 1 deletion packages/artalk-sidebar/src/admin/site-list.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import '../style/site-list.less'

import Context from 'artalk/types/context'
import Context from 'artalk/src/context'
import * as Utils from 'artalk/src/lib/utils'
import * as Ui from 'artalk/src/lib/ui'
import { SiteData } from 'artalk/types/artalk-data'
Expand Down
6 changes: 4 additions & 2 deletions packages/artalk-sidebar/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@ export default async function InitSidebar(conf: ArtalkConfig, user: LocalUser, v

// 初始化用户数据
user = user || {}
artalk.ctx.user.update({
artalk.ctx.user.data = {
...artalk.ctx.user.data,
...user
})
}
artalk.ctx.user.save()

// 初始化 Sidebar
const sidebarCtx = new SidebarCtx()
Expand Down
2 changes: 1 addition & 1 deletion packages/artalk-sidebar/src/sidebar-component.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import ArtalkComponent from 'artalk/src/lib/component'
import Context from 'artalk/types/context'
import Context from 'artalk/src/context'
import { SidebarCtx } from './main'

export default class Component extends ArtalkComponent {
Expand Down
4 changes: 2 additions & 2 deletions packages/artalk-sidebar/src/sidebar-root.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import './style/sidebar.less'

import Context from 'artalk/types/context'
import Context from 'artalk/src/context'
import * as Utils from 'artalk/src/lib/utils'
import * as Ui from 'artalk/src/lib/ui'
import Comment from 'artalk/src/comment'
import Comment from 'artalk/src/components/comment'
import { SiteData } from 'artalk/types/artalk-data'
import Api from 'artalk/src/api'

Expand Down
4 changes: 2 additions & 2 deletions packages/artalk-sidebar/src/sidebar-view.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Context from 'artalk/types/context'
import Context from 'artalk/src/context'
import * as Utils from 'artalk/src/lib/utils'
import Comment from 'artalk/src/comment'
import Comment from 'artalk/src/components/comment'
import Component from './sidebar-component'
import { SidebarCtx } from './main'

Expand Down
12 changes: 6 additions & 6 deletions packages/artalk-sidebar/src/sidebar-views/comments-view.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Context from 'artalk/types/context'
import Context from 'artalk/src/context'
import * as Utils from 'artalk/src/lib/utils'
import ListLite from 'artalk/src/list/list-lite'
import ListLite from 'artalk/src/components/list-lite'

import SidebarView from '../sidebar-view'

Expand Down Expand Up @@ -39,10 +39,10 @@ export default class MessageView extends SidebarView {
this.list.pageMode = 'pagination'
this.list.noCommentText = '<div class="atk-sidebar-no-content">无内容</div>'
this.list.renderComment = (comment) => {
const pageURL = comment.getData().page_url
comment.getRender().setOpenURL(`${pageURL}#atk-comment-${comment.getID()}`)
comment.getConf().onReplyBtnClick = () => {
this.ctx.trigger('editor-reply', {data: comment.getData(), $el: comment.getEl(), scroll: true})
const pageURL = comment.data.page_url
comment.setOpenURL(`${pageURL}#atk-comment-${comment.data.id}`)
comment.onReplyBtnClick = () => {
this.ctx.trigger('editor-reply', {data: comment.data, $el: comment.$el, scroll: true})
}
}
this.list.paramsEditor = (params) => {
Expand Down
4 changes: 2 additions & 2 deletions packages/artalk-sidebar/src/sidebar-views/pages-view.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import Api from 'artalk/src/api'
import Context from 'artalk/types/context'
import Context from 'artalk/src/context'
import * as Utils from 'artalk/src/lib/utils'
import * as Ui from 'artalk/src/lib/ui'
import Comment from 'artalk/src/comment'
import Comment from 'artalk/src/components/comment'
import Pagination, { PaginationConf } from 'artalk/src/components/pagination'

import SidebarView from '../sidebar-view'
Expand Down
4 changes: 2 additions & 2 deletions packages/artalk-sidebar/src/sidebar-views/setting-view.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Api from 'artalk/src/api'
import Context from 'artalk/types/context'
import Context from 'artalk/src/context'
import * as Utils from 'artalk/src/lib/utils'
import Comment from 'artalk/src/comment'
import Comment from 'artalk/src/components/comment'

import SiteList from '../admin/site-list'
import SidebarView from '../sidebar-view'
Expand Down
4 changes: 2 additions & 2 deletions packages/artalk-sidebar/src/sidebar-views/sites-view.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Api from 'artalk/src/api'
import Context from 'artalk/types/context'
import Context from 'artalk/src/context'
import * as Utils from 'artalk/src/lib/utils'
import Comment from 'artalk/src/comment'
import Comment from 'artalk/src/components/comment'

import SiteList from '../admin/site-list'
import SidebarView from '../sidebar-view'
Expand Down
4 changes: 2 additions & 2 deletions packages/artalk-sidebar/src/sidebar-views/transfer-view.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import Api from 'artalk/src/api'
import Context from 'artalk/types/context'
import Context from 'artalk/src/context'
import * as Utils from 'artalk/src/lib/utils'
import * as Ui from 'artalk/src/lib/ui'
import Comment from 'artalk/src/comment'
import Comment from 'artalk/src/components/comment'

import SiteList from '../admin/site-list'
import SidebarView from '../sidebar-view'
Expand Down
3 changes: 1 addition & 2 deletions packages/artalk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@
"types": "./types/index.d.ts",
"scripts": {
"dev": "vite",
"build": "pnpm lint && vite build && pnpm build:lite",
"build:lite": "vite build --config vite-lite.config.ts",
"build": "pnpm lint && vite build",
"build:demo": "vite build --config vite-demo.config.ts",
"serve": "vite preview",
"deploy": "gh-pages -d deploy",
Expand Down
2 changes: 1 addition & 1 deletion packages/artalk/src/api/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { CommentData, ListData, UserData, PageData, SiteData, NotifyData } from '~/types/artalk-data'
import ArtalkConfig from '~/types/artalk-config'
import Context from '~/types/context'
import Context from '../context'
import { Fetch, ToFormData, POST, GET } from './request'
import * as Utils from '../lib/utils'
import 'abortcontroller-polyfill/dist/polyfill-patch-fetch'
Expand Down
2 changes: 1 addition & 1 deletion packages/artalk/src/api/request.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Context from '~/types/context'
import Context from '../context'

/** 公共请求函数 */
export async function Fetch(ctx: Context, input: RequestInfo, init: RequestInit, timeout?: number): Promise<any> {
Expand Down
15 changes: 7 additions & 8 deletions packages/artalk/src/artalk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,15 @@ import './style/main.less'

import ArtalkConfig from '~/types/artalk-config'
import { EventPayloadMap, Handler } from '~/types/event'
import Context from '~/types/context'
import ConcreteContext from './context'
import Context from './context'
import defaults from './defaults'

import CheckerLauncher from './lib/checker'
import Editor from './editor'
import List from './list'
import SidebarLayer from './layer/sidebar-layer'
import Editor from './components/editor'
import List from './components/list'
import SidebarLayer from './components/sidebar-layer'

import Layer, { GetLayerWrap } from './layer'
import Layer, { GetLayerWrap } from './components/layer'
import Api from './api'
import * as Utils from './lib/utils'
import * as Ui from './lib/ui'
Expand All @@ -32,7 +31,7 @@ export default class Artalk {
public list!: List
public sidebarLayer!: SidebarLayer

constructor(customConf: Partial<ArtalkConfig>) {
constructor (customConf: ArtalkConfig) {
// 配置
this.conf = Utils.mergeDeep(Artalk.defaults, customConf)
this.conf.server = this.conf.server.replace(/\/$/, '').replace(/\/api\/?$/, '')
Expand Down Expand Up @@ -68,7 +67,7 @@ export default class Artalk {
}

// Context 初始化
this.ctx = new ConcreteContext(this.$root, this.conf)
this.ctx = new Context(this.$root, this.conf)

// 界面初始化
this.$root.classList.add('artalk')
Expand Down
87 changes: 0 additions & 87 deletions packages/artalk/src/comment/actions.ts

This file was deleted.

Loading

0 comments on commit 9d72d59

Please sign in to comment.