File tree Expand file tree Collapse file tree 4 files changed +9
-23
lines changed
Expand file tree Collapse file tree 4 files changed +9
-23
lines changed Original file line number Diff line number Diff line change @@ -85,15 +85,5 @@ export default [
8585 file : production ? 'dist/discuss.admin.js' : 'public/dist/discuss.admin.js'
8686 } ,
8787 plugins
88- } ,
89- {
90- input : 'src/client/emot.js' ,
91- output : {
92- sourcemap : true ,
93- format : 'iife' ,
94- name : 'discussEmot' ,
95- file : production ? 'dist/emot.js' : 'public/dist/emot.js'
96- } ,
97- plugins
9888 }
9989]
Original file line number Diff line number Diff line change 1- import { version } from '../../package.json'
1+ import { version } from '../../../ package.json'
22
33const key = [
44 '应援' ,
@@ -133,7 +133,7 @@ const key = [
133133 '偷偷看'
134134]
135135
136- export default window . DiscussEmot = ( emotCDN ) => {
136+ export default ( emotCDN ) => {
137137 emotCDN = ( emotCDN || 'https://unpkg.com' ) . replace ( / \/ $ / , '' ) + `/discuss@${ version } /assets/emot/`
138138 const items = { }
139139 for ( const i of key ) items [ i ] = emotCDN + i + '.png'
@@ -176,7 +176,7 @@ export default window.DiscussEmot = (emotCDN) => {
176176 太可怕了 : 'ヽ(*。>Д<)o゜'
177177 }
178178 } ,
179- [ ' <img src="' + items [ '鼓掌' ] + '">' ] : {
179+ [ ` <img src=${ items [ '鼓掌' ] } >` ] : {
180180 type : 'image' ,
181181 items : items
182182 }
Original file line number Diff line number Diff line change @@ -11,7 +11,7 @@ scriptUrl = scriptUrl
1111 . replace ( / \/ [ ^ / ] + $ / , '/' ) // 去除文件名
1212
1313window . DChunk = [ ]
14- const map = { emot : 'emot.js' , admin : 'discuss.admin.js' }
14+ const map = { admin : 'discuss.admin.js' }
1515const loadScript = ( chunk , callback ) => {
1616 if ( window . DChunk . includes ( chunk ) ) return callback ( )
1717 window . DChunk . push ( chunk )
Original file line number Diff line number Diff line change 22 import { onMount , afterUpdate , createEventDispatcher } from ' svelte'
33 import { options , msg , lazy } from ' ../lib/stores'
44 import request from ' ../lib/request'
5- import loadScript from ' ../lib/import '
5+ import emotFn from ' ../lib/emot '
66 import Emotion from ' ../../../assets/svg/Emotion.svg'
77 import Loading from ' ../../../assets/svg/Loading.svg'
88 import Setting from ' ../../../assets/svg/Setting.svg'
9393 if (/ \. json$ / .test (emot)) {
9494 emotMaps = await request ({ url: emot, method: ' GET' })
9595 } else if (! emot) {
96- loadScript (' emot' , () => {
97- emotMaps = window .discussEmot (D .emotCDN )
98- })
96+ emotMaps = emotFn (D .emotCDN )
9997 } else {
10098 emotMaps = emot
10199 }
117115 function ParseEmot () {
118116 getEmotAll ()
119117 let content = metas .content .value
120- const reg = / \[ (?<emot>. *? )\] / g
121118 const emots = []
122- const arr = content .matchAll (reg)
123- for (const item of arr) {
124- emots .push (item .groups .emot )
125- }
119+ content .replace (/ \[ (. *? )\] / g , ($0 , $1 ) => {
120+ emots .push ($1)
121+ })
126122
127123 for (const emot of emots) {
128124 const link = emotAll[emot]
You can’t perform that action at this time.
0 commit comments