Skip to content

Commit

Permalink
refactor: 将组件内script风格从optionsAPI修改为CompositionAPI
Browse files Browse the repository at this point in the history
  • Loading branch information
JeacsonSnake committed Aug 3, 2024
1 parent aeb5927 commit 488e81e
Show file tree
Hide file tree
Showing 3 changed files with 297 additions and 312 deletions.
18 changes: 8 additions & 10 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,11 @@ import 'element-plus/theme-chalk/index.css'
// import fonts
import './assets/fonts/index.css'

// import axios & vue-axios
import axios from 'axios'
import VueAxios from 'vue-axios'

const app = createApp({
render: () => h(App)
});

// use axois & vue-axios
app.use(VueAxios, axios)
})

// Register Element Plus components
app.use(Button)
app.use(Dialog)
app.use(Table)
Expand All @@ -51,15 +45,19 @@ app.use(Select)
app.use(Option)
app.use(Tooltip)
app.use(Link)
app.config.globalProperties.$elLoading = Loading
app.use(Loading)

// Global properties
app.config.globalProperties.$message = Message
app.config.globalProperties.$alert = MessageBox.alert
app.config.globalProperties.$confirm = MessageBox.confirm
app.config.globalProperties.$prompt = MessageBox.prompt

app.config.globalProperties.$httpRequestList = [] //管理所有请求中断方法的集合
app.config.globalProperties.$httpRequestList = [] // 管理所有请求中断方法的集合.

// Use store, and router
app.use(store)
app.use(router)

// Mount the app
app.mount('#app')
114 changes: 57 additions & 57 deletions src/util/result.js
Original file line number Diff line number Diff line change
@@ -1,72 +1,72 @@
const gameRule = {
ZhuangYuanChaJinHua: new RegExp('114444'), // 状元插金花(状元)
LiuBoHong: new RegExp('444444'), // 状元六博红(状元)
BianDiJing: new RegExp('111111'), // 状元遍地锦(状元)
LiuBoHei: new RegExp('^(1{6})|(2{6})|(3{6})|(5{6})|(6{6})$'), // 状元六博黑(状元)
WuBoHong: new RegExp('^44444[5-6]{1}$|^[1-3]{1}44444$'), // 状元五红王(状元)
WuBoHei: new RegExp(
'(?=^d*((1{5})|(2{5})|(3{5})|(5{5})|(6{5}))d*$)(?=[^4]{6})'
), // 状元五子登科(状元)
SiDianHong: new RegExp(
'^4444[5-6]{2}$|^[1-3]{1}4444[5-6]{1}$|^[1-3]{2}4444$'
), // 状元四点红(状元)
DuiTang: new RegExp('123456'), // 对堂(榜眼)
SanHong: new RegExp(
'^444[5-6]{3}$|^[1-3]{1}444[5-6]{2}$|^[1-3]{2}444[5-6]{1}|^[1-3]{3}444$'
), // 三红(探花)
SiJin: new RegExp('^[1]{4}|[2]{4}|[3]{4}|[5]{4}|[6]{4}$'), // 四进(进士)
ErJu: new RegExp('^([1-3]{0,4}44){1}[5-6]{0,4}$'), // 二举(举人)
YiXiu: new RegExp('^([1-3]{0,5}4){1}[5-6]{0,5}$'), // 一秀(秀才)
NULL: new RegExp(''), // 博空
ZhuangYuanChaJinHua: new RegExp('114444'), // 状元插金花(状元)
LiuBoHong: new RegExp('444444'), // 状元六博红(状元)
BianDiJing: new RegExp('111111'), // 状元遍地锦(状元)
LiuBoHei: new RegExp('^(1{6})|(2{6})|(3{6})|(5{6})|(6{6})$'), // 状元六博黑(状元)
WuBoHong: new RegExp('^44444[5-6]{1}$|^[1-3]{1}44444$'), // 状元五红王(状元)
WuBoHei: new RegExp(
'(?=^d*((1{5})|(2{5})|(3{5})|(5{5})|(6{5}))d*$)(?=[^4]{6})'
), // 状元五子登科(状元)
SiDianHong: new RegExp(
'^4444[5-6]{2}$|^[1-3]{1}4444[5-6]{1}$|^[1-3]{2}4444$'
), // 状元四点红(状元)
DuiTang: new RegExp('123456'), // 对堂(榜眼)
SanHong: new RegExp(
'^444[5-6]{3}$|^[1-3]{1}444[5-6]{2}$|^[1-3]{2}444[5-6]{1}|^[1-3]{3}444$'
), // 三红(探花)
SiJin: new RegExp('^[1]{4}|[2]{4}|[3]{4}|[5]{4}|[6]{4}$'), // 四进(进士)
ErJu: new RegExp('^([1-3]{0,4}44){1}[5-6]{0,4}$'), // 二举(举人)
YiXiu: new RegExp('^([1-3]{0,5}4){1}[5-6]{0,5}$'), // 一秀(秀才)
NULL: new RegExp(''), // 博空
}
const zhuangyuan = [
'ZhuangYuanChaJinHua',
'LiuBoHong',
'BianDiJing',
'LiuBoHei',
'WuBoHong',
'WuBoHei',
'SiDianHong',
'ZhuangYuanChaJinHua',
'LiuBoHong',
'BianDiJing',
'LiuBoHei',
'WuBoHong',
'WuBoHei',
'SiDianHong',
]

function generateRandomString() {
let randomString = ''
for (let i = 0; i < 6; i++) {
const randomNumber = Math.floor(Math.random() * 6) + 1
randomString += randomNumber.toString()
}
return randomString
let randomString = ''
for (let i = 0; i < 6; i++) {
const randomNumber = Math.floor(Math.random() * 6) + 1
randomString += randomNumber.toString()
}
return randomString
}

function getRandomResult() {
let randomString = generateRandomString()
let returnObj = {
resultName: '',
resultNum: randomString,
}
let orderdRandomString = Array.from(randomString)
.map(Number)
.sort((a, b) => {
return a - b
})
.join('')
for (let key in gameRule) {
if (gameRule[key].test(orderdRandomString)) {
console.log('key', key)
returnObj.resultName = key
break
let randomString = generateRandomString()
let returnObj = {
resultName: '',
resultNum: randomString,
}
let orderdRandomString = Array.from(randomString)
.map(Number)
.sort((a, b) => {
return a - b
})
.join('')
for (let key in gameRule) {
if (gameRule[key].test(orderdRandomString)) {
// console.log('key', key)
returnObj.resultName = key
break
}
}
}

return returnObj
return returnObj
}

export const getResult = (isONFirst = false) => {
let generatedDiceResult = getRandomResult()
// 如果是第一轮则强制使得结果不出现状元
while (zhuangyuan.includes(generatedDiceResult.resultName) && isONFirst) {
generatedDiceResult = getRandomResult()
}
let generatedDiceResult = getRandomResult()
// 如果是第一轮则强制使得结果不出现状元
while (zhuangyuan.includes(generatedDiceResult.resultName) && isONFirst) {
generatedDiceResult = getRandomResult()
}

return generatedDiceResult
}
return generatedDiceResult
}
Loading

0 comments on commit 488e81e

Please sign in to comment.