Skip to content

Commit

Permalink
No commit message
Browse files Browse the repository at this point in the history
  • Loading branch information
shiyiya committed Jul 28, 2024
1 parent 1ad01fc commit 806fb5f
Show file tree
Hide file tree
Showing 6 changed files with 696 additions and 684 deletions.
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
},
"dependencies": {
"@babel/core": "^7.24.9",
"@babel/preset-env": "^7.24.8",
"@babel/preset-env": "^7.25.0",
"@babel/preset-react": "^7.24.7",
"@types/node": "^20.14.11",
"@types/node": "^20.14.13",
"@types/react": "^18.3.3",
"@types/react-dom": "^18.3.0",
"babel-loader": "^9.1.3",
Expand All @@ -25,12 +25,12 @@
"bulma-switch": "^2.0.4",
"bulma-tooltip": "^3.0.2",
"classnames": "^2.5.1",
"query-string": "^9.0.0",
"query-string": "^9.1.0",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"react-hot-toast": "^2.4.1",
"ts-loader": "^9.5.1",
"typescript": "^5.5.3",
"typescript": "^5.5.4",
"wouter": "^3.3.1"
},
"devDependencies": {
Expand All @@ -46,7 +46,7 @@
"file-loader": "^6.2.0",
"html-webpack-plugin": "^5.6.0",
"mini-css-extract-plugin": "^2.9.0",
"postcss": "^8.4.39",
"postcss": "^8.4.40",
"postcss-flexbugs-fixes": "^5.0.2",
"postcss-loader": "^8.1.1",
"postcss-preset-env": "^9.6.0",
Expand Down
25 changes: 25 additions & 0 deletions packages/shared/components/player/OPlayer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import ReactPlayer from '@oplayer/react'
import ui from '@oplayer/ui'
import React, { useImperativeHandle, useMemo, useRef } from 'react'
import { Playlist, Chromecast } from '@oplayer/plugins'
import { copyToClipboard } from '../../utils/copy'
// import Anime4kPlugin from './ainme4k'

interface OPlayerProps extends PlayerOptions {
Expand Down Expand Up @@ -46,6 +47,30 @@ const OPlayer = React.forwardRef(({ playerIsPlaying, duration, onEvent, autoplay
window.open('https://github.com/shiyiya/oplayer')
},
},
{
icon: '',
name: 'Share',
type: 'selector',
onChange({ value }) {
const url = `https://x.com/intent/post?url=${window.location.href}&text=${document.title}`
if (value == 'Twitter') {
window.open(url)
} else if (value == 'copy') {
copyToClipboard(url)
}
},
key: 'x',
children: [
{
name: 'Copy link',
value: 'copy',
},
{
name: 'Twitter',
value: 'Twitter',
},
] as any,
},
],

icons: {
Expand Down
32 changes: 6 additions & 26 deletions packages/shared/functions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export const handleImg = (opts) =>
type: null,
compress: 1, // 压缩范围(0-1)
maxHeight: window.innerHeight, // 压缩后的最大高度
maxWidth: window.innerWidth // 压缩后的最大宽度
maxWidth: window.innerWidth, // 压缩后的最大宽度
}

if (typeof opts !== 'object') {
Expand Down Expand Up @@ -115,7 +115,7 @@ export const dataURItoBlob = (base64, format) => {
return builder.getBlob(format)
}
return new window.Blob([uBuffer], {
type: format
type: format,
})
}

Expand Down Expand Up @@ -186,7 +186,7 @@ const optWatermark = {
init(img) {
// eslint-disable-next-line no-param-reassign
img.crossOrigin = 'anonymous'
}
},
}

export const getWatermarkImg = (img, brand) =>
Expand Down Expand Up @@ -424,7 +424,7 @@ export const getInitURLParams = () => {
custom: getParameterByName('custom'), // 提交反馈自定义字段
locale: getParameterByName('locale'), // 本地化设置
scale: getParameterByName('scale'), // 缩放比例
submitCallBack: getParameterByName('submitCallBack') // 控制提交反馈后调用 schemaurl(aisee://feedback/info)
submitCallBack: getParameterByName('submitCallBack'), // 控制提交反馈后调用 schemaurl(aisee://feedback/info)
}
if (!window.localStorage) {
return paramsFromURL
Expand Down Expand Up @@ -537,9 +537,7 @@ export const insertCustomButtonClass = (bgColor) => {
}

export const isIphoneX = () =>
/iphone/gi.test(window.navigator.userAgent) &&
window.screen.height === 812 &&
window.screen.width === 375
/iphone/gi.test(window.navigator.userAgent) && window.screen.height === 812 && window.screen.width === 375

export const isAndroid = () => /(android)/i.test(window.navigator.userAgent)

Expand Down Expand Up @@ -576,7 +574,7 @@ export const getMessage = (path, vue) => {
'feedbackPage.foldFaq': '收起完整内容',
'feedbackPage.roleMyself': '我',
'feedbackPage.admin': '管理员',
'feedbackPage.system': '管理员'
'feedbackPage.system': '管理员',
}
return backupMessages[path]
}
Expand Down Expand Up @@ -633,24 +631,6 @@ export const callBackNative = (path, data = {}, cmd) => {
}, 100)
}

export const copyToClipboard = (textToCopy) => {
const textarea = document.createElement('textarea')
textarea.setAttribute('readonly', 'readonly')
textarea.value = textToCopy
textarea.style.position = 'fixed'
textarea.style.top = 0
document.body.insertBefore(textarea, document.body.childNodes[0])
textarea.focus()
textarea.setSelectionRange(0, textToCopy.length) // 兼容 iOS select() 方法不可用问题。最大复制长度 9999
if (document.execCommand('copy')) {
document.execCommand('copy')
document.body.removeChild(textarea)
return 0
}
document.body.removeChild(textarea)
return -1
}

export const resumeHangingPage = () => {
if (isAndroid()) {
return
Expand Down
17 changes: 17 additions & 0 deletions packages/shared/utils/copy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
export const copyToClipboard = (textToCopy: string) => {
const textarea = document.createElement('textarea')
textarea.setAttribute('readonly', 'readonly')
textarea.value = textToCopy
textarea.style.position = 'fixed'
textarea.style.top = '0'
document.body.insertBefore(textarea, document.body.childNodes[0])
textarea.focus()
textarea.setSelectionRange(0, textToCopy.length) // 兼容 iOS select() 方法不可用问题。最大复制长度 9999
if (document.execCommand('copy')) {
document.execCommand('copy')
document.body.removeChild(textarea)
return 0
}
document.body.removeChild(textarea)
return -1
}
Loading

0 comments on commit 806fb5f

Please sign in to comment.