feat: init
This commit is contained in:
74
content.tsx
Normal file
74
content.tsx
Normal file
@@ -0,0 +1,74 @@
|
||||
// scss样式
|
||||
// import styleText from "data-text:./content.scss"
|
||||
import styleText from "data-text:antd/dist/antd.css"
|
||||
|
||||
import type {
|
||||
PlasmoCSConfig,
|
||||
PlasmoGetInlineAnchor,
|
||||
PlasmoGetStyle
|
||||
} from "plasmo"
|
||||
|
||||
export {}
|
||||
import { Button, Space,message,Rate } from 'antd';
|
||||
// import 'antd/dist/antd.css';
|
||||
|
||||
|
||||
|
||||
|
||||
export const getStyle: PlasmoGetStyle = () => {
|
||||
const style = document.createElement("style")
|
||||
style.textContent = styleText
|
||||
return style
|
||||
}
|
||||
|
||||
export const config: PlasmoCSConfig = {
|
||||
matches: ["<all_urls>"], //所有网页
|
||||
// all_frames: true, //所有iframe
|
||||
world: "MAIN" //所有windows
|
||||
}
|
||||
|
||||
// 定位的内连root
|
||||
export const getInlineAnchor: PlasmoGetInlineAnchor = async () =>
|
||||
document.querySelector("#collect_left")
|
||||
|
||||
// javascript
|
||||
console.log(
|
||||
"You may find that having is 1not so pleasing a thing as wanting. This is not logical, but it is often true."
|
||||
)
|
||||
// window全局变量
|
||||
// window.alert(window.location.href)
|
||||
|
||||
// 定义UI元素
|
||||
|
||||
const CustomButton = () => {
|
||||
const [messageApi, contextHolder] = message.useMessage()
|
||||
return (
|
||||
<div className="content">
|
||||
{contextHolder}
|
||||
{/* <Rate allowHalf defaultValue={2.5} /> */}
|
||||
<Button onClick={()=>{
|
||||
|
||||
messageApi.open({
|
||||
type: 'success',
|
||||
content: 'This is a success message',
|
||||
});
|
||||
|
||||
}} type="primary">Primary Button</Button>
|
||||
<button
|
||||
onClick={() => {
|
||||
console.log("click")
|
||||
fetch("https://yapice.smallzhiyuns.com/mock/10/test")
|
||||
.then((data) => {
|
||||
return data.json()
|
||||
})
|
||||
.then((res) => {
|
||||
console.log(`res`, res)
|
||||
})
|
||||
}}>
|
||||
Custom button
|
||||
</button>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export default CustomButton
|
||||
Reference in New Issue
Block a user