dev #5
| 
						 | 
				
			
			@ -8,6 +8,9 @@ jobs:
 | 
			
		|||
  build-for-chrome:
 | 
			
		||||
    name: 构建 Chrome 扩展程序
 | 
			
		||||
    runs-on: ubuntu-latest
 | 
			
		||||
    env:
 | 
			
		||||
      VITE_RUN_ID: ${{ gitea.run_number }}
 | 
			
		||||
      VITE_HASH_ID: ${{ gitea.sha }}
 | 
			
		||||
    
 | 
			
		||||
    steps:
 | 
			
		||||
    - uses: actions/checkout@v3
 | 
			
		||||
| 
						 | 
				
			
			@ -33,6 +36,9 @@ jobs:
 | 
			
		|||
  build-for-firefox:
 | 
			
		||||
    name: 构建 Firefox 附加组件
 | 
			
		||||
    runs-on: ubuntu-latest
 | 
			
		||||
    env:
 | 
			
		||||
      VITE_RUN_ID: ${{ gitea.run_number }}
 | 
			
		||||
      VITE_HASH_ID: ${{ gitea.sha }}
 | 
			
		||||
    
 | 
			
		||||
    steps:
 | 
			
		||||
    - uses: actions/checkout@v3
 | 
			
		||||
| 
						 | 
				
			
			@ -123,4 +129,33 @@ jobs:
 | 
			
		|||
          --api-secret ${{ secrets.FIREFOX_API_SECRET }} \
 | 
			
		||||
          --channel listed
 | 
			
		||||
 | 
			
		||||
    
 | 
			
		||||
  publish-to-edge-addons:
 | 
			
		||||
    name: 发布至 Edge 附加组件商店
 | 
			
		||||
    runs-on: ubuntu-latest
 | 
			
		||||
    needs: build-for-chrome
 | 
			
		||||
    # 仅在 main 分支上执行发布
 | 
			
		||||
    if: gitea.ref == 'refs/heads/main'
 | 
			
		||||
    
 | 
			
		||||
    steps:
 | 
			
		||||
    - name: 下载构建工件
 | 
			
		||||
      uses: actions/download-artifact@v3
 | 
			
		||||
      with:
 | 
			
		||||
        name: chrome-extension
 | 
			
		||||
        path: dist/
 | 
			
		||||
 | 
			
		||||
    - name: 压缩为 ZIP 文件
 | 
			
		||||
      run: |-
 | 
			
		||||
        cd dist && zip -r ../msrmod-edge.zip . && cd ..
 | 
			
		||||
        
 | 
			
		||||
    - name: 设置 Node.js
 | 
			
		||||
      uses: actions/setup-node@v3
 | 
			
		||||
      with:
 | 
			
		||||
        node-version: "22"
 | 
			
		||||
 | 
			
		||||
    - name: 上传扩展程序到 Edge Addons
 | 
			
		||||
      uses: wdzeng/edge-addon@v2
 | 
			
		||||
      with:
 | 
			
		||||
        product-id: d63fd5c5-baba-4fcb-95c8-f11c161f9878
 | 
			
		||||
        zip-path: msrmod-edge.zip
 | 
			
		||||
        api-key: ${{ secrets.EDGE_CLIENT_SECRET }}
 | 
			
		||||
        client-id: ${{ secrets.EDGE_CLIENT_ID }}
 | 
			
		||||
							
								
								
									
										3
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										3
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							| 
						 | 
				
			
			@ -22,3 +22,6 @@ dist-ssr
 | 
			
		|||
*.njsproj
 | 
			
		||||
*.sln
 | 
			
		||||
*.sw?
 | 
			
		||||
 | 
			
		||||
.env
 | 
			
		||||
.env.local
 | 
			
		||||
| 
						 | 
				
			
			@ -1,6 +1,9 @@
 | 
			
		|||
console.log("aaaa")
 | 
			
		||||
 | 
			
		||||
browser.webRequest.onBeforeRequest.addListener(
 | 
			
		||||
// 兼容 Chrome 和 Firefox
 | 
			
		||||
const browserAPI = typeof browser !== 'undefined' ? browser : chrome;
 | 
			
		||||
 | 
			
		||||
browserAPI.webRequest.onBeforeRequest.addListener(
 | 
			
		||||
	async (details) => {
 | 
			
		||||
		console.log(
 | 
			
		||||
			'onBeforeRequest MAIN_FRAME:',
 | 
			
		||||
| 
						 | 
				
			
			@ -11,27 +14,35 @@ browser.webRequest.onBeforeRequest.addListener(
 | 
			
		|||
		)
 | 
			
		||||
 | 
			
		||||
		console.log('recived request for fontset api, redirecting to index.html')
 | 
			
		||||
		const pref = await browser.storage.sync.get('preferences')
 | 
			
		||||
		const pref = await browserAPI.storage.sync.get('preferences')
 | 
			
		||||
 | 
			
		||||
		if (pref === undefined || pref.preferences === undefined || pref.preferences.autoRedirect === undefined || pref.preferences.autoRedirect === true) {
 | 
			
		||||
			const isChrome = typeof browser.runtime.getBrowserInfo === 'undefined';
 | 
			
		||||
			const isChrome = typeof browserAPI.runtime.getBrowserInfo === 'undefined';
 | 
			
		||||
 | 
			
		||||
			if (isChrome) {
 | 
			
		||||
				browser.tabs.create({ url: browser.runtime.getURL('index.html') })
 | 
			
		||||
				browser.tabs.remove(details.tabId)
 | 
			
		||||
				if (
 | 
			
		||||
					details.url === 'https://monster-siren.hypergryph.com/manifest.json' &&
 | 
			
		||||
					details.type === 'other' &&
 | 
			
		||||
					details.frameId === 0
 | 
			
		||||
				) {
 | 
			
		||||
					const pref = await chrome.storage.sync.get('preferences')
 | 
			
		||||
 | 
			
		||||
					chrome.tabs.create({ url: chrome.runtime.getURL('index.html') })
 | 
			
		||||
					chrome.tabs.remove(details.tabId)
 | 
			
		||||
				}
 | 
			
		||||
			} else {
 | 
			
		||||
				// Firefox: 直接在当前标签页导航
 | 
			
		||||
				browser.tabs.update(details.tabId, { url: browser.runtime.getURL('index.html') })
 | 
			
		||||
				browserAPI.tabs.update(details.tabId, { url: browserAPI.runtime.getURL('index.html') })
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
	},
 | 
			
		||||
	{ urls: ['https://monster-siren.hypergryph.com/api/fontset'] },
 | 
			
		||||
	{ urls: ['https://monster-siren.hypergryph.com/api/fontset', 'https://monster-siren.hypergryph.com/manifest.json'] },
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
// 兼容新旧版本的 API
 | 
			
		||||
const actionAPI = browser.action || browser.browserAction;
 | 
			
		||||
const actionAPI = browserAPI.action || browserAPI.browserAction;
 | 
			
		||||
if (actionAPI) {
 | 
			
		||||
	actionAPI.onClicked.addListener(() => {
 | 
			
		||||
		browser.tabs.create({ url: browser.runtime.getURL('index.html') })
 | 
			
		||||
		browserAPI.tabs.create({ url: browserAPI.runtime.getURL('index.html') })
 | 
			
		||||
	})
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -3,10 +3,10 @@
 | 
			
		|||
import XIcon from '../assets/icons/x.vue'
 | 
			
		||||
import { usePreferences } from '../stores/usePreferences'
 | 
			
		||||
import { computed } from 'vue'
 | 
			
		||||
import { cicdInfo } from '../utils'
 | 
			
		||||
 | 
			
		||||
const preferences = usePreferences()
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
defineProps<{
 | 
			
		||||
	present: boolean
 | 
			
		||||
}>()
 | 
			
		||||
| 
						 | 
				
			
			@ -103,7 +103,7 @@ const version = computed(() => {
 | 
			
		|||
									</button>
 | 
			
		||||
								</li>
 | 
			
		||||
							</ul>
 | 
			
		||||
							<div class="text-white/50 text-sm ml-6 mt-2">即使此项目关闭,随时都可以通过点按 MSR Mod 扩展图标启动 MSR Mod。</div>
 | 
			
		||||
							<div class="text-white/50 text-sm mx-6 mt-2">即使此项目关闭,随时都可以通过点按 MSR Mod 扩展图标启动 MSR Mod。</div>
 | 
			
		||||
						</div>
 | 
			
		||||
					</div>
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -133,6 +133,37 @@ const version = computed(() => {
 | 
			
		|||
							</ul>
 | 
			
		||||
						</div>
 | 
			
		||||
					</div>
 | 
			
		||||
 | 
			
		||||
					<div>
 | 
			
		||||
						<div class="px-8">
 | 
			
		||||
							<div class="text-white/50 text-sm ml-6">构建信息</div>
 | 
			
		||||
							<ul class="border border-[#ffffff39] rounded-lg backdrop-blur-lg mt-2 overflow-hidden">
 | 
			
		||||
								<li class="odd:bg-neutral-300/5">
 | 
			
		||||
									<a :href="`https://git.nas.astrian.moe/Astrian/msr-mod/actions/runs/${cicdInfo.runId}`"
 | 
			
		||||
										target="_blank">
 | 
			
		||||
										<div
 | 
			
		||||
											class="flex justify-between items-center px-6 py-4 w-full text-left hover:bg-neutral-300/10 transition-all">
 | 
			
		||||
											<div class="flex flex-col">
 | 
			
		||||
												<div class="text-base text-white">Gitea Actions 运行编号</div>
 | 
			
		||||
												<div class="text-sm text-white/80">{{ cicdInfo.runId }}</div>
 | 
			
		||||
											</div>
 | 
			
		||||
										</div>
 | 
			
		||||
									</a>
 | 
			
		||||
								</li>
 | 
			
		||||
 | 
			
		||||
								<li class="odd:bg-neutral-300/5">
 | 
			
		||||
									<div
 | 
			
		||||
										class="flex justify-between items-center px-6 py-4 w-full text-left hover:bg-neutral-300/10 transition-all">
 | 
			
		||||
										<div class="flex flex-col">
 | 
			
		||||
											<div class="text-base text-white">触发构建的提交哈希</div>
 | 
			
		||||
											<div class="text-sm text-white/80">{{ cicdInfo.hashId }}</div>
 | 
			
		||||
										</div>
 | 
			
		||||
									</div>
 | 
			
		||||
								</li>
 | 
			
		||||
							</ul>
 | 
			
		||||
							<div class="text-white/50 text-sm mx-6 mt-2">MSR Mod 通过 Gitea Actions 自动化完成构建与发布流程。此信息用于验证当前版本的构建来源,确保代码完整性与安全性。</div>
 | 
			
		||||
						</div>
 | 
			
		||||
					</div>
 | 
			
		||||
				</div>
 | 
			
		||||
			</div>
 | 
			
		||||
		</div>
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										4
									
								
								src/utils/cicdInfo.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										4
									
								
								src/utils/cicdInfo.ts
									
									
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,4 @@
 | 
			
		|||
export default {
 | 
			
		||||
	runId: import.meta.env.VITE_RUN_ID ?? '未知',
 | 
			
		||||
	hashId: import.meta.env.VITE_HASH_ID?.slice(0, 10) ?? '未知',
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -1,4 +1,5 @@
 | 
			
		|||
import artistsOrganize from "./artistsOrganize"
 | 
			
		||||
import { audioVisualizer } from "./audioVisualizer"
 | 
			
		||||
import cicdInfo from "./cicdInfo"
 | 
			
		||||
 | 
			
		||||
export { artistsOrganize, audioVisualizer }
 | 
			
		||||
export { artistsOrganize, audioVisualizer, cicdInfo }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue
	
	Block a user